Changeset 98 for trunk/src


Ignore:
Timestamp:
Aug 3, 2009, 11:30:38 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Added deferred window size/move request processing.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/kernel/qeventdispatcher_pm.cpp

    r89 r98  
    13251325}
    13261326
     1327void QEventDispatcherPM::createMsgQueue()
     1328{
     1329    Q_D(QEventDispatcherPM);
     1330    if (d->hmq == NULLHANDLE)
     1331        d->createMsgQueue();
     1332}
     1333
    13271334QT_END_NAMESPACE
  • trunk/src/corelib/kernel/qeventdispatcher_pm_p.h

    r89 r98  
    9090    void startingUp();
    9191    void closingDown();
     92
     93    void createMsgQueue();
    9294};
    9395
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r95 r98  
    5353
    5454#include "qset.h"
     55
     56#include "private/qeventdispatcher_pm_p.h"
    5557
    5658#include "qwidget_p.h"
     
    270272 *****************************************************************************/
    271273
     274struct QPMConfigRequest {
     275    WId         id; // widget to be configured
     276    int         req; // 0=move, 1=resize, 2=setGeo
     277    int         x, y, w, h; // request parameters
     278};
     279
     280Q_GLOBAL_STATIC(QList<QPMConfigRequest*>, configRequests);
     281
     282void qPMRequestConfig(WId id, int req, int x, int y, int w, int h)
     283{
     284    QPMConfigRequest *r = new QPMConfigRequest;
     285    r->id = id;
     286    r->req = req;
     287    r->x = x;
     288    r->y = y;
     289    r->w = w;
     290    r->h = h;
     291    configRequests()->append(r);
     292}
     293
    272294/*****************************************************************************
    273295    GUI event dispatcher
    274296 *****************************************************************************/
    275297
     298class QGuiEventDispatcherPM : public QEventDispatcherPM
     299{
     300    Q_DECLARE_PRIVATE(QEventDispatcherPM)
     301public:
     302    QGuiEventDispatcherPM(QObject *parent = 0);
     303    bool processEvents(QEventLoop::ProcessEventsFlags flags);
     304};
     305
     306QGuiEventDispatcherPM::QGuiEventDispatcherPM(QObject *parent)
     307    : QEventDispatcherPM(parent)
     308{
     309    // pre-create the message queue early as we'll need it anyway in GUI mode
     310    createMsgQueue();
     311}
     312
     313bool QGuiEventDispatcherPM::processEvents(QEventLoop::ProcessEventsFlags flags)
     314{
     315    if (!QEventDispatcherPM::processEvents(flags))
     316        return false;
     317
     318    QPMConfigRequest *r;
     319    for (;;) {
     320        if (configRequests()->isEmpty())
     321            break;
     322        r = configRequests()->takeLast();
     323        QWidget *w = QWidget::find(r->id);
     324        QRect rect(r->x, r->y, r->w, r->h);
     325        int req = r->req;
     326        delete r;
     327
     328        if (w) { // widget exists
     329            if (w->testAttribute(Qt::WA_WState_ConfigPending))
     330                break; // biting our tail
     331            if (req == 0)
     332                w->move(rect.topLeft());
     333            else if (req == 1)
     334                w->resize(rect.size());
     335            else
     336                w->setGeometry(rect);
     337        }
     338    }
     339
     340    return true;
     341}
     342
    276343void QApplicationPrivate::createEventDispatcher()
    277344{
    278     // @todo implement
     345    Q_Q(QApplication);
     346    if (q->type() != QApplication::Tty)
     347        eventDispatcher = new QGuiEventDispatcherPM(q);
     348    else
     349        eventDispatcher = new QEventDispatcherPM(q);
    279350}
    280351
Note: See TracChangeset for help on using the changeset viewer.