diff --git a/examples/widgets/mainwindows/mdi/mdi.pro b/examples/widgets/mainwindows/mdi/mdi.pro index 2e3c232..6c03693 100644 --- a/examples/widgets/mainwindows/mdi/mdi.pro +++ b/examples/widgets/mainwindows/mdi/mdi.pro @@ -6,7 +6,7 @@ SOURCES = main.cpp \ mainwindow.cpp \ mdichild.cpp RESOURCES = mdi.qrc - +CONFIG+=console # install target.path = $$[QT_INSTALL_EXAMPLES]/widgets/mainwindows/mdi INSTALLS += target diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 13da58e..5b9d604 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1573,6 +1573,7 @@ bool QWindow::setKeyboardGrabEnabled(bool grab) Q_D(QWindow); if (grab && QGuiApplicationPrivate::noGrab) return false; + qDebug() << __FUNCTION__ << this << grab; if (d->platformWindow) return d->platformWindow->setKeyboardGrabEnabled(grab); return false; @@ -1590,6 +1591,7 @@ bool QWindow::setKeyboardGrabEnabled(bool grab) bool QWindow::setMouseGrabEnabled(bool grab) { Q_D(QWindow); + qDebug() << __FUNCTION__ << this << grab << "plw" << d->platformWindow; if (grab && QGuiApplicationPrivate::noGrab) return false; if (d->platformWindow) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ed376fe..beed9ae 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2431,6 +2431,7 @@ QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint Qt::MouseButtons buttons, QWidget *buttonDown, QWidget *alienWidget) { + qDebug() << __FUNCTION__ << "candidate" << candidate << "buttonDown" << buttonDown; Q_ASSERT(candidate); QWidget *mouseGrabber = QWidget::mouseGrabber(); @@ -2444,16 +2445,20 @@ QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint QWidget *receiver = candidate; - if (!mouseGrabber) + if (!mouseGrabber) { mouseGrabber = (buttonDown && !isBlockedByModal(buttonDown)) ? buttonDown : alienWidget; + qDebug() << __FUNCTION__ << "if (!mouseGrabber): " << mouseGrabber; + } if (mouseGrabber && mouseGrabber != candidate) { receiver = mouseGrabber; + qDebug() << __FUNCTION__ << "Assigning mouseGrabber: " << receiver; *pos = receiver->mapFromGlobal(candidate->mapToGlobal(windowPos)); #ifdef ALIEN_DEBUG qDebug() << " ** receiver adjusted to:" << receiver << "pos:" << pos; #endif } + qDebug() << __FUNCTION__ << candidate << receiver; return receiver; @@ -2756,6 +2761,7 @@ bool QApplicationPrivate::shouldQuit() static inline void closeAllPopups() { + qDebug() << __FUNCTION__ ; // Close all popups: In case some popup refuses to close, // we give up after 1024 attempts (to avoid an infinite loop). int maxiter = 1024; @@ -2882,6 +2888,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) case QEvent::ApplicationDeactivate: // Close all popups (triggers when switching applications // by pressing ALT-TAB on Windows, which is not receive as key event. + qDebug() << __FUNCTION__ << "Deactivate"; closeAllPopups(); break; case QEvent::Wheel: // User input and window activation makes tooltips sleep diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index 2f6e8ac..8c7704a 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -176,6 +176,7 @@ static void grabForPopup(QWidget *popup) void QApplicationPrivate::closePopup(QWidget *popup) { + qDebug() << __FUNCTION__ << popup; if (!popupWidgets) return; popupWidgets->removeAll(popup); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c2f7a9b..f7c0cdd 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2219,8 +2219,10 @@ void QWidgetPrivate::deactivateWidgetCleanup() if (QApplication::activeWindow() == q) QApplication::setActiveWindow(0); // If the is the active mouse press widget, reset it - if (q == qt_button_down) + if (q == qt_button_down) { + qDebug() << __FUNCTION__ << "clearing" << qt_button_down; qt_button_down = 0; + } } diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 85ae55b..8f5a7d2 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -405,6 +405,7 @@ void QWidget::grabMouse() if (QWindow *window = grabberWindow(this)) window->setMouseGrabEnabled(true); + qDebug() << __FUNCTION__ << this; qt_mouseGrb = this; qt_pressGrab = 0; @@ -423,12 +424,16 @@ bool QWidgetPrivate::stealMouseGrab(bool grab) // This is like a combination of grab/releaseMouse() but with error checking // and it has no effect on the result of mouseGrabber(). Q_Q(QWidget); + qDebug() << __FUNCTION__ << q << grab; + if (q->objectName()== QLatin1String("EditMenu")) + qDebug("EditMenu grabs!"); QWindow *window = grabberWindow(q); return window ? window->setMouseGrabEnabled(grab) : false; } void QWidget::releaseMouse() { + qDebug() << __FUNCTION__ << this ; if (qt_mouseGrb == this) { if (QWindow *window = grabberWindow(this)) window->setMouseGrabEnabled(false); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index ef13826..bc49686 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -486,8 +486,10 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) if (!widget) widget = m_widget; - if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) + if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) { + qDebug() << "Assigning qt_button_down" << widget << (event->type() == QEvent::MouseButtonDblClick ? "DBL" :"SINGLE"); qt_button_down = widget; + } QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(), qt_button_down, widget); diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index eb93e46..afa3ab9 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -442,6 +442,7 @@ void QMenuPrivate::hideUpToMenuBar() while(caused) { #ifndef QT_NO_MENUBAR if (QMenuBar *mb = qobject_cast(caused)) { + qDebug() << __FUNCTION__ << "Clearing menubar"; mb->d_func()->setCurrentAction(0); mb->d_func()->setKeyboardMode(false); caused = 0; @@ -2217,8 +2218,10 @@ void QMenu::hideEvent(QHideEvent *) QAccessible::updateAccessibility(&event); #endif #ifndef QT_NO_MENUBAR - if (QMenuBar *mb = qobject_cast(d->causedPopup.widget)) + if (QMenuBar *mb = qobject_cast(d->causedPopup.widget)) { + qDebug() << __FUNCTION__ << "Clearing menubar"; mb->d_func()->setCurrentAction(0); + } #endif d->mouseDown = 0; d->hasHadMouse = false; @@ -2738,6 +2741,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) d->hideMenu(this); // hide after getting causedPopup #ifndef QT_NO_MENUBAR if (QMenuBar *mb = qobject_cast(caused)) { + qDebug() << __FUNCTION__ << "setting menubar" << d->menuAction; mb->d_func()->setCurrentAction(d->menuAction); mb->d_func()->setKeyboardMode(true); } diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 03ab490..fe09f36 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include #ifndef QT_NO_ACCESSIBILITY # include @@ -274,8 +276,10 @@ void QMenuBarPrivate::focusFirstAction() updateGeometries(); int index = 0; while (index < actions.count() && actionRects.at(index).isNull()) ++index; - if (index < actions.count()) + if (index < actions.count()) { + qDebug() << __FUNCTION__ << "set"<menu() || closePopupMode) return; + qDebug() << __FUNCTION__ << "popupState = true"; popupState = true; if (action->isEnabled() && action->menu()->isEnabled()) { closePopupMode = 0; @@ -359,6 +364,7 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst) void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activateFirst) { + qDebug() << __FUNCTION__ << action << popup << activateFirst; if(currentAction == action && popup == popupState) return; @@ -379,6 +385,7 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat if(currentAction) q->update(actionRect(currentAction)); + qDebug() << __FUNCTION__ << "popupState = " << popup; popupState = popup; #ifndef QT_NO_STATUSTIP QAction *previousAction = currentAction; @@ -904,6 +911,7 @@ QAction *QMenuBar::activeAction() const void QMenuBar::setActiveAction(QAction *act) { Q_D(QMenuBar); + qDebug() << __FUNCTION__ << "set"<setCurrentAction(act, true, false); } @@ -1034,13 +1042,15 @@ void QMenuBar::setVisible(bool visible) */ void QMenuBar::mousePressEvent(QMouseEvent *e) { - Q_D(QMenuBar); + Q_D(QMenuBar); if(e->button() != Qt::LeftButton) return; d->mouseDown = true; QAction *action = d->actionAt(e->pos()); + qDebug() << __FUNCTION__ << e << "action" << action + << "curAction" << d->currentAction << "d->popupState" << d->popupState ; if (!action || !d->isVisible(action)) { d->setCurrentAction(0); #ifndef QT_NO_WHATSTHIS @@ -1051,12 +1061,14 @@ void QMenuBar::mousePressEvent(QMouseEvent *e) } if(d->currentAction == action && d->popupState) { + qDebug() << __FUNCTION__ << "d->popupState , closing" << d->activeMenu; if(QMenu *menu = d->activeMenu) { d->activeMenu = 0; menu->hide(); d->closePopupMode = 1; } } else { + qDebug() << __FUNCTION__ << "setCurrentAction" << action; d->setCurrentAction(action, true); } } @@ -1075,6 +1087,7 @@ void QMenuBar::mouseReleaseEvent(QMouseEvent *e) if((d->closePopupMode && action == d->currentAction) || !action || !action->menu()) { //we set the current action before activating //so that we let the leave event set the current back to 0 + qDebug() << __FUNCTION__ << "setCurrentAction" << action; d->setCurrentAction(action, false); if(action) d->activateAction(action, QAction::Trigger); @@ -1197,8 +1210,10 @@ void QMenuBar::mouseMoveEvent(QMouseEvent *e) d->mouseDown = false; bool popupState = d->popupState || d->mouseDown; QAction *action = d->actionAt(e->pos()); - if ((action && d->isVisible(action)) || !popupState) + if ((action && d->isVisible(action)) || !popupState) { + qDebug() << __FUNCTION__ << "setCurrentAction" << action << popupState; d->setCurrentAction(action, popupState); + } } /*! @@ -1311,9 +1326,10 @@ void QMenuBar::focusInEvent(QFocusEvent *) /*! \reimp */ -void QMenuBar::focusOutEvent(QFocusEvent *) +void QMenuBar::focusOutEvent(QFocusEvent *f) { Q_D(QMenuBar); + qDebug() << __FUNCTION__ << f; if(!d->popupState) { d->setCurrentAction(0); d->setKeyboardMode(false); @@ -1327,6 +1343,7 @@ void QMenuBar::timerEvent (QTimerEvent *e) { Q_D(QMenuBar); if (e->timerId() == d->autoReleaseTimer.timerId()) { + qDebug() << __FUNCTION__ ; d->autoReleaseTimer.stop(); d->setCurrentAction(0); }