1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
From 52afb2a52b17b82fd85150f40200b186517e49f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Wolfgang=20M=C3=BCller?= <wolf@oriole.systems>
Date: Wed, 23 Oct 2024 18:45:46 +0200
Subject: [PATCH 2/3] tabbox: Only skip active window if it is in the client
list
When invoking the tabbox we initially advance the selection by one,
assuming the first item in the client list is the active window which
we'd like to skip. However, since we allow the user to apply a filter to
the clients displayed in the list, we might end up with the active
window missing from the current client list and skipping over an
unrelated client. When using focus chain switching this means we skip
over the last focused window, making quick switching between two windows
impossible.
Instead of advancing the selection unconditionally, make sure not to
advance if the client list does not contain the active window and we are
in the initial invocation of the tabbox in navigatingThroughWindows().
---
src/tabbox/tabbox.cpp | 25 +++++++++++++++++++------
src/tabbox/tabbox.h | 7 ++++++-
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/src/tabbox/tabbox.cpp b/src/tabbox/tabbox.cpp
index f3bbfa99bc..5d6b2cb569 100644
--- a/src/tabbox/tabbox.cpp
+++ b/src/tabbox/tabbox.cpp
@@ -478,6 +478,11 @@ void TabBox::setCurrentIndex(QModelIndex index, bool notifyEffects)
}
}
+bool TabBox::haveActiveClient()
+{
+ return m_tabBox->index(m_tabBox->activeClient()).isValid();
+}
+
void TabBox::show()
{
Q_EMIT tabBoxAdded(m_tabBoxMode);
@@ -808,9 +813,7 @@ void TabBox::navigatingThroughWindows(bool forward, const QKeySequence &shortcut
CDEWalkThroughWindows(forward);
} else {
if (areModKeysDepressed(shortcut)) {
- if (startKDEWalkThroughWindows(mode)) {
- KDEWalkThroughWindows(forward);
- }
+ startKDEWalkThroughWindows(forward, mode);
} else {
// if the shortcut has no modifiers, don't show the tabbox,
// don't grab, but simply go to the next window
@@ -898,7 +901,7 @@ bool TabBox::toggleMode(TabBoxMode mode)
return true;
}
-bool TabBox::startKDEWalkThroughWindows(TabBoxMode mode)
+bool TabBox::startKDEWalkThroughWindows(bool forward, TabBoxMode mode)
{
if (!establishTabBoxGrab()) {
return false;
@@ -911,13 +914,19 @@ bool TabBox::startKDEWalkThroughWindows(TabBoxMode mode)
setMode(mode);
reset();
+
+ if (haveActiveClient()) {
+ nextPrev(forward);
+ }
+
+ delayedShow();
+
return true;
}
void TabBox::KDEWalkThroughWindows(bool forward)
{
nextPrev(forward);
- delayedShow();
}
void TabBox::CDEWalkThroughWindows(bool forward)
@@ -979,7 +988,11 @@ void TabBox::KDEOneStepThroughWindows(bool forward, TabBoxMode mode)
{
setMode(mode);
reset();
- nextPrev(forward);
+
+ if (haveActiveClient()) {
+ nextPrev(forward);
+ }
+
if (Window *c = currentClient()) {
Workspace::self()->activateWindow(c);
shadeActivate(c);
diff --git a/src/tabbox/tabbox.h b/src/tabbox/tabbox.h
index ec4ca2ba28..72e43b3a2e 100644
--- a/src/tabbox/tabbox.h
+++ b/src/tabbox/tabbox.h
@@ -93,6 +93,11 @@ public:
*/
void setCurrentClient(Window *newClient);
+ /**
+ * Return whether the active client is present in the client list.
+ */
+ bool haveActiveClient();
+
void setMode(TabBoxMode mode);
TabBoxMode mode() const
{
@@ -228,7 +233,7 @@ private:
explicit TabBox(QObject *parent);
void loadConfig(const KConfigGroup &config, TabBoxConfig &tabBoxConfig);
- bool startKDEWalkThroughWindows(TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
+ bool startKDEWalkThroughWindows(bool forward, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
void navigatingThroughWindows(bool forward, const QKeySequence &shortcut, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
void KDEWalkThroughWindows(bool forward);
void CDEWalkThroughWindows(bool forward);
--
2.47.0
|