Bug 370185 - On task switcher (Informative, Breeze, Compact,..) can not control switching with arrow keys
Summary: On task switcher (Informative, Breeze, Compact,..) can not control switching ...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Unclassified
Component: tabbox (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal with 2 votes (vote)
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: usability
: 351604 374287 376623 391339 404879 (view as bug list)
Depends on:
Blocks: 308331
  Show dependency treegraph
 
Reported: 2016-10-06 08:04 UTC by Ivan Yonov
Modified: 2019-03-19 15:27 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.15.0


Attachments
attachment-26989-0.html (2.23 KB, text/html)
2019-03-19 15:27 UTC, Ivan Yonov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Yonov 2016-10-06 08:04:53 UTC
On some task switcher themes, after Alt+Tab (and holding Alt) I can switch the tasks back and forward by pushing arrow keys. Such themes are "Cover Switch" and "Flip Switch". 
But on themes like "Informative" or "Compact" this is not possible.

Reproducible: Always

Steps to Reproduce:
1. Choose "Informative" as task switcher theme. Set Alt+Tab as a primary forward shortcut.
2. Open few random app windows.
3. Push Alt+Tab, to switch the tasks. While holding Alt, push Arrow Up key. (Nothing happens.)
4. Change the task switcher theme to "Flip Switch" and repeat the upper. (It works, the tasks are switched on Arrow key while holding Alt).

Actual Results:  
Arrow keys work only on Flip Switch theme. 

Expected Results:  
Arrow keys to work on all available task switcher themes.
Comment 1 Eike Hein 2016-10-06 08:19:29 UTC
Unrelated to Task Manager, reassigning.
Comment 2 Martin Flöser 2017-06-19 15:10:51 UTC
*** Bug 376623 has been marked as a duplicate of this bug. ***
Comment 3 Martin Flöser 2017-06-19 15:11:14 UTC
*** Bug 374287 has been marked as a duplicate of this bug. ***
Comment 4 Alexander Mentyu 2018-09-18 14:31:39 UTC
Can reproduce on also Wayland

Cover Switch - Left/Right arrows are working, Up/Down arrows not working
Flip Switch - All arrows are working
Breeze - No arrows are working
Breeze Dark - No arrows are working
Grid - No arrows are working
Compact - No arrows are working
Small Icons - No arrows are working
Text Only - No arrows are working
Large Icons - No arrows are working
Thumbnails - No arrows are working
Informative - No arrows are working

Operating System: KDE neon Developer Edition
KDE Plasma Version: 5.14.80
Qt Version: 5.11.1
KDE Frameworks Version: 5.51.0
Kernel Version: 4.15.0-34-generic
OS Type: 64-bit
Processors: 8 × Intel® Core™ i5-8250U CPU @ 1.60GHz
Memory: 7,7 GiB of RAM
Comment 5 Alexander Mentyu 2018-09-19 11:34:40 UTC
*** Bug 351604 has been marked as a duplicate of this bug. ***
Comment 6 Kai Uwe Broulik 2018-09-19 11:37:17 UTC
So basically everything that is "tabbox" (the popup windows and sidebar) don't support Arrow keys whereas all KWin effects (cover switch and flip switch) do.
Comment 7 Chris Holland 2018-09-20 01:49:18 UTC
Here's the links to what I found in Bug #374287

-------

It sounds like the QML based tabboxes aren't recieving the keypress events. The flip switch and cover switch are C++ desktop effects, which can hook the keyboard events themselves since they create their own window.

https://github.com/KDE/kwin/blob/master/effects/flipswitch/flipswitch.cpp#L902
https://github.com/KDE/kwin/tree/master/effects/coverswitch

This is where the QML based tabboxes events are handled.

https://github.com/KDE/kwin/blob/master/tabbox/tabboxhandler.cpp#L618

If you do:

PlasmaCore.Dialog {
  mainItem: Item {
    Keys.onPressed: {}
  }
}

then it works in the *preview* but does not work in the actual kwin popup.

I wonder if it's because the popup isn't focused? PlasmaCore.Dialog is a QQuickWindow, which I don't think will do anything if it doesn't contain an activeFocusItem.

https://github.com/qt/qtdeclarative/blob/dev/src/quick/items/qquickwindow.cpp#L1622

Did it work in the past? Did adding the eventFilter to support the mouse wheel break it? I don't remember if it used to work or not.

https://github.com/KDE/kwin/commit/e9d20b80e9a79f514a219357d991092d83665350

I do know that the qml api changed, because a number of task switchers on GHNS no longer work.
Comment 8 Chris Holland 2018-09-23 17:02:09 UTC
The tabboxhandler.cpp eventFilter() function does not receive arrow key events:

https://www.youtube.com/watch?v=noR582a0eBU
Comment 9 Chris Holland 2018-09-24 03:12:07 UTC
Some debug logging:

kwin_tabbox: TabBox::keyPress              150994962
kwin_tabbox: TabBox::grabbedKeyEvent        16777234
kwin_tabbox: TabBoxHandler::grabbedKeyEvent 16777234
kwin_tabbox:     d->m_mainItem && d->window()
kwin_tabbox:     d->window() PlasmaQuick::Dialog(0x15bcc30 exposed, visibility=QWindow::Visibility(Windowed), flags=QFlags<Qt::WindowType>(X11BypassWindowManagerHint|FramelessWindowHint), geometry=498,441 932x206)
kwin_tabbox:     d->window()->contentItem() QQuickRootItem(0x15820e0, parent=0x0, geometry=0,0 932x206)
kwin_tabbox:     d->window()->sendEvent Plasma::FrameSvgItem(0x15be890, parent=0x15820e0, geometry=0,0 932x206)
kwin_tabbox:     d->window()->sendEvent ColorScope(0x16862a0, parent=0x0, geometry=0,0 0x0)

Okay, for some reason TabBoxHandler::grabbedKeyEvent is calling sendEvent to a ColorScope?

We can easily find where it defines PlasmaCore.Dialog is the parent of the FrameSvgItem:
https://github.com/KDE/plasma-framework/blob/master/src/plasmaquick/dialog.cpp#L758

The only other child of the contentItem() is the Dialog::mainItem.
https://github.com/KDE/plasma-framework/blob/master/src/plasmaquick/dialog.cpp#L797

Wait, I just noticed the `ColorScope`'s `parent=0x0`, which means the Dialog is not the "parent"? Uhg. Does that mean it is not the mainItem()?

I'm testing with my "Thumbnail Grid" skin, which is similar to the default skins in kdeplasma-addons/windowswitchers, Breeze's in plasma-workspace.

* https://github.com/Zren/kwin-tabbox-thumbnail_grid/blob/master/package/contents/ui/main.qml
* https://github.com/KDE/kdeplasma-addons/blob/master/windowswitchers/thumbnails/contents/ui/main.qml
* https://github.com/KDE/plasma-workspace/blob/master/lookandfeel/contents/windowswitcher/WindowSwitcher.qml

Actually why do we even care about the children of `contentItem()`?! Why not just iterate the children of the `window()` (the PlasmaCore.Dialog)?

-    const QList<QQuickItem*> items = d->window()->contentItem()->findChildren<QQuickItem*>(QString(), Qt::FindDirectChildrenOnly);
+    const QList<QQuickItem*> items = d->window()->findChildren<QQuickItem*>(QString(), Qt::FindDirectChildrenOnly);

Aha! It works!

https://www.youtube.com/watch?v=S8RL9NlHL8g
Comment 10 Chris Holland 2018-09-24 03:38:40 UTC
Here's a status of (most) QML Skins.

* Breeze needs a key handler added.
* Breeze Dark is falling back on Informative... which is weird.
* United is falling back on a broken skin. I'll try deleting all the broken ones and check again.
* The Informative skin probably just needs to reposition the Keys.onPressed inside the mainItem to work.

-----

* Breeze (Look and Feel)
	* Source: plasma-workspace
	* KeyHandler: None
	* https://github.com/KDE/plasma-workspace/blob/master/lookandfeel/contents/windowswitcher/WindowSwitcher.qml
* Breeze Dark (Look and Feel)
	* Source: breeze
	* Defined to use same as Breeze, but uses Informative.
	* KeyHandler: None
	* https://github.com/KDE/breeze/blob/master/lookandfeel.dark/contents/defaults#L17
* Thumbnail Grid
	* Source: https://store.kde.org/p/1153173/
	* KeyHandler: Dialog.mainItem.Keys.onPressed
	* https://github.com/Zren/kwin-tabbox-thumbnail_grid/blob/master/package/contents/ui/main.qml
* Preview Stack
	* Source: https://store.kde.org/p/1163050
	* KeyHandler: None
* Preview Reel
	* Source: https://store.kde.org/p/1161720
	* KeyHandler: None
* Small Icons
	* Source: kdeplasma-addons
	* KeyHandler: Dialog.mainItem.Keys.onPressed
	* https://github.com/KDE/kdeplasma-addons/blob/master/windowswitchers/small_icons/contents/ui/main.qml
* Informative
	* Source: kdeplasma-addons
	* KeyHandler: Dialog.Keys.onPressed
	* https://github.com/KDE/kdeplasma-addons/blob/master/windowswitchers/informative/contents/ui/main.qml
* Compact
	* Source: kdeplasma-addons
	* KeyHandler: Dialog.mainItem.Keys.onPressed
	* https://github.com/KDE/kdeplasma-addons/blob/master/windowswitchers/compact/contents/ui/main.qml
* Thumbnails
	* Source: kdeplasma-addons
	* KeyHandler: Dialog.mainItem.Keys.onPressed
	* https://github.com/KDE/kdeplasma-addons/blob/master/windowswitchers/thumbnails/contents/ui/main.qml
* Large Icons
	* Source: kdeplasma-addons
	* KeyHandler: Dialog.mainItem.Keys.onPressed
	* https://github.com/KDE/kdeplasma-addons/blob/master/windowswitchers/big_icons/contents/ui/main.qml
* Text Only
	* Source: kdeplasma-addons
	* KeyHandler: Dialog.mainItem.Keys.onPressed
	* https://github.com/KDE/kdeplasma-addons/blob/master/windowswitchers/text/contents/ui/main.qml



Broken:

* United (Look and Feel)
	* Source: https://store.kde.org/p/1167950/
	* Defined to use same as Breeze, but does not load.
	* https://github.com/llucassaw/United/blob/master/contents/defaults#L14
* Window Wall
	* Source: https://store.kde.org/p/1112559
	* Broken (org.kde.kwin 0.1)
* Black Icons
	* Source: https://store.kde.org/p/1112557
	* Broken (org.kde.kwin ?)
* present windows clone with a background
	* Source: https://store.kde.org/p/1112555
	* Broken (org.kde.kwin 0.1)
* Informative with thumbnail
	* Source: https://store.kde.org/p/1112556
	* Broken (org.kde.kwin 0.1)
* Present Windows Clone
	* Source: https://store.kde.org/p/1112558
	* Broken (org.kde.kwin 0.1)
* Scaling Switcher
	* Source: https://store.kde.org/p/1112560
	* Broken (org.kde.kwin 0.1)
Comment 11 Chris Holland 2018-09-24 04:30:14 UTC
https://phabricator.kde.org/D15720
Comment 12 Chris Holland 2018-09-24 18:31:47 UTC
* Grid
	* Source: kdeplasma-addons
	* KeyHandler: Dialog.mainItem.Keys.onPressed
	* https://github.com/KDE/kdeplasma-addons/blob/master/windowswitchers/present_windows/contents/ui/main.qml


-----

After removing all the broken skins, United is also defaulting to Informative.

This is weird, it's not defaulting to the first/last alphabetically...

My theory is that it's scanning for `org.kde.breeze.desktop`, doesn't find a kwin/tabbox/____ with that name, and picks the one before it (informative). Breeze Dark suffers this as well.

big_icons
compact
informative <= Settles for the previous skin
org.kde.breeze.desktop <= Doesn't exist in kwin/tabbox (it's lnf/windowswitcher)
present_windows
preview_reel
preview_stack
small_icons
text
thumbnail_grid
thumbnails

Breeze probably works since it contains the `windowswitcher/WindowSwitcher.qml` in it's LookAndFeel  while the other 2 do not, so it thinks it's suppose to look in kwin/tabbox.
Comment 13 Alexander Mentyu 2018-10-08 16:35:57 UTC
*** Bug 391339 has been marked as a duplicate of this bug. ***
Comment 14 David Edmundson 2018-11-07 16:23:12 UTC
Git commit c42d1607421e900567f6f4fe2644f18afa62e2f9 by David Edmundson.
Committed on 07/11/2018 at 16:22.
Pushed by davidedmundson into branch 'master'.

[TabBox] Fix Arrow Key / Keyboard Events in QML Alt+Tab Skins

Summary:
KWin used to do a quirky trick to send key events to the topmost QQuickItem
rather than things going to the activeFocus item.

Sending it to the window previously would have failed as the window
didn't think it was active.

Since 66986d4afddcd09c28fe3addb0caa09279eda10f we can just let the
window process the events in a normal QtQuick manner.
Fixed-in: 5.15.0

It will require tabboxes to set focus correctly.
The ones I tested did.

Most analysis for this patch was done by Chris Holland.

Test Plan:
Held+alt tab with the "Text" tabbox switcher
pressed up and down

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin, Zren

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16693

M  +1    -7    tabbox/tabboxhandler.cpp

https://commits.kde.org/kwin/c42d1607421e900567f6f4fe2644f18afa62e2f9
Comment 15 Nate Graham 2018-11-15 14:02:20 UTC
Git commit 4d52641657d691a860848fc1f724fe0a141676c9 by Nate Graham.
Committed on 15/11/2018 at 14:02.
Pushed by ngraham into branch 'master'.

[windowswitcher] Implement keyboard navigation

Summary:
Implements keyboard navigation via the up and down arrow keys for the Breeze window switcher.

Support for this went in with D16693.

Test Plan: Alt-tab, use arrow keys, it works!

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D16886

M  +12   -0    lookandfeel/contents/windowswitcher/WindowSwitcher.qml

https://commits.kde.org/plasma-workspace/4d52641657d691a860848fc1f724fe0a141676c9
Comment 16 Chris Holland 2019-01-18 17:59:36 UTC
Git commit 80bd32b12a01e29f3fe88f2a50c0a2a842872c19 by Chris Holland.
Committed on 18/01/2019 at 17:44.
Pushed by cholland into branch 'master'.

Consistent arrow key handling in the Informative Alt+Tab skin

Moved `Dialog.Keys.onPressed` to `Dialog.mainItem.Keys.onPressed` so
that all tabbox skins are consistent. This fixes up/down arrow key
navigation in this skin.

Differential Revision: https://phabricator.kde.org/D16093

M  +12   -11   windowswitchers/informative/contents/ui/main.qml

https://commits.kde.org/kdeplasma-addons/80bd32b12a01e29f3fe88f2a50c0a2a842872c19
Comment 17 dufferzafar 2019-02-18 06:36:09 UTC
Is there a similar feature for the "Large Icons" switcher? Using Left/Right arrow keys there would make a lot of sense.
Comment 18 Nate Graham 2019-02-18 14:48:31 UTC
Yes, it works in 5.15.0.
Comment 19 Luis Fernando Planella Gonzalez 2019-02-19 10:29:43 UTC
I just figured out that for the normal task switching (Alt + Tab) the arrow keys work, but when switching between windows of the same application (Alt + Grave), the arrow keys do nothing...

I think this is part of this same bug, but if you prefer, I can report another one.
Comment 20 Vlad Zahorodnii 2019-03-05 16:54:32 UTC
*** Bug 404879 has been marked as a duplicate of this bug. ***
Comment 21 Vlad Zahorodnii 2019-03-05 16:57:17 UTC
Git commit d7237df172e5a9065e387c94336cc38fd5c1fc13 by Vlad Zagorodniy, on behalf of Chris Holland.
Committed on 05/03/2019 at 16:55.
Pushed by vladz into branch 'Plasma/5.15'.

Consistent arrow key handling in the Informative Alt+Tab skin

Moved `Dialog.Keys.onPressed` to `Dialog.mainItem.Keys.onPressed` so
that all tabbox skins are consistent. This fixes up/down arrow key
navigation in this skin.

Differential Revision: https://phabricator.kde.org/D16093

M  +12   -11   windowswitchers/informative/contents/ui/main.qml

https://commits.kde.org/kdeplasma-addons/d7237df172e5a9065e387c94336cc38fd5c1fc13
Comment 22 Ivan Yonov 2019-03-19 15:27:36 UTC
Created attachment 118915 [details]
attachment-26989-0.html

Thank you all, I see it working now.
You rock!

Иван Йонов
http://i-creativ.net


On Tue, 5 Mar 2019 at 18:57, Vlad Zagorodniy <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=370185
>
> --- Comment #21 from Vlad Zagorodniy <vladzzag@gmail.com> ---
> Git commit d7237df172e5a9065e387c94336cc38fd5c1fc13 by Vlad Zagorodniy, on
> behalf of Chris Holland.
> Committed on 05/03/2019 at 16:55.
> Pushed by vladz into branch 'Plasma/5.15'.
>
> Consistent arrow key handling in the Informative Alt+Tab skin
>
> Moved `Dialog.Keys.onPressed` to `Dialog.mainItem.Keys.onPressed` so
> that all tabbox skins are consistent. This fixes up/down arrow key
> navigation in this skin.
>
> Differential Revision: https://phabricator.kde.org/D16093
>
> M  +12   -11   windowswitchers/informative/contents/ui/main.qml
>
>
> https://commits.kde.org/kdeplasma-addons/d7237df172e5a9065e387c94336cc38fd5c1fc13
>
> --
> You are receiving this mail because:
> You reported the bug.