[gtk+] Bug 655074 - Fix crash with undecorated windows on MacOS Lion



commit 786521d5a818019e5841d209a76ea27ba777125c
Author: Michael Hutchinson <m j hutchinson gmail com>
Date:   Mon Jul 25 10:29:23 2011 +0200

    Bug 655074 - Fix crash with undecorated windows on MacOS Lion

 gdk/quartz/gdkwindow-quartz.c |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index a6fc4ed..5dac054 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -2559,10 +2559,6 @@ gdk_quartz_window_set_decorations (GdkWindow       *window,
 
   old_mask = [impl->toplevel styleMask];
 
-  /* Note, there doesn't seem to be a way to change this without
-   * recreating the toplevel. There might be bad side-effects of doing
-   * that, but it seems alright.
-   */
   if (old_mask != new_mask)
     {
       NSRect rect;
@@ -2586,15 +2582,28 @@ gdk_quartz_window_set_decorations (GdkWindow       *window,
           rect = [NSWindow contentRectForFrameRect:rect styleMask:old_mask];
         }
 
-      impl->toplevel = [impl->toplevel initWithContentRect:rect
-                                                 styleMask:new_mask
-                                                   backing:NSBackingStoreBuffered
-                                                     defer:NO];
-
-      [impl->toplevel setHasShadow: window_type_hint_to_shadow (impl->type_hint)];
-      [impl->toplevel setLevel: window_type_hint_to_level (impl->type_hint)];
+      /* Note, before OS 10.6 there doesn't seem to be a way to change this without
+       * recreating the toplevel. There might be bad side-effects of doing
+       * that, but it seems alright.
+       */
+#if MAC_OS_X_VERSION_MIN_ALLOWED > MAC_OS_X_VERSION_10_5
+      if ([impl->toplevel respondsToSelector:@selector(setStyleMask:)])
+        {
+          [impl->toplevel setStyleMask:new_mask];
+        }
+      else
+#endif
+        {
+          [impl->toplevel release];
+          impl->toplevel = [[GdkQuartzNSWindow alloc] initWithContentRect:rect
+                                                                styleMask:new_mask
+                                                                  backing:NSBackingStoreBuffered
+                                                                    defer:NO];
+          [impl->toplevel setHasShadow: window_type_hint_to_shadow (impl->type_hint)];
+          [impl->toplevel setLevel: window_type_hint_to_level (impl->type_hint)];
+          [impl->toplevel setContentView:old_view];
+        }
 
-      [impl->toplevel setContentView:old_view];
       [impl->toplevel setFrame:rect display:YES];
 
       /* Invalidate the window shadow for non-opaque views that have shadow



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]