Removed unnecessary debug output in xcb plugin.
[profile/ivi/qtbase.git] / src / plugins / platforms / xcb / qxcbwindow.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the plugins of the Qt Toolkit.
8 **
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.
17 **
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.
21 **
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.
29 **
30 ** Other Usage
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.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QXCBWINDOW_H
43 #define QXCBWINDOW_H
44
45 #include <QtGui/QPlatformWindow>
46 #include <QtGui/QSurfaceFormat>
47 #include <QtGui/QImage>
48
49 #include <xcb/xcb.h>
50 #include <xcb/sync.h>
51
52 #include "qxcbobject.h"
53
54 class QXcbScreen;
55 class QXcbEGLSurface;
56
57 class QXcbWindow : public QXcbObject, public QPlatformWindow
58 {
59 public:
60     QXcbWindow(QWindow *window);
61     ~QXcbWindow();
62
63     void setGeometry(const QRect &rect);
64
65     QMargins frameMargins() const;
66
67     void setVisible(bool visible);
68     Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
69     Qt::WindowState setWindowState(Qt::WindowState state);
70     WId winId() const;
71     void setParent(const QPlatformWindow *window);
72
73     void setWindowTitle(const QString &title);
74     void raise();
75     void lower();
76     void propagateSizeHints();
77
78     void requestActivateWindow();
79
80     bool setKeyboardGrabEnabled(bool grab);
81     bool setMouseGrabEnabled(bool grab);
82
83     void setCursor(xcb_cursor_t cursor);
84
85     QSurfaceFormat format() const;
86
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; }
90
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);
99
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);
104
105     void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global);
106
107     void updateSyncRequestCounter();
108     void updateNetWmUserTime(xcb_timestamp_t timestamp);
109     void netWmUserTime() const;
110
111 #if defined(XCB_USE_EGL)
112     QXcbEGLSurface *eglSurface() const;
113 #endif
114
115 private:
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);
120
121     void setNetWmWindowFlags(Qt::WindowFlags flags);
122     void setMotifWindowFlags(Qt::WindowFlags flags);
123
124     void updateMotifWmHintsBeforeMap();
125     void updateNetWmStateBeforeMap();
126
127     void create();
128     void destroy();
129
130     void show();
131     void hide();
132
133     QXcbScreen *m_screen;
134
135     xcb_window_t m_window;
136
137     uint m_depth;
138     QImage::Format m_imageFormat;
139
140     xcb_sync_int64_t m_syncValue;
141     xcb_sync_counter_t m_syncCounter;
142
143     Qt::WindowState m_windowState;
144
145     bool m_mapped;
146     xcb_window_t m_netWmUserTimeWindow;
147
148     QSurfaceFormat m_requestedFormat;
149
150     mutable bool m_dirtyFrameMargins;
151     mutable QMargins m_frameMargins;
152
153 #if defined(XCB_USE_EGL)
154     mutable QXcbEGLSurface *m_eglSurface;
155 #endif
156 };
157
158 #endif