Changeset 78
- Timestamp:
- Apr 2, 2006, 4:11:09 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel/qapplication_pm.cpp
r77 r78 241 241 static bool sm_cancel = FALSE; 242 242 static bool sm_gracefulShutdown = FALSE; 243 bool qt_about_to_destroy_wnd = FALSE; 243 static bool sm_quitSkipped = FALSE; 244 bool qt_about_to_destroy_wnd = FALSE; 244 245 245 246 //#define DEBUG_SESSIONMANAGER … … 1034 1035 #if !defined (QT_NO_SESSIONMANAGER) 1035 1036 case WM_SAVEAPPLICATION: { 1036 #if defined (DEBUG_SESSIONMANAGER) 1037 #if defined (DEBUG_SESSIONMANAGER) 1037 1038 qDebug( "WM_SAVEAPPLICATION: sm_gracefulShutdown=%d " 1038 "qt_about_to_destroy_wnd=%d", 1039 sm_gracefulShutdown, qt_about_to_destroy_wnd ); 1040 #endif 1039 "qt_about_to_destroy_wnd=%d (mp1=%p mp2=%p)", 1040 sm_gracefulShutdown, qt_about_to_destroy_wnd, 1041 mp1, mp2 ); 1042 #endif 1041 1043 // PM seems to post this message to all top-level windows on system 1042 1044 // shutdown, so react only to the first one. Also, this message is 1043 1045 // always sent by WinDestroyWindow(), where it must be also ignored. 1044 if ( !sm_gracefulShutdown && !qt_about_to_destroy_wnd ) { 1046 if ( !qt_about_to_destroy_wnd && !sm_smActive && 1047 !sm_gracefulShutdown ) { 1048 sm_smActive = TRUE; 1045 1049 sm_gracefulShutdown = TRUE; 1050 sm_blockUserInput = TRUE; // prevent user-interaction outside interaction windows 1051 sm_cancel = FALSE; 1052 sm_quitSkipped = FALSE; 1053 if ( qt_session_manager_self ) 1054 qApp->commitData( *qt_session_manager_self ); 1055 sm_smActive = FALSE; // session management has been finished 1056 if ( sm_cancel ) { 1057 // Here we try to cancel the Extended XWorkplace shutdown. 1058 // If it's XWorkplace who sent us WM_SAVEAPPLICATION, then 1059 // it probably passed us non-NULL parameters, so that 1060 // mp1 = it's window handle and mp2 = WM_COMMAND code to 1061 // cancel the shutdown procedure. 1062 HWND shutdownHwnd = HWNDFROMMP(mp1); 1063 if ( WinIsWindow( 0, shutdownHwnd ) ) { 1064 WinPostMsg( shutdownHwnd, WM_COMMAND, mp2, 0 ); 1065 // Ensure we will get WM_QUIT anyway, even if xwp was 1066 // not that fast to post it yet (we need it to correctly 1067 // finish the graceful shutdown procedure) 1068 sm_quitSkipped = TRUE; 1069 } 1070 } 1071 // repost WM_QUIT to ourselves because we might have ignored 1072 // it in qt_app_canQuit(), so will not get one anymore 1073 if ( sm_quitSkipped ) 1074 WinPostMsg( hwnd, WM_QUIT, 0, 0 ); 1046 1075 } 1047 1076 // PMREF recommends to pass it to WinDefWindowProc() … … 1050 1079 } 1051 1080 #endif 1052 1081 1053 1082 /// @todo (dmik) later 1054 1083 // case WM_SETTINGCHANGE: … … 1434 1463 #if 0 1435 1464 qDebug( "WM_ACTIVATE: [%s] %d", widget->name(), SHORT1FROMMP(mp1) ); 1436 #endif 1465 #endif 1437 1466 qApp->pmFocus( widget, SHORT1FROMMP(mp1) ); 1438 1467 break; 1439 1468 1440 1469 case WM_SETFOCUS: 1441 #if 0 1470 #if 0 1442 1471 qDebug( "WM_SETFOCUS: [%s] %s [%s]", widget->name(), 1443 1472 SHORT1FROMMP(mp2) ? "<=" : "=>", 1444 1473 QWidget::find( (HWND)mp1 ) ? QWidget::find( (HWND)mp1 )->name() 1445 1474 : "{foreign}" ); 1446 #endif 1475 #endif 1447 1476 result = FALSE; 1448 1477 if ( !SHORT1FROMMP(mp2) ) { … … 2278 2307 SHORT1FROMMP(qmsg.mp2), SHORT2FROMMP(qmsg.mp2) ); 2279 2308 #endif 2280 2309 2281 2310 static QPoint pos; // window pos (y flipped) 2282 2311 static POINTL gpos = { -1, -1 }; // global pos (y flipped) … … 2288 2317 // candidate for a double click event 2289 2318 static HWND dblClickCandidateWin = 0; 2290 2319 2291 2320 if ( sm_blockUserInput ) //block user interaction during session management 2292 2321 return TRUE; … … 2364 2393 dblClickCandidateWin = 0; 2365 2394 } 2366 2395 2367 2396 if ( type == QEvent::ContextMenu ) { 2368 2397 QPoint g = QPoint( qmsg.ptl.x, qmsg.ptl.y ); … … 2407 2436 // otherwise the specified window gets it unless it is already under the 2408 2437 // pointer. We use this info to check whether the window can be a double 2409 // click candidate (see above). 2438 // click candidate (see above). 2410 2439 if ( qmsg.ptl.x == gpos.x && qmsg.ptl.y == gpos.y ) { 2411 2440 if ( dblClickCandidateWin != qmsg.hwnd ) … … 2547 2576 QMouseEvent e( type, pos, QPoint(gpos.x,gpos.y), button, state ); 2548 2577 QApplication::sendSpontaneousEvent( widget, &e ); 2549 2578 2550 2579 if ( type != QEvent::MouseMove ) 2551 2580 pos.rx() = pos.ry() = -9999; // init for move compression … … 3115 3144 bool QETWidget::translatePaintEvent( const QMSG & ) 3116 3145 { 3117 HPS displayPS = qt_display_ps(); 3118 3146 HPS displayPS = qt_display_ps(); 3147 3119 3148 #if !defined (QT_PM_NO_WIDGETMASK) 3120 3149 // Since we don't use WS_CLIPSIBLINGS and WS_CLIPCHILDREN bits (see … … 3123 3152 validateObstacles(); 3124 3153 #endif 3125 3154 3126 3155 HRGN hrgn = GpiCreateRegion( displayPS, 0, NULL ); 3127 3156 LONG rc = WinQueryUpdateRegion( winId(), hrgn ); … … 3161 3190 } 3162 3191 #endif 3163 3192 3164 3193 // flip y coordinate 3165 3194 rcl.yBottom = height() - (rcl.yBottom + rcl.yTop); … … 3252 3281 // need to move a non top-level window of a foreign process?). 3253 3282 Q_ASSERT( isTopLevel() ); 3254 #endif 3283 #endif 3255 3284 if ( isVisible() ) { 3256 3285 QResizeEvent e( newSize, oldSize ); … … 3430 3459 bool qt_app_canQuit() 3431 3460 { 3432 #if defined (DEBUG_SESSIONMANAGER) 3461 #if defined (DEBUG_SESSIONMANAGER) 3433 3462 qDebug( "qt_app_canQuit(): sm_smActive=%d qt_about_to_destroy_wnd=%d " 3434 3463 "sm_gracefulShutdown=%d sm_cancel=%d", 3435 3464 sm_smActive, qt_about_to_destroy_wnd, 3436 sm_gracefulShutdown, sm_cancel ); 3465 sm_gracefulShutdown, sm_cancel ); 3437 3466 #endif 3438 3467 … … 3443 3472 // progress. Ignore them. 3444 3473 if ( !sm_smActive ) { 3445 sm_smActive = TRUE; 3446 sm_blockUserInput = TRUE; // prevent user-interaction outside interaction windows 3447 sm_cancel = FALSE; 3448 if ( qt_session_manager_self ) 3449 qApp->commitData( *qt_session_manager_self ); 3450 sm_smActive = FALSE; 3451 sm_gracefulShutdown = FALSE; 3452 answer = !sm_cancel; 3453 } 3454 3455 #if defined (DEBUG_SESSIONMANAGER) 3474 if ( sm_gracefulShutdown ) { 3475 // this is WM_QUIT after WM_SAVEAPPLICATION (either posted by the OS 3476 // or by ourselves), confirm the quit depending on what the user wants 3477 sm_quitSkipped = FALSE; 3478 answer = !sm_cancel; 3479 if ( sm_cancel ) { 3480 // the shutdown has been canceled, reset the flag to let the 3481 // graceful shutdown happen again later 3482 sm_gracefulShutdown = FALSE; 3483 } 3484 } else { 3485 // sm_gracefulShutdown is FALSE, so allowsInteraction() and friends 3486 // will return FALSE during commitData() (assuming that WM_QUIT w/o 3487 // WM_SAVEAPPLICATION is an emergency termination) 3488 sm_smActive = TRUE; 3489 sm_blockUserInput = TRUE; // prevent user-interaction outside interaction windows 3490 sm_cancel = FALSE; 3491 if ( qt_session_manager_self ) 3492 qApp->commitData( *qt_session_manager_self ); 3493 sm_smActive = FALSE; 3494 answer = TRUE; // ignore sm_cancel 3495 } 3496 } else { 3497 // if this is a WM_QUIT received during WM_SAVEAPPLICATION handling, 3498 // remember we've skipped (refused) it 3499 if ( sm_gracefulShutdown ) 3500 sm_quitSkipped = TRUE; 3501 } 3502 3503 #if defined (DEBUG_SESSIONMANAGER) 3456 3504 qDebug( "qt_app_canQuit(): answer=%ld", answer ); 3457 3505 #endif
Note:
See TracChangeset
for help on using the changeset viewer.