Bug 351112 - Alt+F3 menu occasionally ("rather often") doesn't grab input when opened by right mouse button click
Summary: Alt+F3 menu occasionally ("rather often") doesn't grab input when opened by r...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: decorations (show other bugs)
Version: 5.3.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 352672 353954 354390 356028 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-08-09 10:40 UTC by Unknown
Modified: 2017-03-06 10:49 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.5


Attachments
Workaround patch (2.78 KB, patch)
2015-09-22 12:55 UTC, Thomas Lübking
Details
Menus not disappearing on 5.8.5 (38.42 KB, image/png)
2017-03-06 10:49 UTC, kdebuac.rhn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Unknown 2015-08-09 10:40:39 UTC
Installed kwin from the arch linux packages to use in an LXQt session. When right clicking a title bar, I cannot cancel out of the menu or make it go away without actually choosing one of the options in the menu. 

Reproducible: Always
Comment 1 Thomas Lübking 2015-08-09 11:01:56 UTC
You mean not even pressing escape works?

Please attach the output of "qdbus org.kde.KWin /KWin supportInformation"

In case you're using some aurorae theme (this includes "plastik!"), please try the breeze decoration.
Comment 2 Thomas Lübking 2015-08-09 12:13:11 UTC
Actually, it randomly fails to grab input on right mouse button invocation.
(Happens on breeze deco as well. Not always, but more than "rarely")

Alt+F3 invocation seems "safe"
Comment 3 Martin Flöser 2015-08-10 08:49:00 UTC
that sounds like a problem in Qt - after all Qt should do the grab for the popup. Maybe we need to update user time before showing the menu (assuming that Qt didn't get the timestamp from the mouse event as that is on our own window and not a Qt managed window).
Comment 4 Thomas Lübking 2015-09-13 19:48:55 UTC
*** Bug 352672 has been marked as a duplicate of this bug. ***
Comment 5 Thomas Lübking 2015-09-13 22:15:46 UTC
New observation: the menu does work as expected (here) after you unfold a submenu and let that close (by hovering another action and wait briefly)
Comment 6 Martin Flöser 2015-09-14 06:26:39 UTC
clicking on a different window (e.g. desktop) also works. Maybe we filter out the events from Qt when it's on our window?
Comment 7 Thomas Lübking 2015-09-14 07:05:57 UTC
*clicking* a different window does not, but activating it does ;-P
(Try clicking xeyes, doesn't work)
That's "normal" and afair handled specially.


While it does not work, the keyboard focus remains on the active window (and it receives mouse signals)
"Making" it work by showing/hiding (latter is important) a submenu takes the input focus from the active window to the menu and also "blocks" mouse input from the active window.

For some reason the input grab fails on initial invocation - but that's related to clicking the decoration, though.

I could assume we (the deco) are grabbing input on button downs, so the popup cannot get it.
Comment 8 Hussam Al-Tayeb 2015-09-14 13:40:27 UTC
Has anyone consulted Qt developers in case this is an upstream issue?
Comment 9 Thomas Lübking 2015-09-16 11:48:09 UTC
They'll ask for a self-contained test case - which we cannot provide (so far)

There's something interesting happening:
a) we receive *two* XCB_MAP_NOTIFY events for the Alt+F3 menu in a row...
b) the popup then gets the focus and looses it immediately - I could assume this is related to the doubled events?
Comment 10 Martin Flöser 2015-09-16 13:46:48 UTC
> There's something interesting happening:
> a) we receive *two* XCB_MAP_NOTIFY events for the Alt+F3 menu in a row...

that might be the widget style destroying the window again in polish() in case 
the window is not ARGB?
Comment 11 Thomas Lübking 2015-09-16 15:21:52 UTC
(In reply to Martin Gräßlin from comment #10)

> that might be the widget style destroying the window again in polish() in
> case  the window is not ARGB?

Maybe, however I had tried ensurePolished() before exec() and that didn't help.
Also I don't get this from other popups.
Comment 12 Thomas Lübking 2015-09-17 22:29:54 UTC
multiple maps seem a red herring - they also occur for the shortcut invocation. one is from the window and one from the root window and it's the same event.

QMenu "needs" the button to be released before exec(), simply leaving the event cycle doesn't help - that's (delaying the menu by "something" > 100ms) however not a viable solution at all.

It's not 100% related to the nested eventloop of the popup, calling ::popup instead of ::exec doesn't change a thing.
Comment 13 Thomas Lübking 2015-09-22 12:55:52 UTC
Created attachment 94675 [details]
Workaround patch

The grab fails while the button is down - Qt then also seems to release the keyboard.

I avoided sending it to the deco, but that didn't help either - nevertheless it seems (from the Qt code) as if the button is currently grabbed (the code is a dumb forward to xcb_grab_pointer)

As a workaround, the patch simply ensures a grab on releasing a button when the popup is visible. So far this works w/o side effects.

Review request later.
Comment 14 Hussam Al-Tayeb 2015-09-22 13:53:45 UTC
Patch works for me in kwin plasma/5.4 branch. Context menu no longer gets stuck.
Comment 15 Martin Flöser 2015-09-28 09:53:33 UTC
Meh, that's a nasty bug in Qt. Anyway: ShipIt(TM)
Comment 16 Martin Flöser 2015-10-16 11:44:32 UTC
*** Bug 353954 has been marked as a duplicate of this bug. ***
Comment 17 Martin Flöser 2015-10-16 11:44:48 UTC
@Thomas: did you push the patch?
Comment 18 Thomas Lübking 2015-10-16 13:33:32 UTC
Ehehh... errrmmm... no. Thanks for the reminder.
Coming. (No problem, pointed 5.5 only anyway)
Comment 19 Thomas Lübking 2015-10-16 13:57:58 UTC
Git commit 801e60b2907690bf6de659a313131b85d3a1e1ac by Thomas Lübking.
Committed on 16/10/2015 at 13:45.
Pushed by luebking into branch 'master'.

force grab on useractions menu

Workaround, this *seems* a Qt problem.
The grab fails while the button is down - Qt then also seems
to release the keyboard.

Not sending it to the deco didn't help either - nevertheless it seems
(from the Qt code) as if the button is currently grabbed
(the code is a dumb forward to xcb_grab_pointer)

As a workaround, the patch simply ensures a grab on releasing a button when
the popup is visible.
FIXED-IN: 5.5

M  +3    -0    events.cpp
M  +8    -5    useractions.cpp
M  +6    -0    useractions.h

http://commits.kde.org/kwin/801e60b2907690bf6de659a313131b85d3a1e1ac
Comment 20 Martin Flöser 2015-10-26 10:02:53 UTC
*** Bug 354390 has been marked as a duplicate of this bug. ***
Comment 21 Thomas Lübking 2015-11-28 16:00:02 UTC
*** Bug 356028 has been marked as a duplicate of this bug. ***
Comment 22 kdebuac.rhn 2017-03-06 10:48:29 UTC
This bug is present again on 5.8.5. The submenu disappears either after selecting an option or driving the mouse pointer back on main menu and waiting for a moment.
Comment 23 kdebuac.rhn 2017-03-06 10:49:59 UTC
Created attachment 104400 [details]
Menus not disappearing on 5.8.5