KWin
Loading...
Searching...
No Matches
tabbox.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6 SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
7 SPDX-FileCopyrightText: 2009 Martin Gräßlin <mgraesslin@kde.org>
8
9 SPDX-License-Identifier: GPL-2.0-or-later
10*/
11
12#pragma once
13
15#include "utils/common.h"
16#include <QKeySequence>
17#include <QModelIndex>
18#include <QTimer>
19
20class KConfigGroup;
21class KLazyLocalizedString;
22class QAction;
23class QMouseEvent;
24class QKeyEvent;
25class QWheelEvent;
26
27namespace KWin
28{
29
30class Workspace;
31class Window;
32class X11EventFilter;
33namespace TabBox
34{
35class TabBoxConfig;
36class TabBox;
38{
39public:
41 ~TabBoxHandlerImpl() override;
42
43 int activeScreen() const override;
44 Window *activeClient() const override;
45 QString desktopName(Window *client) const override;
46 bool isKWinCompositing() const override;
47 Window *nextClientFocusChain(Window *client) const override;
48 Window *firstClientFocusChain() const override;
49 bool isInFocusChain(Window *client) const override;
50 QList<Window *> stackingOrder() const override;
51 void elevateClient(Window *c, QWindow *tabbox, bool elevate) const override;
52 void raiseClient(Window *client) const override;
53 void restack(Window *c, Window *under) override;
54 void shadeClient(Window *c, bool b) const override;
55 Window *clientToAddToList(Window *client) const override;
56 Window *desktopClient() const override;
57 void activateAndClose() override;
58 void highlightWindows(Window *window = nullptr, QWindow *controller = nullptr) override;
59 bool noModifierGrab() const override;
60
61private:
62 bool checkDesktop(Window *client) const;
63 bool checkActivity(Window *client) const;
64 bool checkApplications(Window *client) const;
65 bool checkMinimized(Window *client) const;
66 bool checkMultiScreen(Window *client) const;
67
68 TabBox *m_tabBox;
69};
70
71class KWIN_EXPORT TabBox : public QObject
72{
73 Q_OBJECT
74public:
75 explicit TabBox();
77
82 Window *currentClient();
83
89 QList<Window *> currentClientList();
90
94 void setCurrentClient(Window *newClient);
95
96 void setMode(TabBoxMode mode);
98 {
99 return m_tabBoxMode;
100 }
101
105 void reset(bool partial_reset = false);
106
110 void nextPrev(bool next = true);
111
126 void delayedShow();
127
131 void hide(bool abort = false);
132
140 {
141 ++m_displayRefcount;
142 }
143
149 {
150 --m_displayRefcount;
151 }
152
160 bool isDisplayed() const
161 {
162 return m_displayRefcount > 0;
163 }
164
168 bool isShown() const
169 {
170 return m_isShown;
171 }
172
173 bool handleMouseEvent(QMouseEvent *event);
174 bool handleWheelEvent(QWheelEvent *event);
175 void grabbedKeyEvent(QKeyEvent *event);
176
177 bool isGrabbed() const
178 {
179 return m_tabGrab;
180 }
181
182 void initShortcuts();
183
184 Window *nextClientStatic(Window *) const;
185 Window *previousClientStatic(Window *) const;
186 void keyPress(int key);
187 void modifiersReleased();
188
190 {
191 return m_forcedGlobalMouseGrab;
192 }
193
194 bool noModifierGrab() const
195 {
196 return m_noModifierGrab;
197 }
198 void setCurrentIndex(QModelIndex index, bool notifyEffects = true);
199
200public Q_SLOTS:
205 void show();
206 void close(bool abort = false);
207 void accept(bool closeTabBox = true);
208 void slotWalkThroughWindows();
209 void slotWalkBackThroughWindows();
210 void slotWalkThroughWindowsAlternative();
211 void slotWalkBackThroughWindowsAlternative();
212 void slotWalkThroughCurrentAppWindows();
213 void slotWalkBackThroughCurrentAppWindows();
214 void slotWalkThroughCurrentAppWindowsAlternative();
215 void slotWalkBackThroughCurrentAppWindowsAlternative();
216
217 void handlerReady();
218
219 bool toggle(ElectricBorder eb);
220
221Q_SIGNALS:
222 void tabBoxAdded(int);
225 void tabBoxKeyEvent(QKeyEvent *);
226
227private:
228 explicit TabBox(QObject *parent);
229 void loadConfig(const KConfigGroup &config, TabBoxConfig &tabBoxConfig);
230
231 bool startKDEWalkThroughWindows(TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
232 void navigatingThroughWindows(bool forward, const QKeySequence &shortcut, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
233 void KDEWalkThroughWindows(bool forward);
234 void CDEWalkThroughWindows(bool forward);
235 void KDEOneStepThroughWindows(bool forward, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
236 bool establishTabBoxGrab();
237 void removeTabBoxGrab();
238 template<typename Slot>
239 void key(const KLazyLocalizedString &actionName, Slot slot, const QKeySequence &shortcut = QKeySequence());
240
241 void shadeActivate(Window *c);
242
243 bool toggleMode(TabBoxMode mode);
244
245private Q_SLOTS:
246 void reconfigure();
247 void globalShortcutChanged(QAction *action, const QKeySequence &seq);
248
249private:
250 TabBoxMode m_tabBoxMode;
251 TabBoxHandlerImpl *m_tabBox;
252 int m_delayShowTime;
253
254 QTimer m_delayedShowTimer;
255 int m_displayRefcount;
256
257 TabBoxConfig m_defaultConfig;
258 TabBoxConfig m_alternativeConfig;
259 TabBoxConfig m_defaultCurrentApplicationConfig;
260 TabBoxConfig m_alternativeCurrentApplicationConfig;
261 // false if an effect has referenced the tabbox
262 // true if tabbox is active (independent on showTabbox setting)
263 bool m_isShown;
264 bool m_tabGrab;
265 // true if tabbox is in modal mode which does not require holding a modifier
266 bool m_noModifierGrab;
267 QKeySequence m_cutWalkThroughWindows, m_cutWalkThroughWindowsReverse;
268 QKeySequence m_cutWalkThroughWindowsAlternative, m_cutWalkThroughWindowsAlternativeReverse;
269 QKeySequence m_cutWalkThroughCurrentAppWindows, m_cutWalkThroughCurrentAppWindowsReverse;
270 QKeySequence m_cutWalkThroughCurrentAppWindowsAlternative, m_cutWalkThroughCurrentAppWindowsAlternativeReverse;
271 bool m_forcedGlobalMouseGrab;
272 bool m_ready; // indicates whether the config is completely loaded
273 QList<ElectricBorder> m_borderActivate, m_borderAlternativeActivate;
274 QHash<ElectricBorder, QAction *> m_touchActivate;
275 QHash<ElectricBorder, QAction *> m_touchAlternativeActivate;
276 std::unique_ptr<X11EventFilter> m_x11EventFilter;
277};
278
279} // namespace TabBox
280} // namespace
Window * client(const QModelIndex &index) const
Window * desktopClient() const override
Definition tabbox.cpp:246
QList< Window * > stackingOrder() const override
Definition tabbox.cpp:201
void shadeClient(Window *c, bool b) const override
Definition tabbox.cpp:236
void activateAndClose() override
Definition tabbox.cpp:257
Window * nextClientFocusChain(Window *client) const override
Definition tabbox.cpp:82
void restack(Window *c, Window *under) override
Definition tabbox.cpp:223
Window * clientToAddToList(Window *client) const override
Definition tabbox.cpp:172
void elevateClient(Window *c, QWindow *tabbox, bool elevate) const override
Definition tabbox.cpp:228
bool isKWinCompositing() const override
Definition tabbox.cpp:213
TabBoxHandlerImpl(TabBox *tabBox)
Definition tabbox.cpp:59
int activeScreen() const override
Definition tabbox.cpp:69
QString desktopName(Window *client) const override
Definition tabbox.cpp:74
Window * firstClientFocusChain() const override
Definition tabbox.cpp:87
Window * activeClient() const override
Definition tabbox.cpp:97
void highlightWindows(Window *window=nullptr, QWindow *controller=nullptr) override
Definition tabbox.cpp:262
bool noModifierGrab() const override
Definition tabbox.cpp:277
bool isInFocusChain(Window *client) const override
Definition tabbox.cpp:92
void raiseClient(Window *client) const override
Definition tabbox.cpp:218
TabBoxMode mode() const
Definition tabbox.h:97
bool isShown() const
Definition tabbox.h:168
bool forcedGlobalMouseGrab() const
Definition tabbox.h:189
bool isDisplayed() const
Definition tabbox.h:160
void tabBoxKeyEvent(QKeyEvent *)
bool isGrabbed() const
Definition tabbox.h:177
bool noModifierGrab() const
Definition tabbox.h:194
TabBoxHandler * tabBox
ElectricBorder
Definition globals.h:60
TabBoxMode
Definition globals.h:88