1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
45 #include <qpa/qplatformwindow.h>
46 #include <QtGui/QSurfaceFormat>
47 #include <QtGui/QImage>
52 #include "qxcbobject.h"
60 class QXcbWindow : public QXcbObject, public QPlatformWindow
64 NetWmStateAbove = 0x1,
65 NetWmStateBelow = 0x2,
66 NetWmStateFullScreen = 0x4,
67 NetWmStateMaximizedHorz = 0x8,
68 NetWmStateMaximizedVert = 0x10,
69 NetWmStateModal = 0x20,
70 NetWmStateStaysOnTop = 0x40,
71 NetWmStateDemandsAttention = 0x80
74 Q_DECLARE_FLAGS(NetWmStates, NetWmState)
76 QXcbWindow(QWindow *window);
79 void setGeometry(const QRect &rect);
81 QMargins frameMargins() const;
83 void setVisible(bool visible);
84 void setWindowFlags(Qt::WindowFlags flags);
85 void setWindowState(Qt::WindowState state);
87 void setParent(const QPlatformWindow *window);
89 bool isExposed() const;
91 void setWindowTitle(const QString &title);
92 void setWindowIcon(const QIcon &icon);
95 void propagateSizeHints();
97 void requestActivateWindow();
99 #if XCB_USE_MAEMO_WINDOW_PROPERTIES
100 void handleContentOrientationChange(Qt::ScreenOrientation orientation);
103 bool setKeyboardGrabEnabled(bool grab);
104 bool setMouseGrabEnabled(bool grab);
106 void setCursor(xcb_cursor_t cursor);
108 QSurfaceFormat format() const;
110 bool startSystemResize(const QPoint &pos, Qt::Corner corner);
112 #if !defined(QT_NO_SHAPE)
113 void setMask(const QRegion ®ion);
114 #endif // !QT_NO_SHAPE
116 xcb_window_t xcb_window() const { return m_window; }
117 uint depth() const { return m_depth; }
118 QImage::Format imageFormat() const { return m_imageFormat; }
120 void handleExposeEvent(const xcb_expose_event_t *event);
121 void handleClientMessageEvent(const xcb_client_message_event_t *event);
122 void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event);
123 void handleMapNotifyEvent(const xcb_map_notify_event_t *event);
124 void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event);
125 void handleButtonPressEvent(const xcb_button_press_event_t *event);
126 void handleButtonReleaseEvent(const xcb_button_release_event_t *event);
127 void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event);
129 void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event);
130 void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event);
131 void handleFocusInEvent(const xcb_focus_in_event_t *event);
132 void handleFocusOutEvent(const xcb_focus_out_event_t *event);
133 void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event);
135 void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers);
137 void updateSyncRequestCounter();
138 void updateNetWmUserTime(xcb_timestamp_t timestamp);
139 void netWmUserTime() const;
141 #if defined(XCB_USE_EGL)
142 QXcbEGLSurface *eglSurface() const;
146 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
147 NetWmStates netWmStates();
148 void setNetWmStates(NetWmStates);
150 void setNetWmWindowFlags(Qt::WindowFlags flags);
151 void setMotifWindowFlags(Qt::WindowFlags flags);
153 void updateMotifWmHintsBeforeMap();
154 void updateNetWmStateBeforeMap();
156 void setTransparentForMouseEvents(bool transparent);
157 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
159 QRect windowToWmGeometry(QRect r) const;
167 QXcbScreen *m_screen;
169 xcb_window_t m_window;
172 QImage::Format m_imageFormat;
174 xcb_sync_int64_t m_syncValue;
175 xcb_sync_counter_t m_syncCounter;
177 Qt::WindowState m_windowState;
179 xcb_gravity_t m_gravity;
183 bool m_deferredActivation;
184 bool m_deferredExpose;
185 bool m_configureNotifyPending;
186 xcb_window_t m_netWmUserTimeWindow;
188 QSurfaceFormat m_format;
190 mutable bool m_dirtyFrameMargins;
191 mutable QMargins m_frameMargins;
193 #if defined(XCB_USE_EGL)
194 mutable QXcbEGLSurface *m_eglSurface;
197 QRegion m_exposeRegion;
199 xcb_visualid_t m_visualId;
200 int m_lastWindowStateEvent;