Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.5.0/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) Q_DECL_OVERRIDE;
45
46 QMargins frameMargins() const Q_DECL_OVERRIDE;
47
48 void setVisible(bool visible) Q_DECL_OVERRIDE;
49 void setWindowFlags(Qt::WindowFlags flags) Q_DECL_OVERRIDE;
50 void setWindowState(Qt::WindowState state) Q_DECL_OVERRIDE;
51 WId winId() const Q_DECL_OVERRIDE;
52 void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE;
53
54 bool isExposed() const Q_DECL_OVERRIDE;
55 bool isEmbedded(const QPlatformWindow *parentWindow) const Q_DECL_OVERRIDE;
56 QPoint mapToGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
57 QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
58
59 void setWindowTitle(const QString &title) Q_DECL_OVERRIDE;
60 void setWindowIcon(const QIcon &icon) Q_DECL_OVERRIDE;
61 void raise() Q_DECL_OVERRIDE;
62 void lower() Q_DECL_OVERRIDE;
63 void propagateSizeHints() Q_DECL_OVERRIDE;
64
65 void requestActivateWindow() Q_DECL_OVERRIDE;
66
67 bool setKeyboardGrabEnabled(bool grab) Q_DECL_OVERRIDE;
68 bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE;
69
70 void setCursor(xcb_cursor_t cursor);
71
72 QSurfaceFormat format() const Q_DECL_OVERRIDE;
73
74 void windowEvent(QEvent *event) Q_DECL_OVERRIDE;
75
76 bool startSystemResize(const QPoint &pos, Qt::Corner corner) Q_DECL_OVERRIDE;
77
78 void setOpacity(qreal level) Q_DECL_OVERRIDE;
79 void setMask(const QRegion &region) Q_DECL_OVERRIDE;
80
81 void setAlertState(bool enabled) Q_DECL_OVERRIDE;
82 bool isAlertState() const Q_DECL_OVERRIDE { return m_alertState; }
83
84 xcb_window_t xcb_window() const { return m_window; }
85 uint depth() const { return m_depth; }
86 QImage::Format imageFormat() const { return m_imageFormat; }
87 bool imageNeedsRgbSwap() const { return m_imageRgbSwap; }
88
89 bool handleGenericEvent(xcb_generic_event_t *event, long *result) Q_DECL_OVERRIDE;
90
91 void handleExposeEvent(const xcb_expose_event_t *event) Q_DECL_OVERRIDE;
92 void handleClientMessageEvent(const xcb_client_message_event_t *event) Q_DECL_OVERRIDE;
93 void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) Q_DECL_OVERRIDE;
94 void handleMapNotifyEvent(const xcb_map_notify_event_t *event) Q_DECL_OVERRIDE;
95 void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event) Q_DECL_OVERRIDE;
96 void handleButtonPressEvent(const xcb_button_press_event_t *event) Q_DECL_OVERRIDE;
97 void handleButtonReleaseEvent(const xcb_button_release_event_t *event) Q_DECL_OVERRIDE;
98 void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event) Q_DECL_OVERRIDE;
99
100 void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) Q_DECL_OVERRIDE;
101 void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) Q_DECL_OVERRIDE;
102 void handleFocusInEvent(const xcb_focus_in_event_t *event) Q_DECL_OVERRIDE;
103 void handleFocusOutEvent(const xcb_focus_out_event_t *event) Q_DECL_OVERRIDE;
104 void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) Q_DECL_OVERRIDE;
105 void handleXIMouseEvent(xcb_ge_event_t *) Q_DECL_OVERRIDE;
106
107 QXcbWindow *toWindow() Q_DECL_OVERRIDE;
108
109 void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers);
110
111 void updateNetWmUserTime(xcb_timestamp_t timestamp);
112
113 static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes);
114 static uint visualIdStatic(QWindow *window);
115
116 QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
117 void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types);
118
119 uint visualId() const;
120
121 bool needsSync() const;
122
123 void postSyncWindowRequest();
124 void clearSyncWindowRequest() { m_pendingSyncRequest = 0; }
125
126 qreal devicePixelRatio() const Q_DECL_OVERRIDE;
127
128 QXcbScreen *xcbScreen() const;
129
130 virtual void create();
131 virtual void destroy();
132 void maybeSetScreen(QXcbScreen *screen);
133 QXcbScreen *screenForNativeGeometry(const QRect &newGeometry) const;
134
135 public Q_SLOTS:
136 void updateSyncRequestCounter();
137
138 protected:
139 virtual void resolveFormat() { m_format = window()->requestedFormat(); }
140 virtual void *createVisual() { return Q_NULLPTR; }
141 virtual bool supportsSyncProtocol() { return !window()->supportsOpenGL(); }
142
143 QPoint mapToNative(const QPoint &pos, const QXcbScreen *screen) const;
144 QPoint mapFromNative(const QPoint &pos, const QXcbScreen *screen) const;
145 QRect mapToNative(const QRect &rect, const QXcbScreen *screen) const;
146 QRect mapFromNative(const QRect &rect, const QXcbScreen *screen) const;
147 QXcbScreen *parentScreen();
148
149 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
150 NetWmStates netWmStates();
151 void setNetWmStates(NetWmStates);
152
153 void setNetWmWindowFlags(Qt::WindowFlags flags);
154 void setMotifWindowFlags(Qt::WindowFlags flags);
155
156 void updateMotifWmHintsBeforeMap();
157 void updateNetWmStateBeforeMap();
158
159 void setTransparentForMouseEvents(bool transparent);
160 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
161
162 QRect windowToWmGeometry(QRect r) const;
163 void sendXEmbedMessage(xcb_window_t window, quint32 message,
164 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
165 void handleXEmbedMessage(const xcb_client_message_event_t *event);
166
167 void show();
168 void hide();
169
170 bool relayFocusToModalWindow() const;
171 void doFocusIn();
172 void doFocusOut();
173
174 void handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y,
175 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp);
176
177 void handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y,
178 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp);
179
180 void handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y,
181 Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp);
182
183 xcb_window_t m_window;
184
185 QXcbScreen *m_xcbScreen;
186
187 uint m_depth;
188 QImage::Format m_imageFormat;
189 bool m_imageRgbSwap;
190
191 xcb_sync_int64_t m_syncValue;
192 xcb_sync_counter_t m_syncCounter;
193
194 Qt::WindowState m_windowState;
195
196 xcb_gravity_t m_gravity;
197
198 bool m_mapped;
199 bool m_transparent;
200 bool m_usingSyncProtocol;
201 bool m_deferredActivation;
202 bool m_deferredExpose;
203 bool m_configureNotifyPending;
204 bool m_embedded;
205 bool m_alertState;
206 xcb_window_t m_netWmUserTimeWindow;
207
208 QSurfaceFormat m_format;
209
210 mutable bool m_dirtyFrameMargins;
211 mutable QMargins m_frameMargins;
212
213 QRegion m_exposeRegion;
214
215 xcb_visualid_t m_visualId;
216 int m_lastWindowStateEvent;
217
218 enum SyncState {
219 NoSyncNeeded,
220 SyncReceived,
221 SyncAndConfigureReceived
222 };
223 SyncState m_syncState;
224
225 QXcbSyncWindowRequest *m_pendingSyncRequest;
226 };
227
228 QT_END_NAMESPACE
229
230 Q_DECLARE_METATYPE(QXcbWindow*)
231
232 #endif