]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/utils.mm
Fix discrepancy between different ways of measuring text extents under Mac.
[wxWidgets.git] / src / osx / cocoa / utils.mm
index 3fdecac375f7bd83ea8a996eacdfaf4a3aed5cba..8d74b22883bea2e67eeb82301d8593aaa3fb5176 100644 (file)
@@ -52,7 +52,27 @@ void wxBell()
 
 void wxMacWakeUp()
 {
-    // TODO
+    // ensure that we have an auto release pool in place because the event will
+    // be autoreleased from NSEvent:otherEventWithType and we might not have a
+    // global pool during startup or shutdown and we actually never have it if
+    // we're called from another thread
+    //
+    // FIXME: we can't use wxMacAutoreleasePool here because it's in core and
+    //        we're in base
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    NSEvent* wakeupEvent = [NSEvent otherEventWithType:NSApplicationDefined
+                                    location:NSZeroPoint
+                                    modifierFlags:NSAnyEventMask
+                                    timestamp:0
+                                    windowNumber:0
+                                    context:nil
+                                    subtype:0
+                                    data1:0
+                                    data2:0];
+    [NSApp postEvent:wakeupEvent atStart:NO];
+
+    [pool release];
 }
 
 #endif // wxUSE_BASE
@@ -146,9 +166,9 @@ void wxMacWakeUp()
 }
 @end
 
-/* 
+/*
     allows ShowModal to work when using sheets.
-    see include/wx/osx/cocoa/private.h for more info 
+    see include/wx/osx/cocoa/private.h for more info
 */
 @implementation ModalDialogDelegate
 - (id)init
@@ -159,7 +179,7 @@ void wxMacWakeUp()
     return self;
 }
 
-- (BOOL)finished 
+- (BOOL)finished
 {
     return sheetFinished;
 }
@@ -298,7 +318,7 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
     // called from OnPaint, even with the window's paint dc as source (see wxHTMLWindow)
     NSBitmapImageRep *rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect: [view bounds]] retain];
     [view unlockFocus];
-    
+
     wxBitmap bitmap(width, height);
     if ( [rep respondsToSelector:@selector(CGImage)] )
     {
@@ -321,4 +341,4 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
 
 #endif // wxUSE_GUI
 
-#endif // wxOSX_USE_COCOA
\ No newline at end of file
+#endif // wxOSX_USE_COCOA