Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.6.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 void handleXIMouseEvent(xcb_ge_event_t *) Q_DECL_OVERRIDE;
107
108 QXcbWindow *toWindow() Q_DECL_OVERRIDE;
109
110 void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers);
111
112 void updateNetWmUserTime(xcb_timestamp_t timestamp);
113
114 static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes);
115 static uint visualIdStatic(QWindow *window);
116
117 QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
118 void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags);
119
120 static void setWindowIconTextStatic(QWindow *window, const QString &text);
121
122 static void setParentRelativeBackPixmapStatic(QWindow *window);
123 void setParentRelativeBackPixmap();
124
125 static bool requestSystemTrayWindowDockStatic(const QWindow *window);
126 bool requestSystemTrayWindowDock() const;
127
128 static QRect systemTrayWindowGlobalGeometryStatic(const QWindow *window);
129 QRect systemTrayWindowGlobalGeometry() const;
130 uint visualId() const;
131
132 bool needsSync() const;
133
134 void postSyncWindowRequest();
135 void clearSyncWindowRequest() { m_pendingSyncRequest = 0; }
136
137 QXcbScreen *xcbScreen() const;
138
139 virtual void create();
140 virtual void destroy();
141
142 public Q_SLOTS:
143 void updateSyncRequestCounter();
144
145 protected:
146 virtual void resolveFormat() { m_format = window()->requestedFormat(); }
147 virtual void *createVisual() { return Q_NULLPTR; }
148
149 QXcbScreen *parentScreen();
150
151 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
152 NetWmStates netWmStates();
153 void setNetWmStates(NetWmStates);
154
155 void setMotifWindowFlags(Qt::WindowFlags flags);
156
157 void updateMotifWmHintsBeforeMap();
158 void updateNetWmStateBeforeMap();
159
160 void setTransparentForMouseEvents(bool transparent);
161 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
162
163 QRect windowToWmGeometry(QRect r) const;
164 void sendXEmbedMessage(xcb_window_t window, quint32 message,
165 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
166 void handleXEmbedMessage(const xcb_client_message_event_t *event);
167
168 void show();
169 void hide();
170
171 bool relayFocusToModalWindow() const;
172 void doFocusIn();
173 void doFocusOut();
174
175 bool compressExposeEvent(QRegion &exposeRegion);
176
177 void handleButtonPressEvent(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 handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y,
181 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp);
182
183 void handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y,
184 Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp);
185
186 xcb_window_t m_window;
187
188 uint m_depth;
189 QImage::Format m_imageFormat;
190 bool m_imageRgbSwap;
191
192 xcb_sync_int64_t m_syncValue;
193 xcb_sync_counter_t m_syncCounter;
194
195 Qt::WindowState m_windowState;
196
197 xcb_gravity_t m_gravity;
198
199 bool m_mapped;
200 bool m_transparent;
201 bool m_usingSyncProtocol;
202 bool m_deferredActivation;
203 bool m_embedded;
204 bool m_alertState;
205 xcb_window_t m_netWmUserTimeWindow;
206
207 QSurfaceFormat m_format;
208
209 mutable bool m_dirtyFrameMargins;
210 mutable QMargins m_frameMargins;
211
212 QRegion m_exposeRegion;
213
214 xcb_visualid_t m_visualId;
215 int m_lastWindowStateEvent;
216
217 enum SyncState {
218 NoSyncNeeded,
219 SyncReceived,
220 SyncAndConfigureReceived
221 };
222 SyncState m_syncState;
223
224 QXcbSyncWindowRequest *m_pendingSyncRequest;
225 };
226
227 QT_END_NAMESPACE
228
229 Q_DECLARE_METATYPE(QXcbWindow*)
230
231 #endif