Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.3.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 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 updateSyncRequestCounter();
111 void updateNetWmUserTime(xcb_timestamp_t timestamp);
112
113 #if defined(XCB_USE_EGL)
114 QXcbEGLSurface *eglSurface() const;
115 #endif
116
117 private:
118 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
119 NetWmStates netWmStates();
120 void setNetWmStates(NetWmStates);
121
122 void setNetWmWindowFlags(Qt::WindowFlags flags);
123 void setMotifWindowFlags(Qt::WindowFlags flags);
124
125 void updateMotifWmHintsBeforeMap();
126 void updateNetWmStateBeforeMap();
127
128 void setTransparentForMouseEvents(bool transparent);
129 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
130
131 QRect windowToWmGeometry(QRect r) const;
132 void sendXEmbedMessage(xcb_window_t window, quint32 message,
133 quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
134 void handleXEmbedMessage(const xcb_client_message_event_t *event);
135
136 void create();
137 void destroy();
138
139 void show();
140 void hide();
141
142 QXcbScreen *m_screen;
143
144 xcb_window_t m_window;
145
146 uint m_depth;
147 QImage::Format m_imageFormat;
148
149 xcb_sync_int64_t m_syncValue;
150 xcb_sync_counter_t m_syncCounter;
151
152 Qt::WindowState m_windowState;
153
154 xcb_gravity_t m_gravity;
155
156 bool m_mapped;
157 bool m_transparent;
158 bool m_usingSyncProtocol;
159 bool m_deferredActivation;
160 bool m_deferredExpose;
161 bool m_configureNotifyPending;
162 bool m_embedded;
163 bool m_alertState;
164 xcb_window_t m_netWmUserTimeWindow;
165
166 QSurfaceFormat m_format;
167
168 mutable bool m_dirtyFrameMargins;
169 mutable QMargins m_frameMargins;
170
171 #if defined(XCB_USE_EGL)
172 mutable QXcbEGLSurface *m_eglSurface;
173 #endif
174
175 QRegion m_exposeRegion;
176
177 xcb_visualid_t m_visualId;
178 int m_lastWindowStateEvent;
179 };
180
181 QT_END_NAMESPACE
182
183 #endif