DankMaterialShell icon indicating copy to clipboard operation
DankMaterialShell copied to clipboard

Dock loses focus randomly

Open rollecode opened this issue 1 year ago • 6 comments

Compositor

  • [ ] niri
  • [x] Hyprland
  • [ ] Other (specify)

Distribution

Arch.

dms version

v0.2.4

Description

This is difficult to reproduce and capture, but with the latest version (updated today) dock loses mouse focus so that when I mouse hover on icons, the pointer and arrow flicker and I cannot click icons. Only dms restart fixes this until it happens again.

Expected Behavior

Icons should keep focus.

Steps to Reproduce

  1. Install the latest git version in Arch
  2. Wait for it to happen
  3. Try to click dock icons, can't do it because they are losing focus

rollecode avatar Oct 26 '25 19:10 rollecode

Possible fix 1d211e84741e4deb3b42e9e9b73e7391a71d7c8d

bbedward avatar Oct 27 '25 02:10 bbedward

Possible fix 1d211e8

Thanks, testing this evening in 12 hours or so 👍

rollecode avatar Oct 27 '25 06:10 rollecode

Testing, so far so good. I'll let you know if it appears again.

rollecode avatar Oct 27 '25 19:10 rollecode

It happened again. ☹️

rollecode avatar Oct 27 '25 20:10 rollecode

The issue could be related to MouseArea state corruption during dock model updates. Here's my theory on what might be happening:

  1. Every time a window opens/closes/changes focus, CompositorService.sortedToplevels changes
  2. This triggers dockModel.updateModel() in DockApps.qml (line 242)
  3. updateModel() calls clear() which destroys all delegates and their MouseAreas, then recreates them
  4. During this destruction/recreation cycle, MouseAreas might enter an invalid state on Wayland/Hyprland
  5. The MouseArea could become unresponsive until DMS is restarted

This could explain why:

  • The issue seems random (depends on window operations)
  • Sometimes happens when opening apps
  • Restarting DMS fixes it temporarily
  • It likely started after recent updates (possibly a regression related to my PR #502's changes to dock sizing)

Not entirely sure this will work, but adding preventStealing: true to the MouseArea in DockAppButton.qml might prevent parent/sibling MouseAreas from interfering during model updates:

--- a/Modules/Dock/DockAppButton.qml
+++ b/Modules/Dock/DockAppButton.qml
@@ -219,6 +219,8 @@ Item {

         anchors.fill: parent
+        enabled: true
+        preventStealing: true
         hoverEnabled: true
         cursorShape: longPressing ? Qt.DragMoveCursor : Qt.PointingHandCursor
         acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton

The preventStealing property should (in theory) ensure that the button MouseAreas retain their event handling even when the dock model is being rebuilt.

Testing this fix now on Hyprland/Wayland, but not 100% confident this is the actual issue. Will report back.

rollecode avatar Oct 27 '25 20:10 rollecode

Haven't been able to reproduce this in the later versions (running v0.4.1 now).

rollecode avatar Nov 07 '25 20:11 rollecode