Merge remote branch 'staging/master' into refactor
authorSamuel Rødal <samuel.rodal@nokia.com>
Fri, 20 May 2011 17:45:38 +0000 (19:45 +0200)
committerSamuel Rødal <samuel.rodal@nokia.com>
Fri, 20 May 2011 17:46:19 +0000 (19:46 +0200)
Conflicts:
src/opengl/qgl_qpa.cpp
src/plugins/platforms/glxconvenience/qglxconvenience.cpp
src/plugins/platforms/platforms.pro
src/plugins/platforms/wayland/qwaylandwindow.cpp
src/plugins/platforms/xcb/qxcbwindow.cpp
src/plugins/platforms/xcb/qxcbwindow.h
src/plugins/platforms/xcb/qxcbwindowsurface.cpp
src/widgets/kernel/qwidget_qpa.cpp
tests/auto/qvariant/tst_qvariant.cpp

27 files changed:
1  2 
configure
src/gui/painting/qcolor.cpp
src/gui/painting/qpaintengine_raster.cpp
src/gui/painting/qpaintengineex_p.h
src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
src/opengl/qgl_qpa.cpp
src/opengl/qwindowsurface_gl.cpp
src/plugins/platforms/glxconvenience/qglxconvenience.cpp
src/plugins/platforms/minimal/qminimalintegration.cpp
src/plugins/platforms/minimal/qminimalintegration.h
src/plugins/platforms/platforms.pro
src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
src/plugins/platforms/wayland/qwaylandclipboard.cpp
src/plugins/platforms/wayland/qwaylanddisplay.cpp
src/plugins/platforms/wayland/qwaylandwindow.cpp
src/plugins/platforms/wayland/wayland.pro
src/plugins/platforms/xcb/qxcbwindow.cpp
src/plugins/platforms/xcb/qxcbwindow.h
src/plugins/platforms/xcb/qxcbwindowsurface.cpp
src/uitools/quiloader.cpp
src/widgets/kernel/qwidget_qpa.cpp
src/widgets/platforms/x11/qapplication_x11.cpp
tests/auto/qmetatype/tst_qmetatype.cpp
tests/auto/qwidget/tst_qwidget.cpp
tools/uilib/abstractformbuilder.cpp
tools/uilib/abstractformbuilder.h
tools/uilib/formbuilderextra.cpp

diff --cc configure
Simple merge
Simple merge
Simple merge
@@@ -80,25 -82,36 +80,25 @@@ QGLFormat QGLFormat::fromWindowFormat(c
      return retFormat;
  }
  
 -QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
 +QWindowFormat QGLFormat::toWindowFormat(const QGLFormat &format)
  {
 -    QPlatformWindowFormat retFormat;
 -    retFormat.setAccum(format.accum());
 -    if (format.accumBufferSize() >= 0)
 -        retFormat.setAccumBufferSize(format.accumBufferSize());
 -    retFormat.setAlpha(format.alpha());
 -    if (format.alphaBufferSize() >= 0)
 -        retFormat.setAlphaBufferSize(format.alphaBufferSize());
 +    QWindowFormat retFormat;
-     if (format.alphaBufferSize() >= 0)
-         retFormat.setAlphaBufferSize(format.alphaBufferSize());
++    if (format.alpha())
++        retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize());
      if (format.blueBufferSize() >= 0)
          retFormat.setBlueBufferSize(format.blueBufferSize());
 -    retFormat.setDepth(format.depth());
 -    if (format.depthBufferSize() >= 0)
 -        retFormat.setDepthBufferSize(format.depthBufferSize());
 -    retFormat.setDirectRendering(format.directRendering());
 -    retFormat.setDoubleBuffer(format.doubleBuffer());
      if (format.greenBufferSize() >= 0)
          retFormat.setGreenBufferSize(format.greenBufferSize());
      if (format.redBufferSize() >= 0)
          retFormat.setRedBufferSize(format.redBufferSize());
-     if (format.depthBufferSize() >= 0)
-         retFormat.setDepthBufferSize(format.depthBufferSize());
 -    retFormat.setRgba(format.rgba());
 -    retFormat.setSampleBuffers(format.sampleBuffers());
 -    if (format.samples() >= 0)
 -        retFormat.setSamples(format.samples());
 -    retFormat.setStencil(format.stencil());
 -    if (format.stencilBufferSize() >= 0)
 -        retFormat.setStencilBufferSize(format.stencilBufferSize());
++    if (format.depth())
++        retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize());
 +    retFormat.setSwapBehavior(format.doubleBuffer() ? QWindowFormat::DoubleBuffer : QWindowFormat::DefaultSwapBehavior);
-     if (format.sampleBuffers() && format.samples() > 1)
-         retFormat.setSamples(format.samples());
-     if (format.stencil() && format.stencilBufferSize() > 0)
-         retFormat.setStencilBufferSize(format.stencilBufferSize());
++    if (format.sampleBuffers())
++        retFormat.setSamples(format.samples() == -1 ? 4 : format.samples());
++    if (format.stencil())
++        retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize());
      retFormat.setStereo(format.stereo());
 -    retFormat.setSwapInterval(format.swapInterval());
      return retFormat;
  }
  
@@@ -131,23 -144,25 +131,25 @@@ bool QGLContext::chooseContext(const QG
          d->valid = false;
      }else {
          QWidget *widget = static_cast<QWidget *>(d->paintDevice);
 -        if (!widget->platformWindow()){
 +        if (!widget->windowHandle()->handle()) {
              QGLFormat glformat = format();
 -            QPlatformWindowFormat winFormat = QGLFormat::toPlatformWindowFormat(glformat);
 +            QWindowFormat winFormat = QGLFormat::toWindowFormat(glformat);
              if (shareContext) {
 -                winFormat.setSharedContext(shareContext->d_func()->platformContext);
 +                winFormat.setSharedContext(shareContext->d_func()->windowContext);
              }
 -                winFormat.setAlpha(true);
 -            winFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
 +            widget->windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
+             if (widget->testAttribute(Qt::WA_TranslucentBackground))
++                winFormat.setAlphaBufferSize(qMax(winFormat.alphaBufferSize(), 8));
              winFormat.setWindowSurface(false);
 -            widget->setPlatformWindowFormat(winFormat);
 +            widget->windowHandle()->setWindowFormat(winFormat);
              widget->winId();//make window
          }
 -        d->platformContext = widget->platformWindow()->glContext();
 -        Q_ASSERT(d->platformContext);
 -        d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat());
 -        d->valid =(bool) d->platformContext;
 +        d->windowContext = widget->windowHandle()->glContext();
 +        Q_ASSERT(d->windowContext);
 +        d->glFormat = QGLFormat::fromWindowFormat(d->windowContext->handle()->windowFormat());
 +        d->valid =(bool) d->windowContext;
          if (d->valid) {
 -            d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
 +            d->windowContext->setQGLContextHandle(this,qDeleteQGLContext);
          }
          d->setupSharing();
      }
@@@ -485,14 -542,16 +485,19 @@@ void QGLWindowSurface::beginPaint(cons
      d_ptr->did_paint = true;
      updateGeometry();
  
-     if (!context())
-         return;
      int clearFlags = 0;
  
-     if (context()->d_func()->workaround_needsFullClearOnEveryFrame)
++#if 0
+     QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
++#endif
++    const QGLContext *ctx = QGLContext::currentContext();
+     if (!ctx)
+         return;
+     if (ctx->d_func()->workaround_needsFullClearOnEveryFrame)
          clearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
-     else if (context()->format().alpha())
+     else if (ctx->format().alpha())
          clearFlags = GL_COLOR_BUFFER_BIT;
  
      if (clearFlags) {
@@@ -75,22 -79,40 +79,28 @@@ QVector<int> qglx_buildSpec(const QWind
      spec[i++] = 0;
      spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = drawableBit;
  
 -    if (format.rgba()) {
 -        spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT;
 -        spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
 -        spec[i++] = GLX_GREEN_SIZE; spec[i++] =  (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
 -        spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
 -        if (format.alpha()) {
 -                spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
 -            }
 -
 -        if (format.accum()) {
 -            spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
 -            spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
 -            spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
 +    spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT;
 -            if (format.alpha()) {
 -                spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
 -            }
 -        }
 -    } else {
 -        spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works....
 -        spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8;
 +    spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
 +    spec[i++] = GLX_GREEN_SIZE; spec[i++] =  (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
 +    spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
 +    if (format.hasAlpha()) {
-         spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
++        spec[i++] = GLX_ALPHA_SIZE; spec[i++] = format.alphaBufferSize();
      }
  
 -    spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False;
 +    spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QWindowFormat::SingleBuffer ? True : False;
++
      spec[i++] = GLX_STEREO; spec[i++] =  format.stereo() ? True : False;
  
-     spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize();
 -    if (format.depth()) {
 -        spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize();
++    if (format.depthBufferSize() > 0) {
++        spec[i++] = GLX_DEPTH_SIZE; spec[i++] = format.depthBufferSize();
+     }
  
-     spec[i++] = GLX_STENCIL_SIZE; spec[i++] =  (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
 -    if (format.stencil()) {
++    if (format.stencilBufferSize() > 0) {
+         spec[i++] = GLX_STENCIL_SIZE; spec[i++] =  (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
+     }
 -    if (format.sampleBuffers()) {
 +
 +    if (format.samples() > 1) {
          spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
          spec[i++] = 1;
          spec[i++] = GLX_SAMPLES_ARB;
@@@ -116,11 -138,20 +126,20 @@@ GLXFBConfig qglx_findConfig(Display *di
              for (int i = 0; i < confcount; i++) {
                  chosenConfig = configs[i];
                  // Make sure we try to get an ARGB visual if the format asked for an alpha:
 -                if (reducedFormat.alpha()) {
 +                if (reducedFormat.hasAlpha()) {
                      int alphaSize;
                      glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize);
-                     if (alphaSize > 0)
-                         break;
+                     if (alphaSize > 0) {
+                         XVisualInfo *visual = glXGetVisualFromFBConfig(display, chosenConfig);
+ #if !defined(QT_NO_XRENDER)
+                         XRenderPictFormat *pictFormat = XRenderFindVisualFormat(display, visual->visual);
+                         if (pictFormat->direct.alphaMask > 0)
+                             break;
+ #else
+                         if (visual->depth == 32)
+                             break;
+ #endif
+                     }
                  } else {
                      break; // Just choose the first in the list if there's no alpha requested
                  }
@@@ -6,7 -6,6 +6,10 @@@ contains(QT_CONFIG, wayland) 
      SUBDIRS += wayland
  }
  
+ contains(QT_CONFIG, xcb) {
+     SUBDIRS += xcb
+ }
++
 +mac {
 +    SUBDIRS += cocoa
 +}
  #include "gl_integration/qwaylandglintegration.h"
  #endif
  
+ #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ #include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
+ #endif
  #include <QtCore/QAbstractEventDispatcher>
 -#include <QtGui/QApplication>
 -#include <QtGui/private/qapplication_p.h>
 +#include <QtGui/private/qguiapplication_p.h>
  
  #include <unistd.h>
  #include <fcntl.h>
  #include "qwaylandinputdevice.h"
  #include "qwaylandscreen.h"
  
 -#include <QtGui/QWidget>
 +#include <QtGui/QWindow>
++
+ #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ #include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
+ #endif
+ #include <QCoreApplication>
  #include <QtGui/QWindowSystemInterface>
  
  #include <QDebug>
@@@ -39,12 -39,8 +39,13 @@@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAN
  
  INCLUDEPATH += $$PWD
  
 +QT += gui-private
 +QT += opengl-private
 +QT += core-private
 +QT += widgets-private
 +
  include ($$PWD/gl_integration/gl_integration.pri)
+ include ($$PWD/windowmanager_integration/windowmanager_integration.pri)
  
  include (../fontdatabases/genericunix/genericunix.pri)
  
@@@ -133,21 -111,16 +133,22 @@@ void QXcbWindow::create(
          | XCB_EVENT_MASK_FOCUS_CHANGE
      };
  
 +    QRect rect = window()->geometry();
 +
 +    xcb_window_t xcb_parent_id = m_screen->root();
 +    if (parent() && !window()->isTopLevel())
 +        xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window();
 +
  #if defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
-     if (window()->surfaceType() == QWindow::OpenGLSurface
 -    if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
 -        && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)
 -        || tlw->platformWindowFormat().alpha())
++    if ((window()->surfaceType() == QWindow::OpenGLSurface
 +        && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
++        || window()->requestedWindowFormat().hasAlpha())
      {
  #if defined(XCB_USE_GLX)
 -        XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat());
 +        XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), window()->requestedWindowFormat());
  #elif defined(XCB_USE_EGL)
          EGLDisplay eglDisplay = connection()->egl_display();
 -        EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true);
 +        EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,window()->requestedWindowFormat(),true);
          VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig);
  
          XVisualInfo visualInfoTemplate;
          visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount);
  #endif //XCB_USE_GLX
          if (visualInfo) {
 -            Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone);
+             m_depth = visualInfo->depth;
+             m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
 +            Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), xcb_parent_id, visualInfo->visual, AllocNone);
  
              XSetWindowAttributes a;
+             a.background_pixel = WhitePixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber());
+             a.border_pixel = BlackPixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber());
              a.colormap = cmap;
 -            m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(),
 +            m_window = XCreateWindow(DISPLAY_FROM_XCB(this), xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(),
                                        0, visualInfo->depth, InputOutput, visualInfo->visual,
-                                       CWColormap, &a);
+                                       CWBackPixel|CWBorderPixel|CWColormap, &a);
  
 -            printf("created GL window: %d\n", m_window);
 +            printf("created GL window: %x\n", m_window);
          } else {
              qFatal("no window!");
          }
@@@ -43,7 -43,8 +43,8 @@@
  #define QXCBWINDOW_H
  
  #include <QtGui/QPlatformWindow>
 -#include <QtGui/QPlatformWindowFormat>
 +#include <QtGui/QWindowFormat>
+ #include <QtGui/QImage>
  
  #include <xcb/xcb.h>
  #include <xcb/sync.h>
@@@ -75,7 -74,9 +76,9 @@@ public
  
      QPlatformGLContext *glContext() const;
  
 -    xcb_window_t window() const { return m_window; }
 +    xcb_window_t xcb_window() const { return m_window; }
+     uint depth() const { return m_depth; }
+     QImage::Format format() const { return m_format; }
  
      void handleExposeEvent(const xcb_expose_event_t *event);
      void handleClientMessageEvent(const xcb_client_message_event_t *event);
@@@ -228,10 -242,11 +239,11 @@@ void QXcbWindowSurface::resize(const QS
      Q_XCB_NOOP(connection());
      QWindowSurface::resize(size);
  
 -    QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(window()));
 -    QXcbWindow* win = static_cast<QXcbWindow *>(window()->platformWindow());
 +    QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window()));
++    QXcbWindow* win = static_cast<QXcbWindow *>(window()->handle());
  
      delete m_image;
-     m_image = new QXcbShmImage(screen, size);
+     m_image = new QXcbShmImage(screen, size, win->depth(), win->format());
      Q_XCB_NOOP(connection());
  
      m_syncingResize = true;
Simple merge
index 6721fdb,0000000..0248767
mode 100644,000000..100644
--- /dev/null
@@@ -1,851 -1,0 +1,858 @@@
 +/****************************************************************************
 +**
 +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
 +** All rights reserved.
 +** Contact: Nokia Corporation (qt-info@nokia.com)
 +**
 +** This file is part of the QtGui module of the Qt Toolkit.
 +**
 +** $QT_BEGIN_LICENSE:LGPL$
 +** No Commercial Usage
 +** This file contains pre-release code and may not be distributed.
 +** You may use this file in accordance with the terms and conditions
 +** contained in the Technology Preview License Agreement accompanying
 +** this package.
 +**
 +** GNU Lesser General Public License Usage
 +** Alternatively, this file may be used under the terms of the GNU Lesser
 +** General Public License version 2.1 as published by the Free Software
 +** Foundation and appearing in the file LICENSE.LGPL included in the
 +** packaging of this file.  Please review the following information to
 +** ensure the GNU Lesser General Public License version 2.1 requirements
 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 +**
 +** In addition, as a special exception, Nokia gives you certain additional
 +** rights.  These rights are described in the Nokia Qt LGPL Exception
 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 +**
 +** If you have questions regarding the use of this file, please contact
 +** Nokia at qt-info@nokia.com.
 +**
 +**
 +**
 +**
 +**
 +**
 +**
 +**
 +** $QT_END_LICENSE$
 +**
 +****************************************************************************/
 +
 +#include "QtWidgets/qwidget.h"
 +#include "QtGui/qevent.h"
 +#include "QtWidgets/qapplication.h"
 +#include "private/qbackingstore_p.h"
 +#include "private/qwidget_p.h"
 +#include "private/qwidgetwindow_qpa_p.h"
 +#include "private/qapplication_p.h"
 +#include "QtWidgets/qdesktopwidget.h"
 +#include "QtGui/qplatformwindow_qpa.h"
 +#include "QtGui/qplatformglcontext_qpa.h"
 +#include "QtGui/private/qwindow_p.h"
 +
 +#include <QtGui/QPlatformCursor>
 +
 +QT_BEGIN_NAMESPACE
 +
 +void q_createNativeChildrenAndSetParent(QWindow *parentWindow, const QWidget *parentWidget)
 +{
 +    QObjectList children = parentWidget->children();
 +    for (int i = 0; i < children.size(); i++) {
 +        if (children.at(i)->isWidgetType()) {
 +            const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i));
 +            if (childWidget) { // should not be necessary
 +                if (childWidget->testAttribute(Qt::WA_NativeWindow)) {
 +                    if (!childWidget->windowHandle())
 +                        childWidget->winId();
 +                    if (childWidget->windowHandle())
 +                        childWidget->windowHandle()->setParent(parentWindow);
 +                } else {
 +                    q_createNativeChildrenAndSetParent(parentWindow,childWidget);
 +                }
 +            }
 +        }
 +    }
 +
 +}
 +
 +void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
 +{
 +    Q_Q(QWidget);
 +
 +    Q_UNUSED(window);
 +    Q_UNUSED(initializeWindow);
 +    Q_UNUSED(destroyOldWindow);
 +
 +    Qt::WindowFlags flags = data.window_flags;
 +
 +    if ((!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow()) || q->windowType() == Qt::Desktop )
 +        return; // we only care about real toplevels
 +
 +    QWindowSurface *surface = q->windowSurface();
 +
 +    QWindow *win = topData()->window;
 +
 +    win->setWindowFlags(data.window_flags);
 +    win->setGeometry(q->geometry());
 +
++    if (q->testAttribute(Qt::WA_TranslucentBackground)) {
++        QWindowFormat format = win->requestedWindowFormat();
++        format.setAlphaBufferSize(8);
++        win->setWindowFormat(format);
++    }
++
 +    if (QWidget *nativeParent = q->nativeParentWidget()) {
 +        if (nativeParent->windowHandle())
 +            win->setParent(nativeParent->windowHandle());
 +    }
 +
 +    win->create();
 +
 +    data.window_flags = win->windowFlags();
 +
 +    if (!surface ) {
 +        if (win) {
 +            surface = QGuiApplicationPrivate::platformIntegration()->createWindowSurface(win, win->winId());
 +            q->setWindowSurface(surface);
 +        } else {
 +            q->setAttribute(Qt::WA_PaintOnScreen,true);
 +        }
 +    }
 +
 +    setWinId(win->winId());
 +
 +//    first check children. and create them if necessary
 +//    q_createNativeChildrenAndSetParent(q->windowHandle(),q);
 +
 +    QGuiApplicationPrivate::platformIntegration()->moveToScreen(win, topData()->screenIndex);
 +//    qDebug() << "create_sys" << q << q->internalWinId();
 +}
 +
 +void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
 +{
 +    Q_D(QWidget);
 +
 +    if ((windowType() == Qt::Popup))
 +        qApp->d_func()->closePopup(this);
 +
 +    //### we don't have proper focus event handling yet
 +    if (this == QApplicationPrivate::active_window)
 +        QApplication::setActiveWindow(0);
 +
 +    if (windowType() != Qt::Desktop) {
 +        if (destroySubWindows) {
 +            QObjectList childList(children());
 +            for (int i = 0; i < childList.size(); i++) {
 +                QWidget *widget = qobject_cast<QWidget *>(childList.at(i));
 +                if (widget && widget->testAttribute(Qt::WA_NativeWindow)) {
 +                    if (widget->windowHandle()) {
 +                        widget->destroy();
 +                    }
 +                }
 +            }
 +        }
 +        if (destroyWindow) {
 +            d->deleteTLSysExtra();
 +        } else {
 +            if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
 +                d->hide_sys();
 +            }
 +        }
 +    }
 +}
 +
 +void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
 +{
 +    Q_Q(QWidget);
 +
 +    Qt::WindowFlags oldFlags = data.window_flags;
 +
 +    int targetScreen = -1;
 +    // Handle a request to move the widget to a particular screen
 +    if (newparent && newparent->windowType() == Qt::Desktop) {
 +        // make sure the widget is created on the same screen as the
 +        // programmer specified desktop widget
 +
 +        // get the desktop's screen number
 +        targetScreen = newparent->window()->d_func()->topData()->screenIndex;
 +        newparent = 0;
 +    }
 +
 +    if (parent != newparent) {
 +        QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function???
 +        if (q->windowHandle()) {
 +            q->windowHandle()->setWindowFlags(f);
 +            QWidget *parentWithWindow =
 +                newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0;
 +            q->windowHandle()->setParent(parentWithWindow ? parentWithWindow->windowHandle() : 0);
 +        }
 +    }
 +
 +    if (!newparent) {
 +        f |= Qt::Window;
 +        if (targetScreen == -1) {
 +            if (parent)
 +                targetScreen = q->parentWidget()->window()->d_func()->topData()->screenIndex;
 +        }
 +    }
 +
 +    bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
 +
 +    // Reparenting toplevel to child
 +    if (!(f&Qt::Window) && (oldFlags&Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
 +        //qDebug() << "setParent_sys() change from toplevel";
 +        q->destroy();
 +    }
 +
 +    data.window_flags = f;
 +    q->setAttribute(Qt::WA_WState_Created, false);
 +    q->setAttribute(Qt::WA_WState_Visible, false);
 +    q->setAttribute(Qt::WA_WState_Hidden, false);
 +
 +    if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
 +        q->setAttribute(Qt::WA_WState_Hidden);
 +    q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
 +
 +    // move the window to the selected screen
 +    if (!newparent && targetScreen != -1) {
 +        if (maybeTopData())
 +            maybeTopData()->screenIndex = targetScreen;
 +        // only if it is already created
 +        if (q->testAttribute(Qt::WA_WState_Created)) {
 +            QPlatformIntegration *platform = QGuiApplicationPrivate::platformIntegration();
 +            platform->moveToScreen(q->windowHandle(), targetScreen);
 +        }
 +    }
 +}
 +
 +QPoint QWidget::mapToGlobal(const QPoint &pos) const
 +{
 +    int           x=pos.x(), y=pos.y();
 +    const QWidget* w = this;
 +    while (w) {
 +        x += w->data->crect.x();
 +        y += w->data->crect.y();
 +        w = w->isWindow() ? 0 : w->parentWidget();
 +    }
 +    return QPoint(x, y);
 +}
 +
 +QPoint QWidget::mapFromGlobal(const QPoint &pos) const
 +{
 +    int           x=pos.x(), y=pos.y();
 +    const QWidget* w = this;
 +    while (w) {
 +        x -= w->data->crect.x();
 +        y -= w->data->crect.y();
 +        w = w->isWindow() ? 0 : w->parentWidget();
 +    }
 +    return QPoint(x, y);
 +}
 +
 +void QWidgetPrivate::updateSystemBackground() {}
 +
 +#ifndef QT_NO_CURSOR
 +void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
 +{
 +    Q_UNUSED(cursor);
 +    Q_Q(QWidget);
 +    if (q->isVisible())
 +        qt_qpa_set_cursor(q, false);
 +}
 +
 +void QWidgetPrivate::unsetCursor_sys()
 +{
 +    Q_Q(QWidget);
 +    if (q->isVisible())
 +        qt_qpa_set_cursor(q, false);
 +}
 +
 +void QWidgetPrivate::updateCursor() const
 +{
 +    // XXX
 +}
 +
 +#endif //QT_NO_CURSOR
 +
 +void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
 +{
 +    Q_Q(QWidget);
 +    if (!q->isWindow())
 +        return;
 +
 +    if (QWindow *window = q->windowHandle())
 +        window->setWindowTitle(caption);
 +
 +}
 +
 +void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/)
 +{
 +}
 +
 +void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
 +{
 +    Q_UNUSED(iconText);
 +}
 +
 +QWidget *qt_pressGrab = 0;
 +QWidget *qt_mouseGrb = 0;
 +static QWidget *keyboardGrb = 0;
 +
 +void QWidget::grabMouse()
 +{
 +    if (qt_mouseGrb)
 +        qt_mouseGrb->releaseMouse();
 +
 +    // XXX
 +    //qwsDisplay()->grabMouse(this,true);
 +
 +    qt_mouseGrb = this;
 +    qt_pressGrab = 0;
 +}
 +
 +#ifndef QT_NO_CURSOR
 +void QWidget::grabMouse(const QCursor &cursor)
 +{
 +    Q_UNUSED(cursor);
 +
 +    if (qt_mouseGrb)
 +        qt_mouseGrb->releaseMouse();
 +
 +    // XXX
 +    //qwsDisplay()->grabMouse(this,true);
 +    //qwsDisplay()->selectCursor(this, cursor.handle());
 +    qt_mouseGrb = this;
 +    qt_pressGrab = 0;
 +}
 +#endif
 +
 +void QWidget::releaseMouse()
 +{
 +    if (qt_mouseGrb == this) {
 +        // XXX
 +        //qwsDisplay()->grabMouse(this,false);
 +        qt_mouseGrb = 0;
 +    }
 +}
 +
 +void QWidget::grabKeyboard()
 +{
 +    if (keyboardGrb)
 +        keyboardGrb->releaseKeyboard();
 +    // XXX
 +    //qwsDisplay()->grabKeyboard(this, true);
 +    keyboardGrb = this;
 +}
 +
 +void QWidget::releaseKeyboard()
 +{
 +    if (keyboardGrb == this) {
 +        // XXX
 +        //qwsDisplay()->grabKeyboard(this, false);
 +        keyboardGrb = 0;
 +    }
 +}
 +
 +QWidget *QWidget::mouseGrabber()
 +{
 +    if (qt_mouseGrb)
 +        return qt_mouseGrb;
 +    return qt_pressGrab;
 +}
 +
 +QWidget *QWidget::keyboardGrabber()
 +{
 +    return keyboardGrb;
 +}
 +
 +void QWidget::activateWindow()
 +{
 +    if (windowHandle())
 +        windowHandle()->requestActivateWindow();
 +}
 +
 +void QWidgetPrivate::show_sys()
 +{
 +    Q_Q(QWidget);
 +    q->setAttribute(Qt::WA_Mapped);
 +    if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
 +        invalidateBuffer(q->rect());
 +        return;
 +    }
 +
 +    QApplication::postEvent(q, new QUpdateLaterEvent(q->rect()));
 +
 +    if (!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow))
 +        return;
 +
 +    QWindow *window = q->windowHandle();
 +    if (window) {
 +        QRect geomRect = q->geometry();
 +        if (!q->isWindow()) {
 +            QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
 +            geomRect.moveTopLeft(topLeftOfWindow);
 +        }
 +        const QRect windowRect = window->geometry();
 +        if (windowRect != geomRect) {
 +            window->setGeometry(geomRect);
 +        }
 +        if (QWindowSurface *surface = q->windowSurface()) {
 +            if (windowRect.size() != geomRect.size()) {
 +                surface->resize(geomRect.size());
 +            }
 +        }
++
 +        if (window)
 +            window->setVisible(true);
 +    }
 +}
 +
 +
 +void QWidgetPrivate::hide_sys()
 +{
 +    Q_Q(QWidget);
 +    q->setAttribute(Qt::WA_Mapped, false);
 +    if (!q->isWindow()) {
 +        QWidget *p = q->parentWidget();
 +        if (p &&p->isVisible()) {
 +            invalidateBuffer(q->rect());
 +        }
 +        return;
 +    }
 +    if (QWindow *window = q->windowHandle()) {
 +         window->setVisible(false);
 +     }
 +
 +    //### we don't yet have proper focus event handling
 +    if (q == QApplicationPrivate::active_window)
 +        QApplication::setActiveWindow(0);
 +
 +}
 +
 +void QWidgetPrivate::setMaxWindowState_helper()
 +{
 +    setFullScreenSize_helper(); //### decoration size
 +}
 +
 +void QWidgetPrivate::setFullScreenSize_helper()
 +{
 +    Q_Q(QWidget);
 +
 +    const uint old_state = data.in_set_window_state;
 +    data.in_set_window_state = 1;
 +
 +    const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q));
 +    q->move(screen.topLeft());
 +    q->resize(screen.size());
 +
 +    data.in_set_window_state = old_state;
 +}
 +
 +static Qt::WindowState effectiveState(Qt::WindowStates state)
 + {
 +     if (state & Qt::WindowMinimized)
 +         return Qt::WindowMinimized;
 +     else if (state & Qt::WindowFullScreen)
 +         return Qt::WindowFullScreen;
 +     else if (state & Qt::WindowMaximized)
 +         return Qt::WindowMaximized;
 +     return Qt::WindowNoState;
 + }
 +
 +void QWidget::setWindowState(Qt::WindowStates newstate)
 +{
 +    Q_D(QWidget);
 +    Qt::WindowStates oldstate = windowState();
 +    if (oldstate == newstate)
 +        return;
 +    if (isWindow() && !testAttribute(Qt::WA_WState_Created))
 +        create();
 +
 +    data->window_state = newstate;
 +    data->in_set_window_state = 1;
 +    bool needShow = false;
 +    Qt::WindowState newEffectiveState = effectiveState(newstate);
 +    Qt::WindowState oldEffectiveState = effectiveState(oldstate);
 +    if (isWindow() && newEffectiveState != oldEffectiveState) {
 +        d->createTLExtra();
 +        if (oldEffectiveState == Qt::WindowNoState) { //normal
 +            d->topData()->normalGeometry = geometry();
 +        } else if (oldEffectiveState == Qt::WindowFullScreen) {
 +            setParent(0, d->topData()->savedFlags);
 +            needShow = true;
 +        } else if (oldEffectiveState == Qt::WindowMinimized) {
 +            needShow = true;
 +        }
 +
 +        Q_ASSERT(windowHandle());
 +        windowHandle()->setWindowState(newEffectiveState);
 +        bool supported = windowHandle()->windowState() == newEffectiveState;
 +
 +        if (!supported) {
 +            // emulate the window state
 +            if (newEffectiveState == Qt::WindowMinimized) {
 +                //### not ideal...
 +                hide();
 +                needShow = false;
 +            } else if (newEffectiveState == Qt::WindowFullScreen) {
 +                d->topData()->savedFlags = windowFlags();
 +                setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint));
 +                d->setFullScreenSize_helper();
 +                raise();
 +                needShow = true;
 +            } else if (newEffectiveState == Qt::WindowMaximized) {
 +                createWinId();
 +                d->setMaxWindowState_helper();
 +            } else if (newEffectiveState == Qt::WindowNoState) {
 +                // reset old geometry
 +                QRect r = d->topData()->normalGeometry;
 +                if (r.width() >= 0) {
 +                    d->topData()->normalGeometry = QRect(0,0,-1,-1);
 +                    setGeometry(r);
 +                }
 +            }
 +        }
 +    }
 +    data->in_set_window_state = 0;
 +
 +    if (needShow)
 +        show();
 +
 +    if (newstate & Qt::WindowActive)
 +        activateWindow();
 +
 +    QWindowStateChangeEvent e(oldstate);
 +    QApplication::sendEvent(this, &e);
 +}
 +
 +void QWidgetPrivate::setFocus_sys()
 +{
 +
 +}
 +
 +void QWidgetPrivate::raise_sys()
 +{
 +    Q_Q(QWidget);
 +    if (q->isWindow()) {
 +        q->windowHandle()->raise();
 +    }
 +}
 +
 +void QWidgetPrivate::lower_sys()
 +{
 +    Q_Q(QWidget);
 +    if (q->isWindow()) {
 +        Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
 +        q->windowHandle()->lower();
 +    } else if (QWidget *p = q->parentWidget()) {
 +        setDirtyOpaqueRegion();
 +        p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
 +    }
 +}
 +
 +void QWidgetPrivate::stackUnder_sys(QWidget*)
 +{
 +    Q_Q(QWidget);
 +    if (QWidget *p = q->parentWidget()) {
 +        setDirtyOpaqueRegion();
 +        p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
 +    }
 +}
 +
 +void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
 +{
 +    Q_Q(QWidget);
 +    if (extra) {                                // any size restrictions?
 +        w = qMin(w,extra->maxw);
 +        h = qMin(h,extra->maxh);
 +        w = qMax(w,extra->minw);
 +        h = qMax(h,extra->minh);
 +    }
 +
 +    QPoint oldp = q->geometry().topLeft();
 +    QSize olds = q->size();
 +    QRect r(x, y, w, h);
 +
 +    bool isResize = olds != r.size();
 +    isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter?
 +
 +
 +    // We only care about stuff that changes the geometry, or may
 +    // cause the window manager to change its state
 +    if (r.size() == olds && oldp == r.topLeft())
 +        return;
 +
 +    if (!data.in_set_window_state) {
 +        q->data->window_state &= ~Qt::WindowMaximized;
 +        q->data->window_state &= ~Qt::WindowFullScreen;
 +        if (q->isWindow())
 +            topData()->normalGeometry = QRect(0, 0, -1, -1);
 +    }
 +
 +    QPoint oldPos = q->pos();
 +    data.crect = r;
 +
 +    if (q->isVisible()) {
 +        if (q->windowHandle()) {
 +            if (q->isWindow()) {
 +                q->windowHandle()->setGeometry(q->geometry());
 +            } else {
 +                QPoint posInNativeParent =  q->mapTo(q->nativeParentWidget(),QPoint());
 +                q->windowHandle()->setGeometry(QRect(posInNativeParent,r.size()));
 +            }
 +            const QWidgetBackingStore *bs = maybeBackingStore();
 +            if (bs->windowSurface) {
 +                if (isResize)
 +                    bs->windowSurface->resize(r.size());
 +            }
 +        } else {
 +            if (isMove && !isResize)
 +                moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y());
 +            else
 +                invalidateBuffer_resizeHelper(oldPos, olds);
 +        }
 +
 +        if (isMove) {
 +            QMoveEvent e(q->pos(), oldPos);
 +            QApplication::sendEvent(q, &e);
 +        }
 +        if (isResize) {
 +            QResizeEvent e(r.size(), olds);
 +            QApplication::sendEvent(q, &e);
 +            if (q->windowHandle())
 +                q->update();
 +        }
 +    } else { // not visible
 +        if (isMove && q->pos() != oldPos)
 +            q->setAttribute(Qt::WA_PendingMoveEvent, true);
 +        if (isResize)
 +            q->setAttribute(Qt::WA_PendingResizeEvent, true);
 +    }
 +
 +}
 +
 +void QWidgetPrivate::setConstraints_sys()
 +{
 +    Q_Q(QWidget);
 +    if (extra && q->windowHandle()) {
 +        QWindow *win = q->windowHandle();
 +        QWindowPrivate *winp = qt_window_private(win);
 +
 +        winp->minimumSize = QSize(extra->minw, extra->minh);
 +        winp->maximumSize = QSize(extra->maxw, extra->maxh);
 +
 +        if (extra->topextra) {
 +            winp->baseSize = QSize(extra->topextra->basew, extra->topextra->baseh);
 +            winp->sizeIncrement = QSize(extra->topextra->incw, extra->topextra->inch);
 +        }
 +
 +        if (winp->platformWindow)
 +            winp->platformWindow->propagateSizeHints();
 +    }
 +}
 +
 +void QWidgetPrivate::scroll_sys(int dx, int dy)
 +{
 +    Q_Q(QWidget);
 +    scrollChildren(dx, dy);
 +    scrollRect(q->rect(), dx, dy);
 +}
 +
 +void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
 +{
 +    scrollRect(r, dx, dy);
 +}
 +
 +int QWidget::metric(PaintDeviceMetric m) const
 +{
 +    Q_D(const QWidget);
 +
 +    QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(windowHandle());
 +    if (!screen) {
 +        if (m == PdmDpiX || m == PdmDpiY)
 +              return 72;
 +        return QPaintDevice::metric(m);
 +    }
 +    int val;
 +    if (m == PdmWidth) {
 +        val = data->crect.width();
 +    } else if (m == PdmWidthMM) {
 +        val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width();
 +    } else if (m == PdmHeight) {
 +        val = data->crect.height();
 +    } else if (m == PdmHeightMM) {
 +        val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height();
 +    } else if (m == PdmDepth) {
 +        return screen->depth();
 +    } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
 +        if (d->extra && d->extra->customDpiX)
 +            return d->extra->customDpiX;
 +        else if (d->parent)
 +            return static_cast<QWidget *>(d->parent)->metric(m);
 +        return qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4));
 +    } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
 +        if (d->extra && d->extra->customDpiY)
 +            return d->extra->customDpiY;
 +        else if (d->parent)
 +            return static_cast<QWidget *>(d->parent)->metric(m);
 +        return qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4));
 +    } else {
 +        val = QPaintDevice::metric(m);// XXX
 +    }
 +    return val;
 +}
 +
 +/*!
 +    \preliminary
 +
 +    Returns the QPlatformWindow this widget will be drawn into.
 +*/
 +QWindow *QWidget::windowHandle() const
 +{
 +    Q_D(const QWidget);
 +    QTLWExtra *extra = d->maybeTopData();
 +    if (extra && extra->window)
 +        return extra->window;
 +
 +    return 0;
 +}
 +
 +void QWidgetPrivate::createSysExtra()
 +{
 +}
 +
 +void QWidgetPrivate::deleteSysExtra()
 +{
 +
 +}
 +
 +void QWidgetPrivate::createTLSysExtra()
 +{
 +    Q_Q(QWidget);
 +    extra->topextra->screenIndex = 0;
 +    extra->topextra->window = new QWidgetWindow(q);
 +}
 +
 +void QWidgetPrivate::deleteTLSysExtra()
 +{
 +    if (extra && extra->topextra) {
 +        //the toplevel might have a context with a "qglcontext associated with it. We need to
 +        //delete the qglcontext before we delete the qplatformglcontext.
 +        //One unfortunate thing about this is that we potentially create a glContext just to
 +        //delete it straight afterwards.
 +        if (extra->topextra->window) {
 +            extra->topextra->window->destroy();
 +        }
 +        setWinId(0);
 +        //hmmm. should we delete window..
 +        delete extra->topextra->window;
 +        extra->topextra->window = 0;
 +    }
 +}
 +
 +void QWidgetPrivate::registerDropSite(bool on)
 +{
 +    Q_UNUSED(on);
 +}
 +
 +void QWidgetPrivate::setMask_sys(const QRegion &region)
 +{
 +    Q_UNUSED(region);
 +    // XXX
 +}
 +
 +void QWidgetPrivate::updateFrameStrut()
 +{
 +    // XXX
 +}
 +
 +void QWidgetPrivate::setWindowOpacity_sys(qreal level)
 +{
 +    Q_Q(QWidget);
 +    if (q->windowHandle())
 +        q->windowHandle()->setOpacity(level);
 +}
 +
 +void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
 +{
 +    Q_UNUSED(dontShow);
 +    Q_UNUSED(oldRect);
 +    // XXX
 +}
 +
 +QPaintEngine *QWidget::paintEngine() const
 +{
 +    qWarning("QWidget::paintEngine: Should no longer be called");
 +    return 0; //##### @@@
 +}
 +
 +QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
 +{
 +    //This function should not be called.
 +    Q_ASSERT(false);
 +    return 0;
 +}
 +
 +void QWidgetPrivate::setModal_sys()
 +{
 +    Q_Q(QWidget);
 +    if (q->windowHandle())
 +        q->windowHandle()->setWindowModality(q->windowModality());
 +}
 +
 +#ifndef QT_NO_CURSOR
 +void qt_qpa_set_cursor(QWidget * w, bool force)
 +{
 +    static QCursor arrowCursor(Qt::ArrowCursor);
 +    static QPointer<QWidget> lastUnderMouse = 0;
 +
 +    QCursor * override = QApplication::overrideCursor();
 +
 +    if (override && w != 0)
 +        return;
 +
 +    QWidget *cursorWidget;
 +    QCursor cursorCursor;
 +
 +    do {
 +        if (w == 0) {
 +            if (override) {
 +                cursorCursor = *override;
 +                cursorWidget = QApplication::topLevelAt(QCursor::pos());
 +                break;
 +            }
 +            w = QApplication::widgetAt(QCursor::pos());
 +            if (w == 0) // clear the override cursor while over empty space
 +                w = QApplication::desktop();
 +        } else if (force) {
 +            lastUnderMouse = w;
 +        } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse
 +                   && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
 +            w = lastUnderMouse;
 +        }
 +        if (w == QApplication::desktop() && !override) {
 +            cursorCursor = arrowCursor;
 +            cursorWidget = w;
 +            break;
 +        }
 +
 +        QWidget * curWin = QApplication::activeWindow();
 +        if (!curWin && w && w->internalWinId())
 +            return;
 +        QWidget* cW = w && !w->internalWinId() ? w : curWin;
 +
 +        if (!cW || cW->window() != w->window() ||
 +            !cW->isVisible() || !cW->underMouse() || override)
 +            return;
 +
 +        cursorCursor = w->cursor();
 +        cursorWidget = w;
 +    } while (0);
 +    foreach (QWeakPointer<QPlatformCursor> cursor, QPlatformCursorPrivate::getInstances())
 +        if (cursor)
 +            cursor.data()->changeCursor(&cursorCursor, cursorWidget->windowHandle());
 +}
 +#endif //QT_NO_CURSOR 
 +
 +QT_END_NAMESPACE
Simple merge
Simple merge
Simple merge
Simple merge