Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qxcbwindow.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QXCBWINDOW_H
5#define QXCBWINDOW_H
6
7#include <qpa/qplatformwindow.h>
8#include <qpa/qplatformwindow_p.h>
9#include <QtCore/QObject>
10#include <QtCore/QPointer>
11#include <QtGui/QSurfaceFormat>
12#include <QtGui/QImage>
13
14#include <xcb/xcb.h>
15#include <xcb/sync.h>
16
17#include "qxcbobject.h"
18
20
21class QXcbScreen;
23class QIcon;
24
26 , public QNativeInterface::Private::QXcbWindow
27{
29public:
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
40 };
41
42 Q_DECLARE_FLAGS(NetWmStates, NetWmState)
43
45 RecreationNotNeeded = 0,
46 WindowStaysOnTopHintChanged = 0x1,
47 WindowStaysOnBottomHintChanged = 0x2
48 };
49 Q_DECLARE_FLAGS(RecreationReasons, RecreationReason)
50
53
54 void setGeometry(const QRect &rect) override;
55
56 QMargins frameMargins() const override;
57
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;
63
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;
68
69 void setWindowTitle(const QString &title) override;
70 void setWindowIconText(const QString &title) override;
71 void setWindowIcon(const QIcon &icon) override;
72 void raise() override;
73 void lower() override;
74 void propagateSizeHints() override;
75
76 void requestActivateWindow() override;
77
78 bool setKeyboardGrabEnabled(bool grab) override;
79 bool setMouseGrabEnabled(bool grab) override;
80
81 QSurfaceFormat format() const override;
82
83 bool windowEvent(QEvent *event) override;
84
85 bool startSystemResize(Qt::Edges edges) override;
86 bool startSystemMove() override;
87
88 void setOpacity(qreal level) override;
89 void setMask(const QRegion &region) override;
90
91 void setAlertState(bool enabled) override;
92 bool isAlertState() const override { return m_alertState; }
93
94 xcb_window_t xcb_window() const { return m_window; }
95 uint depth() const { return m_depth; }
96 QImage::Format imageFormat() const { return m_imageFormat; }
97 bool imageNeedsRgbSwap() const { return m_imageRgbSwap; }
98
99 bool handleNativeEvent(xcb_generic_event_t *event) override;
100
101 void handleExposeEvent(const xcb_expose_event_t *event) override;
102 void handleClientMessageEvent(const xcb_client_message_event_t *event) override;
103 void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) override;
104 void handleMapNotifyEvent(const xcb_map_notify_event_t *event) override;
105 void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event) override;
106 void handleButtonPressEvent(const xcb_button_press_event_t *event) override;
107 void handleButtonReleaseEvent(const xcb_button_release_event_t *event) override;
108 void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event) override;
109
110 void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) override;
111 void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) override;
112 void handleFocusInEvent(const xcb_focus_in_event_t *event) override;
113 void handleFocusOutEvent(const xcb_focus_out_event_t *event) override;
114 void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) override;
116 void handleXIEnterLeave(xcb_ge_event_t *) override;
117
118 QXcbWindow *toWindow() override;
119
120 void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
121 Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
122
123 void updateNetWmUserTime(xcb_timestamp_t timestamp);
124 void updateWmTransientFor();
125 void registerWmTransientForChild(QXcbWindow *);
126
127 WindowTypes wmWindowTypes() const;
128 void setWmWindowType(WindowTypes types, Qt::WindowFlags flags);
129 void setWindowType(WindowTypes windowTypes) override { setWmWindowType(windowTypes, window()->flags()); }
130 void setWindowRole(const QString &role) override;
131
132 void setParentRelativeBackPixmap();
133 bool requestSystemTrayWindowDock();
134 uint visualId() const override;
135
136 bool needsSync() const;
137
138 void postSyncWindowRequest();
139 void clearSyncWindowRequest() { m_pendingSyncRequest = nullptr; }
140
141 QXcbScreen *xcbScreen() const;
142
143 QPoint lastPointerPosition() const { return m_lastPointerPosition; }
144 QPoint lastPointerGlobalPosition() const { return m_lastPointerGlobalPosition; }
145
146 bool startSystemMoveResize(const QPoint &pos, int edges);
147 void doStartSystemMoveResize(const QPoint &globalPos, int edges);
148
150 {
151 return window->objectName() == QLatin1StringView("QSystemTrayIconSysWindow");
152 }
153
154 virtual void create();
155 virtual void destroy();
156
157 static void setWindowTitle(const QXcbConnection *conn, xcb_window_t window, const QString &title);
158 static QString windowTitle(const QXcbConnection *conn, xcb_window_t window);
159
160 int swapInterval() const { return m_swapInterval; }
161 void setSwapInterval(int swapInterval) { m_swapInterval = swapInterval; }
162
163public Q_SLOTS:
164 void updateSyncRequestCounter();
165
166protected:
167 virtual void resolveFormat(const QSurfaceFormat &format) { m_format = format; }
168 virtual const xcb_visualtype_t *createVisual();
169 void setImageFormatForVisual(const xcb_visualtype_t *visual);
170
171 QXcbScreen *parentScreen();
172 QXcbScreen *initialScreen() const;
173
174 void setNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
175 void setNetWmState(Qt::WindowFlags flags);
176 void setNetWmState(Qt::WindowStates state);
177 void setNetWmStateOnUnmappedWindow();
178 NetWmStates netWmStates();
179
180 void setMotifWmHints(Qt::WindowFlags flags);
181
182 void setTransparentForMouseEvents(bool transparent);
183 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
184
185 void sendXEmbedMessage(xcb_window_t window, quint32 message,
186 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
187 void handleXEmbedMessage(const xcb_client_message_event_t *event);
188
189 void show();
190 void hide();
191
192 bool relayFocusToModalWindow() const;
193 void doFocusIn();
194 void doFocusOut();
195
196 void handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y,
197 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp,
199
200 void handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y,
201 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp,
203
204 void handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y,
205 Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp,
207
208 void handleEnterNotifyEvent(int event_x, int event_y, int root_x, int root_y,
209 quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
210
211 void handleLeaveNotifyEvent(int root_x, int root_y,
212 quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
213
214 xcb_window_t m_window = 0;
215
216 uint m_depth = 0;
218 bool m_imageRgbSwap = false;
219
220 xcb_sync_int64_t m_syncValue;
221 xcb_sync_counter_t m_syncCounter = 0;
222
223 Qt::WindowStates m_windowState = Qt::WindowNoState;
224
226 bool m_mapped = false;
227 bool m_transparent = false;
228 bool m_deferredActivation = false;
229 bool m_embedded = false;
230 bool m_alertState = false;
231 bool m_minimized = false;
232 bool m_trayIconWindow = false;
233 bool m_ignorePressedWindowOnMouseLeave = false;
234 xcb_window_t m_netWmUserTimeWindow = XCB_NONE;
235
237
238 mutable bool m_dirtyFrameMargins = false;
240
245
246 xcb_visualid_t m_visualId = 0;
247 // Last sent state. Initialized to an invalid state, on purpose.
248 Qt::WindowStates m_lastWindowStateEvent = Qt::WindowActive;
249
253 SyncAndConfigureReceived
254 };
255 SyncState m_syncState = NoSyncNeeded;
256
257 QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr;
258 int m_swapInterval = -1;
259
260 qreal m_sizeHintsScaleFactor = 1.0;
261
262 RecreationReasons m_recreationReasons = RecreationNotNeeded;
263
264 QList<QPointer<QXcbWindow>> m_wmTransientForChildren;
265};
266
268{
269public:
270 QXcbForeignWindow(QWindow *window, WId nativeHandle);
272 bool isForeignWindow() const override { return true; }
273
274protected:
275 void create() override {} // No-op
276};
277
278QList<xcb_rectangle_t> qRegionToXcbRectangleList(const QRegion &region);
279
281
283
284#endif
\inmodule QtCore
Definition qcoreevent.h:45
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
\inmodule QtCore
Definition qmargins.h:24
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtCore
Definition qobject.h:103
void setParent(QObject *parent)
Makes the object a child of parent.
Definition qobject.cpp:2195
The QPlatformWindow class provides an abstraction for top-level windows.
virtual bool startSystemMove()
Reimplement this method to start a system move operation if the system supports it and return true to...
virtual bool isExposed() const
Returns if this window is exposed in the windowing system.
virtual void setWindowFlags(Qt::WindowFlags flags)
Requests setting the window flags of this surface to flags.
virtual QPoint mapFromGlobal(const QPoint &pos) const
Translates the global screen coordinate pos to window coordinates using native methods.
virtual void setVisible(bool visible)
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
virtual void setWindowTitle(const QString &title)
Reimplement to set the window title to title.
QWindow * window() const
Returns the window which belongs to the QPlatformWindow.
virtual bool windowEvent(QEvent *event)
Reimplement this method to be able to do any platform specific event handling.
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or resized using the QWindow API.
virtual void setMask(const QRegion &region)
Reimplement to be able to let Qt set the mask of a window.
virtual void requestActivateWindow()
Reimplement to let Qt be able to request activation/focus for a window.
virtual void setOpacity(qreal level)
Reimplement to be able to let Qt set the opacity level of a window.
virtual void raise()
Reimplement to be able to let Qt raise windows to the top of the desktop.
virtual void propagateSizeHints()
Reimplement to propagate the size hints of the QWindow.
virtual void setAlertState(bool enabled)
Reimplement this method to set whether the window demands attention (for example, by flashing the tas...
virtual WId winId() const
Reimplement in subclasses to return a handle to the native window.
virtual QMargins frameMargins() const
virtual QPoint mapToGlobal(const QPoint &pos) const
Translates the window coordinate pos to global screen coordinates using native methods.
virtual bool startSystemResize(Qt::Edges edges)
Reimplement this method to start a system resize operation if the system supports it and return true ...
virtual bool setKeyboardGrabEnabled(bool grab)
virtual void lower()
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
virtual bool setMouseGrabEnabled(bool grab)
virtual void setWindowIcon(const QIcon &icon)
Reimplement to set the window icon to icon.
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
\inmodule QtGui
Definition qwindow.h:63
bool isForeignWindow() const override
Definition qxcbwindow.h:272
void create() override
Definition qxcbwindow.h:275
QXcbForeignWindow(QWindow *window, WId nativeHandle)
virtual void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *)
virtual void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *)
virtual void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource=Qt::MouseEventNotSynthesized)
virtual void handleButtonPressEvent(const xcb_button_press_event_t *)
virtual void handleEnterNotifyEvent(const xcb_enter_notify_event_t *)
virtual void handleMapNotifyEvent(const xcb_map_notify_event_t *)
virtual void handleClientMessageEvent(const xcb_client_message_event_t *)
virtual void handleXIEnterLeave(xcb_ge_event_t *)
virtual void handleMotionNotifyEvent(const xcb_motion_notify_event_t *)
virtual void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *)
virtual void handleButtonReleaseEvent(const xcb_button_release_event_t *)
virtual void handleExposeEvent(const xcb_expose_event_t *)
virtual void handleFocusOutEvent(const xcb_focus_out_event_t *)
virtual void handleFocusInEvent(const xcb_focus_in_event_t *)
virtual void handlePropertyNotifyEvent(const xcb_property_notify_event_t *)
virtual bool handleNativeEvent(xcb_generic_event_t *)
virtual QXcbWindow * toWindow()
xcb_window_t xcb_window() const
Definition qxcbwindow.h:94
QPoint lastPointerPosition() const
Definition qxcbwindow.h:143
void clearSyncWindowRequest()
Definition qxcbwindow.h:139
void setWindowType(WindowTypes windowTypes) override
Definition qxcbwindow.h:129
QMargins m_frameMargins
Definition qxcbwindow.h:239
QRegion m_exposeRegion
Definition qxcbwindow.h:241
QImage::Format imageFormat() const
Definition qxcbwindow.h:96
void setSwapInterval(int swapInterval)
Definition qxcbwindow.h:161
uint depth() const
Definition qxcbwindow.h:95
QSurfaceFormat m_format
Definition qxcbwindow.h:236
xcb_sync_int64_t m_syncValue
Definition qxcbwindow.h:220
QList< QPointer< QXcbWindow > > m_wmTransientForChildren
Definition qxcbwindow.h:264
bool imageNeedsRgbSwap() const
Definition qxcbwindow.h:97
QPoint m_lastPointerPosition
Definition qxcbwindow.h:243
QPoint m_lastPointerGlobalPosition
Definition qxcbwindow.h:244
static bool isTrayIconWindow(QWindow *window)
Definition qxcbwindow.h:149
int swapInterval() const
Definition qxcbwindow.h:160
QSize m_oldWindowSize
Definition qxcbwindow.h:242
bool isAlertState() const override
Reimplement this method return whether the window is in an alert state.
Definition qxcbwindow.h:92
QPoint lastPointerGlobalPosition() const
Definition qxcbwindow.h:144
virtual void resolveFormat(const QSurfaceFormat &format)
Definition qxcbwindow.h:167
QMutex m_mappedMutex
Definition qxcbwindow.h:225
EGLImageKHR int int EGLuint64KHR * modifiers
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
@ WindowNoState
Definition qnamespace.h:252
@ WindowActive
Definition qnamespace.h:256
MouseEventSource
@ MouseEventNotSynthesized
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_METATYPE(TYPE)
Definition qmetatype.h:1525
GLenum mode
GLenum GLuint GLint level
GLsizei GLenum GLenum * types
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum type
GLbitfield flags
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
struct _cl_event * event
#define Q_OBJECT
#define Q_SLOTS
unsigned int quint32
Definition qtypes.h:50
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
unsigned char quint8
Definition qtypes.h:46
static bool isEmbedded(const QWindow *w)
Definition qwidget.cpp:6612
static QString windowTitle(HWND hwnd)
#define Q_XCB_EXPORT
Definition qxcbexport.h:14
QList< xcb_rectangle_t > qRegionToXcbRectangleList(const QRegion &region)
view show()
[18] //! [19]
QFuture< QSet< QChar > > set
[10]
QString title
[35]
edit hide()
w setWindowState(w->windowState() ^ Qt::WindowFullScreen)
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
view create()
QJSValue global