Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.4.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 QXcbEGLSurface;
23 class QXcbSyncWindowRequest;
24 class QIcon;
25
26 class QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
27 {
28 public:
29 enum NetWmState {
30 NetWmStateAbove = 0x1,
31 NetWmStateBelow = 0x2,
32 NetWmStateFullScreen = 0x4,
33 NetWmStateMaximizedHorz = 0x8,
34 NetWmStateMaximizedVert = 0x10,
35 NetWmStateModal = 0x20,
36 NetWmStateStaysOnTop = 0x40,
37 NetWmStateDemandsAttention = 0x80
38 };
39
40 Q_DECLARE_FLAGS(NetWmStates, NetWmState)
41
42 QXcbWindow(QWindow *window);
43 ~QXcbWindow();
44
45 void setGeometry(const QRect &rect);
46
47 QMargins frameMargins() const;
48
49 void setVisible(bool visible);
50 void setWindowFlags(Qt::WindowFlags flags);
51 void setWindowState(Qt::WindowState state);
52 WId winId() const;
53 void setParent(const QPlatformWindow *window);
54
55 bool isExposed() const;
56 bool isEmbedded(const QPlatformWindow *parentWindow) const;
57 QPoint mapToGlobal(const QPoint &pos) const;
58 QPoint mapFromGlobal(const QPoint &pos) const;
59
60 void setWindowTitle(const QString &title);
61 void setWindowIcon(const QIcon &icon);
62 void raise();
63 void lower();
64 void propagateSizeHints();
65
66 void requestActivateWindow();
67
68 bool setKeyboardGrabEnabled(bool grab);
69 bool setMouseGrabEnabled(bool grab);
70
71 void setCursor(xcb_cursor_t cursor);
72
73 QSurfaceFormat format() const;
74
75 void windowEvent(QEvent *event);
76
77 bool startSystemResize(const QPoint &pos, Qt::Corner corner);
78
79 void setOpacity(qreal level);
80 void setMask(const QRegion &region);
81
82 void setAlertState(bool enabled);
83 bool isAlertState() const { 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
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
106 QXcbWindow *toWindow() Q_DECL_OVERRIDE;
107
108 void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers);
109
110 void updateNetWmUserTime(xcb_timestamp_t timestamp);
111
112 #if defined(XCB_USE_EGL)
113 QXcbEGLSurface *eglSurface() const;
114 #endif
115
116 static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes);
117
118 QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
119 void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types);
120
121 bool needsSync() const;
122
123 void postSyncWindowRequest();
124 void clearSyncWindowRequest() { m_pendingSyncRequest = 0; }
125
126 qreal devicePixelRatio() const;
127
128 public Q_SLOTS:
129 void updateSyncRequestCounter();
130
131 private:
132 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
133 NetWmStates netWmStates();
134 void setNetWmStates(NetWmStates);
135
136 void setNetWmWindowFlags(Qt::WindowFlags flags);
137 void setMotifWindowFlags(Qt::WindowFlags flags);
138
139 void updateMotifWmHintsBeforeMap();
140 void updateNetWmStateBeforeMap();
141
142 void setTransparentForMouseEvents(bool transparent);
143 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
144
145 QRect windowToWmGeometry(QRect r) const;
146 void sendXEmbedMessage(xcb_window_t window, quint32 message,
147 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
148 void handleXEmbedMessage(const xcb_client_message_event_t *event);
149
150 void create();
151 void destroy();
152
153 void show();
154 void hide();
155
156 bool relayFocusToModalWindow() const;
157 void doFocusIn();
158 void doFocusOut();
159
160 QXcbScreen *m_screen;
161
162 xcb_window_t m_window;
163
164 uint m_depth;
165 QImage::Format m_imageFormat;
166
167 xcb_sync_int64_t m_syncValue;
168 xcb_sync_counter_t m_syncCounter;
169
170 Qt::WindowState m_windowState;
171
172 xcb_gravity_t m_gravity;
173
174 bool m_mapped;
175 bool m_transparent;
176 bool m_usingSyncProtocol;
177 bool m_deferredActivation;
178 bool m_deferredExpose;
179 bool m_configureNotifyPending;
180 bool m_embedded;
181 bool m_alertState;
182 xcb_window_t m_netWmUserTimeWindow;
183
184 QSurfaceFormat m_format;
185
186 mutable bool m_dirtyFrameMargins;
187 mutable QMargins m_frameMargins;
188
189 #if defined(XCB_USE_EGL)
190 mutable QXcbEGLSurface *m_eglSurface;
191 #endif
192
193 QRegion m_exposeRegion;
194
195 xcb_visualid_t m_visualId;
196 int m_lastWindowStateEvent;
197
198 enum SyncState {
199 NoSyncNeeded,
200 SyncReceived,
201 SyncAndConfigureReceived
202 };
203 SyncState m_syncState;
204
205 QXcbSyncWindowRequest *m_pendingSyncRequest;
206 };
207
208 QT_END_NAMESPACE
209
210 Q_DECLARE_METATYPE(QXcbWindow*)
211
212 #endif