Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.9.4/qxcbwindow.h

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5 #ifndef QXCBWINDOW_H
6 #define QXCBWINDOW_H
7
8 #include <qpa/qplatformwindow.h>
9 #include <QtGui/QSurfaceFormat>
10 #include <QtGui/QImage>
11
12 #include <xcb/xcb.h>
13 #include <xcb/sync.h>
14
15 #include "qxcbobject.h"
16
17 #include <QtPlatformHeaders/qxcbwindowfunctions.h>
18
19 QT_BEGIN_NAMESPACE
20
21 class QXcbScreen;
22 class QXcbSyncWindowRequest;
23 class QIcon;
24
25 class Q_XCB_EXPORT QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
26 {
27 public:
28 enum NetWmState {
29 NetWmStateAbove = 0x1,
30 NetWmStateBelow = 0x2,
31 NetWmStateFullScreen = 0x4,
32 NetWmStateMaximizedHorz = 0x8,
33 NetWmStateMaximizedVert = 0x10,
34 NetWmStateModal = 0x20,
35 NetWmStateStaysOnTop = 0x40,
36 NetWmStateDemandsAttention = 0x80
37 };
38
39 Q_DECLARE_FLAGS(NetWmStates, NetWmState)
40
41 QXcbWindow(QWindow *window);
42 ~QXcbWindow();
43
44 void setGeometry(const QRect &rect) override;
45
46 QMargins frameMargins() const override;
47
48 void setVisible(bool visible) override;
49 void setWindowFlags(Qt::WindowFlags flags) override;
50 void setWindowState(Qt::WindowState state) override;
51 WId winId() const override;
52 void setParent(const QPlatformWindow *window) override;
53
54 bool isExposed() const override;
55 bool isEmbedded() const override;
56 QPoint mapToGlobal(const QPoint &pos) const override;
57 QPoint mapFromGlobal(const QPoint &pos) const override;
58
59 void setWindowTitle(const QString &title) override;
60 void setWindowIconText(const QString &title);
61 void setWindowIcon(const QIcon &icon) override;
62 void raise() override;
63 void lower() override;
64 void propagateSizeHints() override;
65
66 void requestActivateWindow() override;
67
68 bool setKeyboardGrabEnabled(bool grab) override;
69 bool setMouseGrabEnabled(bool grab) override;
70
71 void setCursor(xcb_cursor_t cursor, bool isBitmapCursor);
72
73 QSurfaceFormat format() const override;
74
75 void windowEvent(QEvent *event) override;
76
77 bool startSystemResize(const QPoint &pos, Qt::Corner corner) override;
78
79 void setOpacity(qreal level) override;
80 void setMask(const QRegion &region) override;
81
82 void setAlertState(bool enabled) override;
83 bool isAlertState() const override { return m_alertState; }
84
85 xcb_window_t xcb_window() const { return m_window; }
86 uint depth() const { return m_depth; }
87 QImage::Format imageFormat() const { return m_imageFormat; }
88 bool imageNeedsRgbSwap() const { return m_imageRgbSwap; }
89
90 bool handleGenericEvent(xcb_generic_event_t *event, long *result) override;
91
92 void handleExposeEvent(const xcb_expose_event_t *event) override;
93 void handleClientMessageEvent(const xcb_client_message_event_t *event) override;
94 void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) override;
95 void handleMapNotifyEvent(const xcb_map_notify_event_t *event) override;
96 void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event) override;
97 void handleButtonPressEvent(const xcb_button_press_event_t *event) override;
98 void handleButtonReleaseEvent(const xcb_button_release_event_t *event) override;
99 void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event) override;
100
101 void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) override;
102 void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) override;
103 void handleFocusInEvent(const xcb_focus_in_event_t *event) override;
104 void handleFocusOutEvent(const xcb_focus_out_event_t *event) override;
105 void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) override;
106 #ifdef XCB_USE_XINPUT22
107 void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) override;
108 void handleXIEnterLeave(xcb_ge_event_t *) override;
109 #endif
110
111 QXcbWindow *toWindow() override;
112
113 void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
114 Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source);
115
116 void updateNetWmUserTime(xcb_timestamp_t timestamp);
117
118 static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes);
119 static void setWmWindowRoleStatic(QWindow *window, const QByteArray &role);
120 static uint visualIdStatic(QWindow *window);
121
122 QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
123 void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags);
124 void setWmWindowRole(const QByteArray &role);
125
126 static void setWindowIconTextStatic(QWindow *window, const QString &text);
127
128 static void setParentRelativeBackPixmapStatic(QWindow *window);
129 void setParentRelativeBackPixmap();
130
131 static bool requestSystemTrayWindowDockStatic(const QWindow *window);
132 bool requestSystemTrayWindowDock() const;
133
134 static QRect systemTrayWindowGlobalGeometryStatic(const QWindow *window);
135 QRect systemTrayWindowGlobalGeometry() const;
136 uint visualId() const;
137
138 bool needsSync() const;
139
140 void postSyncWindowRequest();
141 void clearSyncWindowRequest() { m_pendingSyncRequest = 0; }
142
143 QXcbScreen *xcbScreen() const;
144
145 bool doStartSystemResize(const QPoint &globalPos, Qt::Corner corner);
146
147 virtual void create();
148 virtual void destroy();
149
150 public Q_SLOTS:
151 void updateSyncRequestCounter();
152
153 protected:
154 virtual void resolveFormat(const QSurfaceFormat &format) { m_format = format; }
155 virtual const xcb_visualtype_t *createVisual();
156
157 QXcbScreen *parentScreen();
158
159 QXcbScreen *initialScreen() const;
160 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
161 NetWmStates netWmStates();
162 void setNetWmStates(NetWmStates);
163
164 void setMotifWindowFlags(Qt::WindowFlags flags);
165 void setNetWmStateWindowFlags(Qt::WindowFlags flags);
166
167 void updateMotifWmHintsBeforeMap();
168 void updateNetWmStateBeforeMap();
169
170 void setTransparentForMouseEvents(bool transparent);
171 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
172
173 QRect windowToWmGeometry(QRect r) const;
174 void sendXEmbedMessage(xcb_window_t window, quint32 message,
175 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
176 void handleXEmbedMessage(const xcb_client_message_event_t *event);
177
178 void show();
179 void hide();
180
181 bool relayFocusToModalWindow() const;
182 void doFocusIn();
183 void doFocusOut();
184
185 bool compressExposeEvent(QRegion &exposeRegion);
186
187 void handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y,
188 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
189
190 void handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y,
191 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
192
193 void handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y,
194 Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
195
196 void handleEnterNotifyEvent(int event_x, int event_y, int root_x, int root_y,
197 quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
198
199 void handleLeaveNotifyEvent(int root_x, int root_y,
200 quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
201
202 xcb_window_t m_window = 0;
203 xcb_colormap_t m_cmap = 0;
204
205 uint m_depth = 0;
206 QImage::Format m_imageFormat = QImage::Format_ARGB32_Premultiplied;
207 bool m_imageRgbSwap = false;
208
209 xcb_sync_int64_t m_syncValue;
210 xcb_sync_counter_t m_syncCounter = 0;
211
212 Qt::WindowState m_windowState = Qt::WindowNoState;
213
214 xcb_gravity_t m_gravity = XCB_GRAVITY_STATIC;
215
216 bool m_mapped = false;
217 bool m_transparent = false;
218 bool m_usingSyncProtocol = false;
219 bool m_deferredActivation = false;
220 bool m_embedded = false;
221 bool m_alertState = false;
222 xcb_window_t m_netWmUserTimeWindow = XCB_NONE;
223
224 QSurfaceFormat m_format;
225
226 mutable bool m_dirtyFrameMargins = false;
227 mutable QMargins m_frameMargins;
228
229 QRegion m_exposeRegion;
230 QSize m_oldWindowSize;
231
232 xcb_visualid_t m_visualId = 0;
233 int m_lastWindowStateEvent = -1;
234
235 enum SyncState {
236 NoSyncNeeded,
237 SyncReceived,
238 SyncAndConfigureReceived
239 };
240 SyncState m_syncState = NoSyncNeeded;
241
242 QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr;
243 xcb_cursor_t m_currentBitmapCursor = XCB_CURSOR_NONE;
244 };
245
246 class QXcbForeignWindow : public QXcbWindow
247 {
248 public:
249 QXcbForeignWindow(QWindow *window, WId nativeHandle)
250 : QXcbWindow(window) { m_window = nativeHandle; }
251 ~QXcbForeignWindow();
252 bool isForeignWindow() const override { return true; }
253
254 protected:
255 void create() override {} // No-op
256 };
257
258 QT_END_NAMESPACE
259
260 Q_DECLARE_METATYPE(QXcbWindow*)
261
262 #endif