Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.4.2/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 QPlatformScreen *screenForNativeGeometry(const QRect &newGeometry) const;
129
130 public Q_SLOTS:
131 void updateSyncRequestCounter();
132
133 private:
134 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
135 NetWmStates netWmStates();
136 void setNetWmStates(NetWmStates);
137
138 void setNetWmWindowFlags(Qt::WindowFlags flags);
139 void setMotifWindowFlags(Qt::WindowFlags flags);
140
141 void updateMotifWmHintsBeforeMap();
142 void updateNetWmStateBeforeMap();
143
144 void setTransparentForMouseEvents(bool transparent);
145 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
146
147 QRect windowToWmGeometry(QRect r) const;
148 void sendXEmbedMessage(xcb_window_t window, quint32 message,
149 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
150 void handleXEmbedMessage(const xcb_client_message_event_t *event);
151
152 void create();
153 void destroy();
154
155 void show();
156 void hide();
157
158 bool relayFocusToModalWindow() const;
159 void doFocusIn();
160 void doFocusOut();
161
162 QXcbScreen *m_screen;
163
164 xcb_window_t m_window;
165
166 uint m_depth;
167 QImage::Format m_imageFormat;
168
169 xcb_sync_int64_t m_syncValue;
170 xcb_sync_counter_t m_syncCounter;
171
172 Qt::WindowState m_windowState;
173
174 xcb_gravity_t m_gravity;
175
176 bool m_mapped;
177 bool m_transparent;
178 bool m_usingSyncProtocol;
179 bool m_deferredActivation;
180 bool m_deferredExpose;
181 bool m_configureNotifyPending;
182 bool m_embedded;
183 bool m_alertState;
184 xcb_window_t m_netWmUserTimeWindow;
185
186 QSurfaceFormat m_format;
187
188 mutable bool m_dirtyFrameMargins;
189 mutable QMargins m_frameMargins;
190
191 #if defined(XCB_USE_EGL)
192 mutable QXcbEGLSurface *m_eglSurface;
193 #endif
194
195 QRegion m_exposeRegion;
196
197 xcb_visualid_t m_visualId;
198 int m_lastWindowStateEvent;
199
200 enum SyncState {
201 NoSyncNeeded,
202 SyncReceived,
203 SyncAndConfigureReceived
204 };
205 SyncState m_syncState;
206
207 QXcbSyncWindowRequest *m_pendingSyncRequest;
208 };
209
210 QT_END_NAMESPACE
211
212 Q_DECLARE_METATYPE(QXcbWindow*)
213
214 #endif