Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qwidget_x11.cpp

    r651 r769  
    347347}
    348348
    349 static Bool checkForConfigureAndExpose(Display *, XEvent *e, XPointer)
    350 {
    351     return e->type == ConfigureNotify || e->type == Expose;
    352 }
    353 
    354349Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
    355350{
     
    364359        return;
    365360
    366     if (!(w->windowFlags() & Qt::X11BypassWindowManagerHint)) {
    367         // if the window is not override-redirect, then the window manager
    368         // will reparent us to the frame decoration window.
    369         while (!XCheckTypedWindowEvent(X11->display, w->effectiveWinId(), ReparentNotify, &ev)) {
    370             if (t.elapsed() > maximumWaitTime)
    371                 return;
    372             qApp->syncX(); // non-busy wait
    373         }
    374     }
    375 
    376     while (!XCheckTypedWindowEvent(X11->display, w->effectiveWinId(), MapNotify, &ev)) {
     361    WId winid = w->internalWinId();
     362
     363    // first deliver events that are already in the local queue
     364    QApplication::sendPostedEvents();
     365
     366    // the normal sequence is:
     367    //  ... ConfigureNotify ... ReparentNotify ... MapNotify ... Expose
     368    // with X11BypassWindowManagerHint:
     369    //  ConfigureNotify ... MapNotify ... Expose
     370
     371    enum State {
     372        Initial, Mapped
     373    } state = Initial;
     374
     375    do {
     376        if (XEventsQueued(X11->display, QueuedAlready)) {
     377            XNextEvent(X11->display, &ev);
     378            qApp->x11ProcessEvent(&ev);
     379
     380            switch (state) {
     381            case Initial:
     382                if (ev.type == MapNotify && ev.xany.window == winid)
     383                    state = Mapped;
     384                break;
     385            case Mapped:
     386                if (ev.type == Expose && ev.xany.window == winid)
     387                    return;
     388                break;
     389            }
     390        } else {
     391            if (!XEventsQueued(X11->display, QueuedAfterFlush))
     392                qApp->syncX(); // non-busy wait
     393        }
    377394        if (t.elapsed() > maximumWaitTime)
    378395            return;
    379         qApp->syncX(); // non-busy wait
    380     }
    381 
    382     qApp->x11ProcessEvent(&ev);
    383 
    384     // ok, seems like the window manager successfully reparented us, we'll wait
    385     // for the first paint event to arrive, while handling ConfigureNotify in
    386     // the arrival order
    387     while(1)
    388     {
    389         if (XCheckIfEvent(X11->display, &ev, checkForConfigureAndExpose, 0)) {
    390             qApp->x11ProcessEvent(&ev);
    391             if (ev.type == Expose)
    392                 return;
    393         }
    394         if (t.elapsed() > maximumWaitTime)
    395             return;
    396         qApp->syncX(); // non-busy wait
    397     }
     396    } while(1);
    398397}
    399398
Note: See TracChangeset for help on using the changeset viewer.