Changeset 110


Ignore:
Timestamp:
Jul 30, 2006, 7:11:51 PM (19 years ago)
Author:
dmik
Message:

Widgets: Implemented QDesktopWidget::availableGeometry().

Location:
trunk/src/kernel
Files:
2 edited

Legend:

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

    r109 r110  
    951951//
    952952
    953 // some undocumented messages (they have the WM_U_ prefix for clarity)
    954 //@@TODO (dmik): are they all available in Warp3?
    955953enum {
     954    // some undocumented messages (they have the WM_U_ prefix for clarity)
     955   
    956956    // sent to hwnd that has been entered to by a mouse pointer.
    957957    // FID_CLIENT also receives enter messages of its WC_FRAME.
     
    962962    // mp1 = hwnd that is left, mp2 = hwnd that is entered
    963963    WM_U_MOUSELEAVE = 0x41F,
     964
     965    // some undocumented system values
     966   
     967    SV_WORKAREA_YTOP = 51,           
     968    SV_WORKAREA_YBOTTOM = 52,           
     969    SV_WORKAREA_XRIGHT = 53,           
     970    SV_WORKAREA_XLEFT = 54,
    964971};
    965972
     
    10801087#endif
    10811088
    1082 /// @todo (dmik) later
    1083 //    case WM_SETTINGCHANGE:
    1084 //#ifdef Q_OS_TEMP
    1085 //      // CE SIP hide/show
    1086 //      if ( wParam == SPI_SETSIPINFO ) {
    1087 //          QResizeEvent re( QSize(0, 0), QSize(0, 0) ); // Calculated by QDesktopWidget
    1088 //          QApplication::sendEvent( qt_desktopWidget, &re );
    1089 //          break;
    1090 //      }
    1091 //#endif
    1092 //      // ignore spurious XP message when user logs in again after locking
    1093 //      if ( qApp->type() == QApplication::Tty )
    1094 //          break;
    1095 //      if ( QApplication::desktopSettingsAware() && wParam != SPI_SETWORKAREA ) {
    1096 //          widget = (QETWidget*)QWidget::find( hwnd );
    1097 //          if ( widget ) {
    1098 //              widget->markFrameStrutDirty();
    1099 //              if ( !widget->parentWidget() )
    1100 //                  qt_set_windows_resources();
    1101 //          }
    1102 //      }
    1103 //      break;
    1104 //    case WM_SYSCOLORCHANGE:
    1105 //      if ( qApp->type() == QApplication::Tty )
    1106 //          break;
    1107 //      if ( QApplication::desktopSettingsAware() ) {
    1108 //          widget = (QETWidget*)QWidget::find( hwnd );
    1109 //          if ( widget && !widget->parentWidget() )
    1110 //              qt_set_windows_resources();
    1111 //      }
    1112 //      break;
     1089        case WM_SYSVALUECHANGED: {
     1090            // This message is sent to all top-level widgets, handle only once
     1091            QWidgetList *list = QApplication::topLevelWidgets();
     1092            bool firstWidget = list->first()->winId() == hwnd;
     1093            delete list;
     1094            if ( !firstWidget )
     1095                break;
     1096            LONG from = (LONG) mp1;
     1097            LONG to = (LONG) mp2;
     1098            #define _IS_SV(sv) (from >= (sv) && to <= (sv))
     1099            if ( _IS_SV( SV_WORKAREA_XLEFT ) || _IS_SV( SV_WORKAREA_XRIGHT ) ||
     1100                 _IS_SV( SV_WORKAREA_YBOTTOM ) || _IS_SV( SV_WORKAREA_YTOP ) ) {
     1101                 // send a special invalid resize event to QDesktopWidget
     1102                 QResizeEvent re( QSize( -1, -1 ), QSize( -1, -1 ) );
     1103                 QApplication::sendEvent( qt_desktopWidget, &re );
     1104                 /// @todo (dmik) enumerate all top-level widgets and
     1105                 //  remaximize those that are maximized
     1106            } else {
     1107                 /// @todo (dmik) call qt_set_pm_resources() in the way it is
     1108                 //  done in WM_SYSCOLORCHANGE for relevant SV_ values.
     1109            }
     1110            #undef _IS_SV
     1111            break;
     1112        }
     1113
     1114        case WM_SYSCOLORCHANGE: {
     1115            // This message is sent to all top-level widgets, handle only once
     1116            QWidgetList *list = QApplication::topLevelWidgets();
     1117            bool firstWidget = list->first()->winId() == hwnd;
     1118            delete list;
     1119            if ( !firstWidget )
     1120                break;
     1121            if ( qApp->type() == QApplication::Tty )
     1122                break;
     1123            if ( QApplication::desktopSettingsAware() ) {
     1124                widget = (QETWidget*)QWidget::find( hwnd );
     1125                if ( widget && !widget->parentWidget() )
     1126                    qt_set_pm_resources();
     1127            }
     1128            break;
     1129        }
    11131130
    11141131        case WM_BUTTON1DOWN:
     
    20122029        }
    20132030    }
     2031    delete list;
    20142032
    20152033    if ( mgl ) {
  • trunk/src/kernel/qdesktopwidget_pm.cpp

    r8 r110  
    5252  \endomit
    5353*/
     54
     55// just stolen from xWorkplace sources
     56static
     57APIRET qt_DosQueryProcAddr( PCSZ pcszModuleName, ULONG ulOrdinal, PFN *ppfn )
     58{
     59    HMODULE hmod = NULL;
     60    APIRET rc = 0;
     61    if ( !(rc = DosQueryModuleHandle( (PSZ)pcszModuleName, &hmod )) ) {
     62        if ( (rc = DosQueryProcAddr( hmod, ulOrdinal, NULL, ppfn )) ) {
     63            // the CP programming guide and reference says use
     64            // DosLoadModule if DosQueryProcAddr fails with this error
     65            if ( rc == ERROR_INVALID_HANDLE ) {
     66                if ( !(rc = DosLoadModule( NULL, 0, (PSZ) pcszModuleName,
     67                                            &hmod )) ) {
     68                    rc = DosQueryProcAddr( hmod, ulOrdinal, NULL, ppfn );
     69                }
     70            }
     71        }
     72    }
     73    return rc;
     74}
     75
     76class QDesktopWidgetPrivate
     77{
     78public:
     79
     80    QRect workArea;
     81};
    5482
    5583/*!
     
    105133: QWidget( 0, "desktop", WType_Desktop )
    106134{
     135    d = new QDesktopWidgetPrivate();
    107136}
    108137
     
    112141QDesktopWidget::~QDesktopWidget()
    113142{
     143    delete d;
    114144}
    115145
     
    181211const QRect& QDesktopWidget::availableGeometry( int /*screen*/ ) const
    182212{
    183     //@@TODO (dmik): use WinGetMaxPosition () to take into account such
    184     //  things as XCenter?
     213    typedef   
     214    BOOL (APIENTRY *WinQueryDesktopWorkArea_T) (HWND hwndDesktop,
     215                                                PRECTL pwrcWorkArea);
     216    static WinQueryDesktopWorkArea_T WinQueryDesktopWorkArea =
     217        (WinQueryDesktopWorkArea_T) ~0;
     218   
     219    if ( (ULONG) WinQueryDesktopWorkArea == (ULONG) ~0 ) {
     220        if ( qt_DosQueryProcAddr( "PMMERGE", 5469,
     221                                  (PFN *) &WinQueryDesktopWorkArea ) )
     222            WinQueryDesktopWorkArea = NULL;
     223    }
     224
     225    if ( WinQueryDesktopWorkArea ) {
     226        RECTL rcl;
     227        if ( WinQueryDesktopWorkArea( HWND_DESKTOP, &rcl ) ) {
     228            // flip y coordinates
     229            d->workArea.setCoords( rcl.xLeft, height() - rcl.yTop,
     230                                   rcl.xRight - 1,
     231                                   height() - (rcl.yBottom + 1) );
     232            return d->workArea;
     233        }
     234    }
     235   
    185236    return geometry();
    186237}
     
    252303    \reimp
    253304*/
    254 void QDesktopWidget::resizeEvent( QResizeEvent * )
    255 {
    256     // do nothing, since the desktop cannot be dynamically resized in OS/2
    257     //@@TODO (dmik): emit workAreaResized() when XCenter changes its size
    258     //  while reducing the desktop area?
     305void QDesktopWidget::resizeEvent( QResizeEvent *e )
     306{
     307    if ( e && !e->size().isValid() && !e->oldSize().isValid() ) {
     308        // This is a Work Area Changed notification, see WM_SYSVALUECHANGED
     309        // in qapplication_pm.cpp
     310        emit workAreaResized( 0 );
     311        return;
     312    }
     313   
     314    // nothing to do, the desktop cannot be dynamically resized in OS/2
    259315}
    260316
Note: See TracChangeset for help on using the changeset viewer.