KWin
Loading...
Searching...
No Matches
globals.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: 2006 Lubos Lunak <l.lunak@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "config-kwin.h"
13
14#include <QCoreApplication>
15#include <QImage>
16#include <QPoint>
17#include <QVariant>
18#include <QVector2D>
19
20#include <kwin_export.h>
21
22#define KWIN_QT5_PORTING 0
23
24namespace KWin
25{
26KWIN_EXPORT Q_NAMESPACE
27
38 /* XRenderCompositing = 1<<1, */
40 };
41
47
49 PlacementArea, // geometry where a window will be initially placed after being mapped
50 MovementArea, // ??? window movement snapping area? ignore struts
51 MaximizeArea, // geometry to which a window will be maximized
52 MaximizeFullArea, // like MaximizeArea, but ignore struts - used e.g. for topmenu
53 FullScreenArea, // area for fullscreen windows
54 // these below don't depend on xinerama settings
55 WorkArea, // whole workarea (all screens together)
56 FullArea, // whole area (all screens together), ignore struts
57 ScreenArea, // one whole screen, ignore struts
58};
59
73
74// TODO: Hardcoding is bad, need to add some way of registering global actions to these.
75// When designing the new system we must keep in mind that we have conditional actions
76// such as "only when moving windows" desktop switching that the current global action
77// system doesn't support.
79 ElectricActionNone, // No special action, not set, desktop switch or an effect
80 ElectricActionShowDesktop, // Show desktop or restore
82 ElectricActionKRunner, // Open KRunner
83 ElectricActionActivityManager, // Activity Manager
84 ElectricActionApplicationLauncher, // Application Launcher
86};
87
89 TabBoxWindowsMode, // Primary window switching mode
90 TabBoxWindowsAlternativeMode, // Secondary window switching mode
91 TabBoxCurrentAppWindowsMode, // Same as primary window switching mode but only for windows of current application
92 TabBoxCurrentAppWindowsAlternativeMode, // Same as secondary switching mode but only for windows of current application
93};
94
100
110
115enum class SwipeDirection {
116 Invalid,
117 Down,
118 Left,
119 Up,
120 Right,
121};
122
123enum class PinchDirection {
124 Expanding,
126};
127
132enum class SessionState {
133 Normal,
134 Saving,
135 Quitting,
136};
138
139enum class LED {
140 NumLock = 1 << 0,
141 CapsLock = 1 << 1,
142 ScrollLock = 1 << 2
143};
144Q_DECLARE_FLAGS(LEDs, LED)
145Q_FLAG_NS(LEDs)
146
147
150enum class Gravity {
151 None,
152 Left,
153 Right,
154 Top,
155 Bottom,
156 TopLeft,
157 TopRight,
160};
161
162enum Layer {
169 NotificationLayer, // layer for windows of type notification
170 ActiveLayer, // active fullscreen, or active dialog
171 PopupLayer, // tooltips, sub- and context menus
172 CriticalNotificationLayer, // layer for notifications that should be shown even on top of fullscreen
173 OnScreenDisplayLayer, // layer for On Screen Display windows such as volume feedback
175 NumLayers, // number of layers, must be last
176};
178
179// TODO: could this be in Tile itself?
180enum class QuickTileFlag {
181 None = 0,
182 Left = 1 << 0,
183 Right = 1 << 1,
184 Top = 1 << 2,
185 Bottom = 1 << 3,
186 Custom = 1 << 4,
188 Vertical = Top | Bottom,
189 Maximize = Left | Right | Top | Bottom,
190};
192Q_DECLARE_FLAGS(QuickTileMode, QuickTileFlag)
193
194
199{
200public:
202 : m_image()
203 , m_hotSpot()
204 {
205 }
206 explicit PlatformCursorImage(const QImage &image, const QPointF &hotSpot)
207 : m_image(image)
208 , m_hotSpot(hotSpot)
209 {
210 }
211 virtual ~PlatformCursorImage() = default;
212
213 bool isNull() const
214 {
215 return m_image.isNull();
216 }
217 QImage image() const
218 {
219 return m_image;
220 }
221 QPointF hotSpot() const
222 {
223 return m_hotSpot;
224 }
225
226private:
227 QImage m_image;
228 QPointF m_hotSpot;
229};
230
234inline KWIN_EXPORT QRect infiniteRegion()
235{
236 // INT_MIN / 2 because width/height is used (INT_MIN+INT_MAX==-1)
237 return QRect(INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX);
238}
239
243KWIN_EXPORT inline QRectF scaledRect(const QRectF &rect, qreal scale)
244{
245 return QRectF{rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale};
246}
247
251KWIN_EXPORT inline QVector2D roundVector(const QVector2D &input)
252{
253 return QVector2D(std::round(input.x()), std::round(input.y()));
254}
255
262KWIN_EXPORT inline QPoint flooredPoint(const QPointF &point)
263{
264 return QPoint(std::floor(point.x()), std::floor(point.y()));
265}
266
271static inline bool exclusiveContains(const QRectF &rect, const QPointF &point)
272{
273 return point.x() >= rect.x() && point.y() >= rect.y() && point.x() < (rect.x() + rect.width()) && point.y() < (rect.y() + rect.height());
274}
275
277 VSync,
279 Async,
281};
283
284enum class ContentType {
285 None = 0,
286 Photo = 1,
287 Video = 2,
288 Game = 3,
289};
291
292enum class VrrPolicy {
293 Never = 0,
294 Always = 1,
295 Automatic = 2,
296};
298
300 VSync,
301 Async
302};
304
305} // namespace
306
307Q_DECLARE_METATYPE(std::chrono::nanoseconds)
308
309#define KWIN_SINGLETON_VARIABLE(ClassName, variableName) \
310public: \
311 static ClassName *create(QObject *parent = nullptr); \
312 static ClassName *self() \
313 { \
314 return variableName; \
315 } \
316 \
317protected: \
318 explicit ClassName(QObject *parent = nullptr); \
319 \
320private: \
321 static ClassName *variableName;
322
323#define KWIN_SINGLETON(ClassName) KWIN_SINGLETON_VARIABLE(ClassName, s_self)
324
325#define KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, FactoredClassName, variableName) \
326 ClassName *ClassName::variableName = nullptr; \
327 ClassName *ClassName::create(QObject *parent) \
328 { \
329 Q_ASSERT(!variableName); \
330 variableName = new FactoredClassName(parent); \
331 return variableName; \
332 }
333#define KWIN_SINGLETON_FACTORY_VARIABLE(ClassName, variableName) KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, ClassName, variableName)
334#define KWIN_SINGLETON_FACTORY_FACTORED(ClassName, FactoredClassName) KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, FactoredClassName, s_self)
335#define KWIN_SINGLETON_FACTORY(ClassName) KWIN_SINGLETON_FACTORY_VARIABLE(ClassName, s_self)
PlatformCursorImage(const QImage &image, const QPointF &hotSpot)
Definition globals.h:206
QImage image() const
Definition globals.h:217
QPointF hotSpot() const
Definition globals.h:221
virtual ~PlatformCursorImage()=default
Q_DECLARE_METATYPE(KWin::SwitchEvent::State)
KWIN_EXPORT QRect infiniteRegion()
Definition globals.h:234
Gravity
Definition globals.h:150
PointerAxisDirection
The direction in which a pointer axis is moved.
Definition globals.h:104
@ PointerAxisUp
Definition globals.h:105
@ PointerAxisLeft
Definition globals.h:107
@ PointerAxisDown
Definition globals.h:106
@ PointerAxisRight
Definition globals.h:108
@ None
Definition options.h:37
VrrPolicy
Definition globals.h:292
SessionState
Definition globals.h:132
clientAreaOption
Definition globals.h:48
@ FullScreenArea
Definition globals.h:53
@ MovementArea
Definition globals.h:50
@ MaximizeArea
Definition globals.h:51
@ MaximizeFullArea
Definition globals.h:52
@ ScreenArea
Definition globals.h:57
@ PlacementArea
Definition globals.h:49
@ FullArea
Definition globals.h:56
@ WorkArea
Definition globals.h:55
KWinOption
Definition globals.h:95
@ CloseButtonCorner
Definition globals.h:96
@ SwitchDesktopOnScreenEdgeMovingWindows
Definition globals.h:98
@ SwitchDesktopOnScreenEdge
Definition globals.h:97
PresentationMode
Definition globals.h:276
Q_ENUM_NS(PresentationMode)
QuickTileFlag
Definition globals.h:180
ElectricBorder
Definition globals.h:60
@ ElectricNone
Definition globals.h:70
@ ElectricTopLeft
Definition globals.h:68
@ ElectricBottomLeft
Definition globals.h:66
@ ElectricBottom
Definition globals.h:65
@ ElectricTopRight
Definition globals.h:62
@ ElectricTop
Definition globals.h:61
@ ElectricRight
Definition globals.h:63
@ ElectricBottomRight
Definition globals.h:64
@ ElectricLeft
Definition globals.h:67
@ ELECTRIC_COUNT
Definition globals.h:69
PinchDirection
Definition globals.h:123
OpenGLPlatformInterface
Definition globals.h:42
@ EglPlatformInterface
Definition globals.h:45
@ NoOpenGLPlatformInterface
Definition globals.h:43
@ GlxPlatformInterface
Definition globals.h:44
ElectricBorderAction
Definition globals.h:78
@ ElectricActionActivityManager
Definition globals.h:83
@ ElectricActionLockScreen
Definition globals.h:81
@ ElectricActionNone
Definition globals.h:79
@ ELECTRIC_ACTION_COUNT
Definition globals.h:85
@ ElectricActionApplicationLauncher
Definition globals.h:84
@ ElectricActionKRunner
Definition globals.h:82
@ ElectricActionShowDesktop
Definition globals.h:80
PresentationModeHint
Definition globals.h:299
CompositingType
Definition globals.h:28
@ QPainterCompositing
Definition globals.h:39
@ NoCompositing
Definition globals.h:29
@ OpenGLCompositing
Definition globals.h:37
TabBoxMode
Definition globals.h:88
@ TabBoxCurrentAppWindowsMode
Definition globals.h:91
@ TabBoxCurrentAppWindowsAlternativeMode
Definition globals.h:92
@ TabBoxWindowsAlternativeMode
Definition globals.h:90
@ TabBoxWindowsMode
Definition globals.h:89
SwipeDirection
Directions for swipe gestures.
Definition globals.h:115
InputRedirection * input()
Definition input.h:549
KWIN_EXPORT QPoint flooredPoint(const QPointF &point)
Definition globals.h:262
KWIN_EXPORT QRectF scaledRect(const QRectF &rect, qreal scale)
Definition globals.h:243
Layer
Definition globals.h:162
@ BelowLayer
Definition globals.h:166
@ UnknownLayer
Definition globals.h:163
@ DesktopLayer
Definition globals.h:165
@ CriticalNotificationLayer
Definition globals.h:172
@ AboveLayer
Definition globals.h:168
@ ActiveLayer
Definition globals.h:170
@ OverlayLayer
Definition globals.h:174
@ PopupLayer
Definition globals.h:171
@ NotificationLayer
Definition globals.h:169
@ NumLayers
Definition globals.h:175
@ NormalLayer
Definition globals.h:167
@ FirstLayer
Definition globals.h:164
@ OnScreenDisplayLayer
Definition globals.h:173
KWIN_EXPORT QVector2D roundVector(const QVector2D &input)
Definition globals.h:251
ContentType
Definition globals.h:284