diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-07-29 13:48:46 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-07-30 07:23:58 (GMT) |
commit | f752633b878840634ca374fb9c1e8755aa1fd886 (patch) | |
tree | 60bfc935f1d9b04998e01e10c34834b285415d56 /src/gui | |
parent | 15ccaa0995da2061009d269fa875e8601da1a3c8 (diff) | |
download | Qt-f752633b878840634ca374fb9c1e8755aa1fd886.zip Qt-f752633b878840634ca374fb9c1e8755aa1fd886.tar.gz Qt-f752633b878840634ca374fb9c1e8755aa1fd886.tar.bz2 |
Unable to change focus between two line edits on mac
This is because we try to decide whether the window cocoa tells
us to be active should be active, and if we desagree, we do nothing.
The result is that Qt and Cocoa ends up in different states.
I decided to remove a lot of the logic that went on in this case, and
the resons is:
1. By checking the callplaces to
onApplicationWindowChangedActivation, we know that we always have a
valid widget pointer, and we know that the widget always is a window
(otherwise Cocoa would never tell us that the widget got active).
2. We can never end up doing nothing in this response. The best
we can do is to follow what Cocoa tells us. If this turns out to
break something, it would probably be better to check why we get an
activation call in the first place for a window that should not be
activated (e.g. is canBecomeKeyWindow set correctly?)
Task: 253610
RevBy: msorvig
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qapplication_mac.mm | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 0d86c8e..be23949 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -1481,6 +1481,7 @@ QWidget *QApplicationPrivate::tryModalHelper_sys(QWidget *top) return top; } +#ifndef QT_MAC_USE_COCOA static bool qt_try_modal(QWidget *widget, EventRef event) { QWidget * top = 0; @@ -1514,6 +1515,7 @@ static bool qt_try_modal(QWidget *widget, EventRef event) #endif return !block_event; } +#endif OSStatus QApplicationPrivate::tabletProximityCallback(EventHandlerCallRef, EventRef carbonEvent, void *) @@ -2894,52 +2896,25 @@ bool QApplicationPrivate::canQuit() #endif } -void onApplicationWindowChangedActivation( QWidget*widget, bool activated ) +void onApplicationWindowChangedActivation(QWidget *widget, bool activated) { #if QT_MAC_USE_COCOA - QApplication *app = qApp; + if (!widget) + return; - if ( activated ) - { - if (QApplicationPrivate::app_style) - { + if (activated) { + if (QApplicationPrivate::app_style) { QEvent ev(QEvent::Style); qt_sendSpontaneousEvent(QApplicationPrivate::app_style, &ev); } - - if (widget && app_do_modal && !qt_try_modal(widget, NULL)) - return; - - if (widget && widget->window()->isVisible()) - { - QWidget *tlw = widget->window(); - - if (tlw->isWindow() && !(tlw->windowType() == Qt::Popup) - && !qt_mac_is_macdrawer(tlw) - && (!tlw->parentWidget() || tlw->isModal() || !(tlw->windowType() == Qt::Tool))) { - bool just_send_event = false; -#if 0 - WindowActivationScope scope; - if ( GetWindowActivationScope((OSWindowRef)wid, &scope) == noErr && - scope == kWindowActivationScopeIndependent) - { - if ( GetFrontWindowOfClass(kAllWindowClasses, true) != wid ) - just_send_event = true; - } -#endif - if (just_send_event) { - QEvent e(QEvent::WindowActivate); - qt_sendSpontaneousEvent(widget, &e); - } else { - app->setActiveWindow(tlw); - } - } - } + qApp->setActiveWindow(widget); } else { // deactivated - if (widget && QApplicationPrivate::active_window == widget) - app->setActiveWindow(0); + if (QApplicationPrivate::active_window == widget) + qApp->setActiveWindow(0); } + QMenuBar::macUpdateMenuBar(); + #else Q_UNUSED(widget); Q_UNUSED(activated); |