Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.3.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 QT_BEGIN_NAMESPACE
18
19 class QXcbScreen;
20 class QXcbEGLSurface;
21 class QIcon;
22 class QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
23 {
24 public:
25 enum NetWmState {
26 NetWmStateAbove = 0x1,
27 NetWmStateBelow = 0x2,
28 NetWmStateFullScreen = 0x4,
29 NetWmStateMaximizedHorz = 0x8,
30 NetWmStateMaximizedVert = 0x10,
31 NetWmStateModal = 0x20,
32 NetWmStateStaysOnTop = 0x40,
33 NetWmStateDemandsAttention = 0x80
34 };
35
36 Q_DECLARE_FLAGS(NetWmStates, NetWmState)
37
38 QXcbWindow(QWindow *window);
39 ~QXcbWindow();
40
41 void setGeometry(const QRect &rect);
42
43 QMargins frameMargins() const;
44
45 void setVisible(bool visible);
46 void setWindowFlags(Qt::WindowFlags flags);
47 void setWindowState(Qt::WindowState state);
48 WId winId() const;
49 void setParent(const QPlatformWindow *window);
50
51 bool isExposed() const;
52 bool isEmbedded(const QPlatformWindow *parentWindow) const;
53 QPoint mapToGlobal(const QPoint &pos) const;
54 QPoint mapFromGlobal(const QPoint &pos) const;
55
56 void setWindowTitle(const QString &title);
57 void setWindowIcon(const QIcon &icon);
58 void raise();
59 void lower();
60 void propagateSizeHints();
61
62 void requestActivateWindow();
63
64 #if XCB_USE_MAEMO_WINDOW_PROPERTIES
65 void handleContentOrientationChange(Qt::ScreenOrientation orientation);
66 #endif
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 bool needsSync() const;
117
118 public Q_SLOTS:
119 void updateSyncRequestCounter();
120
121 private:
122 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
123 NetWmStates netWmStates();
124 void setNetWmStates(NetWmStates);
125
126 void setNetWmWindowFlags(Qt::WindowFlags flags);
127 void setMotifWindowFlags(Qt::WindowFlags flags);
128
129 void updateMotifWmHintsBeforeMap();
130 void updateNetWmStateBeforeMap();
131
132 void setTransparentForMouseEvents(bool transparent);
133 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
134
135 QRect windowToWmGeometry(QRect r) const;
136 void sendXEmbedMessage(xcb_window_t window, quint32 message,
137 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
138 void handleXEmbedMessage(const xcb_client_message_event_t *event);
139
140 void create();
141 void destroy();
142
143 void show();
144 void hide();
145
146 bool relayFocusToModalWindow() const;
147 void doFocusIn();
148 void doFocusOut();
149
150 QXcbScreen *m_screen;
151
152 xcb_window_t m_window;
153
154 uint m_depth;
155 QImage::Format m_imageFormat;
156
157 xcb_sync_int64_t m_syncValue;
158 xcb_sync_counter_t m_syncCounter;
159
160 Qt::WindowState m_windowState;
161
162 xcb_gravity_t m_gravity;
163
164 bool m_mapped;
165 bool m_transparent;
166 bool m_usingSyncProtocol;
167 bool m_deferredActivation;
168 bool m_deferredExpose;
169 bool m_configureNotifyPending;
170 bool m_embedded;
171 bool m_alertState;
172 xcb_window_t m_netWmUserTimeWindow;
173
174 QSurfaceFormat m_format;
175
176 mutable bool m_dirtyFrameMargins;
177 mutable QMargins m_frameMargins;
178
179 #if defined(XCB_USE_EGL)
180 mutable QXcbEGLSurface *m_eglSurface;
181 #endif
182
183 QRegion m_exposeRegion;
184
185 xcb_visualid_t m_visualId;
186 int m_lastWindowStateEvent;
187
188 enum SyncState {
189 NoSyncNeeded,
190 SyncReceived,
191 SyncAndConfigureReceived
192 };
193 SyncState m_syncState;
194 };
195
196 QT_END_NAMESPACE
197
198 Q_DECLARE_METATYPE(QXcbWindow*)
199
200 #endif