Changeset 120 for trunk/src/gui/kernel/qapplication_pm.cpp
- Timestamp:
- Aug 18, 2009, 4:30:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qapplication_pm.cpp
r117 r120 44 44 #include "qt_os2.h" 45 45 46 #include "qdebug.h" 47 46 48 #include "qapplication.h" 47 49 #include "qapplication_p.h" … … 61 63 #include "qkeymapper_p.h" 62 64 #include "qcursor_p.h" 65 66 #define QT_DEBUGMSGFLOW 63 67 64 68 QT_BEGIN_NAMESPACE … … 120 124 // void syncBackingStore(const QRegion &rgn) { d_func()->syncBackingStore(rgn); } 121 125 // 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(); } 124 128 // QRect frameStrut() const { return d_func()->frameStrut(); } 125 129 bool pmEvent(QMSG *m, MRESULT *r) { return QWidget::pmEvent(m, r); } … … 494 498 // flip y coordinate 495 499 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 496 508 497 509 // send through app filter … … 709 721 #endif 710 722 723 MRESULT rc = (MRESULT) FALSE; 724 711 725 HWND hwndC = WinWindowFromID(hwnd, FID_CLIENT); 712 726 QETWidget *widget = (QETWidget*)QWidget::find(hwndC); … … 714 728 break; 715 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 716 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) { 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 717 806 default: 718 807 break; … … 1476 1565 d_func()->hd = WinBeginPaint(internalWinId(), 0, &rcl); 1477 1566 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); 1482 1569 #endif 1483 1570 … … 1501 1588 // Mapping region from system to qt (32 bit) coordinate system. 1502 1589 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 1508 1594 // @todo use hrgn here converted to QRegion? 1509 1595 d_func()->syncBackingStore(updRect); … … 1512 1598 d_func()->hd = NULLHANDLE; 1513 1599 1514 #if 11515 qDebug( "WM_PAINT: [%s] END", QWidgetPrivate::name(this).constData());1600 #if defined(QT_DEBUGMSGFLOW) 1601 qDebug() << " PAINT END"; 1516 1602 #endif 1517 1603 … … 1659 1745 } 1660 1746 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 */ 1753 QWidget *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 */ 1770 QDbgStr 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 1780 QDbgStr qStrHWND(HWND hwnd) 1781 { 1782 return QString().sprintf("%08lX/", hwnd) + 1783 qWidgetName(qWidgetFromHWND(hwnd)); 1784 } 1785 1786 QDbgStr qStrHPS(HPS hps) 1787 { 1788 return QString().sprintf("%08lX", hps); 1789 } 1790 1791 QDbgStr qStrHPOINTER(HPOINTER hptr) 1792 { 1793 return QString().sprintf("%08lX", hptr); 1794 } 1795 1796 QDbgStr qStrHRGN(HRGN hrgn) 1797 { 1798 return QString().sprintf("%08lX", hrgn); 1799 } 1800 1801 QDbgStr 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 1838 QDbgStr 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 1661 1844 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.