- Timestamp:
- Aug 27, 2009, 1:32:24 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qapplication_pm.cpp
r122 r133 439 439 QWidget *QApplication::topLevelAt(const QPoint &pos) 440 440 { 441 // @todo implement 442 return 0; 441 // flip y coordinate 442 int y = desktop()->height() - (pos.y() + 1); 443 POINTL ptl = { pos.x(), y }; 444 HWND hwnd = WinWindowFromPoint(HWND_DESKTOP, &ptl, FALSE); 445 if (hwnd == NULLHANDLE) 446 return 0; 447 448 QWidget *w = qWidgetFromHWND(hwnd); 449 return w ? w->window() : 0; 443 450 } 444 451 … … 932 939 void QApplicationPrivate::openPopup(QWidget *popup) 933 940 { 934 // @todo implement 941 if (!QApplicationPrivate::popupWidgets) 942 QApplicationPrivate::popupWidgets = new QWidgetList; 943 QApplicationPrivate::popupWidgets->append(popup); 944 if (!popup->isEnabled()) 945 return; 946 947 if (QApplicationPrivate::popupWidgets->count() == 1 && !qt_nograb()) { 948 Q_ASSERT(popup->testAttribute(Qt::WA_WState_Created)); 949 setAutoCapture(popup->d_func()->frameWinId()); // grab mouse/keyboard 950 } 951 // Popups are not focus-handled by the window system (the first 952 // popup grabbed the keyboard), so we have to do that manually: A 953 // new popup gets the focus 954 if (popup->focusWidget()) { 955 popup->focusWidget()->setFocus(Qt::PopupFocusReason); 956 } else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup 957 if (QWidget *fw = q_func()->focusWidget()) { 958 QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); 959 q_func()->sendEvent(fw, &e); 960 } 961 } 935 962 } 936 963 937 964 void QApplicationPrivate::closePopup(QWidget *popup) 938 965 { 939 // @todo implement 966 if (!QApplicationPrivate::popupWidgets) 967 return; 968 QApplicationPrivate::popupWidgets->removeAll(popup); 969 POINTL curPos; 970 WinQueryPointerPos(HWND_DESKTOP, &curPos); 971 // flip y coordinate 972 curPos.y = q_func()->desktop()->height() - (curPos.y + 1); 973 974 if (QApplicationPrivate::popupWidgets->isEmpty()) { // this was the last popup 975 delete QApplicationPrivate::popupWidgets; 976 QApplicationPrivate::popupWidgets = 0; 977 replayPopupMouseEvent = (!popup->geometry().contains(QPoint(curPos.x, curPos.y)) 978 && !popup->testAttribute(Qt::WA_NoMouseReplay)); 979 if (!popup->isEnabled()) 980 return; 981 if (!qt_nograb()) // grabbing not disabled 982 releaseAutoCapture(); 983 QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget() 984 : q_func()->focusWidget(); 985 if (fw) { 986 if (fw != q_func()->focusWidget()) { 987 fw->setFocus(Qt::PopupFocusReason); 988 } else { 989 QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); 990 q_func()->sendEvent(fw, &e); 991 } 992 } 993 } else { 994 // Popups are not focus-handled by the window system (the 995 // first popup grabbed the keyboard), so we have to do that 996 // manually: A popup was closed, so the previous popup gets 997 // the focus. 998 QWidget* aw = QApplicationPrivate::popupWidgets->last(); 999 if (QApplicationPrivate::popupWidgets->count() == 1) { 1000 Q_ASSERT(aw->testAttribute(Qt::WA_WState_Created)); 1001 setAutoCapture(aw->internalWinId()); 1002 } 1003 if (QWidget *fw = aw->focusWidget()) 1004 fw->setFocus(Qt::PopupFocusReason); 1005 } 940 1006 } 941 1007
Note:
See TracChangeset
for help on using the changeset viewer.