src/gui/kernel/qwidget_qws.cpp
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 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 QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qcursor.h"
       
    43 #include "qapplication.h"
       
    44 #include "qapplication_p.h"
       
    45 #include "qpainter.h"
       
    46 #include "qbitmap.h"
       
    47 #include "qimage.h"
       
    48 #include "qhash.h"
       
    49 #include "qstack.h"
       
    50 #include "qlayout.h"
       
    51 #include "qtextcodec.h"
       
    52 #include "qinputcontext.h"
       
    53 #include "qdesktopwidget.h"
       
    54 
       
    55 #include "qwsdisplay_qws.h"
       
    56 #include "private/qwsdisplay_qws_p.h"
       
    57 #include "qscreen_qws.h"
       
    58 #include "qwsmanager_qws.h"
       
    59 #include <private/qwsmanager_p.h>
       
    60 #include <private/qbackingstore_p.h>
       
    61 #include <private/qwindowsurface_qws_p.h>
       
    62 #include <private/qwslock_p.h>
       
    63 #include "qpaintengine.h"
       
    64 
       
    65 #include "qdebug.h"
       
    66 
       
    67 #include "qwidget_p.h"
       
    68 
       
    69 QT_BEGIN_NAMESPACE
       
    70 
       
    71 QT_USE_NAMESPACE
       
    72 
       
    73 extern int *qt_last_x;
       
    74 extern int *qt_last_y;
       
    75 extern WId qt_last_cursor;
       
    76 extern bool qws_overrideCursor;
       
    77 extern QWidget *qt_pressGrab;
       
    78 extern QWidget *qt_mouseGrb;
       
    79 
       
    80 static QWidget *keyboardGrb = 0;
       
    81 
       
    82 static int takeLocalId()
       
    83 {
       
    84     static int n=-1000;
       
    85     return --n;
       
    86 }
       
    87 
       
    88 class QWSServer;
       
    89 extern QWSServer *qwsServer;
       
    90 
       
    91 static inline bool isServerProcess()
       
    92 {
       
    93     return (qwsServer != 0);
       
    94 }
       
    95 
       
    96 /*****************************************************************************
       
    97   QWidget member functions
       
    98  *****************************************************************************/
       
    99 
       
   100 void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destroyOldWindow*/)
       
   101 {
       
   102     Q_Q(QWidget);
       
   103     Qt::WindowType type = q->windowType();
       
   104 
       
   105     // Make sure the WindowTitleHint is on if any of the title bar hints are set
       
   106     // Note: This might be moved to cross-platform QWidgetPrivate::adjustFlags()
       
   107     if (  !(data.window_flags & Qt::CustomizeWindowHint) && (
       
   108            (data.window_flags & Qt::WindowSystemMenuHint) ||
       
   109            (data.window_flags & Qt::WindowContextHelpButtonHint) ||
       
   110            (data.window_flags & Qt::WindowMinimizeButtonHint) ||
       
   111            (data.window_flags & Qt::WindowMaximizeButtonHint) ||
       
   112            (data.window_flags & Qt::WindowCloseButtonHint) ) ) {
       
   113         data.window_flags |= Qt::WindowTitleHint;
       
   114     }
       
   115 
       
   116     // Decoration plugins on QWS don't support switching on the close button on its own
       
   117     if (data.window_flags & Qt::WindowCloseButtonHint)
       
   118         data.window_flags |= Qt::WindowSystemMenuHint;
       
   119 
       
   120     Qt::WindowFlags flags = data.window_flags;
       
   121 
       
   122     data.alloc_region_index = -1;
       
   123 
       
   124     // we don't have a "Drawer" window type
       
   125     if (type == Qt::Drawer) {
       
   126         type = Qt::Widget;
       
   127         flags &= ~Qt::WindowType_Mask;
       
   128     }
       
   129 
       
   130 
       
   131     bool topLevel = (flags & Qt::Window);
       
   132     bool popup = (type == Qt::Popup);
       
   133     bool dialog = (type == Qt::Dialog
       
   134                    || type == Qt::Sheet
       
   135                    || (flags & Qt::MSWindowsFixedSizeDialogHint));
       
   136     bool desktop = (type == Qt::Desktop);
       
   137     bool tool = (type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip);
       
   138 
       
   139 
       
   140 #ifndef QT_NO_WARNING_OUTPUT
       
   141     static bool toolWarningShown = false;
       
   142     if (!toolWarningShown && type == Qt::Tool && !(flags & Qt::FramelessWindowHint)) {
       
   143         qWarning("Qt for Embedded Linux " QT_VERSION_STR " does not support tool windows with frames.\n"
       
   144                  "This behavior will change in a later release. To ensure compatibility with\n"
       
   145                  "future versions, use (Qt::Tool | Qt::FramelessWindowHint).");
       
   146         toolWarningShown = true;
       
   147     }
       
   148 #endif
       
   149 
       
   150     WId           id;
       
   151     QWSDisplay* dpy = QWidget::qwsDisplay();
       
   152 
       
   153     if (!window)                                // always initialize
       
   154         initializeWindow = true;
       
   155 
       
   156     // use the size of the primary screen to determine the default window size
       
   157     QList<QScreen *> screens = qt_screen->subScreens();
       
   158     if (screens.isEmpty())
       
   159         screens.append(qt_screen);
       
   160     int sw = screens[0]->width();
       
   161     int sh = screens[0]->height();
       
   162 
       
   163     if (desktop) {                                // desktop widget
       
   164         dialog = popup = false;                        // force these flags off
       
   165         data.crect.setRect(0, 0, sw, sh);
       
   166     } else if (topLevel && !q->testAttribute(Qt::WA_Resized)) {
       
   167         int width = sw / 2;
       
   168         int height = 4 * sh / 10;
       
   169         if (extra) {
       
   170             width = qMax(qMin(width, extra->maxw), extra->minw);
       
   171             height = qMax(qMin(height, extra->maxh), extra->minh);
       
   172         }
       
   173         data.crect.setSize(QSize(width, height));
       
   174     }
       
   175 
       
   176     if (window) {                                // override the old window
       
   177         id = window;
       
   178         setWinId(window);
       
   179     } else if (desktop) {                        // desktop widget
       
   180         id = (WId)-2;                                // id = root window
       
   181 #if 0
       
   182         QWidget *otherDesktop = q->find(id);        // is there another desktop?
       
   183         if (otherDesktop && otherDesktop->testWFlags(Qt::WPaintDesktop)) {
       
   184             otherDesktop->d_func()->setWinId(0);        // remove id from widget mapper
       
   185             setWinId(id);                        // make sure otherDesktop is
       
   186             otherDesktop->d_func()->setWinId(id);        //   found first
       
   187         } else
       
   188 #endif
       
   189         {
       
   190             setWinId(id);
       
   191         }
       
   192     } else {
       
   193         id = topLevel ? dpy->takeId() : takeLocalId();
       
   194         setWinId(id);                                // set widget id/handle + hd
       
   195     }
       
   196 
       
   197 
       
   198     bool hasFrame = true;
       
   199     if (topLevel) {
       
   200         if (desktop || popup || tool || q->testAttribute(Qt::WA_DontShowOnScreen))
       
   201             hasFrame = false;
       
   202         else
       
   203             hasFrame = !(flags & Qt::FramelessWindowHint);
       
   204     }
       
   205     if (desktop) {
       
   206         q->setAttribute(Qt::WA_WState_Visible);
       
   207     } else if (topLevel) {                        // set X cursor
       
   208         //QCursor *oc = QApplication::overrideCursor();
       
   209         if (initializeWindow) {
       
   210             //XXX XDefineCursor(dpy, winid, oc ? oc->handle() : cursor().handle());
       
   211         }
       
   212         QWidget::qwsDisplay()->nameRegion(q->internalWinId(), q->objectName(), q->windowTitle());
       
   213     }
       
   214 
       
   215     if (topLevel) {
       
   216         createTLExtra();
       
   217         QTLWExtra *topextra = extra->topextra;
       
   218 #ifndef QT_NO_QWS_MANAGER
       
   219         if (hasFrame) {
       
   220             // get size of wm decoration and make the old crect the new frect
       
   221             QRect cr = data.crect;
       
   222             QRegion r = QApplication::qwsDecoration().region(q, cr) | cr;
       
   223             QRect br(r.boundingRect());
       
   224             topextra->frameStrut.setCoords(cr.x() - br.x(),
       
   225                                                   cr.y() - br.y(),
       
   226                                                   br.right() - cr.right(),
       
   227                                                   br.bottom() - cr.bottom());
       
   228             if (!q->testAttribute(Qt::WA_Moved) || topextra->posFromMove)
       
   229                 data.crect.translate(topextra->frameStrut.left(), topextra->frameStrut.top());
       
   230             if (!topData()->qwsManager) {
       
   231                 topData()->qwsManager = new QWSManager(q);
       
   232                 if((q->data->window_state & ~Qt::WindowActive) == Qt::WindowMaximized)
       
   233                     topData()->qwsManager->maximize();
       
   234             }
       
   235 
       
   236         } else if (topData()->qwsManager) {
       
   237             delete topData()->qwsManager;
       
   238             topData()->qwsManager = 0;
       
   239             data.crect.translate(-topextra->frameStrut.left(), -topextra->frameStrut.top());
       
   240             topextra->frameStrut.setCoords(0, 0, 0, 0);
       
   241         }
       
   242 #endif
       
   243         if (!topextra->caption.isEmpty())
       
   244             setWindowTitle_helper(topextra->caption);
       
   245 
       
   246         //XXX If we are session managed, inform the window manager about it
       
   247     } else {
       
   248         if (extra && extra->topextra)        { // already allocated due to reparent?
       
   249             extra->topextra->frameStrut.setCoords(0, 0, 0, 0);
       
   250         }
       
   251         //updateRequestedRegion(mapToGlobal(QPoint(0,0)));
       
   252     }
       
   253 }
       
   254 
       
   255 
       
   256 void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
       
   257 {
       
   258     Q_D(QWidget);
       
   259 
       
   260     if (!isWindow() && parentWidget())
       
   261         parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
       
   262 
       
   263     d->deactivateWidgetCleanup();
       
   264     if (testAttribute(Qt::WA_WState_Created)) {
       
   265         setAttribute(Qt::WA_WState_Created, false);
       
   266         QObjectList childObjects =  children();
       
   267         for (int i = 0; i < childObjects.size(); ++i) {
       
   268             QObject *obj = childObjects.at(i);
       
   269             if (obj->isWidgetType())
       
   270                 static_cast<QWidget*>(obj)->destroy(destroySubWindows,
       
   271                                                      destroySubWindows);
       
   272         }
       
   273         releaseMouse();
       
   274         if (qt_pressGrab == this)
       
   275           qt_pressGrab = 0;
       
   276 
       
   277         if (keyboardGrb == this)
       
   278             releaseKeyboard();
       
   279         if (testAttribute(Qt::WA_ShowModal))                // just be sure we leave modal
       
   280             QApplicationPrivate::leaveModal(this);
       
   281         else if ((windowType() == Qt::Popup))
       
   282             qApp->d_func()->closePopup(this);
       
   283 
       
   284         if (d->ic) {
       
   285             delete d->ic;
       
   286             d->ic =0;
       
   287         } else {
       
   288             // release previous focus information participating with
       
   289             // preedit preservation of qic -- while we still have a winId
       
   290             QInputContext *qic = inputContext();
       
   291             if (qic)
       
   292                 qic->widgetDestroyed(this);
       
   293         }
       
   294 
       
   295         if ((windowType() == Qt::Desktop)) {
       
   296         } else {
       
   297             if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
       
   298                 d->hide_sys();
       
   299             }
       
   300             if (destroyWindow && isWindow()) {
       
   301                 if (d->extra && d->extra->topextra && d->extra->topextra->backingStore)
       
   302                     d->extra->topextra->backingStore->windowSurface->setGeometry(QRect());
       
   303                 qwsDisplay()->destroyRegion(internalWinId());
       
   304             }
       
   305         }
       
   306         QT_TRY {
       
   307             d->setWinId(0);
       
   308         } QT_CATCH (const std::bad_alloc &) {
       
   309             // swallow - destructors must not throw
       
   310         }
       
   311     }
       
   312 }
       
   313 
       
   314 
       
   315 void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
       
   316 {
       
   317     Q_Q(QWidget);
       
   318     bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
       
   319      if (q->isVisible() && q->parentWidget() && parent != q->parentWidget())
       
   320         q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
       
   321 #ifndef QT_NO_CURSOR
       
   322     QCursor oldcurs;
       
   323     bool setcurs=q->testAttribute(Qt::WA_SetCursor);
       
   324     if (setcurs) {
       
   325         oldcurs = q->cursor();
       
   326         q->unsetCursor();
       
   327     }
       
   328 #endif
       
   329 
       
   330     WId old_winid = data.winid;
       
   331     if ((q->windowType() == Qt::Desktop))
       
   332         old_winid = 0;
       
   333 
       
   334     if (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_WState_Created))
       
   335         hide_sys();
       
   336 
       
   337     setWinId(0);
       
   338 
       
   339     if (parent != newparent) {
       
   340         QWidget *oldparent = q->parentWidget();
       
   341         QObjectPrivate::setParent_helper(newparent);
       
   342         if (oldparent) {
       
   343 //            oldparent->d_func()->setChildrenAllocatedDirty();
       
   344 //            oldparent->data->paintable_region_dirty = true;
       
   345         }
       
   346         if (newparent) {
       
   347 //            newparent->d_func()->setChildrenAllocatedDirty();
       
   348 //            newparent->data->paintable_region_dirty = true;
       
   349             //@@@@@@@
       
   350         }
       
   351     }
       
   352     Qt::FocusPolicy fp = q->focusPolicy();
       
   353     QSize    s            = q->size();
       
   354     //QBrush   bgc    = background();                        // save colors
       
   355     bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
       
   356 
       
   357     data.window_flags = f;
       
   358     q->setAttribute(Qt::WA_WState_Created, false);
       
   359     q->setAttribute(Qt::WA_WState_Visible, false);
       
   360     q->setAttribute(Qt::WA_WState_Hidden, false);
       
   361     adjustFlags(data.window_flags, q);
       
   362     // keep compatibility with previous versions, we need to preserve the created state
       
   363     // (but we recreate the winId for the widget being reparented, again for compatibility)
       
   364     if (wasCreated || (!q->isWindow() && newparent->testAttribute(Qt::WA_WState_Created)))
       
   365         createWinId();
       
   366     if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
       
   367         q->setAttribute(Qt::WA_WState_Hidden);
       
   368     q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
       
   369 
       
   370     if (q->isWindow()) {
       
   371         QRect fs = frameStrut();
       
   372         data.crect = QRect(fs.left(), fs.top(), s.width(), s.height());
       
   373         if ((data.window_flags & Qt::FramelessWindowHint) && extra && extra->topextra)
       
   374             extra->topextra->frameStrut.setCoords(0, 0, 0, 0);
       
   375     } else {
       
   376         data.crect = QRect(0, 0, s.width(), s.height());
       
   377     }
       
   378 
       
   379     q->setFocusPolicy(fp);
       
   380     if (extra && !extra->mask.isEmpty()) {
       
   381         QRegion r = extra->mask;
       
   382         extra->mask = QRegion();
       
   383         q->setMask(r);
       
   384     }
       
   385     if ((int)old_winid > 0) {
       
   386         QWidget::qwsDisplay()->destroyRegion(old_winid);
       
   387         extra->topextra->backingStore->windowSurface->setGeometry(QRect());
       
   388     }
       
   389 #ifndef QT_NO_CURSOR
       
   390     if (setcurs) {
       
   391         q->setCursor(oldcurs);
       
   392     }
       
   393 #endif
       
   394 }
       
   395 
       
   396 
       
   397 QPoint QWidget::mapToGlobal(const QPoint &pos) const
       
   398 {
       
   399     int           x=pos.x(), y=pos.y();
       
   400     const QWidget* w = this;
       
   401     while (w) {
       
   402         x += w->data->crect.x();
       
   403         y += w->data->crect.y();
       
   404         w = w->isWindow() ? 0 : w->parentWidget();
       
   405     }
       
   406     return QPoint(x, y);
       
   407 }
       
   408 
       
   409 QPoint QWidget::mapFromGlobal(const QPoint &pos) const
       
   410 {
       
   411     int           x=pos.x(), y=pos.y();
       
   412     const QWidget* w = this;
       
   413     while (w) {
       
   414         x -= w->data->crect.x();
       
   415         y -= w->data->crect.y();
       
   416         w = w->isWindow() ? 0 : w->parentWidget();
       
   417     }
       
   418     return QPoint(x, y);
       
   419 }
       
   420 
       
   421 #if 0 // #####
       
   422 void QWidget::setMicroFocusHint(int x, int y, int width, int height,
       
   423                                  bool text, QFont *)
       
   424 {
       
   425     if (QRect(x, y, width, height) != microFocusHint()) {
       
   426         d->createExtra();
       
   427         d->extra->micro_focus_hint.setRect(x, y, width, height);
       
   428     }
       
   429 #ifndef QT_NO_QWS_INPUTMETHODS
       
   430     if (text) {
       
   431         QWidget *tlw = window();
       
   432         int winid = tlw->internalWinId();
       
   433         QPoint p(x, y + height);
       
   434         QPoint gp = mapToGlobal(p);
       
   435 
       
   436         QRect r = QRect(mapToGlobal(QPoint(0,0)),
       
   437                          size());
       
   438 
       
   439         r.setBottom(tlw->geometry().bottom());
       
   440 
       
   441         //qDebug("QWidget::setMicroFocusHint %d %d %d %d", r.x(),
       
   442         //        r.y(), r.width(), r.height());
       
   443         QInputContext::setMicroFocusWidget(this);
       
   444 
       
   445         qwsDisplay()->setIMInfo(winid, gp.x(), gp.y(), r);
       
   446 
       
   447         //send font info,  ###if necessary
       
   448         qwsDisplay()->setInputFont(winid, font());
       
   449     }
       
   450 #endif
       
   451 }
       
   452 #endif
       
   453 
       
   454 void QWidgetPrivate::updateSystemBackground() {}
       
   455 
       
   456 #ifndef QT_NO_CURSOR
       
   457 void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
       
   458 {
       
   459     Q_UNUSED(cursor);
       
   460     Q_Q(QWidget);
       
   461     if (q->isVisible())
       
   462         updateCursor();
       
   463 }
       
   464 
       
   465 void QWidgetPrivate::unsetCursor_sys()
       
   466 {
       
   467     Q_Q(QWidget);
       
   468     if (q->isVisible())
       
   469         updateCursor();
       
   470 }
       
   471 #endif //QT_NO_CURSOR
       
   472 
       
   473 void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
       
   474 {
       
   475     Q_Q(QWidget);
       
   476     QWidget::qwsDisplay()->setWindowCaption(q, caption);
       
   477 }
       
   478 
       
   479 void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/)
       
   480 {
       
   481 #if 0
       
   482      QTLWExtra* x = d->topData();
       
   483      delete x->icon;
       
   484      x->icon = 0;
       
   485     QBitmap mask;
       
   486     if (unscaledPixmap.isNull()) {
       
   487     } else {
       
   488         QImage unscaledIcon = unscaledPixmap.toImage();
       
   489         QPixmap pixmap =
       
   490             QPixmap::fromImage(unscaledIcon.scale(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
       
   491         x->icon = new QPixmap(pixmap);
       
   492         mask = pixmap.mask() ? *pixmap.mask() : pixmap.createHeuristicMask();
       
   493     }
       
   494 #endif
       
   495 }
       
   496 
       
   497 void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
       
   498 {
       
   499     Q_UNUSED(iconText);
       
   500 }
       
   501 
       
   502 void QWidget::grabMouse()
       
   503 {
       
   504     if (qt_mouseGrb)
       
   505         qt_mouseGrb->releaseMouse();
       
   506 
       
   507     qwsDisplay()->grabMouse(this,true);
       
   508 
       
   509     qt_mouseGrb = this;
       
   510     qt_pressGrab = 0;
       
   511 }
       
   512 
       
   513 #ifndef QT_NO_CURSOR
       
   514 void QWidget::grabMouse(const QCursor &cursor)
       
   515 {
       
   516     if (qt_mouseGrb)
       
   517         qt_mouseGrb->releaseMouse();
       
   518 
       
   519     qwsDisplay()->grabMouse(this,true);
       
   520     qwsDisplay()->selectCursor(this, cursor.handle());
       
   521     qt_mouseGrb = this;
       
   522     qt_pressGrab = 0;
       
   523 }
       
   524 #endif
       
   525 
       
   526 void QWidget::releaseMouse()
       
   527 {
       
   528     if (qt_mouseGrb == this) {
       
   529         qwsDisplay()->grabMouse(this,false);
       
   530         qt_mouseGrb = 0;
       
   531     }
       
   532 }
       
   533 
       
   534 void QWidget::grabKeyboard()
       
   535 {
       
   536     if (keyboardGrb)
       
   537         keyboardGrb->releaseKeyboard();
       
   538     qwsDisplay()->grabKeyboard(this, true);
       
   539     keyboardGrb = this;
       
   540 }
       
   541 
       
   542 void QWidget::releaseKeyboard()
       
   543 {
       
   544     if (keyboardGrb == this) {
       
   545         qwsDisplay()->grabKeyboard(this, false);
       
   546         keyboardGrb = 0;
       
   547     }
       
   548 }
       
   549 
       
   550 
       
   551 QWidget *QWidget::mouseGrabber()
       
   552 {
       
   553     if (qt_mouseGrb)
       
   554         return qt_mouseGrb;
       
   555     return qt_pressGrab;
       
   556 }
       
   557 
       
   558 
       
   559 QWidget *QWidget::keyboardGrabber()
       
   560 {
       
   561     return keyboardGrb;
       
   562 }
       
   563 
       
   564 void QWidget::activateWindow()
       
   565 {
       
   566     QWidget *tlw = window();
       
   567     if (tlw->isVisible()) {
       
   568         Q_ASSERT(tlw->testAttribute(Qt::WA_WState_Created));
       
   569         qwsDisplay()->requestFocus(tlw->internalWinId(), true);
       
   570     }
       
   571 }
       
   572 
       
   573 void QWidgetPrivate::show_sys()
       
   574 {
       
   575     Q_Q(QWidget);
       
   576     q->setAttribute(Qt::WA_Mapped);
       
   577     if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
       
   578         invalidateBuffer(q->rect());
       
   579         return;
       
   580     }
       
   581 
       
   582     if (q->isWindow()) {
       
   583 
       
   584 
       
   585         if (!q->testAttribute(Qt::WA_ShowWithoutActivating)
       
   586             && q->windowType() != Qt::Popup
       
   587             && q->windowType() != Qt::Tool
       
   588             && q->windowType() != Qt::ToolTip) {
       
   589             QWidget::qwsDisplay()->requestFocus(data.winid,true);
       
   590         }
       
   591 
       
   592 
       
   593         if (QWindowSurface *surface = q->windowSurface()) {
       
   594             const QRect frameRect = q->frameGeometry();
       
   595             if (surface->geometry() != frameRect)
       
   596                 surface->setGeometry(frameRect);
       
   597         }
       
   598 
       
   599         QRegion r = localRequestedRegion();
       
   600 #ifndef QT_NO_QWS_MANAGER
       
   601         if (extra && extra->topextra && extra->topextra->qwsManager) {
       
   602             r.translate(data.crect.topLeft());
       
   603             r += extra->topextra->qwsManager->region();
       
   604             r.translate(-data.crect.topLeft());
       
   605         }
       
   606 #endif
       
   607         data.fstrut_dirty = true;
       
   608         invalidateBuffer(r);
       
   609 	bool staysontop =
       
   610             (q->windowFlags() & Qt::WindowStaysOnTopHint)
       
   611             || q->windowType() == Qt::Popup;
       
   612         if (!staysontop && q->parentWidget()) { // if our parent stays on top, so must we
       
   613             QWidget *ptl = q->parentWidget()->window();
       
   614             if (ptl && (ptl->windowFlags() & Qt::WindowStaysOnTopHint))
       
   615                 staysontop = true;
       
   616         }
       
   617 
       
   618         QWSChangeAltitudeCommand::Altitude altitude;
       
   619         altitude = staysontop ? QWSChangeAltitudeCommand::StaysOnTop : QWSChangeAltitudeCommand::Raise;
       
   620         QWidget::qwsDisplay()->setAltitude(data.winid, altitude, true);
       
   621         if (!q->objectName().isEmpty()) {
       
   622             QWidget::qwsDisplay()->setWindowCaption(q, q->windowTitle());
       
   623         }
       
   624     }
       
   625 #ifdef Q_BACKINGSTORE_SUBSURFACES
       
   626     else if ( extra && extra->topextra && extra->topextra->windowSurface) {
       
   627         QWSWindowSurface *surface;
       
   628         surface = static_cast<QWSWindowSurface*>(q->windowSurface());
       
   629         const QPoint p = q->mapToGlobal(QPoint());
       
   630         surface->setGeometry(QRect(p, q->size()));
       
   631     }
       
   632 #endif
       
   633 
       
   634     if (!q->window()->data->in_show) {
       
   635          invalidateBuffer(q->rect());
       
   636     }
       
   637 }
       
   638 
       
   639 
       
   640 void QWidgetPrivate::hide_sys()
       
   641 {
       
   642     Q_Q(QWidget);
       
   643     deactivateWidgetCleanup();
       
   644 
       
   645     if (q->isWindow()) {
       
   646         q->releaseMouse();
       
   647 //        requestWindowRegion(QRegion());
       
   648 
       
   649         if (extra->topextra->backingStore)
       
   650             extra->topextra->backingStore->releaseBuffer();
       
   651 
       
   652 
       
   653         QWidget::qwsDisplay()->requestFocus(data.winid,false);
       
   654     } else {
       
   655         QWidget *p = q->parentWidget();
       
   656         if (p &&p->isVisible()) {
       
   657             invalidateBuffer(q->rect());
       
   658         }
       
   659     }
       
   660 }
       
   661 
       
   662 
       
   663 
       
   664 static Qt::WindowStates effectiveState(Qt::WindowStates state)
       
   665  {
       
   666      if (state & Qt::WindowMinimized)
       
   667          return Qt::WindowMinimized;
       
   668      else if (state & Qt::WindowFullScreen)
       
   669          return Qt::WindowFullScreen;
       
   670      else if (state & Qt::WindowMaximized)
       
   671          return Qt::WindowMaximized;
       
   672      return Qt::WindowNoState;
       
   673  }
       
   674 
       
   675 void QWidgetPrivate::setMaxWindowState_helper()
       
   676 {
       
   677     // in_set_window_state is usually set in setWindowState(), but this
       
   678     // function is used in other functions as well
       
   679     // (e.g QApplicationPrivate::setMaxWindowRect())
       
   680     const uint old_state = data.in_set_window_state;
       
   681     data.in_set_window_state = 1;
       
   682 
       
   683 #ifndef QT_NO_QWS_MANAGER
       
   684     if (extra && extra->topextra && extra->topextra->qwsManager)
       
   685         extra->topextra->qwsManager->maximize();
       
   686     else
       
   687 #endif
       
   688     {
       
   689         Q_Q(QWidget);
       
   690         const QDesktopWidget *desktop = QApplication::desktop();
       
   691         const int screen = desktop->screenNumber(q);
       
   692         const QRect maxWindowRect = desktop->availableGeometry(screen);
       
   693         q->setGeometry(maxWindowRect);
       
   694     }
       
   695     data.in_set_window_state = old_state;
       
   696 }
       
   697 
       
   698 void QWidgetPrivate::setFullScreenSize_helper()
       
   699 {
       
   700     Q_Q(QWidget);
       
   701 
       
   702     const uint old_state = data.in_set_window_state;
       
   703     data.in_set_window_state = 1;
       
   704 
       
   705     const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q));
       
   706     q->move(screen.topLeft());
       
   707     q->resize(screen.size());
       
   708 
       
   709     data.in_set_window_state = old_state;
       
   710 }
       
   711 
       
   712 void QWidget::setWindowState(Qt::WindowStates newstate)
       
   713 {
       
   714     Q_D(QWidget);
       
   715     Qt::WindowStates oldstate = windowState();
       
   716     if (oldstate == newstate)
       
   717         return;
       
   718     if (isWindow() && !testAttribute(Qt::WA_WState_Created))
       
   719         create();
       
   720 
       
   721     data->window_state = newstate;
       
   722     data->in_set_window_state = 1;
       
   723     bool needShow = false;
       
   724     Qt::WindowStates newEffectiveState = effectiveState(newstate);
       
   725     Qt::WindowStates oldEffectiveState = effectiveState(oldstate);
       
   726     if (isWindow() && newEffectiveState != oldEffectiveState) {
       
   727         d->createTLExtra();
       
   728         if (oldEffectiveState == Qt::WindowNoState) { //normal
       
   729             d->topData()->normalGeometry = geometry();
       
   730         } else if (oldEffectiveState == Qt::WindowFullScreen) {
       
   731             setParent(0, d->topData()->savedFlags);
       
   732             needShow = true;
       
   733         } else if (oldEffectiveState == Qt::WindowMinimized) {
       
   734             needShow = true;
       
   735         }
       
   736 
       
   737         if (newEffectiveState == Qt::WindowMinimized) {
       
   738             //### not ideal...
       
   739             hide();
       
   740             needShow = false;
       
   741         } else if (newEffectiveState == Qt::WindowFullScreen) {
       
   742             d->topData()->savedFlags = windowFlags();
       
   743             setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint));
       
   744             d->setFullScreenSize_helper();
       
   745             raise();
       
   746             needShow = true;
       
   747         } else if (newEffectiveState == Qt::WindowMaximized) {
       
   748             createWinId();
       
   749             d->setMaxWindowState_helper();
       
   750         } else { //normal
       
   751             QRect r = d->topData()->normalGeometry;
       
   752             if (r.width() >= 0) {
       
   753                 d->topData()->normalGeometry = QRect(0,0,-1,-1);
       
   754                 setGeometry(r);
       
   755             }
       
   756         }
       
   757     }
       
   758     data->in_set_window_state = 0;
       
   759 
       
   760     if (needShow)
       
   761         show();
       
   762 
       
   763     if (newstate & Qt::WindowActive)
       
   764         activateWindow();
       
   765 
       
   766     QWindowStateChangeEvent e(oldstate);
       
   767     QApplication::sendEvent(this, &e);
       
   768 }
       
   769 
       
   770 void QWidgetPrivate::setFocus_sys()
       
   771 {
       
   772 
       
   773 }
       
   774 
       
   775 void QWidgetPrivate::raise_sys()
       
   776 {
       
   777     Q_Q(QWidget);
       
   778     //@@@ transaction
       
   779     if (q->isWindow()) {
       
   780         Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
       
   781         QWidget::qwsDisplay()->setAltitude(q->internalWinId(),
       
   782                                            QWSChangeAltitudeCommand::Raise);
       
   783         // XXX: subsurfaces?
       
   784 #ifdef QT_NO_WINDOWGROUPHINT
       
   785 #else
       
   786         QObjectList childObjects =  q->children();
       
   787         if (!childObjects.isEmpty()) {
       
   788             QWidgetList toraise;
       
   789             for (int i = 0; i < childObjects.size(); ++i) {
       
   790                 QObject *obj = childObjects.at(i);
       
   791                 if (obj->isWidgetType()) {
       
   792                     QWidget* w = static_cast<QWidget*>(obj);
       
   793                     if (w->isWindow())
       
   794                         toraise.append(w);
       
   795                 }
       
   796             }
       
   797 
       
   798             for (int i = 0; i < toraise.size(); ++i) {
       
   799                 QWidget *w = toraise.at(i);
       
   800                 if (w->isVisible())
       
   801                     w->raise();
       
   802             }
       
   803         }
       
   804 #endif // QT_NO_WINDOWGROUPHINT
       
   805     }
       
   806 }
       
   807 
       
   808 void QWidgetPrivate::lower_sys()
       
   809 {
       
   810     Q_Q(QWidget);
       
   811     if (q->isWindow()) {
       
   812         Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
       
   813         QWidget::qwsDisplay()->setAltitude(data.winid,
       
   814                                            QWSChangeAltitudeCommand::Lower);
       
   815     } else if (QWidget *p = q->parentWidget()) {
       
   816         setDirtyOpaqueRegion();
       
   817         p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
       
   818     }
       
   819 }
       
   820 
       
   821 void QWidgetPrivate::stackUnder_sys(QWidget*)
       
   822 {
       
   823     Q_Q(QWidget);
       
   824     if (QWidget *p = q->parentWidget()) {
       
   825         setDirtyOpaqueRegion();
       
   826         p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
       
   827     }
       
   828 }
       
   829 
       
   830 void QWidgetPrivate::moveSurface(QWindowSurface *surface, const QPoint &offset)
       
   831 {
       
   832     QWSWindowSurface *s = static_cast<QWSWindowSurface*>(surface);
       
   833     if (!s->move(offset))
       
   834         s->invalidateBuffer();
       
   835 
       
   836     QWSDisplay::instance()->moveRegion(s->winId(), offset.x(), offset.y());
       
   837 }
       
   838 
       
   839 void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
       
   840 {
       
   841     Q_Q(QWidget);
       
   842     if (extra) {                                // any size restrictions?
       
   843         w = qMin(w,extra->maxw);
       
   844         h = qMin(h,extra->maxh);
       
   845         w = qMax(w,extra->minw);
       
   846         h = qMax(h,extra->minh);
       
   847     }
       
   848 
       
   849     QPoint oldp = q->geometry().topLeft();
       
   850     QSize olds = q->size();
       
   851     QRect r(x, y, w, h);
       
   852 
       
   853     bool isResize = olds != r.size();
       
   854     isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter?
       
   855 
       
   856     // We only care about stuff that changes the geometry, or may
       
   857     // cause the window manager to change its state
       
   858     if (r.size() == olds && oldp == r.topLeft())
       
   859         return;
       
   860 
       
   861     if (!data.in_set_window_state) {
       
   862         q->data->window_state &= ~Qt::WindowMaximized;
       
   863         q->data->window_state &= ~Qt::WindowFullScreen;
       
   864         if (q->isWindow())
       
   865             topData()->normalGeometry = QRect(0, 0, -1, -1);
       
   866     }
       
   867     QPoint oldPos = q->pos();
       
   868     data.crect = r;
       
   869 
       
   870     if ((q->windowType() == Qt::Desktop))
       
   871         return;
       
   872 
       
   873     if (q->isVisible()) {
       
   874 
       
   875         bool toplevelMove = false;
       
   876         QWSWindowSurface *surface = 0;
       
   877 
       
   878         if (q->isWindow()) {
       
   879             //### ConfigPending not implemented, do we need it?
       
   880             //setAttribute(Qt::WA_WState_ConfigPending);
       
   881             const QWidgetBackingStore *bs = maybeBackingStore();
       
   882             if (bs)
       
   883                 surface = static_cast<QWSWindowSurface*>(bs->windowSurface);
       
   884             if (isMove && !isResize && surface) {
       
   885                 const QPoint offset(x - oldp.x(), y - oldp.y());
       
   886                 moveSurface(surface, offset);
       
   887                 toplevelMove = true; //server moves window, but we must send moveEvent, which might trigger painting
       
   888 
       
   889 #ifdef Q_BACKINGSTORE_SUBSURFACES
       
   890                 QList<QWindowSurface*> surfaces = bs->subSurfaces;
       
   891                 for (int i = 0; i < surfaces.size(); ++i)
       
   892                     moveSurface(surfaces.at(i), offset);
       
   893 #endif
       
   894             } else {
       
   895                     updateFrameStrut();
       
   896             }
       
   897         }
       
   898 
       
   899         if (!toplevelMove) {
       
   900             if (q->isWindow()) {
       
   901                 if (surface)
       
   902                     surface->setGeometry(q->frameGeometry());
       
   903                 else
       
   904                     invalidateBuffer(q->rect()); //###
       
   905 
       
   906 #ifdef Q_BACKINGSTORE_SUBSURFACES
       
   907                 // XXX: should not resize subsurfaces. Children within a layout
       
   908                 // will be resized automatically while children with a static
       
   909                 // geometry should get a new clip region instead.
       
   910                 const QRect clipRect = q->geometry();
       
   911                 QWidgetBackingStore *bs = maybeBackingStore();
       
   912                 QList<QWindowSurface*> surfaces = bs->subSurfaces;
       
   913                 for (int i = 0; i < surfaces.size(); ++i) {
       
   914                     QWSWindowSurface *s = static_cast<QWSWindowSurface*>(surfaces.at(i));
       
   915                     QRect srect = s->geometry();
       
   916                     s->setGeometry(clipRect & srect);
       
   917                 }
       
   918 #endif
       
   919             }
       
   920 #ifdef Q_BACKINGSTORE_SUBSURFACES
       
   921             // XXX: merge this case with the isWindow() case
       
   922             else if (maybeTopData() && maybeTopData()->windowSurface) {
       
   923                 QWSWindowSurface *surface;
       
   924                 surface = static_cast<QWSWindowSurface*>(q->windowSurface());
       
   925                 if (isMove && !isResize) {
       
   926                     moveSurface(surface, QPoint(x - oldp.x(), y - oldp.y()));
       
   927                 } else {
       
   928                     const QPoint p = q->mapToGlobal(QPoint());
       
   929                     surface->setGeometry(QRect(p, QSize(w, h)));
       
   930                 }
       
   931             }
       
   932 #endif
       
   933             else {
       
   934                 if (isMove && !isResize)
       
   935                     moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y());
       
   936                 else
       
   937                     invalidateBuffer_resizeHelper(oldPos, olds);
       
   938             }
       
   939         }
       
   940 
       
   941         //### must have frame geometry correct before sending move/resize events
       
   942         if (isMove) {
       
   943             QMoveEvent e(q->pos(), oldPos);
       
   944             QApplication::sendEvent(q, &e);
       
   945         }
       
   946         if (isResize) {
       
   947             QResizeEvent e(r.size(), olds);
       
   948             QApplication::sendEvent(q, &e);
       
   949         }
       
   950 
       
   951     } else { // not visible
       
   952         if (isMove && q->pos() != oldPos)
       
   953             q->setAttribute(Qt::WA_PendingMoveEvent, true);
       
   954         if (isResize)
       
   955             q->setAttribute(Qt::WA_PendingResizeEvent, true);
       
   956     }
       
   957 }
       
   958 
       
   959 void QWidgetPrivate::setConstraints_sys()
       
   960 {
       
   961 }
       
   962 
       
   963 QScreen* QWidgetPrivate::getScreen() const
       
   964 {
       
   965     Q_Q(const QWidget);
       
   966 
       
   967     const QList<QScreen*> subScreens = qt_screen->subScreens();
       
   968     if (subScreens.isEmpty() || q->windowType() == Qt::Desktop)
       
   969         return qt_screen;
       
   970 
       
   971     const int screen = QApplication::desktop()->screenNumber(q);
       
   972 
       
   973     return qt_screen->subScreens().at(screen < 0 ? 0 : screen);
       
   974 }
       
   975 
       
   976 void QWidgetPrivate::scroll_sys(int dx, int dy)
       
   977 {
       
   978     Q_Q(QWidget);
       
   979     scrollChildren(dx, dy);
       
   980     scrollRect(q->rect(), dx, dy);
       
   981 }
       
   982 
       
   983 void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
       
   984 {
       
   985     scrollRect(r, dx, dy);
       
   986 }
       
   987 
       
   988 int QWidget::metric(PaintDeviceMetric m) const
       
   989 {
       
   990     Q_D(const QWidget);
       
   991 
       
   992     int val;
       
   993     if (m == PdmWidth) {
       
   994         val = data->crect.width();
       
   995     } else if (m == PdmWidthMM) {
       
   996         const QScreen *screen = d->getScreen();
       
   997         val = data->crect.width() * screen->physicalWidth() / screen->width();
       
   998     } else if (m == PdmHeight) {
       
   999         val = data->crect.height();
       
  1000     } else if (m == PdmHeightMM) {
       
  1001         const QScreen *screen = d->getScreen();
       
  1002         val = data->crect.height() * screen->physicalHeight() / screen->height();
       
  1003     } else if (m == PdmDepth) {
       
  1004         return qwsDisplay()->depth();
       
  1005     } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
       
  1006         if (d->extra && d->extra->customDpiX)
       
  1007             return d->extra->customDpiX;
       
  1008         else if (d->parent)
       
  1009             return static_cast<QWidget *>(d->parent)->metric(m);
       
  1010         const QScreen *screen = d->getScreen();
       
  1011         return qRound(screen->width() / double(screen->physicalWidth() / 25.4));
       
  1012     } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
       
  1013         if (d->extra && d->extra->customDpiY)
       
  1014             return d->extra->customDpiY;
       
  1015         else if (d->parent)
       
  1016             return static_cast<QWidget *>(d->parent)->metric(m);
       
  1017         const QScreen *screen = d->getScreen();
       
  1018         return qRound(screen->height() / double(screen->physicalHeight() / 25.4));
       
  1019     } else {
       
  1020         val = QPaintDevice::metric(m);// XXX
       
  1021     }
       
  1022     return val;
       
  1023 }
       
  1024 
       
  1025 void QWidgetPrivate::createSysExtra()
       
  1026 {
       
  1027 }
       
  1028 
       
  1029 void QWidgetPrivate::deleteSysExtra()
       
  1030 {
       
  1031 }
       
  1032 
       
  1033 void QWidgetPrivate::createTLSysExtra()
       
  1034 {
       
  1035 #ifndef QT_NO_QWS_MANAGER
       
  1036     extra->topextra->qwsManager = 0;
       
  1037 #endif
       
  1038 }
       
  1039 
       
  1040 void QWidgetPrivate::deleteTLSysExtra()
       
  1041 {
       
  1042 }
       
  1043 
       
  1044 void QWidgetPrivate::registerDropSite(bool on)
       
  1045 {
       
  1046     Q_UNUSED(on);
       
  1047 }
       
  1048 
       
  1049 QRegion QWidgetPrivate::localRequestedRegion() const
       
  1050 {
       
  1051     Q_Q(const QWidget);
       
  1052     QRegion r(q->rect());
       
  1053     if (extra && !extra->mask.isEmpty())
       
  1054         r &= extra->mask;
       
  1055 
       
  1056     return r;
       
  1057 }
       
  1058 
       
  1059 QRegion QWidgetPrivate::localAllocatedRegion() const
       
  1060 {
       
  1061     Q_Q(const QWidget);
       
  1062 
       
  1063     QWidgetBackingStore *wbs = q->window()->d_func()->maybeBackingStore();
       
  1064 
       
  1065     QWindowSurface *ws = wbs ? wbs->windowSurface : 0;
       
  1066     if (!ws)
       
  1067         return QRegion();
       
  1068     QRegion r = static_cast<QWSWindowSurface*>(ws)->clipRegion();
       
  1069     if (!q->isWindow()) {
       
  1070         QPoint off = q->mapTo(q->window(), QPoint());
       
  1071         r &= localRequestedRegion().translated(off);
       
  1072         r.translate(-off);
       
  1073     }
       
  1074     return r;
       
  1075 }
       
  1076 
       
  1077 inline bool QRect::intersects(const QRect &r) const
       
  1078 {
       
  1079     return (qMax(x1, r.x1) <= qMin(x2, r.x2) &&
       
  1080              qMax(y1, r.y1) <= qMin(y2, r.y2));
       
  1081 }
       
  1082 
       
  1083 void QWidgetPrivate::setMask_sys(const QRegion &region)
       
  1084 {
       
  1085     Q_UNUSED(region);
       
  1086     Q_Q(QWidget);
       
  1087 
       
  1088     if (!q->isVisible() || !q->isWindow())
       
  1089         return;
       
  1090 
       
  1091     data.fstrut_dirty = true;
       
  1092     invalidateBuffer(q->rect());
       
  1093     QWindowSurface *surface = extra->topextra->backingStore->windowSurface;
       
  1094     if (surface) {
       
  1095         // QWSWindowSurface::setGeometry() returns without doing anything
       
  1096         // if old geom  == new geom. Therefore, we need to reset the old value.
       
  1097         surface->QWindowSurface::setGeometry(QRect());
       
  1098         surface->setGeometry(q->frameGeometry());
       
  1099     }
       
  1100 }
       
  1101 
       
  1102 void QWidgetPrivate::updateFrameStrut()
       
  1103 {
       
  1104     Q_Q(QWidget);
       
  1105 
       
  1106     if(!q->isVisible() || (q->windowType() == Qt::Desktop)) {
       
  1107         data.fstrut_dirty = q->isVisible();
       
  1108         return;
       
  1109     }
       
  1110 
       
  1111 #ifndef QT_NO_QWS_MANAGER
       
  1112     if (extra && extra->topextra && extra->topextra->qwsManager) {
       
  1113         QTLWExtra *topextra = extra->topextra;
       
  1114         const QRect oldFrameStrut = topextra->frameStrut;
       
  1115         const QRect contents = data.crect;
       
  1116         QRegion r = localRequestedRegion().translated(contents.topLeft());
       
  1117         r += extra->topextra->qwsManager->region();
       
  1118         const QRect frame = r.boundingRect();
       
  1119 
       
  1120         topextra->frameStrut.setCoords(contents.left() - frame.left(),
       
  1121                                        contents.top() - frame.top(),
       
  1122                                        frame.right() - contents.right(),
       
  1123                                        frame.bottom() - contents.bottom());
       
  1124         topextra->qwsManager->repaintRegion(QDecoration::All, QDecoration::Normal);
       
  1125     }
       
  1126 #endif
       
  1127     data.fstrut_dirty = false;
       
  1128 }
       
  1129 
       
  1130 #ifndef QT_NO_CURSOR
       
  1131 void QWidgetPrivate::updateCursor() const
       
  1132 {
       
  1133     Q_Q(const QWidget);
       
  1134 
       
  1135     if (QApplication::overrideCursor())
       
  1136         return;
       
  1137 
       
  1138     if (qt_last_x
       
  1139         && (!QWidget::mouseGrabber() || QWidget::mouseGrabber() == q)
       
  1140         && qt_last_cursor != (WId)q->cursor().handle())
       
  1141     {
       
  1142         const QPoint pos(*qt_last_x, *qt_last_y);
       
  1143         const QPoint offset = q->mapToGlobal(QPoint());
       
  1144         if (!localAllocatedRegion().contains(pos - offset))
       
  1145             return;
       
  1146 
       
  1147         const QWidget *w = q->childAt(q->mapFromGlobal(pos));
       
  1148         if (!w || w->cursor().handle() == q->cursor().handle())
       
  1149             QWidget::qwsDisplay()->selectCursor(const_cast<QWidget*>(q),
       
  1150                                                 q->cursor().handle());
       
  1151     }
       
  1152 }
       
  1153 #endif
       
  1154 
       
  1155 void QWidgetPrivate::setWindowOpacity_sys(qreal level)
       
  1156 {
       
  1157     Q_Q(QWidget);
       
  1158     Q_UNUSED(level);
       
  1159     createWinId();
       
  1160     QWidget::qwsDisplay()->setOpacity(q->data->winid, topData()->opacity);
       
  1161 }
       
  1162 
       
  1163 //static QSingleCleanupHandler<QWSPaintEngine> qt_paintengine_cleanup_handler;
       
  1164 //static QWSPaintEngine *qt_widget_paintengine = 0;
       
  1165 QPaintEngine *QWidget::paintEngine() const
       
  1166 {
       
  1167     qWarning("QWidget::paintEngine: Should no longer be called");
       
  1168     return 0; //##### @@@
       
  1169 //     if (!qt_widget_paintengine) {
       
  1170 //         qt_widget_paintengine = new QRasterPaintEngine();
       
  1171 //         qt_paintengine_cleanup_handler.set(&qt_widget_paintengine);
       
  1172 //     }
       
  1173 //     if (qt_widget_paintengine->isActive()) {
       
  1174 //         if (d->extraPaintEngine)
       
  1175 //             return d->extraPaintEngine;
       
  1176 //         const_cast<QWidget *>(this)->d_func()->extraPaintEngine = new QRasterPaintEngine();
       
  1177 //         return d->extraPaintEngine;
       
  1178 //     }
       
  1179 //    return qt_widget_paintengine;
       
  1180 }
       
  1181 
       
  1182 QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
       
  1183 {
       
  1184     Q_Q(QWidget);
       
  1185     if (q->windowType() == Qt::Desktop)
       
  1186         return 0;
       
  1187     q->ensurePolished();
       
  1188     return qt_screen->createSurface(q);
       
  1189 }
       
  1190 
       
  1191 void QWidgetPrivate::setModal_sys()
       
  1192 {
       
  1193 }
       
  1194 
       
  1195 
       
  1196 QT_END_NAMESPACE