Changeset 121 for trunk/src


Ignore:
Timestamp:
Aug 19, 2009, 11:26:52 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: 1) Fixed window state change handling so that the window is properly redrawn after being un-minimized using the window manager command. 2) Fixed frame strut update during minimize.

Location:
trunk/src/gui/kernel
Files:
4 edited

Legend:

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

    r120 r121  
    600600            }
    601601
    602             case WM_MOVE:   // move window
    603602            case WM_SIZE: { // resize window
    604603                if (widget->translateConfigEvent(qmsg))
     
    698697            }
    699698
    700             default:
    701                 break;
    702             }
    703         }
    704 
    705     } while(0);
    706 
    707     return WinDefWindowProc(hwnd, msg, mp1, mp2);
    708 }
    709 
    710 PFNWP QtOldFrameProc = 0;
    711 
    712 MRESULT EXPENTRY QtFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    713 {
    714     do {
    715         if (!qApp) // unstable app state
    716             break;
    717 #if 0
    718         // make sure we show widgets (e.g. scrollbars) when the user resizes
    719         if (qApp->loopLevel())
    720             qApp->sendPostedEvents(0, QEvent::ShowWindowRequest);
    721 #endif
    722 
    723         MRESULT rc = (MRESULT) FALSE;
    724 
    725         HWND hwndC = WinWindowFromID(hwnd, FID_CLIENT);
    726         QETWidget *widget = (QETWidget*)QWidget::find(hwndC);
    727         if (!widget) // don't know this widget
    728             break;
    729 
    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 
    745         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) {
     699            case WM_MINMAXFRAME: {
     700                PSWP pswp = (PSWP)mp1;
     701
     702                bool window_state_change = false;
     703                Qt::WindowStates oldstate = Qt::WindowStates(widget->dataPtr()->window_state);
     704
     705                if (pswp->fl & SWP_MINIMIZE) {
    775706                    window_state_change = true;
    776                     if (awp & AWP_MAXIMIZED)
     707                    widget->dataPtr()->window_state |= Qt::WindowMinimized;
     708                    if (widget->isVisible()) {
     709                        QHideEvent e;
     710                        qt_sendSpontaneousEvent(widget, &e);
     711                        widget->dptr()->hideChildren(true);
     712                        const QString title = widget->windowIconText();
     713                        if (!title.isEmpty())
     714                            widget->dptr()->setWindowTitle_helper(title);
     715                    }
     716                } else if (pswp->fl & (SWP_MAXIMIZE | SWP_RESTORE)) {
     717                    window_state_change = true;
     718                    if (pswp->fl & SWP_MAXIMIZE) {
     719                        widget->topData()->normalGeometry = widget->geometry();
    777720                        widget->dataPtr()->window_state |= Qt::WindowMaximized;
    778                     else if (!widget->isMinimized())
     721                    }
     722                    else if (!widget->isMinimized()) {
    779723                        widget->dataPtr()->window_state &= ~Qt::WindowMaximized;
     724                    }
    780725
    781726                    if (widget->isMinimized()) {
     
    789734                    }
    790735                }
    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().
     736
     737                if (window_state_change) {
    798738                    QWindowStateChangeEvent e(oldstate);
    799739                    qt_sendSpontaneousEvent(widget, &e);
    800740                }
    801             }
    802 
    803             return rc;
     741
     742                break;
     743            }
     744
     745            default:
     746                break;
     747            }
     748        }
     749
     750    } while(0);
     751
     752    return WinDefWindowProc(hwnd, msg, mp1, mp2);
     753}
     754
     755PFNWP QtOldFrameProc = 0;
     756
     757MRESULT EXPENTRY QtFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     758{
     759    do {
     760        if (!qApp) // unstable app state
     761            break;
     762#if 0
     763        // make sure we show widgets (e.g. scrollbars) when the user resizes
     764        if (qApp->loopLevel())
     765            qApp->sendPostedEvents(0, QEvent::ShowWindowRequest);
     766#endif
     767
     768        HWND hwndC = WinWindowFromID(hwnd, FID_CLIENT);
     769        QETWidget *widget = (QETWidget*)QWidget::find(hwndC);
     770        if (!widget) // don't know this widget
     771            break;
     772
     773        Q_ASSERT(widget->isWindow());
     774
     775        QMSG qmsg; // create QMSG structure
     776        qmsg.hwnd = hwnd;
     777        qmsg.msg = msg;
     778        qmsg.mp1 = mp1;
     779        qmsg.mp2 = mp2;
     780
     781#if defined(QT_DEBUGMSGFLOW)
     782        {
     783            QString str = qStrQMSG(qmsg);
     784            if (!str.isEmpty())
     785                qDebug() << "*** [F]" << str.toUtf8().constData();
     786        }
     787#endif
     788
     789        switch(msg) {
     790
     791        case WM_MOVE: { // move window
     792            // note that we handle it nere instead of having CS_MOVENOTIFY
     793            // on the client and handling in QtWndProc because we don't want
     794            // client inside frame window move messages that would appear during
     795            // minimize/maximize otherwise
     796            if (widget->translateConfigEvent(qmsg))
     797                return (MRESULT)TRUE;
     798            break;
    804799        }
    805800
     
    16401635    }
    16411636
    1642     QRect cr = geometry();
    16431637    if (qmsg.msg == WM_SIZE) { // resize event
    1644         QSize oldSize = size();
    1645         QSize newSize(SHORT1FROMMP(qmsg.mp2), SHORT2FROMMP(qmsg.mp2));
    1646         cr.setSize(newSize);
    1647         data->crect = cr;
     1638        QSize oldSize = data->crect.size();
     1639        QSize newSize;
     1640        if (isWindow()) {
     1641            // the frame strut may have changed (e.g. after minimize)
     1642            d_func()->updateFrameStrut();
     1643            newSize = data->crect.size();
     1644        } else {
     1645            newSize = QSize(SHORT1FROMMP(qmsg.mp2), SHORT2FROMMP(qmsg.mp2));
     1646            data->crect.setSize(newSize);
     1647        }
    16481648        if (isWindow()) {                        // update title/icon text
    16491649            d_func()->createTLExtra();
     
    17021702        }
    17031703    } else if (qmsg.msg == WM_MOVE) { // move event
    1704         QPoint oldPos = geometry().topLeft();
     1704        QPoint oldPos = data->crect.topLeft();
    17051705        SWP swp;
    17061706        if (isWindow()) {
     
    17181718        QPoint newCPos(swp.x, swp.y);
    17191719        if (newCPos != oldPos) {
    1720             cr.moveTopLeft(newCPos);
    1721             data->crect = cr;
     1720            data->crect.moveTopLeft(newCPos);
    17221721            if (isVisible()) {
    17231722                QMoveEvent e(newCPos, oldPos); // cpos (client position)
     
    17781777}
    17791778
     1779/*****************************************************************************
     1780  PM struct/message debug helpers
     1781 *****************************************************************************/
     1782
     1783typedef QLatin1String QCStr;
     1784
     1785#define myDefFlagEx(var,fl,varstr,flstr) if (var & fl) { \
     1786    if (!varstr.isEmpty()) varstr += QCStr("|"); varstr += QCStr(flstr); \
     1787} else do {} while(0)
     1788
     1789#define myDefFlag(var,fl,varstr) myDefFlagEx(var,fl,varstr,#fl)
     1790#define myDefFlagCut(var,fl,varstr,pos) myDefFlagEx(var,fl,varstr,#fl + pos)
     1791
    17801792QDbgStr qStrHWND(HWND hwnd)
    17811793{
     
    18161828    myCaseBegin(WM_SIZE)
    18171829        str += QString().
    1818             sprintf(" old (%hd,%ld) new (%hd,%hd)",
     1830            sprintf(" old (%hd,%hd) new (%hd,%hd)",
    18191831                    SHORT1FROMMP(qmsg.mp1), SHORT2FROMMP(qmsg.mp1),
    18201832                    SHORT1FROMMP(qmsg.mp2), SHORT2FROMMP(qmsg.mp2));
     1833        SWP swp;
     1834        WinQueryWindowPos(qmsg.hwnd, &swp);
     1835        str += QCStr(" ") + qStrSWP(swp);
     1836        HWND p = WinQueryWindow(qmsg.hwnd, QW_PARENT);
     1837        if (p != NULLHANDLE && p != WinQueryDesktopWindow(0, 0)) {
     1838            WinQueryWindowPos(p, &swp);
     1839            str += QCStr(" p ") + qStrSWP(swp);
     1840        }
    18211841        break;
    18221842    myCaseEnd()
    18231843
    18241844    myCaseBegin(WM_MOVE)
     1845        SWP swp;
     1846        WinQueryWindowPos(qmsg.hwnd, &swp);
     1847        str += QCStr(" ") + qStrSWP(swp);
     1848        HWND p = WinQueryWindow(qmsg.hwnd, QW_PARENT);
     1849        if (p != NULLHANDLE && p != WinQueryDesktopWindow(0, 0)) {
     1850            WinQueryWindowPos(p, &swp);
     1851            str += QCStr(" p ") + qStrSWP(swp);
     1852        }
    18251853        break;
    18261854    myCaseEnd()
    18271855
     1856    myCaseBegin(WM_WINDOWPOSCHANGED)
     1857        str += QCStr(" ") + qStrSWP(*((PSWP) qmsg.mp1));
     1858        ULONG awp = LONGFROMMP(qmsg.mp2);
     1859        QString awpstr;
     1860        myDefFlagEx(awp, AWP_MINIMIZED, awpstr, "MIN");
     1861        myDefFlagEx(awp, AWP_MAXIMIZED, awpstr, "MAX");
     1862        myDefFlagEx(awp, AWP_RESTORED, awpstr, "REST");
     1863        myDefFlagEx(awp, AWP_ACTIVATE, awpstr, "ACT");
     1864        myDefFlagEx(awp, AWP_DEACTIVATE, awpstr, "DEACT");
     1865        str += QCStr(" AWP(") + awpstr + QCStr(")");
     1866        break;
     1867    myCaseEnd()
     1868
     1869    myCaseBegin(WM_MINMAXFRAME)
     1870        str += QCStr(" ") + qStrSWP(*((PSWP) qmsg.mp1));
     1871        break;
     1872    myCaseEnd()
     1873
    18281874    default:
    18291875        break;
     
    18421888}
    18431889
     1890QDbgStr qStrSWP(const SWP &swp)
     1891{
     1892    QString fl;
     1893    myDefFlagEx(swp.fl, SWP_SHOW, fl, "SHOW");
     1894    myDefFlagEx(swp.fl, SWP_HIDE, fl, "HIDE");
     1895    myDefFlagEx(swp.fl, SWP_ACTIVATE, fl, "ACT");
     1896    myDefFlagEx(swp.fl, SWP_DEACTIVATE, fl, "DEACT");
     1897    myDefFlagEx(swp.fl, SWP_MAXIMIZE, fl, "MAX");
     1898    myDefFlagEx(swp.fl, SWP_MINIMIZE, fl, "MIN");
     1899    myDefFlagEx(swp.fl, SWP_RESTORE, fl, "REST");
     1900    myDefFlagEx(swp.fl, SWP_MOVE, fl, "MOVE");
     1901    myDefFlagEx(swp.fl, SWP_SIZE, fl, "SIZE");
     1902    myDefFlagEx(swp.fl, SWP_ZORDER, fl, "ZORD");
     1903
     1904    return QString().sprintf("SWP(%ld,%ld %ldx%ld %08lX ",
     1905                             swp.x, swp.y, swp.cx, swp.cy, swp.hwndInsertBehind) +
     1906        fl + QLatin1String(")");
     1907}
     1908
     1909#undef myDefFlagCut
     1910#undef myDefFlag
     1911#undef myDefFlagEx
     1912
    18441913QT_END_NAMESPACE
  • trunk/src/gui/kernel/qwidget_p.h

    r120 r121  
    157157    HWND fId;
    158158    HSWITCH swEntry;
    159     uint inSetWindowState : 1;
    160159#endif
    161160    QRect normalGeometry; // used by showMin/maximized/FullScreen
  • trunk/src/gui/kernel/qwidget_pm.cpp

    r120 r121  
    9090        // WC_FRAME parent HWND internally maintaned for them
    9191        cname = QLatin1String("QWindow");
    92         style |= CS_MOVENOTIFY;
    9392    } else {
    9493        cname = QLatin1String("QWidget");
     
    13931392        Q_ASSERT(fId != NULLHANDLE);
    13941393
    1395         // set flag for the WM_WINDOWPOSCHANGED handler in QtFrameProc
    1396         d->topData()->inSetWindowState = true;
    1397 
    13981394        // Ensure the initial size is valid, since we store it as normalGeometry below.
    13991395        if (!testAttribute(Qt::WA_Resized) && !isVisible())
     
    14581454            }
    14591455        }
    1460 
    1461         // set flag for the WM_WINDOWPOSCHANGED handler in QtFrameProc
    1462         d->topData()->inSetWindowState = false;
    1463     }
     1456    }
     1457
    14641458    data->window_state = newstate;
    1465     QWindowStateChangeEvent e(oldstate);
    1466     QApplication::sendEvent(this, &e);
     1459    // Note: QWindowStateChangeEvent is sent from QtWndProc(WM_MINMAXFRAME)
    14671460}
    14681461
     
    19401933    extra->topextra->fId = NULLHANDLE;
    19411934    extra->topextra->swEntry = NULLHANDLE;
    1942     extra->topextra->inSetWindowState = false;
    19431935}
    19441936
     
    19891981    fs.setCoords(cswp.x, cswp.y, swp.cx - cswp.x - cswp.cx,
    19901982                                 swp.cy - cswp.y - cswp.cy);
    1991     // @todo do we really need to update crect here??
    1992     //data.crect.setRect(swp.x + cswp.x, swp.y + cswp.y, cswp.cx, cswp.cy);
     1983    data.crect.setRect(swp.x + cswp.x, swp.y + cswp.y, cswp.cx, cswp.cy);
    19931984
    19941985    data.fstrut_dirty = false;
  • trunk/src/gui/kernel/qwindowdefs_pm.h

    r120 r121  
    103103
    104104Q_CORE_EXPORT QDbgStr qStrRECTL(const RECTL &rcl);
     105Q_CORE_EXPORT QDbgStr qStrSWP(const SWP &swp);
    105106
    106107#endif // defined(QT_OS2_H)
     
    111112// Prints a non-quoted QString
    112113inline QDebug operator<<(QDebug dbg, const QDbgStr &str)
    113 { dbg << str.utf8().constData(); return dbg; }
     114{ dbg << str.toUtf8().constData(); return dbg; }
     115
     116#if defined(QT_OS2_H)
    114117
    115118inline QDebug operator<<(QDebug dbg, const RECTL &rcl)
    116119{ dbg << qStrRECTL(rcl); return dbg; }
     120
     121inline QDebug operator<<(QDebug dbg, const SWP &swp)
     122{ dbg << qStrSWP(swp); return dbg; }
     123
     124#endif // defined(QT_OS2_H)
    117125
    118126#endif // defined(QDEBUG_H) && !defined(QT_NO_DEBUG_STREAM)
Note: See TracChangeset for help on using the changeset viewer.