- Timestamp:
- Aug 19, 2009, 11:26:52 PM (16 years ago)
- Location:
- trunk/src/gui/kernel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qapplication_pm.cpp
r120 r121 600 600 } 601 601 602 case WM_MOVE: // move window603 602 case WM_SIZE: { // resize window 604 603 if (widget->translateConfigEvent(qmsg)) … … 698 697 } 699 698 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) { 775 706 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(); 777 720 widget->dataPtr()->window_state |= Qt::WindowMaximized; 778 else if (!widget->isMinimized()) 721 } 722 else if (!widget->isMinimized()) { 779 723 widget->dataPtr()->window_state &= ~Qt::WindowMaximized; 724 } 780 725 781 726 if (widget->isMinimized()) { … … 789 734 } 790 735 } 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) { 798 738 QWindowStateChangeEvent e(oldstate); 799 739 qt_sendSpontaneousEvent(widget, &e); 800 740 } 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 755 PFNWP QtOldFrameProc = 0; 756 757 MRESULT 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; 804 799 } 805 800 … … 1640 1635 } 1641 1636 1642 QRect cr = geometry();1643 1637 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 } 1648 1648 if (isWindow()) { // update title/icon text 1649 1649 d_func()->createTLExtra(); … … 1702 1702 } 1703 1703 } else if (qmsg.msg == WM_MOVE) { // move event 1704 QPoint oldPos = geometry().topLeft();1704 QPoint oldPos = data->crect.topLeft(); 1705 1705 SWP swp; 1706 1706 if (isWindow()) { … … 1718 1718 QPoint newCPos(swp.x, swp.y); 1719 1719 if (newCPos != oldPos) { 1720 cr.moveTopLeft(newCPos); 1721 data->crect = cr; 1720 data->crect.moveTopLeft(newCPos); 1722 1721 if (isVisible()) { 1723 1722 QMoveEvent e(newCPos, oldPos); // cpos (client position) … … 1778 1777 } 1779 1778 1779 /***************************************************************************** 1780 PM struct/message debug helpers 1781 *****************************************************************************/ 1782 1783 typedef 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 1780 1792 QDbgStr qStrHWND(HWND hwnd) 1781 1793 { … … 1816 1828 myCaseBegin(WM_SIZE) 1817 1829 str += QString(). 1818 sprintf(" old (%hd,% ld) new (%hd,%hd)",1830 sprintf(" old (%hd,%hd) new (%hd,%hd)", 1819 1831 SHORT1FROMMP(qmsg.mp1), SHORT2FROMMP(qmsg.mp1), 1820 1832 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 } 1821 1841 break; 1822 1842 myCaseEnd() 1823 1843 1824 1844 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 } 1825 1853 break; 1826 1854 myCaseEnd() 1827 1855 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 1828 1874 default: 1829 1875 break; … … 1842 1888 } 1843 1889 1890 QDbgStr 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 1844 1913 QT_END_NAMESPACE -
trunk/src/gui/kernel/qwidget_p.h
r120 r121 157 157 HWND fId; 158 158 HSWITCH swEntry; 159 uint inSetWindowState : 1;160 159 #endif 161 160 QRect normalGeometry; // used by showMin/maximized/FullScreen -
trunk/src/gui/kernel/qwidget_pm.cpp
r120 r121 90 90 // WC_FRAME parent HWND internally maintaned for them 91 91 cname = QLatin1String("QWindow"); 92 style |= CS_MOVENOTIFY;93 92 } else { 94 93 cname = QLatin1String("QWidget"); … … 1393 1392 Q_ASSERT(fId != NULLHANDLE); 1394 1393 1395 // set flag for the WM_WINDOWPOSCHANGED handler in QtFrameProc1396 d->topData()->inSetWindowState = true;1397 1398 1394 // Ensure the initial size is valid, since we store it as normalGeometry below. 1399 1395 if (!testAttribute(Qt::WA_Resized) && !isVisible()) … … 1458 1454 } 1459 1455 } 1460 1461 // set flag for the WM_WINDOWPOSCHANGED handler in QtFrameProc 1462 d->topData()->inSetWindowState = false; 1463 } 1456 } 1457 1464 1458 data->window_state = newstate; 1465 QWindowStateChangeEvent e(oldstate); 1466 QApplication::sendEvent(this, &e); 1459 // Note: QWindowStateChangeEvent is sent from QtWndProc(WM_MINMAXFRAME) 1467 1460 } 1468 1461 … … 1940 1933 extra->topextra->fId = NULLHANDLE; 1941 1934 extra->topextra->swEntry = NULLHANDLE; 1942 extra->topextra->inSetWindowState = false;1943 1935 } 1944 1936 … … 1989 1981 fs.setCoords(cswp.x, cswp.y, swp.cx - cswp.x - cswp.cx, 1990 1982 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); 1993 1984 1994 1985 data.fstrut_dirty = false; -
trunk/src/gui/kernel/qwindowdefs_pm.h
r120 r121 103 103 104 104 Q_CORE_EXPORT QDbgStr qStrRECTL(const RECTL &rcl); 105 Q_CORE_EXPORT QDbgStr qStrSWP(const SWP &swp); 105 106 106 107 #endif // defined(QT_OS2_H) … … 111 112 // Prints a non-quoted QString 112 113 inline 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) 114 117 115 118 inline QDebug operator<<(QDebug dbg, const RECTL &rcl) 116 119 { dbg << qStrRECTL(rcl); return dbg; } 120 121 inline QDebug operator<<(QDebug dbg, const SWP &swp) 122 { dbg << qStrSWP(swp); return dbg; } 123 124 #endif // defined(QT_OS2_H) 117 125 118 126 #endif // defined(QDEBUG_H) && !defined(QT_NO_DEBUG_STREAM)
Note:
See TracChangeset
for help on using the changeset viewer.