Skip to content

Conversation

@Aquilesorei
Copy link

Description

This PR fixes the issue where touchscreen taps on COSMIC panel applets show hover effects but don't trigger click events.

Problem

Currently, when using a touchscreen to tap on panel applets:

  • Touch events show visual hover feedback (applet icons highlight)
  • Touch events don't generate click events that applets expect
  • This affects all applets including network, battery, settings, custom applets, etc.

Solution

The fix adds synthetic click generation in the touch up handler when:

  1. Touch up occurs quickly after touch down (within 200ms timeout)
  2. Generates synthetic button press/release events using the existing pointer infrastructure
  3. Preserves all existing touch event handling

Changes

  • Add TOUCH_CLICK_TIMEOUT_MS constant (200ms) for touch-to-click conversion
  • Import ButtonEvent and ButtonState from smithay for synthetic click generation
  • Enhance touch up handler to check time difference from touch down
  • Generate synthetic button press/release events when within timeout
  • Maintain existing touch event flow for compatibility

Testing

Compiled and tested on Pop!_OS 24.04 LTS with COSMIC DE. The fix enables proper touchscreen interaction with all panel applets.

Environment

  • Pop!_OS 24.04 LTS
  • COSMIC DE with cosmic-panel version 0.1.0175924951924.04~b23a2df
  • Linux kernel 6.16.3

Fixes touchscreen interaction issues reported in COSMIC panel usage.

Add synthetic click generation when touch up occurs quickly after touch down.
This addresses the issue where touchscreen taps show hover effects but don't
trigger click events on panel applets.

- Add TOUCH_CLICK_TIMEOUT_MS constant (200ms) for touch-to-click conversion
- Import ButtonEvent and ButtonState from smithay for synthetic clicks
- In touch up handler, check time difference from touch down
- Generate synthetic button press/release events when within timeout
- Preserve existing touch event handling

Fixes touchscreen interaction with COSMIC panel applets.
@ids1024
Copy link
Member

ids1024 commented Oct 14, 2025

I don't think we should ever generate a pointer event from a touch event. We should just be passing touch events through to the applet, then the applet is responsible for interpreting it.

In #425 (comment), I commented that the way c_hovered_surface is handled seems to be causing some issues with touch events. I still haven't looked into that more to figure out how to properly fix that without causing pointer input issues. Not sure if that's the same issue this is meant to address.

@Aquilesorei
Copy link
Author

I don't think we should ever generate a pointer event from a touch event. We should just be passing touch events through to the applet, then the applet is responsible for interpreting it.

In #425 (comment), I commented that the way c_hovered_surface is handled seems to be causing some issues with touch events. I still haven't looked into that more to figure out how to properly fix that without causing pointer input issues. Not sure if that's the same issue this is meant to address.

Yes , it is the same issue I was trying to fix.

@kajusnau
Copy link

kajusnau commented Oct 16, 2025

I don't think we should ever generate a pointer event from a touch event. We should just be passing touch events through to the applet, then the applet is responsible for interpreting it.

I agree with the general idea.
However, if the root cause with c_hovered_surface is tricky to track down and fix, this PR could prove to be quite useful to enable general touch screen desktop support, as some applets are quite crucial for normal desktop use. At least temporarily.

Anyway, just throwing in my 2 cents.

I was also about to open an issue to track progress on this, but seems like there already is one, so tagging it here: #451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants