1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
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 Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
85 Qt::WindowState 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 xcb_window_t xcb_window() const { return m_window; }
113 uint depth() const { return m_depth; }
114 QImage::Format imageFormat() const { return m_imageFormat; }
116 void handleExposeEvent(const xcb_expose_event_t *event);
117 void handleClientMessageEvent(const xcb_client_message_event_t *event);
118 void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event);
119 void handleMapNotifyEvent(const xcb_map_notify_event_t *event);
120 void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event);
121 void handleButtonPressEvent(const xcb_button_press_event_t *event);
122 void handleButtonReleaseEvent(const xcb_button_release_event_t *event);
123 void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event);
125 void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event);
126 void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event);
127 void handleFocusInEvent(const xcb_focus_in_event_t *event);
128 void handleFocusOutEvent(const xcb_focus_out_event_t *event);
129 void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event);
131 void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers);
133 void updateSyncRequestCounter();
134 void updateNetWmUserTime(xcb_timestamp_t timestamp);
135 void netWmUserTime() const;
137 #if defined(XCB_USE_EGL)
138 QXcbEGLSurface *eglSurface() const;
142 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
143 NetWmStates netWmStates();
144 void setNetWmStates(NetWmStates);
146 void setNetWmWindowFlags(Qt::WindowFlags flags);
147 void setMotifWindowFlags(Qt::WindowFlags flags);
149 void updateMotifWmHintsBeforeMap();
150 void updateNetWmStateBeforeMap();
152 void setTransparentForMouseEvents(bool transparent);
153 void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
155 QRect windowToWmGeometry(QRect r) const;
163 QXcbScreen *m_screen;
165 xcb_window_t m_window;
168 QImage::Format m_imageFormat;
170 xcb_sync_int64_t m_syncValue;
171 xcb_sync_counter_t m_syncCounter;
173 Qt::WindowState m_windowState;
175 xcb_gravity_t m_gravity;
179 bool m_deferredActivation;
180 bool m_deferredExpose;
181 bool m_configureNotifyPending;
182 xcb_window_t m_netWmUserTimeWindow;
184 QSurfaceFormat m_format;
186 mutable bool m_dirtyFrameMargins;
187 mutable QMargins m_frameMargins;
189 #if defined(XCB_USE_EGL)
190 mutable QXcbEGLSurface *m_eglSurface;
193 QRegion m_exposeRegion;
195 xcb_visualid_t m_visualId;
196 int m_lastWindowStateEvent;