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"
57 class QXcbWindow : public QXcbObject, public QPlatformWindow
60 QXcbWindow(QWindow *window);
63 void setGeometry(const QRect &rect);
65 QMargins frameMargins() const;
67 void setVisible(bool visible);
68 Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
69 Qt::WindowState setWindowState(Qt::WindowState state);
71 void setParent(const QPlatformWindow *window);
73 void setWindowTitle(const QString &title);
76 void propagateSizeHints();
78 void requestActivateWindow();
80 bool setKeyboardGrabEnabled(bool grab);
81 bool setMouseGrabEnabled(bool grab);
83 void setCursor(xcb_cursor_t cursor);
85 QSurfaceFormat format() const;
87 xcb_window_t xcb_window() const { return m_window; }
88 uint depth() const { return m_depth; }
89 QImage::Format imageFormat() const { return m_imageFormat; }
91 void handleExposeEvent(const xcb_expose_event_t *event);
92 void handleClientMessageEvent(const xcb_client_message_event_t *event);
93 void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event);
94 void handleMapNotifyEvent(const xcb_map_notify_event_t *event);
95 void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event);
96 void handleButtonPressEvent(const xcb_button_press_event_t *event);
97 void handleButtonReleaseEvent(const xcb_button_release_event_t *event);
98 void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event);
100 void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event);
101 void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event);
102 void handleFocusInEvent(const xcb_focus_in_event_t *event);
103 void handleFocusOutEvent(const xcb_focus_out_event_t *event);
105 void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global);
107 void updateSyncRequestCounter();
108 void updateNetWmUserTime(xcb_timestamp_t timestamp);
109 void netWmUserTime() const;
111 #if defined(XCB_USE_EGL)
112 QXcbEGLSurface *eglSurface() const;
116 void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
117 QVector<xcb_atom_t> getNetWmState();
118 void setNetWmState(const QVector<xcb_atom_t> &atoms);
119 void printNetWmState(const QVector<xcb_atom_t> &state);
121 void setNetWmWindowFlags(Qt::WindowFlags flags);
122 void setMotifWindowFlags(Qt::WindowFlags flags);
124 void updateMotifWmHintsBeforeMap();
125 void updateNetWmStateBeforeMap();
133 QXcbScreen *m_screen;
135 xcb_window_t m_window;
138 QImage::Format m_imageFormat;
140 xcb_sync_int64_t m_syncValue;
141 xcb_sync_counter_t m_syncCounter;
143 Qt::WindowState m_windowState;
146 xcb_window_t m_netWmUserTimeWindow;
148 QSurfaceFormat m_requestedFormat;
150 mutable bool m_dirtyFrameMargins;
151 mutable QMargins m_frameMargins;
153 #if defined(XCB_USE_EGL)
154 mutable QXcbEGLSurface *m_eglSurface;