25class Q_XCB_EXPORT QXcbWindow :
public QObject,
public QXcbObject,
public QXcbWindowEventListener,
public QPlatformWindow
26 ,
public QNativeInterface::Private::QXcbWindow
31 NetWmStateAbove = 0x1,
32 NetWmStateBelow = 0x2,
33 NetWmStateFullScreen = 0x4,
34 NetWmStateMaximizedHorz = 0x8,
35 NetWmStateMaximizedVert = 0x10,
36 NetWmStateModal = 0x20,
37 NetWmStateStaysOnTop = 0x40,
38 NetWmStateDemandsAttention = 0x80,
39 NetWmStateHidden = 0x100
42 Q_DECLARE_FLAGS(NetWmStates, NetWmState)
44 enum RecreationReason {
45 RecreationNotNeeded = 0,
46 WindowStaysOnTopHintChanged = 0x1,
47 WindowStaysOnBottomHintChanged = 0x2
49 Q_DECLARE_FLAGS(RecreationReasons, RecreationReason)
51 QXcbWindow(QWindow *window);
54 void setGeometry(
const QRect &rect) override;
56 QMargins frameMargins()
const override;
58 void setVisible(
bool visible) override;
59 void setWindowFlags(Qt::WindowFlags flags) override;
60 void setWindowState(Qt::WindowStates state) override;
61 WId winId()
const override;
62 void setParent(
const QPlatformWindow *window) override;
64 bool isExposed()
const override;
65 bool isEmbedded()
const override;
66 QPoint mapToGlobal(
const QPoint &pos)
const override;
67 QPoint mapFromGlobal(
const QPoint &pos)
const override;
69 void setWindowTitle(
const QString &title) override;
70 QString windowTitle()
const override;
71 void setWindowIconText(
const QString &title) override;
72 void setWindowIcon(
const QIcon &icon) override;
73 void raise() override;
74 void lower() override;
75 void propagateSizeHints() override;
77 void requestActivateWindow() override;
79 bool setKeyboardGrabEnabled(
bool grab) override;
80 bool setMouseGrabEnabled(
bool grab) override;
82 QSurfaceFormat format()
const override;
84 bool windowEvent(QEvent *event) override;
86 bool startSystemResize(Qt::Edges edges) override;
87 bool startSystemMove() override;
89 void setOpacity(qreal level) override;
90 void setMask(
const QRegion ®ion) override;
92 void setAlertState(
bool enabled) override;
93 bool isAlertState()
const override {
return m_alertState; }
95 xcb_window_t xcb_window()
const {
return m_window; }
96 uint depth()
const {
return m_depth; }
97 QImage::Format imageFormat()
const {
return m_imageFormat; }
98 bool imageNeedsRgbSwap()
const {
return m_imageRgbSwap; }
100 bool handleNativeEvent(xcb_generic_event_t *event) override;
102 void handleExposeEvent(
const xcb_expose_event_t *event) override;
103 void handleClientMessageEvent(
const xcb_client_message_event_t *event) override;
104 void handleConfigureNotifyEvent(
const xcb_configure_notify_event_t *event) override;
105 void handleMapNotifyEvent(
const xcb_map_notify_event_t *event) override;
106 void handleUnmapNotifyEvent(
const xcb_unmap_notify_event_t *event) override;
107 void handleButtonPressEvent(
const xcb_button_press_event_t *event) override;
108 void handleButtonReleaseEvent(
const xcb_button_release_event_t *event) override;
109 void handleMotionNotifyEvent(
const xcb_motion_notify_event_t *event) override;
111 void handleEnterNotifyEvent(
const xcb_enter_notify_event_t *event) override;
112 void handleLeaveNotifyEvent(
const xcb_leave_notify_event_t *event) override;
113 void handleFocusInEvent(
const xcb_focus_in_event_t *event) override;
114 void handleFocusOutEvent(
const xcb_focus_out_event_t *event) override;
115 void handlePropertyNotifyEvent(
const xcb_property_notify_event_t *event) override;
116 void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) override;
117 void handleXIEnterLeave(xcb_ge_event_t *) override;
119 QXcbWindow *toWindow() override;
121 void handleMouseEvent(xcb_timestamp_t time,
const QPoint &local,
const QPoint &global,
122 Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
124 void updateNetWmUserTime(xcb_timestamp_t timestamp);
125 void updateWmTransientFor();
126 void registerWmTransientForChild(QXcbWindow *);
128 WindowTypes wmWindowTypes()
const;
129 void setWmWindowType(WindowTypes types, Qt::WindowFlags flags);
130 void setWindowType(WindowTypes windowTypes) override { setWmWindowType(windowTypes, window()->flags()); }
131 void setWindowRole(
const QString &role) override;
133 void setParentRelativeBackPixmap();
134 bool requestSystemTrayWindowDock();
135 uint visualId()
const override;
137 bool needsSync()
const;
139 void postSyncWindowRequest();
140 void clearSyncWindowRequest() { m_pendingSyncRequest =
nullptr; }
142 QXcbScreen *xcbScreen()
const;
144 QPoint lastPointerPosition()
const {
return m_lastPointerPosition; }
145 QPoint lastPointerGlobalPosition()
const {
return m_lastPointerGlobalPosition; }
147 bool startSystemMoveResize(
const QPoint &pos,
int edges);
148 void doStartSystemMoveResize(
const QPoint &globalPos,
int edges);
150 static bool isTrayIconWindow(QWindow *window)
152 return window->objectName() == QLatin1StringView(
"QSystemTrayIconSysWindow");
155 virtual void create();
156 virtual void destroy();
158 static void setWindowTitle(
const QXcbConnection *conn, xcb_window_t window,
const QString &title);
159 static QString windowTitle(
const QXcbConnection *conn, xcb_window_t window);
161 int swapInterval()
const {
return m_swapInterval; }
162 void setSwapInterval(
int swapInterval) { m_swapInterval = swapInterval; }
165 void updateSyncRequestCounter();
168 virtual void resolveFormat(
const QSurfaceFormat &format) { m_format = format; }
169 virtual const xcb_visualtype_t *createVisual();
170 void setImageFormatForVisual(
const xcb_visualtype_t *visual);
172 QXcbScreen *parentScreen();
173 QXcbScreen *initialScreen()
const;
175 void setNetWmState(
bool set, xcb_atom_t one, xcb_atom_t two = 0);
176 void setNetWmState(Qt::WindowFlags flags);
177 void setNetWmState(Qt::WindowStates state);
178 void setNetWmStateOnUnmappedWindow();
179 NetWmStates netWmStates();
181 void setMotifWmHints(Qt::WindowFlags flags);
183 void setTransparentForMouseEvents(
bool transparent);
184 void updateDoesNotAcceptFocus(
bool doesNotAcceptFocus);
186 void sendXEmbedMessage(xcb_window_t window, quint32 message,
187 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
188 void handleXEmbedMessage(
const xcb_client_message_event_t *event);
193 bool relayFocusToModalWindow()
const;
197 void handleButtonPressEvent(
int event_x,
int event_y,
int root_x,
int root_y,
198 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp,
199 QEvent::Type type, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
201 void handleButtonReleaseEvent(
int event_x,
int event_y,
int root_x,
int root_y,
202 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp,
203 QEvent::Type type, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
205 void handleMotionNotifyEvent(
int event_x,
int event_y,
int root_x,
int root_y,
206 Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp,
207 QEvent::Type type, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
209 void handleEnterNotifyEvent(
int event_x,
int event_y,
int root_x,
int root_y,
210 quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
212 void handleLeaveNotifyEvent(
int root_x,
int root_y,
213 quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
215 xcb_window_t m_window = 0;
218 QImage::Format m_imageFormat = QImage::Format_ARGB32_Premultiplied;
219 bool m_imageRgbSwap =
false;
221 xcb_sync_int64_t m_syncValue;
222 xcb_sync_counter_t m_syncCounter = 0;
224 Qt::WindowStates m_windowState = Qt::WindowNoState;
226 QMutex m_mappedMutex;
227 bool m_mapped =
false;
228 bool m_transparent =
false;
229 bool m_deferredActivation =
false;
230 bool m_embedded =
false;
231 bool m_alertState =
false;
232 bool m_minimized =
false;
233 bool m_trayIconWindow =
false;
234 bool m_ignorePressedWindowOnMouseLeave =
false;
235 xcb_window_t m_netWmUserTimeWindow = XCB_NONE;
237 QSurfaceFormat m_format;
239 mutable bool m_dirtyFrameMargins =
false;
240 mutable QMargins m_frameMargins;
242 QRegion m_exposeRegion;
243 QSize m_oldWindowSize;
244 QPoint m_lastPointerPosition;
245 QPoint m_lastPointerGlobalPosition;
247 xcb_visualid_t m_visualId = 0;
249 Qt::WindowStates m_lastWindowStateEvent = Qt::WindowActive;
254 SyncAndConfigureReceived
256 SyncState m_syncState = NoSyncNeeded;
258 QXcbSyncWindowRequest *m_pendingSyncRequest =
nullptr;
259 int m_swapInterval = -1;
261 qreal m_sizeHintsScaleFactor = 1.0;
263 RecreationReasons m_recreationReasons = RecreationNotNeeded;
265 QList<QPointer<QXcbWindow>> m_wmTransientForChildren;