Bug 392784

Summary: Triggering "Window Move" when LeftButton is held down doesn't move window
Product: [Plasma] kwin Reporter: Chris Holland <zrenfire>
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Chris Holland 2018-04-06 00:33:01 UTC
Ran into this bug(?) while trying to recreate the Unity drag to unmaximize feature. I was originally trying to use libtaskmanager's "requestMove" function, but I've since tested with the global shortcut and it also doesn't work.

You can quickly test with:

sleep 5; qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Window Move"

First run the command, then hold the LeftButton down until the shortcut is activated.

You'll notice the mouse moved to the center of the window, but the window will not follow the mouse. Nor will LeftClicks do anything anywhere on the screen. The mouse can still be moved around, but mouse clicks do nothing. If you release the mouse the window quickly moves to where you released it. Mouse clicks are still not responsive until you press Space (accept move) or Esc (cancel move).



I broke down the function calls here:

* https://github.com/kotelnik/plasma-applet-active-window-control/issues/30#issuecomment-364255622

The taskmanager widget calls `performMouseCommand(Options::MouseMove, ...)`

* https://github.com/KDE/kwin/blob/2e868c50df0aab40e4814724ee090ded6bd9072e/events.cpp#L1168
* https://github.com/KDE/kwin/blob/master/abstract_client.cpp#L998

while it seems the global shortcut calls `performMouseCommand(Options::MouseUnrestrictedMove, ...)`

* https://github.com/KDE/kwin/blob/d3aa33b51bd635008b519f565bdf0492e1531090/kwinbindings.cpp#L67
* https://github.com/KDE/kwin/blob/a0c91c6e19fec54054d1d6684d7c7a8ec0f1688c/useractions.cpp#L1710
* https://github.com/KDE/kwin/blob/a0c91c6e19fec54054d1d6684d7c7a8ec0f1688c/useractions.cpp#L1095

AbractClient uses almost the same logic for both though

* https://github.com/KDE/kwin/blob/master/abstract_client.cpp#L998
Comment 1 Martin Flöser 2018-04-06 04:27:23 UTC
Window move only works if KWin can grab the X mouse. By pressing the mouse before activating the window most likely holds a grab. Thus KWin cannot grab. This is an application bug: don't grab!