[Kde-cygwin-cvs] CVS: qt-3/src/kernel qapplication_win.cpp,1.1.2.30.2.92,1.1.2.30.2.93 qeventloop_wi
Status: Inactive
Brought to you by:
habacker
From: Christian E. <che...@us...> - 2005-10-09 17:08:07
|
Update of /cvsroot/kde-cygwin/qt-3/src/kernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30654/src/kernel Modified Files: Tag: QT_WIN32_3_3_BRANCH qapplication_win.cpp qeventloop_win.cpp qwidget_win.cpp Log Message: QWidget::setWindowState() from Qt4 add WM_SYSCOMMAND to send correct QEvent::WindowStateChange add qWinRequestConfig() for internalSetGeometry() & WState_ConfigPending Index: qapplication_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qapplication_win.cpp,v retrieving revision 1.1.2.30.2.92 retrieving revision 1.1.2.30.2.93 diff -u -r1.1.2.30.2.92 -r1.1.2.30.2.93 --- qapplication_win.cpp 4 Oct 2005 19:37:16 -0000 1.1.2.30.2.92 +++ qapplication_win.cpp 9 Oct 2005 17:07:23 -0000 1.1.2.30.2.93 @@ -266,6 +266,8 @@ { return QApplication::sendSpontaneousEvent( receiver, event ); } + void showChildren( bool spontaneous ) { showChildren( spontaneous ); } + void hideChildren( bool spontaneous ) { hideChildren( spontaneous ); } }; @@ -770,6 +772,63 @@ /***************************************************************************** + Safe configuration (move,resize,setGeometry) mechanism to avoid + recursion when processing messages. + *****************************************************************************/ + +struct QWinConfigRequest { + WId id; // widget to be configured + int req; // 0=move, 1=resize, 2=setGeo + int x, y, w, h; // request parameters +}; + +QList<QWinConfigRequest> *configRequests = 0; + +void qWinRequestConfig(WId id, int req, int x, int y, int w, int h) +{ + if ( !configRequests ) // create queue + configRequests = new QList<QWinConfigRequest>; + QWinConfigRequest *r = new QWinConfigRequest; + r->id = id; // create new request + r->req = req; + r->x = x; + r->y = y; + r->w = w; + r->h = h; + configRequests->append( r ); // store request in queue +} + +void qWinProcessConfigRequests() // perform requests in queue +{ + if ( !configRequests ) + return; + QWinConfigRequest *r; + for ( ;; ) { + if ( configRequests->isEmpty() ) + break; + r = configRequests->last(); + configRequests->removeLast(); + QWidget *w = QWidget::find( r->id ); + QRect rect( r->x, r->y, r->w, r->h ); + int req = r->req; + delete r; + + if ( w ) { // widget exists + if ( w->testWState( Qt::WState_ConfigPending ) ) + return; // biting our tail + if ( req == 0 ) + w->move( rect.topLeft() ); + else if ( req == 1 ) + w->resize( rect.size() ); + else + w->setGeometry( rect ); + } + } + delete configRequests; + configRequests = 0; +} + +/***************************************************************************** Platform specific global and internal functions *****************************************************************************/ @@ -2381,63 +2440,7 @@ return k0 || k1; } -/* - int code = -1; - int count = 0; - char ascii = 0; - bool autor = false; - QString text; - if ( !isEnabled() ) - return TRUE; - - // Bit 29 and 31 are only set on WM_KEYUP ! - QEvent::Type type = ( ( msg.lParam & 0x90000000 ) == 0 ) ? QEvent::KeyPress : QEvent::KeyRelease; - - if ( !translateKeyEventInternal( msg, count, text, state, ascii, code ) ) - return TRUE; - -// if ( code == Qt::Key_Shift ) // why 321nc sends them! -// return FALSE; - if ( ( code == Qt::Key_Control ) || ( code == Qt::Key_Alt ) || - ( code == Qt::Key_Shift ) ) { - // check for KEY_DOWN and previous state - // Bit 30 - previous state - no define for this - // Bit 29 and 31 are only set on WM_KEYUP ! - if ( ( ( msg.lParam & 0x40000000 ) == 0x40000000 ) && - ( ( msg.lParam & 0x90000000 ) == 0 ) ) - return FALSE; - } - bool isAccel = false; - if ( !grab && ( HIWORD( msg.lParam ) & KF_ALTDOWN ) ) { // test for accel if the keyboard is not grabbed - QKeyEvent a( QEvent::AccelAvailable, code, ascii, state, text, false, - QMAX( count, int( text.length() ) ) ); - a.ignore(); - QApplication::sendEvent( topLevelWidget(), &a ); - isAccel = a.isAccepted(); - } - - // process acceleraters before popups - QKeyEvent e( type, code, ascii, state, text, autor, - QMAX( count, int( text.length() ) ) ); - if ( type == QEvent::KeyPress && !grab ) { - // send accel events if the keyboard is not grabbed - QKeyEvent aa( QEvent::AccelOverride, code, ascii, state, text, autor, - QMAX( count, int( text.length() ) ) ); - aa.ignore(); - QApplication::sendEvent( this, &aa ); - if ( !aa.isAccepted() ) { - QKeyEvent a( QEvent::Accel, code, ascii, state, text, autor, - QMAX( count, int( text.length() ) ) ); - a.ignore(); - QApplication::sendEvent( topLevelWidget(), &a ); - if ( a.isAccepted() ) - return FALSE; - } - } - QApplication::sendSpontaneousEvent( this, &e ); - return FALSE; -} */ bool QETWidget::translateEraseEvent( const MSG &msg ) { #ifdef DEBUG_QAPPLICATION @@ -2453,7 +2456,7 @@ hdc = hdcOld; /* An application should return nonzero in response to WM_ERASEBKGND if it processes the message and erases the background */ - return TRUE; + return true; } bool QETWidget::translatePaintEvent( const MSG &msg ) @@ -2464,7 +2467,14 @@ PAINTSTRUCT ps; QRegion paintRegion( 0, 0, 1, 1 ); // otherwise we would pollute empty_region - GetUpdateRgn ( winid, paintRegion.handle (), FALSE ); + int res = GetUpdateRgn ( winid, paintRegion.handle (), FALSE ); +/* + if ( !GetUpdateRect( winId(), 0, false ) // The update bounding rect is invalid + || ( res == ERROR ) + || ( res == NULLREGION ) ) { + return false; + } +*/ HDC hdcOld = hdc; hdc = BeginPaint( winid, &ps ); #ifdef DEBUG_QAPPLICATION @@ -2476,7 +2486,7 @@ EndPaint( winid, &ps ); hdc = hdcOld; - return FALSE; + return true; } //Defined in qwidget_win.cpp @@ -2487,11 +2497,11 @@ bool QETWidget::translateConfigEvent( const MSG &msg ) { if ( !testWState( Qt::WState_Created ) ) // in QWidget::create() - return false; + return true; if ( testWState( Qt::WState_ConfigPending ) ) - return false; + return true; if ( !isTopLevel() ) - return false; + return true; setWState( Qt::WState_ConfigPending ); // set config flag QRect cr = geometry(); if ( msg.message == WM_SIZE ) { // resize event @@ -2560,7 +2570,7 @@ } } clearWState( Qt::WState_ConfigPending ); // clear config flag - return false; + return true; } @@ -2740,9 +2750,14 @@ if ( !qt_try_modal( widget, &msg, ret ) ) return 1; + if ( !widget ) + widget = (QETWidget*)QWidget::find( hWnd ); + if ( !widget ) // don't know this widget + goto do_default; + // WM95_MOUSEWHEEL is not const if ( uMsg == WM_MOUSEWHEEL || uMsg == WM95_MOUSEWHEEL ) - return ( widget->translateWheelEvent(msg) ); // mouse event + return ( widget->translateWheelEvent( msg) ); // mouse event switch ( uMsg ) { case WM_LBUTTONDOWN: @@ -2829,7 +2844,7 @@ break; } case WM_SYSCHAR: - return TRUE; // consume event + return 0; // consume event break; case WM_INPUTLANGCHANGE: { @@ -2842,6 +2857,56 @@ break; } + case WM_SYSCOMMAND: { +#ifndef Q_OS_TEMP + bool window_state_change = false; + unsigned int oldstate = widget->windowState(); + switch(wParam) { + case SC_CONTEXTHELP: +#ifndef QT_NO_WHATSTHIS + QWhatsThis::enterWhatsThisMode(); +#endif + QT_WA({ + DefWindowProcW( hWnd, WM_NCPAINT, 1, 0 ); + } , { + DefWindowProcA( hWnd, WM_NCPAINT, 1, 0 ); + }); + break; + case SC_MINIMIZE: + window_state_change = true; + widget->setWindowState( oldstate | Qt::WindowMinimized ); + if ( widget->isVisible() ) { + QHideEvent e; + widget->sendSpontaneousEvent( widget, &e ); + widget->hideChildren(true); + } + break; + case SC_MAXIMIZE: + case SC_RESTORE: + window_state_change = true; + if ( widget->isMinimized() ) { + oldstate &= ~Qt::WindowMinimized; + widget->showChildren(true); + widget->setWindowState( oldstate ); + QShowEvent e; + widget->sendSpontaneousEvent( widget, &e ); + } + if (wParam == SC_MAXIMIZE) + widget->setWindowState( oldstate | Qt::WindowMaximized ); + else + widget->setWindowState( oldstate & ~Qt::WindowMaximized ); + break; + default: + break; + } + + if ( window_state_change ) { + QEvent e( QEvent::WindowStateChange ); + widget->sendSpontaneousEvent( widget, &e ); + } +#endif + break; + } case WM_SETTINGCHANGE: if ( !msg.wParam ) { QString area = QT_WA_INLINE(QString::fromUcs2( ( unsigned short * ) msg.lParam ), @@ -2872,17 +2937,16 @@ break; #endif case WM_PAINT: - if ( widget ) - return ( widget->translatePaintEvent( msg ) ); + if ( widget->translatePaintEvent( msg ) ) + return 0; break; case WM_ERASEBKGND: - if ( widget ) - return ( widget->translateEraseEvent( msg ) ); + return ( widget->translateEraseEvent( msg ) ); break; case WM_MOVE: // move window case WM_SIZE: // resize window - if ( widget ) - return ( widget->translateConfigEvent( msg ) ); + if ( widget->translateConfigEvent( msg ) ) + return 0; break; case WM_ACTIVATE: if ( widget ) { @@ -2908,17 +2972,17 @@ clear_key_rec(); // Ensure nothing gets consider an auto-repeat press later } return FALSE; + break; #ifndef Q_OS_TEMP - case WM_MOUSEACTIVATE: - if ( widget ) { - const QWidget * tlw = widget->topLevelWidget(); - // Do not change activation if the clicked widget is inside a floating dock window - if ( tlw->inherits( "QDockWidget" ) && qApp->activeWindow() - && !qApp->activeWindow() ->inherits( "QDockWidget" ) ) - return MA_NOACTIVATE; - } - return FALSE; + case WM_MOUSEACTIVATE: { + const QWidget * tlw = widget->topLevelWidget(); + // Do not change activation if the clicked widget is inside a floating dock window + if ( tlw->inherits( "QDockWidget" ) && qApp->activeWindow() + && !qApp->activeWindow() ->inherits( "QDockWidget" ) ) + return MA_NOACTIVATE; + break; + } #endif case WM_RBUTTONDOWN: @@ -2938,7 +3002,9 @@ widget = ( QETWidget* ) w; } - return ( !widget->translateMouseEvent( msg ) ); // mouse event + if ( widget->translateMouseEvent( msg ) ) + return 0; + break; case WM_MOUSELEAVE: // We receive a mouse leave for curWin, meaning // the mouse was moved outside our widgets @@ -2975,7 +3041,7 @@ } return FALSE; case WM_DESTROY: - if ( widget && widget->testWState( Qt::WState_Reparented ) ) { + if ( widget->testWState( Qt::WState_Reparented ) ) { return false; } if ( widget == qApp->mainWidget() ) { @@ -3092,6 +3158,7 @@ qDebug( "qapplication_win.cpp: processNextEvent: DefWindowProc: %s", getMsgName( uMsg ) ); #endif +do_default: return QT_WA_INLINE ( DefWindowProcW( hWnd, uMsg, wParam, lParam ), DefWindowProcA( hWnd, uMsg, wParam, lParam ) ); } Index: qeventloop_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qeventloop_win.cpp,v retrieving revision 1.1.2.10.2.21 retrieving revision 1.1.2.10.2.22 diff -u -r1.1.2.10.2.21 -r1.1.2.10.2.22 --- qeventloop_win.cpp 17 Jul 2005 14:08:44 -0000 1.1.2.10.2.21 +++ qeventloop_win.cpp 9 Oct 2005 17:07:23 -0000 1.1.2.10.2.22 @@ -55,7 +55,10 @@ QSNDict sn_write; QSNDict sn_except; +struct QWinConfigRequest; extern bool qt_is_gui_used; +extern QList<QWinConfigRequest*> *configRequests = 0; +void qWinProcessConfigRequests(); // from qeventloop_win_utils.cpp FILETIME *qt_wait_timer(); @@ -245,6 +248,8 @@ // handle gui and posted events if ( qt_is_gui_used ) { + if ( configRequests ) // any pending configs? + qWinProcessConfigRequests(); QApplication::sendPostedEvents(); MSG msg; Index: qwidget_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qwidget_win.cpp,v retrieving revision 1.1.2.15.2.59 retrieving revision 1.1.2.15.2.60 diff -u -r1.1.2.15.2.59 -r1.1.2.15.2.60 --- qwidget_win.cpp 4 Oct 2005 19:37:16 -0000 1.1.2.15.2.59 +++ qwidget_win.cpp 9 Oct 2005 17:07:23 -0000 1.1.2.15.2.60 @@ -1384,6 +1384,7 @@ } /* coordinates are excluding the window frame ! */ +void qWinRequestConfig(WId, int, int, int, int, int); void QWidget::internalSetGeometry( int x, int y, int w, int h, bool isMove ) { #ifdef DEBUG_QWIDGET @@ -1436,59 +1437,61 @@ bool isResize = size() != oldSize; - // CCJ - set WState_ConfigPending further up than the X11 code since it needs - // to be set before the WM_WINDOWPOSCHANGED message is sent by SetWindowPos. - if (isResize) + if ( testWState( Qt::WState_ConfigPending ) ) { // processing config event + qWinRequestConfig( winId(), isMove ? 2 : 1, x, y, w, h ); + } else { setWState( WState_ConfigPending ); - - if ( isTopLevel() ) { - - RECT myrect; //to create a client area of the right size instead of a win - - int capWidth, xBdrWidth, yBdrWidth; - getWndBorderInfo( winId(), capWidth, xBdrWidth, yBdrWidth ); - QRect frameRect = frameGeometry(); - myrect.left = crect.left() - xBdrWidth; - myrect.top = crect.top() - capWidth; - myrect.right = crect.right() + xBdrWidth + 1; - myrect.bottom = crect.bottom() + yBdrWidth + 1; - -#ifdef DEBUG_QWIDGET - - qDebug( "qwidget_win.cpp: fstrut: %d isMove %d", fstrut_dirty, isMove ); - qDebug( "qwidget_win.cpp: Window Border Info: caption Width: %d, X border Width: %d, Y Border Width: %d", capWidth, xBdrWidth, yBdrWidth ); - qDebug( "qwidget_win.cpp: myrect: l: %ld, t: %ld, r: %ld, b: %ld", myrect.left, myrect.top, myrect.right, myrect.bottom ); -#endif - - if ( isMove ) - SetWindowPos( winid, 0, - myrect.left, // x, - myrect.top, // y, - myrect.right - myrect.left, // w, - myrect.bottom - myrect.top, // h, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING ); - else - SetWindowPos( winid, 0, - 0, 0, - myrect.right - myrect.left, // w, - myrect.bottom - myrect.top, // h, - SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING ); - -#ifdef DEBUG_QWIDGET - - GetWindowRect( winId(), &myrect ); - qDebug( "qwidget_win.cpp: myrect after Update: l: %ld, t: %ld, r: %ld, b: %ld", myrect.left, myrect.top, myrect.right, myrect.bottom ); -#endif - } else { // not toplevel window -#ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp: internalSetGeometry Non-Top-Level Window" ); -#endif - - if ( isMove ) { - SetWindowPos( winid, 0, x, y, w, h, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING ); - } else if ( isResize ) { - SetWindowPos( winid, 0, 0, 0, w, h, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING ); + if ( isTopLevel() ) { + + RECT myrect; //to create a client area of the right size instead of a win + + int capWidth, xBdrWidth, yBdrWidth; + getWndBorderInfo( winId(), capWidth, xBdrWidth, yBdrWidth ); + QRect frameRect = frameGeometry(); + myrect.left = crect.left() - xBdrWidth; + myrect.top = crect.top() - capWidth; + myrect.right = crect.right() + xBdrWidth + 1; + myrect.bottom = crect.bottom() + yBdrWidth + 1; + + #ifdef DEBUG_QWIDGET + + qDebug( "qwidget_win.cpp: fstrut: %d isMove %d", fstrut_dirty, isMove ); + qDebug( "qwidget_win.cpp: Window Border Info: caption Width: %d, X border Width: %d, Y Border Width: %d", capWidth, xBdrWidth, yBdrWidth ); + qDebug( "qwidget_win.cpp: myrect: l: %ld, t: %ld, r: %ld, b: %ld", myrect.left, myrect.top, myrect.right, myrect.bottom ); + #endif + + if ( isMove ) + SetWindowPos( winid, 0, + myrect.left, // x, + myrect.top, // y, + myrect.right - myrect.left, // w, + myrect.bottom - myrect.top, // h, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING ); + else + SetWindowPos( winid, 0, + 0, 0, + myrect.right - myrect.left, // w, + myrect.bottom - myrect.top, // h, + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING ); + +#ifdef DEBUG_QWIDGET + + GetWindowRect( winId(), &myrect ); + qDebug( "qwidget_win.cpp: myrect after Update: l: %ld, t: %ld, r: %ld, b: %ld", myrect.left, myrect.top, myrect.right, myrect.bottom ); +#endif + } else { // not toplevel window +#ifdef DEBUG_QWIDGET + qDebug( "qwidget_win.cpp: internalSetGeometry Non-Top-Level Window" ); +#endif + + if ( isMove ) { + InvalidateRect( winid, 0, false ); + SetWindowPos( winid, 0, x, y, w, h, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING ); + } else if ( isResize ) { + SetWindowPos( winid, 0, 0, 0, w, h, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING ); + } } + clearWState( WState_ConfigPending ); } if ( isVisible() ) { @@ -1513,7 +1516,6 @@ QApplication::postEvent( this, new QResizeEvent( size(), oldSize ) ); } - clearWState( WState_ConfigPending ); } /*! @@ -2102,104 +2104,94 @@ */ void QWidget::setWindowState( unsigned int newstate ) { - bool needShow = FALSE; - + QWidget *d = this; unsigned int oldstate = windowState(); - if ( isTopLevel() ) { - QTLWExtra * top = topData(); + if (oldstate == newstate) + return; - if ( ( oldstate & WindowMaximized ) != ( newstate & WindowMaximized ) ) { - if ( ! ( newstate & WindowFullScreen ) ) { - if ( newstate & WindowMaximized ) { - // save original geometry - const QRect normalGeometry = geometry(); - - if ( isVisible() ) { - updateFrameStrut(); - const QRect maxRect = QApplication::desktop() ->availableGeometry( this ); - const QRect r = top->normalGeometry; - setGeometry( maxRect.x() + top->fleft, - maxRect.y() + top->ftop, - maxRect.width() - top->fleft - top->fright, - maxRect.height() - top->ftop - top->fbottom ); - top->normalGeometry = r; + int max = SW_MAXIMIZE; + int min = SW_MINIMIZE; + int normal = SW_SHOWNOACTIVATE; + if (newstate & Qt::WindowActive) { + max = SW_SHOWMAXIMIZED; + min = SW_SHOWMINIMIZED; + normal = SW_SHOWNORMAL; + } + + if (isTopLevel()) { + + // Ensure the initial size is valid, since we store it as normalGeometry below. + if (!isVisible()) + adjustSize(); + + if ((oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized)) { + if (newstate & Qt::WindowMaximized && !(oldstate & Qt::WindowFullScreen)) + d->topData()->normalGeometry = geometry(); + if (isVisible() && !(newstate & Qt::WindowMinimized)) { + ShowWindow(winId(), (newstate & Qt::WindowMaximized) ? max : normal); + if (!(newstate & Qt::WindowFullScreen)) { + QRect r = d->topData()->normalGeometry; + if (!(newstate & Qt::WindowMaximized) && r.width() >= 0) { + if (pos() != r.topLeft() || size() !=r.size()) { + d->topData()->normalGeometry = QRect(0,0,-1,-1); + setGeometry(r); + } } - - if ( top->normalGeometry.width() < 0 ) - top->normalGeometry = normalGeometry; } else { - // restore original geometry - setGeometry( top->normalGeometry ); + d->updateFrameStrut(); } } } - if ( ( oldstate & WindowFullScreen ) != ( newstate & WindowFullScreen ) ) { - needShow = isVisible(); - - if ( newstate & WindowFullScreen ) { - const QRect normalGeometry = QRect( pos(), size() ); + if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) { + if (newstate & Qt::WindowFullScreen) { + if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized)) + d->topData()->normalGeometry = geometry(); + d->topData()->savedFlags = GetWindowLongA(winId(), GWL_STYLE); + UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP; + if (isVisible()) + style |= WS_VISIBLE; + SetWindowLongA(winId(), GWL_STYLE, style); + QRect r = qApp->desktop()->screenGeometry(this); + UINT swpf = SWP_FRAMECHANGED; + if (newstate & Qt::WindowActive) + swpf |= SWP_NOACTIVATE; - top->savedFlags = getWFlags(); - reparent( 0, WType_TopLevel | WStyle_Customize | WStyle_NoBorder | - // preserve some widget flags - ( getWFlags() & 0xffff0000 ), - mapToGlobal( QPoint( 0, 0 ) ) ); - const QRect r = top->normalGeometry; - setGeometry( qApp->desktop() ->screenGeometry( this ) ); - top->normalGeometry = r; - - if ( top->normalGeometry.width() < 0 ) - top->normalGeometry = normalGeometry; + SetWindowPos(winId(), HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf); + d->updateFrameStrut(); } else { - reparent( 0, top->savedFlags, mapToGlobal( QPoint( 0, 0 ) ) ); - - if ( newstate & WindowMaximized ) { - // from fullscreen to maximized - updateFrameStrut(); - const QRect maxRect = QApplication::desktop() ->availableGeometry( this ); - const QRect r = top->normalGeometry; - setGeometry( maxRect.x() + top->fleft, - maxRect.y() + top->ftop, - maxRect.width() - top->fleft - top->fright, - maxRect.height() - top->ftop - top->fbottom ); - top->normalGeometry = r; - } else { - // restore original geometry - setGeometry( top->normalGeometry ); + UINT style = d->topData()->savedFlags; + if (isVisible()) + style |= WS_VISIBLE; + SetWindowLongA(winId(), GWL_STYLE, style); + + UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE; + if (newstate & Qt::WindowActive) + swpf |= SWP_NOACTIVATE; + SetWindowPos(winId(), 0, 0, 0, 0, 0, swpf); + d->updateFrameStrut(); + + // preserve maximized state + if (isVisible()) + ShowWindow(winId(), (newstate & Qt::WindowMaximized) ? max : normal); + + if (!(newstate & Qt::WindowMaximized)) { + QRect r = d->topData()->normalGeometry; + d->topData()->normalGeometry = QRect(0,0,-1,-1); + if (r.isValid()) + setGeometry(r); } } } - if ( ( oldstate & WindowMinimized ) != ( newstate & WindowMinimized ) ) { - if ( isVisible() ) { - int nCmdShow; - /* Window should get minimized */ - if ( newstate & WindowMinimized ) { - /* Don't forget WindowActive ! */ - if ( newstate & WindowActive ) - nCmdShow = SW_SHOWMINIMIZED; - else - nCmdShow = SW_MINIMIZE ; - /* Window was minimized and should get maximized */ - } else if ( newstate & WindowMaximized ) { - if ( newstate & WindowActive ) - nCmdShow = SW_SHOWMAXIMIZED ; - else - nCmdShow = SW_MAXIMIZE; - /* Window was minimzed and should now be shown */ - } else { - if ( newstate & WindowActive ) - nCmdShow = SW_SHOWNORMAL ; - else - nCmdShow = SW_SHOWNOACTIVATE ; - } - ShowWindow( winId(), nCmdShow ); - } - needShow = false; + if ((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) { + if (isVisible()) + ShowWindow(winId(), (newstate & Qt::WindowMinimized) ? min : + (newstate & Qt::WindowMaximized) ? max : normal); } } + widget_state &= ~( WState_Minimized | WState_Maximized | WState_FullScreen ); if ( newstate & WindowMinimized ) widget_state |= WState_Minimized; @@ -2208,12 +2200,6 @@ if ( newstate & WindowFullScreen ) widget_state |= WState_FullScreen; - if ( needShow ) - show(); - - if ( newstate & WindowActive ) - setActiveWindow(); - QEvent e( QEvent::WindowStateChange ); QApplication::sendEvent( this, &e ); } |