Changeset 432 for trunk/src/gui/kernel
- Timestamp:
- Dec 18, 2009, 2:36:30 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qapplication_pm.cpp
r428 r432 110 110 QPointer<QWidget> qt_last_mouse_receiver = 0; 111 111 112 static HWND foreignActiveWnd = NULLHANDLE; 113 static HWND foreignFocusWnd = NULLHANDLE; 114 112 115 static HWND autoCaptureWnd = NULLHANDLE; 113 116 static bool autoCaptureReleased = FALSE; … … 1016 1019 } 1017 1020 1018 case WM_ SETFOCUS: {1021 case WM_FOCUSCHANGE: { 1019 1022 HWND hwnd = (HWND)mp1; 1020 1023 bool focus = SHORT1FROMMP(mp2); … … 1023 1026 // we don't get focus, so unset it now 1024 1027 if (QApplication::activePopupWidget()) { 1028 foreignFocusWnd = hwnd; 1025 1029 // Another application was activated while our popups are open, 1026 1030 // then close all popups. In case some popup refuses to close, … … 1437 1441 return; 1438 1442 1439 if (QApplicationPrivate::popupWidgets->count() == 1 && !qt_nograb()) { 1440 Q_ASSERT(popup->testAttribute(Qt::WA_WState_Created)); 1441 setAutoCapture(popup->d_func()->frameWinId()); // grab mouse/keyboard 1442 } 1443 if (QApplicationPrivate::popupWidgets->count() == 1) { 1444 if (!qt_nograb()) { 1445 Q_ASSERT(popup->testAttribute(Qt::WA_WState_Created)); 1446 setAutoCapture(popup->d_func()->frameWinId()); // grab mouse/keyboard 1447 } 1448 if (!qWidgetFromHWND(WinQueryActiveWindow(HWND_DESKTOP))) { 1449 // the popup is opened while another application is active. Steal 1450 // the focus (to receive keyboard input and to make sure we get 1451 // WM_FOCUSCHANGE when clicked outside) but not the active state. 1452 ULONG flags = FC_NOSETACTIVE | FC_NOLOSEACTIVE; 1453 WinFocusChange(HWND_DESKTOP, popup->d_func()->frameWinId(), flags); 1454 foreignActiveWnd = WinQueryActiveWindow(HWND_DESKTOP); 1455 } 1456 } 1457 1443 1458 // Popups are not focus-handled by the window system (the first 1444 1459 // popup grabbed the keyboard), so we have to do that manually: A … … 1464 1479 curPos.y = q_func()->desktop()->height() - (curPos.y + 1); 1465 1480 1466 if (QApplicationPrivate::popupWidgets->isEmpty()) { // this was the last popup 1481 if (QApplicationPrivate::popupWidgets->isEmpty()) { 1482 // this was the last popup 1483 if (foreignActiveWnd != NULLHANDLE && foreignFocusWnd != NULLHANDLE) { 1484 // we stole focus from another application so PM won't send it 1485 // WM_ACTIVATE(FALSE). Our duty is to do it for PM. 1486 HWND parent, desktop = WinQueryDesktopWindow(0, NULLHANDLE); 1487 // find the top-level window of the window actually getting focus 1488 while ((parent = WinQueryWindow(foreignFocusWnd, QW_PARENT)) != desktop) 1489 foreignFocusWnd = parent; 1490 // send deactivation to the old active window if it differs 1491 if (foreignFocusWnd != foreignActiveWnd) 1492 WinSendMsg(foreignActiveWnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)foreignActiveWnd); 1493 } 1494 foreignActiveWnd = NULLHANDLE; 1495 foreignFocusWnd = NULLHANDLE; 1496 1467 1497 delete QApplicationPrivate::popupWidgets; 1468 1498 QApplicationPrivate::popupWidgets = 0; … … 2553 2583 HWND hwnd = (HWND)qmsg.mp2; 2554 2584 str += QCStr(" Active(") + QCStr(active ? "TRUE) " : "FALSE)"); 2555 str += QString().sprintf(" hwnd %08lX.", hwnd);2585 str += QString().sprintf(" hwndActive %08lX.", hwnd); 2556 2586 str += qWidgetName(qWidgetFromHWND(hwnd)); 2557 2587 break; … … 2562 2592 bool focus = SHORT1FROMMP(qmsg.mp2); 2563 2593 str += QCStr(" Focus(") + QCStr(focus ? "TRUE) " : "FALSE)"); 2564 str += QString().sprintf(" hwnd %08lX.", hwnd);2594 str += QString().sprintf(" hwndFocus %08lX.", hwnd); 2565 2595 str += qWidgetName(qWidgetFromHWND(hwnd)); 2596 break; 2597 myCaseEnd() 2598 2599 myCaseBegin(WM_FOCUSCHANGE) 2600 HWND hwnd = (HWND)qmsg.mp1; 2601 bool focus = SHORT1FROMMP(qmsg.mp2); 2602 bool fl = SHORT2FROMMP(qmsg.mp2); 2603 QString flstr; 2604 myDefFlagEx(fl, FC_NOSETFOCUS, flstr, "NOSETFCS"); 2605 myDefFlagEx(fl, FC_NOLOSEFOCUS, flstr, "NOLOSEFCS"); 2606 myDefFlagEx(fl, FC_NOSETACTIVE, flstr, "NOSETACT"); 2607 myDefFlagEx(fl, FC_NOLOSEACTIVE, flstr, "NOLOSEACT"); 2608 myDefFlagEx(fl, FC_NOSETSELECTION, flstr, "NOSETSEL"); 2609 myDefFlagEx(fl, FC_NOLOSESELECTION, flstr, "NOSETSEL"); 2610 str += QCStr(" Focus(") + QCStr(focus ? "TRUE) " : "FALSE)"); 2611 str += QString().sprintf(" hwndFocus %08lX.", hwnd); 2612 str += qWidgetName(qWidgetFromHWND(hwnd)); 2613 str += QCStr(" FC(") + flstr + QCStr(")"); 2566 2614 break; 2567 2615 myCaseEnd()
Note:
See TracChangeset
for help on using the changeset viewer.