Bug 361598 - Alt+Tab does not always work when pressing it quickly
Summary: Alt+Tab does not always work when pressing it quickly
Status: RESOLVED WORKSFORME
Alias: None
Product: kwin
Classification: Plasma
Component: tabbox (show other bugs)
Version: 5.6.1
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2016-04-10 16:04 UTC by Alexander Potashev
Modified: 2018-09-28 11:31 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Potashev 2016-04-10 16:04:22 UTC
See Steps to Reproduce.

Reproducible: Always

Steps to Reproduce:
1. Open at least two applications.
2. Press Alt+Tab and release it very quickly, so that the task switcher does not appear.


Actual Results:  
Sometimes the window is not switched.

Expected Results:  
Window should always switch.
Comment 1 Thomas Lübking 2016-04-10 16:26:02 UTC
Might be rather a problem in kglobalaccel - if you assign the alt+tab shortcut to something different (eg. showin krunner) and apply your "Press Alt+Tab and release it very quickly™" pattern, does that trigger krunner reliably?

> Alexander Potashev 
Do you use a multilayout keyboard and/or some input mapper (xim, fctix, etc..) for cyrillic input?
Comment 2 Martin Flöser 2016-04-11 06:01:39 UTC
The window only shows if you have alt pressed for more than 90 msec. So if you do a quick alt+Tab the window is not supposed to show. Is that maybe the case for you?
Comment 3 Martin Flöser 2016-09-14 13:47:53 UTC
any information on the questions in comment #1 and comment #2 which could help us?
Comment 4 Daniel Lichtenberger 2017-04-23 14:09:23 UTC
I also experience this problem with Plasma 5.9.4. I tried disabling/modifying various desktop effects, reducing or increasing animation speed, as well as using the compact application switcher. 

When the application switcher fails, the Alt+Tab command seems to be registered.  The current window briefly loses focus, but it is re-focused after a short delay instead of switching to the previous window. 

I can kind of reliably reproduce the issue using xdotool, to rule out keyboard or keypress timing issues:

for i in {1..10}; do echo 'Switching...'; xdotool key 'alt+Tab'; sleep 1; done

Usually this works as expected, toggling between the konsole window and the previously selected window, but sometimes the same window gets focused multiple times. I used several applications as the previous window (Dolphin, Firefox, VS Code, ...), but couldn't notice a pattern. Is there any debug output that could help diagnose the problem?
Comment 5 Martin Flöser 2017-04-23 19:36:09 UTC
You could run kwin from a konsole and watch the debug output.
Comment 6 Daniel Lichtenberger 2017-04-28 16:21:40 UTC
The only two lines kwin logs when switching windows with the script from my previous comment are (after enabling debug options as described in https://github.com/lxde/lxqt/issues/836#issuecomment-144931359):

kwin_tabbox: areKeySymXsDepressed:  any of  2
kwin_tabbox: 0 : keySymX=0x "ffe9"  i= 8  mask=0x "1"  keymap[i]=0x "1"


_Sometimes_ the last number is "0" instead of "1", as in:

kwin_tabbox: areKeySymXsDepressed:  any of  2
kwin_tabbox: 0 : keySymX=0x "ffe9"  i= 8  mask=0x "1"  keymap[i]=0x "0"

However, there doesn't seem to be a direct link between the issue and this change in output (sometimes switching fails when it printed "0" before, sometimes when it printed "1").
Comment 7 Daniel Lichtenberger 2017-05-07 17:41:18 UTC
Adding some debug statements to kwin pointed me towards grabXKeyboard in utils.cpp. Whenever Alt-Tabbing fails, this method returned false because XCB returns XCB_GRAB_STATUS_ALREADY_GRABBED instead of XCB_GRAB_STATUS_SUCCESS.

"xdotool key XF86LogGrabInfo" lists only kwin and kglobalaccel5 grabs, so maybe some race condition with the KDE hotkey handling? Unfortunately the XCB response does not seem to include any other information that may lead to the client that is actually holding the keyboard lock (which I assume is not kwin itself, as it correctly seems to release the keyboard grab).
Comment 8 Wolfgang Bauer 2018-05-30 15:38:09 UTC
Maybe fixed by https://phabricator.kde.org/D13128 ?
Comment 9 Andrew Crouthamel 2018-09-28 03:35:02 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days, the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information.

For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please set the bug status as REPORTED so that the KDE team knows that the bug is ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 10 Alexander Potashev 2018-09-28 11:09:36 UTC
Could not reproduce lately, might be indeed fixed. May be it was only reproducible on machines of really poor performance.
Comment 11 Daniel Lichtenberger 2018-09-28 11:31:00 UTC
Seems to have been fixed (my HW didn't change).