1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the plugins of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include <QtGui/QPlatformWindow>
46 #include <QtGui/QSurfaceFormat>
47 #include <QtGui/QImage>
52 #include "qxcbobject.h"
59 class QXcbWindow : public QXcbObject, public QPlatformWindow
62 QXcbWindow(QWindow *window);
65 void setGeometry(const QRect &rect);
67 QMargins frameMargins() const;
69 void setVisible(bool visible);
70 Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
71 Qt::WindowState setWindowState(Qt::WindowState state);
73 void setParent(const QPlatformWindow *window);
75 void setWindowTitle(const QString &title);
78 void propagateSizeHints();
80 void requestActivateWindow();
82 bool setKeyboardGrabEnabled(bool grab);
83 bool setMouseGrabEnabled(bool grab);
85 void setCursor(xcb_cursor_t cursor);
87 QSurfaceFormat format() const;
89 xcb_window_t xcb_window() const { return m_window; }
90 uint depth() const { return m_depth; }
91 QImage::Format imageFormat() const { return m_imageFormat; }
93 void handleExposeEvent(const xcb_expose_event_t *event);
94 void handleClientMessageEvent(const xcb_client_message_event_t *event);
95 void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event);
96 void handleMapNotifyEvent(const xcb_map_notify_event_t *event);
97 void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event);
98 void handleButtonPressEvent(const xcb_button_press_event_t *event);
99 void handleButtonReleaseEvent(const xcb_button_release_event_t *event);
100 void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event);
102 void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event);
103 void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event);
104 void handleFocusInEvent(const xcb_focus_in_event_t *event);
105 void handleFocusOutEvent(const xcb_focus_out_event_t *event);
107 void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global);
109 void updateSyncRequestCounter();
110 void updateNetWmUserTime(xcb_timestamp_t timestamp);
111 void netWmUserTime() const;
113 #if defined(XCB_USE_EGL)
114 QXcbEGLSurface *eglSurface() const;
118 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
119 QVector<xcb_atom_t> getNetWmState();
120 void setNetWmState(const QVector<xcb_atom_t> &atoms);
121 void printNetWmState(const QVector<xcb_atom_t> &state);
123 void setNetWmWindowFlags(Qt::WindowFlags flags);
124 void setMotifWindowFlags(Qt::WindowFlags flags);
126 void updateMotifWmHintsBeforeMap();
127 void updateNetWmStateBeforeMap();
129 void setTransparentForMouseEvents(bool transparent);
137 QXcbScreen *m_screen;
139 xcb_window_t m_window;
142 QImage::Format m_imageFormat;
144 xcb_sync_int64_t m_syncValue;
145 xcb_sync_counter_t m_syncCounter;
147 Qt::WindowState m_windowState;
151 xcb_window_t m_netWmUserTimeWindow;
153 QSurfaceFormat m_requestedFormat;
155 mutable bool m_dirtyFrameMargins;
156 mutable QMargins m_frameMargins;
158 #if defined(XCB_USE_EGL)
159 mutable QXcbEGLSurface *m_eglSurface;
162 QRegion m_exposeRegion;