Ignore:
Timestamp:
Aug 18, 2009, 4:30:00 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: QWidget::setWindowState/setGeometry_sys/setWSGeometry in progress.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r117 r120  
    4444#include "qt_os2.h"
    4545
     46#include "qdebug.h"
     47
    4648#include "qapplication.h"
    4749#include "qapplication_p.h"
     
    6163#include "qkeymapper_p.h"
    6264#include "qcursor_p.h"
     65
     66#define QT_DEBUGMSGFLOW
    6367
    6468QT_BEGIN_NAMESPACE
     
    120124//  void syncBackingStore(const QRegion &rgn) { d_func()->syncBackingStore(rgn); }
    121125//  void syncBackingStore() { d_func()->syncBackingStore(); }
    122 //  QWidgetData *dataPtr() { return data; }
    123 //  QWidgetPrivate *dptr() { return d_func(); }
     126    QWidgetData *dataPtr() { return data; }
     127    QWidgetPrivate *dptr() { return d_func(); }
    124128//  QRect frameStrut() const { return d_func()->frameStrut(); }
    125129    bool        pmEvent(QMSG *m, MRESULT *r) { return QWidget::pmEvent(m, r); }
     
    494498        // flip y coordinate
    495499        qmsg.ptl.y = QApplication::desktop()->height() - (qmsg.ptl.y + 1);
     500
     501#if defined(QT_DEBUGMSGFLOW)
     502        {
     503            QString str = qStrQMSG(qmsg);
     504            if (!str.isEmpty())
     505                qDebug() << "*** [W]" << str.toUtf8().constData();
     506        }
     507#endif
    496508
    497509        // send through app filter
     
    709721#endif
    710722
     723        MRESULT rc = (MRESULT) FALSE;
     724
    711725        HWND hwndC = WinWindowFromID(hwnd, FID_CLIENT);
    712726        QETWidget *widget = (QETWidget*)QWidget::find(hwndC);
     
    714728            break;
    715729
     730        Q_ASSERT(widget->isWindow());
     731
     732#if defined(QT_DEBUGMSGFLOW)
     733        {
     734            QMSG qmsg; // create QMSG structure
     735            qmsg.hwnd = hwnd;
     736            qmsg.msg = msg;
     737            qmsg.mp1 = mp1;
     738            qmsg.mp2 = mp2;
     739            QString str = qStrQMSG(qmsg);
     740            if (!str.isEmpty())
     741                qDebug() << "*** [F]" << str.toUtf8().constData();
     742        }
     743#endif
     744
    716745        switch(msg) {
     746
     747        case WM_WINDOWPOSCHANGED: {
     748            // We detect spontaneous min/max/restore events here instead of
     749            // WM_MINMAXFRAME, because WM_MINMAXFRAME is a pre-process message
     750            // (i.e. no actual changes have been made). We need actual changes
     751            // in order to update the frame strut and send WindowStateChange.
     752            rc = QtOldFrameProc(hwnd, msg, mp1, mp2);
     753
     754            ULONG awp = LONGFROMMP(mp2);
     755
     756            bool window_state_change = false;
     757            Qt::WindowStates oldstate = Qt::WindowStates(widget->dataPtr()->window_state);
     758
     759            if (awp & AWP_MINIMIZED) {
     760                window_state_change = true;
     761                widget->dataPtr()->window_state |= Qt::WindowMinimized;
     762                if (widget->isVisible()) {
     763                    QHideEvent e;
     764                    qt_sendSpontaneousEvent(widget, &e);
     765                    widget->dptr()->hideChildren(true);
     766                    const QString title = widget->windowIconText();
     767                    if (!title.isEmpty())
     768                        widget->dptr()->setWindowTitle_helper(title);
     769                }
     770            } else {
     771                if (awp & AWP_MAXIMIZED) {
     772                    widget->topData()->normalGeometry = widget->geometry();
     773                }
     774                if (awp & AWP_RESTORED) {
     775                    window_state_change = true;
     776                    if (awp & AWP_MAXIMIZED)
     777                        widget->dataPtr()->window_state |= Qt::WindowMaximized;
     778                    else if (!widget->isMinimized())
     779                        widget->dataPtr()->window_state &= ~Qt::WindowMaximized;
     780
     781                    if (widget->isMinimized()) {
     782                        widget->dataPtr()->window_state &= ~Qt::WindowMinimized;
     783                        widget->dptr()->showChildren(true);
     784                        QShowEvent e;
     785                        qt_sendSpontaneousEvent(widget, &e);
     786                        const QString title = widget->windowTitle();
     787                        if (!title.isEmpty())
     788                            widget->dptr()->setWindowTitle_helper(title);
     789                    }
     790                }
     791            }
     792
     793            if (window_state_change) {
     794                widget->dptr()->updateFrameStrut();
     795                if (!widget->topData()->inSetWindowState) {
     796                    // send WindowStateChange event if this message is NOT
     797                    // originated from QWidget::setWindowState().
     798                    QWindowStateChangeEvent e(oldstate);
     799                    qt_sendSpontaneousEvent(widget, &e);
     800                }
     801            }
     802
     803            return rc;
     804        }
     805
    717806        default:
    718807            break;
     
    14761565    d_func()->hd = WinBeginPaint(internalWinId(), 0, &rcl);
    14771566
    1478 #if 1
    1479     qDebug("WM_PAINT: [%s] BEGIN %ld,%ld-%ld,%ld hps=%08lX",
    1480            QWidgetPrivate::name(this).constData(),
    1481            rcl.xLeft, rcl.yBottom, rcl.xRight, rcl.yTop, d_func()->hd);
     1567#if defined(QT_DEBUGMSGFLOW)
     1568    qDebug() << " PAINT BEGIN:" << rcl << "hps:" << qStrHPS(d_func()->hd);
    14821569#endif
    14831570
     
    15011588    // Mapping region from system to qt (32 bit) coordinate system.
    15021589    updRect.translate(data->wrect.topLeft());
    1503 #if 1
    1504     qDebug("WM_PAINT: [%s] update=%d,%d/%d,%d",
    1505            QWidgetPrivate::name(this).constData(),
    1506            updRect.x(), updRect.y(), updRect.width(), updRect.height());
    1507 #endif
     1590#if defined(QT_DEBUGMSGFLOW)
     1591    qDebug() << " PAINT updRect:" << updRect;
     1592#endif
     1593
    15081594    // @todo use hrgn here converted to QRegion?
    15091595    d_func()->syncBackingStore(updRect);
     
    15121598    d_func()->hd = NULLHANDLE;
    15131599
    1514 #if 1
    1515     qDebug("WM_PAINT: [%s] END", QWidgetPrivate::name(this).constData());
     1600#if defined(QT_DEBUGMSGFLOW)
     1601    qDebug() << " PAINT END";
    15161602#endif
    15171603
     
    16591745}
    16601746
     1747
     1748/*!
     1749    Returns a QWidget pointer or 0 if there is no widget corresponding to the
     1750    given HWND. As opposed to QWidget::find(), correctly handles WC_FRAME
     1751    windows created for top level widgets. Used for debugging.
     1752 */
     1753QWidget *qWidgetFromHWND(HWND hwnd)
     1754{
     1755    char buf[10];
     1756    if (WinQueryClassName(hwnd, sizeof(buf), buf)) {
     1757        if (!strcmp(buf, "#1")) // WC_FRAME
     1758            hwnd = WinWindowFromID(hwnd, FID_CLIENT);
     1759        return QWidget::find(hwnd);
     1760    }
     1761    return 0;
     1762}
     1763
     1764/*!
     1765    \internal
     1766
     1767    Returns a human readable widget name in the form "class/name". Used for
     1768    debugging.
     1769 */
     1770QDbgStr qWidgetName(QWidget *w)
     1771{
     1772    if (w)
     1773        return QString()
     1774            .sprintf("%s.%s", w->metaObject()->className(),
     1775                     w->objectName().isEmpty() ? "<noname>" :
     1776                     w->objectName().toUtf8().constData());
     1777    return QString(QLatin1String("<no-widget>"));
     1778}
     1779
     1780QDbgStr qStrHWND(HWND hwnd)
     1781{
     1782    return QString().sprintf("%08lX/", hwnd) +
     1783           qWidgetName(qWidgetFromHWND(hwnd));
     1784}
     1785
     1786QDbgStr qStrHPS(HPS hps)
     1787{
     1788    return QString().sprintf("%08lX", hps);
     1789}
     1790
     1791QDbgStr qStrHPOINTER(HPOINTER hptr)
     1792{
     1793    return QString().sprintf("%08lX", hptr);
     1794}
     1795
     1796QDbgStr qStrHRGN(HRGN hrgn)
     1797{
     1798    return QString().sprintf("%08lX", hrgn);
     1799}
     1800
     1801QDbgStr qStrQMSG(const QMSG &qmsg)
     1802{
     1803    QString str;
     1804
     1805    #define myCaseBegin(a) case a: { \
     1806        str = QString().sprintf(#a ": hwnd %08lX.", qmsg.hwnd); \
     1807        str += qWidgetName(qWidgetFromHWND(qmsg.hwnd));
     1808    #define myCaseEnd() }
     1809
     1810    switch (qmsg.msg) {
     1811
     1812    myCaseBegin(WM_PAINT)
     1813        break;
     1814    myCaseEnd()
     1815
     1816    myCaseBegin(WM_SIZE)
     1817        str += QString().
     1818            sprintf(" old (%hd,%ld) new (%hd,%hd)",
     1819                    SHORT1FROMMP(qmsg.mp1), SHORT2FROMMP(qmsg.mp1),
     1820                    SHORT1FROMMP(qmsg.mp2), SHORT2FROMMP(qmsg.mp2));
     1821        break;
     1822    myCaseEnd()
     1823
     1824    myCaseBegin(WM_MOVE)
     1825        break;
     1826    myCaseEnd()
     1827
     1828    default:
     1829        break;
     1830    }
     1831
     1832    return str;
     1833
     1834    #undef myCaseEnd
     1835    #undef myCaseBegin
     1836}
     1837
     1838QDbgStr qStrRECTL(const RECTL &rcl)
     1839{
     1840    return QString().sprintf("RECTL(%ld,%ld %ld,%ld)",
     1841                             rcl.xLeft, rcl.yBottom, rcl.xRight, rcl.yTop);
     1842}
     1843
    16611844QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.