Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.7.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 = 0) 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 setWindowIconText(const QString &title);
61 void setWindowIcon(const QIcon &icon) Q_DECL_OVERRIDE;
62 void raise() Q_DECL_OVERRIDE;
63 void lower() Q_DECL_OVERRIDE;
64 void propagateSizeHints() Q_DECL_OVERRIDE;
65
66 void requestActivateWindow() Q_DECL_OVERRIDE;
67
68 bool setKeyboardGrabEnabled(bool grab) Q_DECL_OVERRIDE;
69 bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE;
70
71 void setCursor(xcb_cursor_t cursor);
72
73 QSurfaceFormat format() const Q_DECL_OVERRIDE;
74
75 void windowEvent(QEvent *event) Q_DECL_OVERRIDE;
76
77 bool startSystemResize(const QPoint &pos, Qt::Corner corner) Q_DECL_OVERRIDE;
78
79 void setOpacity(qreal level) Q_DECL_OVERRIDE;
80 void setMask(const QRegion &region) Q_DECL_OVERRIDE;
81
82 void setAlertState(bool enabled) Q_DECL_OVERRIDE;
83 bool isAlertState() const Q_DECL_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) Q_DECL_OVERRIDE;
91
92 void handleExposeEvent(const xcb_expose_event_t *event) Q_DECL_OVERRIDE;
93 void handleClientMessageEvent(const xcb_client_message_event_t *event) Q_DECL_OVERRIDE;
94 void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) Q_DECL_OVERRIDE;
95 void handleMapNotifyEvent(const xcb_map_notify_event_t *event) Q_DECL_OVERRIDE;
96 void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event) Q_DECL_OVERRIDE;
97 void handleButtonPressEvent(const xcb_button_press_event_t *event) Q_DECL_OVERRIDE;
98 void handleButtonReleaseEvent(const xcb_button_release_event_t *event) Q_DECL_OVERRIDE;
99 void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event) Q_DECL_OVERRIDE;
100
101 void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) Q_DECL_OVERRIDE;
102 void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) Q_DECL_OVERRIDE;
103 void handleFocusInEvent(const xcb_focus_in_event_t *event) Q_DECL_OVERRIDE;
104 void handleFocusOutEvent(const xcb_focus_out_event_t *event) Q_DECL_OVERRIDE;
105 void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) Q_DECL_OVERRIDE;
106 #ifdef XCB_USE_XINPUT22
107 void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) Q_DECL_OVERRIDE;
108 void handleXIEnterLeave(xcb_ge_event_t *) Q_DECL_OVERRIDE;
109 #endif
110
111 QXcbWindow *toWindow() Q_DECL_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 uint visualIdStatic(QWindow *window);
120
121 QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
122 void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags);
123
124 static void setWindowIconTextStatic(QWindow *window, const QString &text);
125
126 static void setParentRelativeBackPixmapStatic(QWindow *window);
127 void setParentRelativeBackPixmap();
128
129 static bool requestSystemTrayWindowDockStatic(const QWindow *window);
130 bool requestSystemTrayWindowDock() const;
131
132 static QRect systemTrayWindowGlobalGeometryStatic(const QWindow *window);
133 QRect systemTrayWindowGlobalGeometry() const;
134 uint visualId() const;
135
136 bool needsSync() const;
137
138 void postSyncWindowRequest();
139 void clearSyncWindowRequest() { m_pendingSyncRequest = 0; }
140
141 QXcbScreen *xcbScreen() const;
142
143 virtual void create();
144 virtual void destroy();
145
146 public Q_SLOTS:
147 void updateSyncRequestCounter();
148
149 protected:
150 virtual void resolveFormat(const QSurfaceFormat &format) { m_format = format; }
151 virtual const xcb_visualtype_t *createVisual();
152
153 QXcbScreen *parentScreen();
154
155 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
156 NetWmStates netWmStates();
157 void setNetWmStates(NetWmStates);
158
159 void setMotifWindowFlags(Qt::WindowFlags flags);
160 void setNetWmStateWindowFlags(Qt::WindowFlags flags);
161
162 void updateMotifWmHintsBeforeMap();
163 void updateNetWmStateBeforeMap();
164
165 void setTransparentForMouseEvents(bool transparent);
166 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
167
168 QRect windowToWmGeometry(QRect r) const;
169 void sendXEmbedMessage(xcb_window_t window, quint32 message,
170 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
171 void handleXEmbedMessage(const xcb_client_message_event_t *event);
172
173 void show();
174 void hide();
175
176 bool relayFocusToModalWindow() const;
177 void doFocusIn();
178 void doFocusOut();
179
180 bool compressExposeEvent(QRegion &exposeRegion);
181
182 void handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y,
183 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
184
185 void handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y,
186 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
187
188 void handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y,
189 Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
190
191 void handleEnterNotifyEvent(int event_x, int event_y, int root_x, int root_y,
192 quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
193
194 void handleLeaveNotifyEvent(int root_x, int root_y,
195 quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
196
197 xcb_window_t m_window;
198
199 uint m_depth;
200 QImage::Format m_imageFormat;
201 bool m_imageRgbSwap;
202
203 xcb_sync_int64_t m_syncValue;
204 xcb_sync_counter_t m_syncCounter;
205
206 Qt::WindowState m_windowState;
207
208 xcb_gravity_t m_gravity;
209
210 bool m_mapped;
211 bool m_transparent;
212 bool m_usingSyncProtocol;
213 bool m_deferredActivation;
214 bool m_embedded;
215 bool m_alertState;
216 xcb_window_t m_netWmUserTimeWindow;
217
218 QSurfaceFormat m_format;
219
220 mutable bool m_dirtyFrameMargins;
221 mutable QMargins m_frameMargins;
222
223 QRegion m_exposeRegion;
224
225 xcb_visualid_t m_visualId;
226 int m_lastWindowStateEvent;
227
228 enum SyncState {
229 NoSyncNeeded,
230 SyncReceived,
231 SyncAndConfigureReceived
232 };
233 SyncState m_syncState;
234
235 QXcbSyncWindowRequest *m_pendingSyncRequest;
236 };
237
238 QT_END_NAMESPACE
239
240 Q_DECLARE_METATYPE(QXcbWindow*)
241
242 #endif