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 ****************************************************************************/
42 #include <QtGui/private/qguiapplication_p.h>
43 #include "qxlibwindow.h"
45 #include "qxlibintegration.h"
46 #include "qxlibscreen.h"
47 #include "qxlibkeyboard.h"
48 #include "qxlibstatic.h"
49 #include "qxlibdisplay.h"
51 #if !defined(QT_NO_OPENGL)
52 #if !defined(QT_OPENGL_ES_2)
53 #include "qglxintegration.h"
54 #include "private/qglxconvenience_p.h"
56 #include "../eglconvenience/qeglconvenience.h"
57 #include "../eglconvenience/qeglplatformcontext.h"
58 #include "../eglconvenience/qxlibeglintegration.h"
59 #endif //QT_OPENGL_ES_2
63 #include <QtGui/QWindowSystemInterface>
64 #include <QSocketNotifier>
65 #include <QApplication>
72 QHash<Window, QXlibWindow *> QXlibWindow::windowMap;
75 QXlibWindow::QXlibWindow(QWindow *window)
76 : QPlatformWindow(window)
78 , mScreen(QXlibScreen::testLiteScreenForWidget(window))
82 int w = window->width();
83 int h = window->height();
85 #if !defined(QT_NO_OPENGL)
86 if(window->surfaceType() == QWindow::OpenGLSurface) {
87 #if !defined(QT_OPENGL_ES_2)
88 XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber(),
91 QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat());
93 EGLDisplay eglDisplay = mScreen->eglDisplay();
94 EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat);
95 VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(), eglDisplay, eglConfig);
97 XVisualInfo visualInfoTemplate;
98 memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
99 visualInfoTemplate.visualid = id;
101 XVisualInfo *visualInfo;
102 int matchingCount = 0;
103 visualInfo = XGetVisualInfo(mScreen->display()->nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);
104 #endif //!defined(QT_OPENGL_ES_2)
106 mDepth = visualInfo->depth;
107 mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
108 mVisual = visualInfo->visual;
109 Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(), mScreen->rootWindow(), visualInfo->visual, AllocNone);
111 XSetWindowAttributes a;
112 a.background_pixel = WhitePixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber());
113 a.border_pixel = BlackPixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber());
115 x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h,
116 0, visualInfo->depth, InputOutput, visualInfo->visual,
117 CWBackPixel|CWBorderPixel|CWColormap, &a);
119 qFatal("no window!");
122 #endif //!defined(QT_NO_OPENGL)
124 mDepth = mScreen->depth();
125 mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
126 mVisual = mScreen->defaultVisual();
128 x_window = XCreateSimpleWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),
129 x, y, w, h, 0 /*border_width*/,
130 mScreen->blackPixel(), mScreen->whitePixel());
134 qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window;
137 XSetWindowBackgroundPixmap(mScreen->display()->nativeDisplay(), x_window, XNone);
139 XSelectInput(mScreen->display()->nativeDisplay(), x_window,
140 ExposureMask | KeyPressMask | KeyReleaseMask |
141 EnterWindowMask | LeaveWindowMask | FocusChangeMask |
142 PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
143 ButtonMotionMask | PropertyChangeMask |
144 StructureNotifyMask);
150 protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW); // support del window protocol
151 protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_TAKE_FOCUS); // support take focus window protocol
152 // protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_PING); // support _NET_WM_PING protocol
154 protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_SYNC_REQUEST); // support _NET_WM_SYNC_REQUEST protocol
155 #endif // QT_NO_XSYNC
156 if (window->windowFlags() & Qt::WindowContextHelpButtonHint)
157 protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_CONTEXT_HELP);
158 XSetWMProtocols(mScreen->display()->nativeDisplay(), x_window, protocols, n);
160 windowMap.insert(x_window, this);
165 QXlibWindow::~QXlibWindow()
168 qDebug() << "~QTestLiteWindow" << hex << x_window;
171 windowMap.remove(x_window);
174 XFreeGC(mScreen->display()->nativeDisplay(), gc);
175 XDestroyWindow(mScreen->display()->nativeDisplay(), x_window);
178 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
180 static Qt::MouseButtons translateMouseButtons(int s)
182 Qt::MouseButtons ret = 0;
184 ret |= Qt::LeftButton;
186 ret |= Qt::MidButton;
188 ret |= Qt::RightButton;
194 void QXlibWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
196 static QPoint mousePoint;
198 Qt::MouseButton button = Qt::NoButton;
199 Qt::MouseButtons buttons = translateMouseButtons(e->state);
200 Qt::KeyboardModifiers modifiers = mScreen->keyboard()->translateModifiers(e->state);
201 if (type != QEvent::MouseMove) {
203 case Button1: button = Qt::LeftButton; break;
204 case Button2: button = Qt::MidButton; break;
205 case Button3: button = Qt::RightButton; break;
211 if (type == QEvent::MouseButtonPress) {
212 //logic borrowed from qapplication_x11.cpp
213 int delta = 120 * ((e->button == Button4 || e->button == 6) ? 1 : -1);
214 bool hor = (((e->button == Button4 || e->button == Button5)
215 && (modifiers & Qt::AltModifier))
216 || (e->button == 6 || e->button == 7));
217 QWindowSystemInterface::handleWheelEvent(window(), e->time,
219 QPoint(e->x_root, e->y_root),
220 delta, hor ? Qt::Horizontal : Qt::Vertical);
224 case 8: button = Qt::BackButton; break; // Also known as Qt::ExtraButton1
225 case 9: button = Qt::ForwardButton; break; // Also known as Qt::ExtraButton2
226 case 10: button = Qt::ExtraButton3; break;
227 case 11: button = Qt::ExtraButton4; break;
228 case 12: button = Qt::ExtraButton5; break;
229 case 13: button = Qt::ExtraButton6; break;
230 case 14: button = Qt::ExtraButton7; break;
231 case 15: button = Qt::ExtraButton8; break;
232 case 16: button = Qt::ExtraButton9; break;
233 case 17: button = Qt::ExtraButton10; break;
234 case 18: button = Qt::ExtraButton11; break;
235 case 19: button = Qt::ExtraButton12; break;
236 case 20: button = Qt::ExtraButton13; break;
237 case 21: button = Qt::ExtraButton14; break;
238 case 22: button = Qt::ExtraButton15; break;
239 case 23: button = Qt::ExtraButton16; break;
240 case 24: button = Qt::ExtraButton17; break;
241 case 25: button = Qt::ExtraButton18; break;
242 case 26: button = Qt::ExtraButton19; break;
243 case 27: button = Qt::ExtraButton20; break;
244 case 28: button = Qt::ExtraButton21; break;
245 case 29: button = Qt::ExtraButton22; break;
246 case 30: button = Qt::ExtraButton23; break;
247 case 31: button = Qt::ExtraButton24; break;
252 buttons ^= button; // X event uses state *before*, Qt uses state *after*
254 QWindowSystemInterface::handleMouseEvent(window(), e->time, QPoint(e->x, e->y),
255 QPoint(e->x_root, e->y_root),
258 mousePoint = QPoint(e->x_root, e->y_root);
261 void QXlibWindow::handleCloseEvent()
263 QWindowSystemInterface::handleCloseEvent(window());
267 void QXlibWindow::handleEnterEvent()
269 QWindowSystemInterface::handleEnterEvent(window());
272 void QXlibWindow::handleLeaveEvent()
274 QWindowSystemInterface::handleLeaveEvent(window());
277 void QXlibWindow::handleFocusInEvent()
279 QWindowSystemInterface::handleWindowActivated(window());
282 void QXlibWindow::handleFocusOutEvent()
284 QWindowSystemInterface::handleWindowActivated(0);
289 void QXlibWindow::setGeometry(const QRect &rect)
291 XMoveResizeWindow(mScreen->display()->nativeDisplay(), x_window, rect.x(), rect.y(), rect.width(), rect.height());
292 QPlatformWindow::setGeometry(rect);
296 Qt::WindowFlags QXlibWindow::windowFlags() const
301 WId QXlibWindow::winId() const
306 void QXlibWindow::setParent(const QPlatformWindow *parent)
308 QPoint topLeft = geometry().topLeft();
309 WId parentWinId = parent ? parent->winId() : mScreen->rootWindow();
310 XReparentWindow(mScreen->display()->nativeDisplay(),x_window,parentWinId,topLeft.x(),topLeft.y());
313 void QXlibWindow::raise()
315 XRaiseWindow(mScreen->display()->nativeDisplay(), x_window);
318 void QXlibWindow::lower()
320 XLowerWindow(mScreen->display()->nativeDisplay(), x_window);
323 void QXlibWindow::setWindowTitle(const QString &title)
325 QByteArray ba = title.toLatin1(); //We're not making a general solution here...
326 XTextProperty windowName;
327 windowName.value = (unsigned char *)ba.constData();
328 windowName.encoding = XA_STRING;
329 windowName.format = 8;
330 windowName.nitems = ba.length();
332 XSetWMName(mScreen->display()->nativeDisplay(), x_window, &windowName);
335 GC QXlibWindow::createGC()
339 gc = XCreateGC(mScreen->display()->nativeDisplay(), x_window, 0, 0);
341 qWarning("QTestLiteWindow::createGC() could not create GC");
346 void QXlibWindow::requestActivateWindow()
348 XSetInputFocus(mScreen->display()->nativeDisplay(), x_window, XRevertToParent, CurrentTime);
351 void QXlibWindow::resizeEvent(XConfigureEvent *e)
353 int xpos = geometry().x();
354 int ypos = geometry().y();
355 if ((e->width != geometry().width() || e->height != geometry().height()) && e->x == 0 && e->y == 0) {
356 //qDebug() << "resize with bogus pos" << e->x << e->y << e->width << e->height << "window"<< hex << window;
358 //qDebug() << "geometry change" << e->x << e->y << e->width << e->height << "window"<< hex << window;
363 qDebug() << hex << x_window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height <<
364 "geometry" << xpos << ypos << e->width << e->height;
367 QRect newRect(xpos, ypos, e->width, e->height);
368 QWindowSystemInterface::handleGeometryChange(window(), newRect);
371 void QXlibWindow::mousePressEvent(XButtonEvent *e)
373 static long prevTime = 0;
374 static Window prevWindow;
375 static int prevX = -999;
376 static int prevY = -999;
378 QEvent::Type type = QEvent::MouseButtonPress;
380 if (e->window == prevWindow && long(e->time) - prevTime < QApplication::doubleClickInterval()
381 && qAbs(e->x - prevX) < 5 && qAbs(e->y - prevY) < 5) {
382 type = QEvent::MouseButtonDblClick;
383 prevTime = e->time - QApplication::doubleClickInterval(); //no double click next time
387 prevWindow = e->window;
391 handleMouseEvent(type, e);
394 QXlibMWMHints QXlibWindow::getMWMHints() const
396 QXlibMWMHints mwmhints;
400 ulong nitems, bytesLeft;
402 Atom atomForMotifWmHints = QXlibStatic::atom(QXlibStatic::_MOTIF_WM_HINTS);
403 if ((XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, atomForMotifWmHints, 0, 5, false,
404 atomForMotifWmHints, &type, &format, &nitems, &bytesLeft,
406 && (type == atomForMotifWmHints
409 mwmhints = *(reinterpret_cast<QXlibMWMHints *>(data));
412 mwmhints.functions = MWM_FUNC_ALL;
413 mwmhints.decorations = MWM_DECOR_ALL;
414 mwmhints.input_mode = 0L;
415 mwmhints.status = 0L;
424 void QXlibWindow::setMWMHints(const QXlibMWMHints &mwmhints)
426 Atom atomForMotifWmHints = QXlibStatic::atom(QXlibStatic::_MOTIF_WM_HINTS);
427 if (mwmhints.flags != 0l) {
428 XChangeProperty(mScreen->display()->nativeDisplay(), x_window,
429 atomForMotifWmHints, atomForMotifWmHints, 32,
430 PropModeReplace, (unsigned char *) &mwmhints, 5);
432 XDeleteProperty(mScreen->display()->nativeDisplay(), x_window, atomForMotifWmHints);
436 // Returns true if we should set WM_TRANSIENT_FOR on \a w
437 static inline bool isTransient(const QWindow *w)
439 return (w->windowType() == Qt::Dialog
440 || w->windowType() == Qt::Sheet
441 || w->windowType() == Qt::Tool
442 || w->windowType() == Qt::SplashScreen
443 || w->windowType() == Qt::ToolTip
444 || w->windowType() == Qt::Drawer
445 || w->windowType() == Qt::Popup);
448 QVector<Atom> QXlibWindow::getNetWmState() const
450 QVector<Atom> returnValue;
452 // Don't read anything, just get the size of the property data
455 ulong propertyLength;
457 uchar *propertyData = 0;
458 if (XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0, 0,
459 False, XA_ATOM, &actualType, &actualFormat,
460 &propertyLength, &bytesLeft, &propertyData) == Success
461 && actualType == XA_ATOM && actualFormat == 32) {
462 returnValue.resize(bytesLeft / 4);
463 XFree((char*) propertyData);
466 if (XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0,
467 returnValue.size(), False, XA_ATOM, &actualType, &actualFormat,
468 &propertyLength, &bytesLeft, &propertyData) != Success) {
470 } else if (propertyLength != (ulong)returnValue.size()) {
471 returnValue.resize(propertyLength);
474 // put it into netWmState
475 if (!returnValue.isEmpty()) {
476 memcpy(returnValue.data(), propertyData, returnValue.size() * sizeof(Atom));
478 XFree((char*) propertyData);
484 Qt::WindowFlags QXlibWindow::setWindowFlags(Qt::WindowFlags flags)
486 // Q_ASSERT(flags & Qt::Window);
487 mWindowFlags = flags;
490 qDebug() << "QTestLiteWindow::setWindowFlags" << hex << x_window << "flags" << flags;
492 Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
494 if (type == Qt::ToolTip)
495 flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint;
496 if (type == Qt::Popup)
497 flags |= Qt::X11BypassWindowManagerHint;
499 bool topLevel = (flags & Qt::Window);
500 bool popup = (type == Qt::Popup);
501 bool dialog = (type == Qt::Dialog
502 || type == Qt::Sheet);
503 bool desktop = (type == Qt::Desktop);
504 bool tool = (type == Qt::Tool || type == Qt::SplashScreen
505 || type == Qt::ToolTip || type == Qt::Drawer);
511 bool tooltip = (type == Qt::ToolTip);
513 XSetWindowAttributes wsa;
515 QXlibMWMHints mwmhints;
517 mwmhints.functions = 0L;
518 mwmhints.decorations = 0;
519 mwmhints.input_mode = 0L;
520 mwmhints.status = 0L;
524 if (type != Qt::SplashScreen) { // && customize) {
525 mwmhints.flags |= MWM_HINTS_DECORATIONS;
527 bool customize = flags & Qt::CustomizeWindowHint;
528 if (!(flags & Qt::FramelessWindowHint) && !(customize && !(flags & Qt::WindowTitleHint))) {
529 mwmhints.decorations |= MWM_DECOR_BORDER;
530 mwmhints.decorations |= MWM_DECOR_RESIZEH;
532 if (flags & Qt::WindowTitleHint)
533 mwmhints.decorations |= MWM_DECOR_TITLE;
535 if (flags & Qt::WindowSystemMenuHint)
536 mwmhints.decorations |= MWM_DECOR_MENU;
538 if (flags & Qt::WindowMinimizeButtonHint) {
539 mwmhints.decorations |= MWM_DECOR_MINIMIZE;
540 mwmhints.functions |= MWM_FUNC_MINIMIZE;
543 if (flags & Qt::WindowMaximizeButtonHint) {
544 mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
545 mwmhints.functions |= MWM_FUNC_MAXIMIZE;
548 if (flags & Qt::WindowCloseButtonHint)
549 mwmhints.functions |= MWM_FUNC_CLOSE;
552 // if type == Qt::SplashScreen
553 mwmhints.decorations = MWM_DECOR_ALL;
557 wsa.save_under = True;
558 wsa_mask |= CWSaveUnder;
561 if (flags & Qt::X11BypassWindowManagerHint) {
562 wsa.override_redirect = True;
563 wsa_mask |= CWOverrideRedirect;
566 if (wsa_mask && initializeWindow) {
568 XChangeWindowAttributes(dpy, id, wsa_mask, &wsa);
571 if (mwmhints.functions != 0) {
572 mwmhints.flags |= MWM_HINTS_FUNCTIONS;
573 mwmhints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
575 mwmhints.functions = MWM_FUNC_ALL;
578 if (!(flags & Qt::FramelessWindowHint)
579 && flags & Qt::CustomizeWindowHint
580 && flags & Qt::WindowTitleHint
582 (Qt::WindowMinimizeButtonHint
583 | Qt::WindowMaximizeButtonHint
584 | Qt::WindowCloseButtonHint))) {
585 // a special case - only the titlebar without any button
586 mwmhints.flags = MWM_HINTS_FUNCTIONS;
587 mwmhints.functions = MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
588 mwmhints.decorations = 0;
591 if (window()->windowModality() == Qt::WindowModal) {
592 mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL;
593 } else if (window()->windowModality() == Qt::ApplicationModal) {
594 mwmhints.input_mode = MWM_INPUT_FULL_APPLICATION_MODAL;
597 setMWMHints(mwmhints);
599 QVector<Atom> netWmState = getNetWmState();
601 if (flags & Qt::WindowStaysOnTopHint) {
602 if (flags & Qt::WindowStaysOnBottomHint)
603 qWarning() << "QWindow: Incompatible window flags: the window can't be on top and on bottom at the same time";
604 if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_ABOVE)))
605 netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_ABOVE));
606 if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_STAYS_ON_TOP)))
607 netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_STAYS_ON_TOP));
608 } else if (flags & Qt::WindowStaysOnBottomHint) {
609 if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_BELOW)))
610 netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_BELOW));
612 if (window()->windowState() & Qt::WindowFullScreen) {
613 if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_FULLSCREEN)))
614 netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_FULLSCREEN));
616 if (window()->windowState() & Qt::WindowMaximized) {
617 if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_HORZ)))
618 netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_HORZ));
619 if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_VERT)))
620 netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_VERT));
622 if (window()->windowModality() != Qt::NonModal) {
623 if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MODAL)))
624 netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MODAL));
627 if (!netWmState.isEmpty()) {
628 XChangeProperty(mScreen->display()->nativeDisplay(), x_window,
629 QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), XA_ATOM, 32, PropModeReplace,
630 (unsigned char *) netWmState.data(), netWmState.size());
632 XDeleteProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE));
635 //##### only if initializeWindow???
637 if (popup || tooltip) { // popup widget
639 qDebug() << "Doing XChangeWindowAttributes for popup" << wsa.override_redirect;
641 // set EWMH window types
642 // setNetWmWindowTypes();
644 wsa.override_redirect = True;
645 wsa.save_under = True;
646 XChangeWindowAttributes(mScreen->display()->nativeDisplay(), x_window, CWOverrideRedirect | CWSaveUnder,
650 qDebug() << "Doing XChangeWindowAttributes for non-popup";
657 Qt::WindowState QXlibWindow::setWindowState(Qt::WindowState state)
663 void QXlibWindow::setVisible(bool visible)
666 qDebug() << "QTestLiteWindow::setVisible" << visible << hex << x_window;
668 if (isTransient(window())) {
669 Window parentXWindow = x_window;
670 QWindow *parent = window()->parent();
671 if (parent && parent->handle()) {
672 QXlibWindow *xlibParent = static_cast<QXlibWindow *>(parent->handle());
673 parentXWindow = xlibParent->x_window;
675 XSetTransientForHint(mScreen->display()->nativeDisplay(),x_window,parentXWindow);
679 qDebug() << ">>> mapping";
680 //ensure that the window is viewed in correct position.
682 XMapWindow(mScreen->display()->nativeDisplay(), x_window);
684 XUnmapWindow(mScreen->display()->nativeDisplay(), x_window);
688 void QXlibWindow::setCursor(const Cursor &cursor)
690 XDefineCursor(mScreen->display()->nativeDisplay(), x_window, cursor);
691 mScreen->display()->flush();
694 QSurfaceFormat QXlibWindow::format() const
696 return window()->format();
700 Window QXlibWindow::xWindow() const
705 GC QXlibWindow::graphicsContext() const
710 void QXlibWindow::doSizeHints()
712 // Q_ASSERT(window()->testAttribute(Qt::WA_WState_Created));
715 QRect g = geometry();
719 s.height = g.height();
720 s.flags |= USPosition;
721 s.flags |= PPosition;
724 s.flags |= PWinGravity;
725 s.win_gravity = QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity;
726 XSetWMNormalHints(mScreen->display()->nativeDisplay(), x_window, &s);
730 QXlibWindow *QXlibWindow::platformWindowForXWindow(Window window)
732 return windowMap.value(window);