summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qt_cocoa_helpers_mac.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-02-09 09:39:37 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-02-10 09:14:33 (GMT)
commit8b112609b7d86572fbb41dc59354da1f958d1910 (patch)
tree4304da66aef9ab4245decf1009752cff6eac1b9b /src/gui/kernel/qt_cocoa_helpers_mac.mm
parent2a1bf99770401576f451806b2e2a8c73853ca99b (diff)
downloadQt-8b112609b7d86572fbb41dc59354da1f958d1910.zip
Qt-8b112609b7d86572fbb41dc59354da1f958d1910.tar.gz
Qt-8b112609b7d86572fbb41dc59354da1f958d1910.tar.bz2
Cocoa: Menu in menubar stays highlighted
If you use the menu bar for a window to open up another window woth no menu bar, the first menu bar stays highlighted once it is set as current again. The reason is that we remove the first menu bar before cocoa gets a chance to update it correctly. This patch implements a system for us to post a message/call to cocoa, so we delay removing the toolbar until after cocoa has finished closing it properly. NB: Rather than posting the call to a window on screen, it would have been better and safer to post it no window, and then receive the event in the event handler of NSApplication. But for the moment, we have decided not to subclass NSApplication... Rev-By:prasanth
Diffstat (limited to 'src/gui/kernel/qt_cocoa_helpers_mac.mm')
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 377e5a0..74514a0 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -1281,6 +1281,30 @@ void qt_cocoaChangeOverrideCursor(const QCursor &cursor)
}
#endif
+bool qt_cocoaPostMessage(id target, SEL selector)
+{
+ if (!target)
+ return false;
+ NSWindow *nswin = [NSApp mainWindow];
+ if (!nswin) {
+ nswin = [NSApp keyWindow];
+ if (!nswin)
+ return false;
+ }
+
+ // WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5!
+ // That is why we need to split the address in two parts:
+ QCocoaPostCallArgs *args = new QCocoaPostCallArgs(target, selector);
+ quint32 lower = quintptr(args);
+ quint32 upper = quintptr(args) >> 32;
+ NSEvent *e = [NSEvent otherEventWithType:NSApplicationDefined
+ location:NSZeroPoint modifierFlags:0 timestamp:0
+ windowNumber:[nswin windowNumber]
+ context:nil subtype:QtCocoaEventSubTypePostMessage data1:lower data2:upper];
+ [NSApp postEvent:e atStart:NO];
+ return true;
+}
+
@implementation DebugNSApplication {
}
- (void)sendEvent:(NSEvent *)event