3 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * Copyright (C) 2005-2007 Imendio AB
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #include <Carbon/Carbon.h>
26 #include "gdkdeviceprivate.h"
27 #include "gdkwindowimpl.h"
28 #include "gdkprivate-quartz.h"
29 #include "gdkscreen-quartz.h"
30 #include "gdkinputprivate.h"
32 static gpointer parent_class;
34 static GSList *update_nswindows;
35 static gboolean in_process_all_updates = FALSE;
37 static GSList *main_window_stack;
39 #define FULLSCREEN_DATA "fullscreen-data"
45 GdkWMDecoration decor;
46 } FullscreenSavedGeometry;
49 static void update_toplevel_order (void);
50 static void clear_toplevel_order (void);
52 static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window);
54 #define WINDOW_IS_TOPLEVEL(window) \
55 (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
56 GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
57 GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
59 static void gdk_window_impl_iface_init (GdkWindowImplIface *iface);
62 gdk_quartz_window_get_nsview (GdkWindow *window)
64 GdkWindowObject *private = (GdkWindowObject *)window;
66 if (GDK_WINDOW_DESTROYED (window))
69 return ((GdkWindowImplQuartz *)private->impl)->view;
73 gdk_quartz_window_get_nswindow (GdkWindow *window)
75 GdkWindowObject *private = (GdkWindowObject *)window;
77 if (GDK_WINDOW_DESTROYED (window))
80 return ((GdkWindowImplQuartz *)private->impl)->toplevel;
84 gdk_window_impl_quartz_get_context (GdkDrawable *drawable,
87 GdkDrawableImplQuartz *drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable);
88 GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (drawable);
89 CGContextRef cg_context;
91 if (GDK_WINDOW_DESTROYED (drawable_impl->wrapper))
94 /* Lock focus when not called as part of a drawRect call. This
95 * is needed when called from outside "real" expose events, for
96 * example for synthesized expose events when realizing windows
97 * and for widgets that send fake expose events like the arrow
98 * buttons in spinbuttons or the position marker in rulers.
100 if (window_impl->in_paint_rect_count == 0)
102 if (![window_impl->view lockFocusIfCanDraw])
106 cg_context = [[NSGraphicsContext currentContext] graphicsPort];
107 CGContextSaveGState (cg_context);
108 CGContextSetAllowsAntialiasing (cg_context, antialias);
110 /* We'll emulate the clipping caused by double buffering here */
111 if (window_impl->begin_paint_count != 0)
117 n_rects = cairo_region_num_rectangles (window_impl->paint_clip_region);
122 cg_rects = g_new (CGRect, n_rects);
124 for (i = 0; i < n_rects; i++)
126 cairo_rectangle_int_t cairo_rect;
127 cairo_region_get_rectangle (window_impl->paint_clip_region,
129 cg_rects[i].origin.x = cairo_rect.x;
130 cg_rects[i].origin.y = cairo_rect.y;
131 cg_rects[i].size.width = cairo_rect.width;
132 cg_rects[i].size.height = cairo_rect.height;
135 CGContextClipToRects (cg_context, cg_rects, n_rects);
137 if (cg_rects != &rect)
145 check_grab_unmap (GdkWindow *window)
148 GdkDisplay *display = gdk_drawable_get_display (window);
149 GdkDeviceManager *device_manager;
151 device_manager = gdk_display_get_device_manager (display);
152 list = gdk_device_manager_list_devices (device_manager,
153 GDK_DEVICE_TYPE_FLOATING);
154 for (l = list; l; l = l->next)
156 _gdk_display_end_device_grab (display, l->data, 0, window, TRUE);
163 check_grab_destroy (GdkWindow *window)
166 GdkDisplay *display = gdk_drawable_get_display (window);
167 GdkDeviceManager *device_manager;
169 /* Make sure there is no lasting grab in this native window */
170 device_manager = gdk_display_get_device_manager (display);
171 list = gdk_device_manager_list_devices (device_manager,
172 GDK_DEVICE_TYPE_MASTER);
174 for (l = list; l; l = l->next)
176 GdkDeviceGrabInfo *grab;
178 grab = _gdk_display_get_last_device_grab (display, l->data);
179 if (grab && grab->native_window == window)
181 /* Serials are always 0 in quartz, but for clarity: */
182 grab->serial_end = grab->serial_start;
183 grab->implicit_ungrab = TRUE;
191 gdk_window_impl_quartz_finalize (GObject *object)
193 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (object);
195 check_grab_destroy (GDK_DRAWABLE_IMPL_QUARTZ (object)->wrapper);
197 if (impl->paint_clip_region)
198 cairo_region_destroy (impl->paint_clip_region);
200 if (impl->transient_for)
201 g_object_unref (impl->transient_for);
203 G_OBJECT_CLASS (parent_class)->finalize (object);
207 gdk_window_impl_quartz_class_init (GdkWindowImplQuartzClass *klass)
209 GObjectClass *object_class = G_OBJECT_CLASS (klass);
210 GdkDrawableImplQuartzClass *drawable_quartz_class = GDK_DRAWABLE_IMPL_QUARTZ_CLASS (klass);
212 parent_class = g_type_class_peek_parent (klass);
214 object_class->finalize = gdk_window_impl_quartz_finalize;
216 drawable_quartz_class->get_context = gdk_window_impl_quartz_get_context;
220 gdk_window_impl_quartz_init (GdkWindowImplQuartz *impl)
222 impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
226 gdk_window_impl_quartz_begin_paint_region (GdkPaintable *paintable,
228 const cairo_region_t *region)
230 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable);
231 GdkWindowObject *private = (GdkWindowObject*)window;
233 GdkPixmap *bg_pixmap;
234 cairo_region_t *clipped_and_offset_region;
235 gboolean free_clipped_and_offset_region = TRUE;
237 bg_pixmap = private->bg_pixmap;
239 clipped_and_offset_region = cairo_region_copy (region);
241 cairo_region_intersect (clipped_and_offset_region,
242 private->clip_region_with_children);
243 cairo_region_translate (clipped_and_offset_region,
244 private->abs_x, private->abs_y);
246 if (impl->begin_paint_count == 0)
248 impl->paint_clip_region = clipped_and_offset_region;
249 free_clipped_and_offset_region = FALSE;
252 cairo_region_union (impl->paint_clip_region, clipped_and_offset_region);
254 impl->begin_paint_count++;
256 if (bg_pixmap == GDK_NO_BG)
259 n_rects = cairo_region_num_rectangles (clipped_and_offset_region);
264 if (bg_pixmap == NULL)
266 CGContextRef cg_context;
270 cg_context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE);
271 color = _gdk_quartz_colormap_get_cgcolor_from_pixel (window,
272 private->bg_color.pixel);
273 CGContextSetFillColorWithColor (cg_context, color);
274 CGColorRelease (color);
276 for (i = 0; i < n_rects; i++)
278 cairo_rectangle_int_t rect;
279 cairo_region_get_rectangle (clipped_and_offset_region, i, &rect);
280 CGContextFillRect (cg_context,
281 CGRectMake (rect.x, rect.y,
282 rect.width, rect.height));
285 gdk_quartz_drawable_release_context (GDK_DRAWABLE (impl), cg_context);
290 int x_offset, y_offset;
292 cairo_rectangle_int_t rect;
295 x_offset = y_offset = 0;
297 while (window && bg_pixmap == GDK_PARENT_RELATIVE_BG)
299 /* If this window should have the same background as the parent,
300 * fetch the parent. (And if the same goes for the parent, fetch
301 * the grandparent, etc.)
303 x_offset += ((GdkWindowObject *) window)->x;
304 y_offset += ((GdkWindowObject *) window)->y;
305 window = GDK_WINDOW (((GdkWindowObject *) window)->parent);
306 bg_pixmap = ((GdkWindowObject *) window)->bg_pixmap;
309 if (bg_pixmap == NULL || bg_pixmap == GDK_NO_BG || bg_pixmap == GDK_PARENT_RELATIVE_BG)
311 /* Parent relative background but the parent doesn't have a
317 /* Note: There should be a CG API to draw tiled images, we might
318 * want to look into that for this.
320 gc = gdk_gc_new (GDK_DRAWABLE (impl));
322 gdk_drawable_get_size (GDK_DRAWABLE (bg_pixmap), &width, &height);
325 cairo_region_get_rectangle (clipped_and_offset_region, 0, &rect);
326 while (x < (rect.x + rect.width))
328 if (x + width >= rect.x)
331 while (y < (rect.y + rect.height))
333 if (y + height >= rect.y)
334 gdk_draw_drawable (GDK_DRAWABLE (impl), gc, bg_pixmap, 0, 0, x, y, width, height);
346 if (free_clipped_and_offset_region)
347 cairo_region_destroy (clipped_and_offset_region);
351 gdk_window_impl_quartz_end_paint (GdkPaintable *paintable)
353 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable);
355 impl->begin_paint_count--;
357 if (impl->begin_paint_count == 0)
359 cairo_region_destroy (impl->paint_clip_region);
360 impl->paint_clip_region = NULL;
365 _gdk_quartz_window_set_needs_display_in_region (GdkWindow *window,
366 cairo_region_t *region)
368 GdkWindowObject *private;
369 GdkWindowImplQuartz *impl;
372 private = GDK_WINDOW_OBJECT (window);
373 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
375 if (!impl->needs_display_region)
376 impl->needs_display_region = cairo_region_create ();
378 cairo_region_union (impl->needs_display_region, region);
380 n_rects = cairo_region_num_rectangles (region);
381 for (i = 0; i < n_rects; i++)
383 cairo_rectangle_int_t rect;
384 cairo_region_get_rectangle (region, i, &rect);
385 [impl->view setNeedsDisplayInRect:NSMakeRect (rect.x, rect.y,
386 rect.width, rect.height)];
391 _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
392 cairo_region_t *region)
394 /* Make sure to only flush each toplevel at most once if we're called
395 * from process_all_updates.
397 if (in_process_all_updates)
401 toplevel = gdk_window_get_toplevel (window);
404 GdkWindowObject *toplevel_private;
405 GdkWindowImplQuartz *toplevel_impl;
408 toplevel_private = (GdkWindowObject *)toplevel;
409 toplevel_impl = (GdkWindowImplQuartz *)toplevel_private->impl;
410 nswindow = toplevel_impl->toplevel;
412 /* In theory, we could skip the flush disabling, since we only
415 if (nswindow && ![nswindow isFlushWindowDisabled])
418 [nswindow disableFlushWindow];
419 update_nswindows = g_slist_prepend (update_nswindows, nswindow);
424 _gdk_quartz_window_set_needs_display_in_region (window, region);
426 /* NOTE: I'm not sure if we should displayIfNeeded here. It slows down a
427 * lot (since it triggers the beam syncing) and things seem to work
433 _gdk_windowing_before_process_all_updates (void)
435 in_process_all_updates = TRUE;
437 NSDisableScreenUpdates ();
441 _gdk_windowing_after_process_all_updates (void)
443 GSList *old_update_nswindows = update_nswindows;
444 GSList *tmp_list = update_nswindows;
446 update_nswindows = NULL;
450 NSWindow *nswindow = tmp_list->data;
452 [[nswindow contentView] displayIfNeeded];
454 _gdk_quartz_drawable_flush (NULL);
456 [nswindow enableFlushWindow];
457 [nswindow flushWindow];
460 tmp_list = tmp_list->next;
463 g_slist_free (old_update_nswindows);
465 in_process_all_updates = FALSE;
467 NSEnableScreenUpdates ();
471 gdk_window_impl_quartz_paintable_init (GdkPaintableIface *iface)
473 iface->begin_paint_region = gdk_window_impl_quartz_begin_paint_region;
474 iface->end_paint = gdk_window_impl_quartz_end_paint;
478 _gdk_window_impl_quartz_get_type (void)
480 static GType object_type = 0;
484 const GTypeInfo object_info =
486 sizeof (GdkWindowImplQuartzClass),
487 (GBaseInitFunc) NULL,
488 (GBaseFinalizeFunc) NULL,
489 (GClassInitFunc) gdk_window_impl_quartz_class_init,
490 NULL, /* class_finalize */
491 NULL, /* class_data */
492 sizeof (GdkWindowImplQuartz),
494 (GInstanceInitFunc) gdk_window_impl_quartz_init,
497 const GInterfaceInfo paintable_info =
499 (GInterfaceInitFunc) gdk_window_impl_quartz_paintable_init,
504 const GInterfaceInfo window_impl_info =
506 (GInterfaceInitFunc) gdk_window_impl_iface_init,
511 object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_QUARTZ,
512 "GdkWindowImplQuartz",
514 g_type_add_interface_static (object_type,
517 g_type_add_interface_static (object_type,
518 GDK_TYPE_WINDOW_IMPL,
526 _gdk_window_impl_get_type (void)
528 return _gdk_window_impl_quartz_get_type ();
532 get_default_title (void)
536 title = g_get_application_name ();
538 title = g_get_prgname ();
544 get_ancestor_coordinates_from_child (GdkWindow *child_window,
547 GdkWindow *ancestor_window,
551 GdkWindowObject *child_private = GDK_WINDOW_OBJECT (child_window);
552 GdkWindowObject *ancestor_private = GDK_WINDOW_OBJECT (ancestor_window);
554 while (child_private != ancestor_private)
556 child_x += child_private->x;
557 child_y += child_private->y;
559 child_private = child_private->parent;
562 *ancestor_x = child_x;
563 *ancestor_y = child_y;
567 _gdk_quartz_window_debug_highlight (GdkWindow *window, gint number)
569 GdkWindowObject *private = GDK_WINDOW_OBJECT (window);
574 static NSWindow *debug_window[10];
575 static NSRect old_rect[10];
579 g_return_if_fail (number >= 0 && number <= 9);
581 if (window == _gdk_root)
586 if (debug_window[number])
587 [debug_window[number] close];
588 debug_window[number] = NULL;
593 toplevel = gdk_window_get_toplevel (window);
594 get_ancestor_coordinates_from_child (window, 0, 0, toplevel, &x, &y);
596 gdk_window_get_origin (toplevel, &tx, &ty);
600 _gdk_quartz_window_gdk_xy_to_xy (x, y + private->height,
603 rect = NSMakeRect (gx, gy, private->width, private->height);
605 if (debug_window[number] && NSEqualRects (rect, old_rect[number]))
608 old_rect[number] = rect;
610 if (debug_window[number])
611 [debug_window[number] close];
613 debug_window[number] = [[NSWindow alloc] initWithContentRect:rect
614 styleMask:NSBorderlessWindowMask
615 backing:NSBackingStoreBuffered
621 color = [NSColor redColor];
624 color = [NSColor blueColor];
627 color = [NSColor greenColor];
630 color = [NSColor yellowColor];
633 color = [NSColor brownColor];
636 color = [NSColor purpleColor];
639 color = [NSColor blackColor];
643 [debug_window[number] setBackgroundColor:color];
644 [debug_window[number] setAlphaValue:0.4];
645 [debug_window[number] setOpaque:NO];
646 [debug_window[number] setReleasedWhenClosed:YES];
647 [debug_window[number] setIgnoresMouseEvents:YES];
648 [debug_window[number] setLevel:NSFloatingWindowLevel];
650 [debug_window[number] orderFront:nil];
654 _gdk_quartz_window_is_ancestor (GdkWindow *ancestor,
657 if (ancestor == NULL || window == NULL)
660 return (gdk_window_get_parent (window) == ancestor ||
661 _gdk_quartz_window_is_ancestor (ancestor,
662 gdk_window_get_parent (window)));
666 /* See notes on top of gdkscreen-quartz.c */
668 _gdk_quartz_window_gdk_xy_to_xy (gint gdk_x,
673 GdkScreenQuartz *screen_quartz = GDK_SCREEN_QUARTZ (_gdk_screen);
676 *ns_y = screen_quartz->height - gdk_y + screen_quartz->min_y;
679 *ns_x = gdk_x + screen_quartz->min_x;
683 _gdk_quartz_window_xy_to_gdk_xy (gint ns_x,
688 GdkScreenQuartz *screen_quartz = GDK_SCREEN_QUARTZ (_gdk_screen);
691 *gdk_y = screen_quartz->height - ns_y + screen_quartz->min_y;
694 *gdk_x = ns_x - screen_quartz->min_x;
698 _gdk_quartz_window_nspoint_to_gdk_xy (NSPoint point,
702 _gdk_quartz_window_xy_to_gdk_xy (point.x, point.y,
707 find_child_window_helper (GdkWindow *window,
712 gboolean get_toplevel)
714 GdkWindowImplQuartz *impl;
717 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
719 if (window == _gdk_root)
720 update_toplevel_order ();
722 for (l = impl->sorted_children; l; l = l->next)
724 GdkWindowObject *child_private = l->data;
725 GdkWindowImplQuartz *child_impl = GDK_WINDOW_IMPL_QUARTZ (child_private->impl);
728 if (!GDK_WINDOW_IS_MAPPED (child_private))
731 temp_x = x_offset + child_private->x;
732 temp_y = y_offset + child_private->y;
734 /* Special-case the root window. We have to include the title
735 * bar in the checks, otherwise the window below the title bar
736 * will be found i.e. events punch through. (If we can find a
737 * better way to deal with the events in gdkevents-quartz, this
738 * might not be needed.)
740 if (window == _gdk_root)
742 NSRect frame = NSMakeRect (0, 0, 100, 100);
747 mask = [child_impl->toplevel styleMask];
749 /* Get the title bar height. */
750 content = [NSWindow contentRectForFrameRect:frame
752 titlebar_height = frame.size.height - content.size.height;
754 if (titlebar_height > 0 &&
755 x >= temp_x && y >= temp_y - titlebar_height &&
756 x < temp_x + child_private->width && y < temp_y)
758 /* The root means "unknown" i.e. a window not managed by
761 return (GdkWindow *)_gdk_root;
765 if ((!get_toplevel || (get_toplevel && window == _gdk_root)) &&
766 x >= temp_x && y >= temp_y &&
767 x < temp_x + child_private->width && y < temp_y + child_private->height)
769 /* Look for child windows. */
770 return find_child_window_helper (l->data,
780 /* Given a GdkWindow and coordinates relative to it, returns the
781 * innermost subwindow that contains the point. If the coordinates are
782 * outside the passed in window, NULL is returned.
785 _gdk_quartz_window_find_child (GdkWindow *window,
788 gboolean get_toplevel)
790 GdkWindowObject *private = GDK_WINDOW_OBJECT (window);
792 if (x >= 0 && y >= 0 && x < private->width && y < private->height)
793 return find_child_window_helper (window, x, y, 0, 0, get_toplevel);
800 _gdk_quartz_window_did_become_main (GdkWindow *window)
802 main_window_stack = g_slist_remove (main_window_stack, window);
804 if (GDK_WINDOW_OBJECT (window)->window_type != GDK_WINDOW_TEMP)
805 main_window_stack = g_slist_prepend (main_window_stack, window);
807 clear_toplevel_order ();
811 _gdk_quartz_window_did_resign_main (GdkWindow *window)
813 GdkWindow *new_window = NULL;
815 if (main_window_stack)
816 new_window = main_window_stack->data;
821 toplevels = gdk_screen_get_toplevel_windows (gdk_screen_get_default ());
823 new_window = toplevels->data;
824 g_list_free (toplevels);
828 new_window != window &&
829 GDK_WINDOW_IS_MAPPED (new_window) &&
830 GDK_WINDOW_OBJECT (new_window)->window_type != GDK_WINDOW_TEMP)
832 GdkWindowObject *private = (GdkWindowObject *) new_window;
833 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
835 [impl->toplevel makeKeyAndOrderFront:impl->toplevel];
838 clear_toplevel_order ();
842 get_nsscreen_for_point (gint x, gint y)
846 NSScreen *screen = NULL;
848 GDK_QUARTZ_ALLOC_POOL;
850 screens = [NSScreen screens];
852 for (i = 0; i < [screens count]; i++)
854 NSRect rect = [[screens objectAtIndex:i] frame];
856 if (x >= rect.origin.x && x <= rect.origin.x + rect.size.width &&
857 y >= rect.origin.y && y <= rect.origin.y + rect.size.height)
859 screen = [screens objectAtIndex:i];
864 GDK_QUARTZ_RELEASE_POOL;
870 _gdk_window_impl_new (GdkWindow *window,
871 GdkWindow *real_parent,
874 GdkEventMask event_mask,
875 GdkWindowAttr *attributes,
876 gint attributes_mask)
878 GdkWindowObject *private;
879 GdkWindowImplQuartz *impl;
880 GdkDrawableImplQuartz *draw_impl;
881 GdkWindowImplQuartz *parent_impl;
883 GDK_QUARTZ_ALLOC_POOL;
885 private = (GdkWindowObject *)window;
887 impl = g_object_new (_gdk_window_impl_get_type (), NULL);
888 private->impl = (GdkDrawable *)impl;
889 draw_impl = GDK_DRAWABLE_IMPL_QUARTZ (impl);
890 draw_impl->wrapper = GDK_DRAWABLE (window);
892 parent_impl = GDK_WINDOW_IMPL_QUARTZ (private->parent->impl);
894 switch (private->window_type)
896 case GDK_WINDOW_TOPLEVEL:
897 case GDK_WINDOW_DIALOG:
898 case GDK_WINDOW_TEMP:
899 if (GDK_WINDOW_TYPE (private->parent) != GDK_WINDOW_ROOT)
901 /* The common code warns for this case */
902 parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl);
906 if (!private->input_only)
908 if (attributes_mask & GDK_WA_COLORMAP)
910 draw_impl->colormap = attributes->colormap;
911 g_object_ref (attributes->colormap);
915 if (visual == gdk_screen_get_system_visual (_gdk_screen))
917 draw_impl->colormap = gdk_screen_get_system_colormap (_gdk_screen);
918 g_object_ref (draw_impl->colormap);
920 else if (visual == gdk_screen_get_rgba_visual (_gdk_screen))
922 draw_impl->colormap = gdk_screen_get_rgba_colormap (_gdk_screen);
923 g_object_ref (draw_impl->colormap);
927 draw_impl->colormap = gdk_colormap_new (visual, FALSE);
933 draw_impl->colormap = gdk_screen_get_system_colormap (_gdk_screen);
934 g_object_ref (draw_impl->colormap);
937 /* Maintain the z-ordered list of children. */
938 if (private->parent != (GdkWindowObject *)_gdk_root)
939 parent_impl->sorted_children = g_list_prepend (parent_impl->sorted_children, window);
941 clear_toplevel_order ();
943 gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
944 (attributes->cursor) :
947 switch (attributes->window_type)
949 case GDK_WINDOW_TOPLEVEL:
950 case GDK_WINDOW_DIALOG:
951 case GDK_WINDOW_TEMP:
956 NSUInteger style_mask;
960 /* initWithContentRect will place on the mainScreen by default.
961 * We want to select the screen to place on ourselves. We need
962 * to find the screen the window will be on and correct the
963 * content_rect coordinates to be relative to that screen.
965 _gdk_quartz_window_gdk_xy_to_xy (private->x, private->y, &nx, &ny);
967 screen = get_nsscreen_for_point (nx, ny);
968 screen_rect = [screen frame];
969 nx -= screen_rect.origin.x;
970 ny -= screen_rect.origin.y;
972 content_rect = NSMakeRect (nx, ny - private->height,
976 if (attributes->window_type == GDK_WINDOW_TEMP ||
977 attributes->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN)
979 style_mask = NSBorderlessWindowMask;
983 style_mask = (NSTitledWindowMask |
984 NSClosableWindowMask |
985 NSMiniaturizableWindowMask |
986 NSResizableWindowMask);
989 impl->toplevel = [[GdkQuartzWindow alloc] initWithContentRect:content_rect
991 backing:NSBackingStoreBuffered
995 if (attributes_mask & GDK_WA_TITLE)
996 title = attributes->title;
998 title = get_default_title ();
1000 gdk_window_set_title (window, title);
1002 if (draw_impl->colormap == gdk_screen_get_rgba_colormap (_gdk_screen))
1004 [impl->toplevel setOpaque:NO];
1005 [impl->toplevel setBackgroundColor:[NSColor clearColor]];
1008 content_rect.origin.x = 0;
1009 content_rect.origin.y = 0;
1011 impl->view = [[GdkQuartzView alloc] initWithFrame:content_rect];
1012 [impl->view setGdkWindow:window];
1013 [impl->toplevel setContentView:impl->view];
1014 [impl->view release];
1018 case GDK_WINDOW_CHILD:
1020 GdkWindowImplQuartz *parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (private->parent)->impl);
1022 if (!private->input_only)
1024 NSRect frame_rect = NSMakeRect (private->x + private->parent->abs_x,
1025 private->y + private->parent->abs_y,
1029 impl->view = [[GdkQuartzView alloc] initWithFrame:frame_rect];
1031 [impl->view setGdkWindow:window];
1033 /* GdkWindows should be hidden by default */
1034 [impl->view setHidden:YES];
1035 [parent_impl->view addSubview:impl->view];
1036 [impl->view release];
1042 g_assert_not_reached ();
1045 GDK_QUARTZ_RELEASE_POOL;
1047 if (attributes_mask & GDK_WA_TYPE_HINT)
1048 gdk_window_set_type_hint (window, attributes->type_hint);
1052 _gdk_quartz_window_update_position (GdkWindow *window)
1055 NSRect content_rect;
1056 GdkWindowObject *private = (GdkWindowObject *)window;
1057 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1059 GDK_QUARTZ_ALLOC_POOL;
1061 frame_rect = [impl->toplevel frame];
1062 content_rect = [impl->toplevel contentRectForFrameRect:frame_rect];
1064 _gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x,
1065 content_rect.origin.y + content_rect.size.height,
1066 &private->x, &private->y);
1069 GDK_QUARTZ_RELEASE_POOL;
1073 _gdk_windowing_update_window_sizes (GdkScreen *screen)
1075 GList *windows, *list;
1076 GdkWindowObject *private = (GdkWindowObject *)_gdk_root;
1078 /* The size of the root window is so that it can contain all
1079 * monitors attached to this machine. The monitors are laid out
1080 * within this root window. We calculate the size of the root window
1081 * and the positions of the different monitors in gdkscreen-quartz.c.
1083 * This data is updated when the monitor configuration is changed.
1089 private->width = gdk_screen_get_width (screen);
1090 private->height = gdk_screen_get_height (screen);
1092 windows = gdk_screen_get_toplevel_windows (screen);
1094 for (list = windows; list; list = list->next)
1095 _gdk_quartz_window_update_position (list->data);
1097 g_list_free (windows);
1101 _gdk_windowing_window_init (void)
1103 GdkWindowObject *private;
1104 GdkWindowImplQuartz *impl;
1105 GdkDrawableImplQuartz *drawable_impl;
1107 g_assert (_gdk_root == NULL);
1109 _gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL);
1111 private = (GdkWindowObject *)_gdk_root;
1112 private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
1113 private->impl_window = private;
1115 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl);
1117 _gdk_windowing_update_window_sizes (_gdk_screen);
1119 private->state = 0; /* We don't want GDK_WINDOW_STATE_WITHDRAWN here */
1120 private->window_type = GDK_WINDOW_ROOT;
1121 private->depth = 24;
1122 private->viewable = TRUE;
1124 drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (private->impl);
1126 drawable_impl->wrapper = GDK_DRAWABLE (private);
1127 drawable_impl->colormap = gdk_screen_get_system_colormap (_gdk_screen);
1128 g_object_ref (drawable_impl->colormap);
1132 _gdk_quartz_window_destroy (GdkWindow *window,
1134 gboolean foreign_destroy)
1136 GdkWindowObject *private;
1137 GdkWindowImplQuartz *impl;
1138 GdkWindowObject *parent;
1140 private = GDK_WINDOW_OBJECT (window);
1141 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1143 main_window_stack = g_slist_remove (main_window_stack, window);
1145 g_list_free (impl->sorted_children);
1146 impl->sorted_children = NULL;
1148 parent = private->parent;
1151 GdkWindowImplQuartz *parent_impl = GDK_WINDOW_IMPL_QUARTZ (parent->impl);
1153 parent_impl->sorted_children = g_list_remove (parent_impl->sorted_children, window);
1156 _gdk_quartz_drawable_finish (GDK_DRAWABLE (impl));
1158 if (!recursing && !foreign_destroy)
1160 GDK_QUARTZ_ALLOC_POOL;
1163 [impl->toplevel close];
1164 else if (impl->view)
1165 [impl->view removeFromSuperview];
1167 GDK_QUARTZ_RELEASE_POOL;
1172 _gdk_windowing_window_destroy_foreign (GdkWindow *window)
1174 /* Foreign windows aren't supported in OSX. */
1177 /* FIXME: This might be possible to simplify with client-side windows. Also
1178 * note that already_mapped is not used yet, see the x11 backend.
1181 gdk_window_quartz_show (GdkWindow *window, gboolean already_mapped)
1183 GdkWindowObject *private = (GdkWindowObject *)window;
1184 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1185 gboolean focus_on_map;
1187 GDK_QUARTZ_ALLOC_POOL;
1189 if (!GDK_WINDOW_IS_MAPPED (window))
1190 focus_on_map = private->focus_on_map;
1192 focus_on_map = TRUE;
1198 make_key = (private->accept_focus && focus_on_map &&
1199 private->window_type != GDK_WINDOW_TEMP);
1201 [(GdkQuartzWindow*)impl->toplevel showAndMakeKey:make_key];
1202 clear_toplevel_order ();
1204 _gdk_quartz_events_send_map_event (window);
1208 [impl->view setHidden:NO];
1211 [impl->view setNeedsDisplay:YES];
1213 gdk_synthesize_window_state (window, GDK_WINDOW_STATE_WITHDRAWN, 0);
1215 if (private->state & GDK_WINDOW_STATE_MAXIMIZED)
1216 gdk_window_maximize (window);
1218 if (private->state & GDK_WINDOW_STATE_ICONIFIED)
1219 gdk_window_iconify (window);
1221 if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
1222 _gdk_quartz_window_attach_to_parent (window);
1224 GDK_QUARTZ_RELEASE_POOL;
1227 /* Temporarily unsets the parent window, if the window is a
1231 _gdk_quartz_window_detach_from_parent (GdkWindow *window)
1233 GdkWindowImplQuartz *impl;
1235 g_return_if_fail (GDK_IS_WINDOW (window));
1237 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1239 g_return_if_fail (impl->toplevel != NULL);
1241 if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
1243 GdkWindowImplQuartz *parent_impl;
1245 parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (impl->transient_for)->impl);
1246 [parent_impl->toplevel removeChildWindow:impl->toplevel];
1247 clear_toplevel_order ();
1251 /* Re-sets the parent window, if the window is a transient. */
1253 _gdk_quartz_window_attach_to_parent (GdkWindow *window)
1255 GdkWindowImplQuartz *impl;
1257 g_return_if_fail (GDK_IS_WINDOW (window));
1259 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1261 g_return_if_fail (impl->toplevel != NULL);
1263 if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
1265 GdkWindowImplQuartz *parent_impl;
1267 parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (impl->transient_for)->impl);
1268 [parent_impl->toplevel addChildWindow:impl->toplevel ordered:NSWindowAbove];
1269 clear_toplevel_order ();
1274 gdk_window_quartz_hide (GdkWindow *window)
1276 GdkWindowObject *private = (GdkWindowObject *)window;
1277 GdkWindowImplQuartz *impl;
1279 /* Make sure we're not stuck in fullscreen mode. */
1280 if (get_fullscreen_geometry (window))
1281 SetSystemUIMode (kUIModeNormal, 0);
1283 check_grab_unmap (window);
1285 _gdk_window_clear_update_area (window);
1287 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1291 /* Update main window. */
1292 main_window_stack = g_slist_remove (main_window_stack, window);
1293 if ([NSApp mainWindow] == impl->toplevel)
1294 _gdk_quartz_window_did_resign_main (window);
1296 if (impl->transient_for)
1297 _gdk_quartz_window_detach_from_parent (window);
1299 [(GdkQuartzWindow*)impl->toplevel hide];
1301 else if (impl->view)
1303 [impl->view setHidden:YES];
1308 gdk_window_quartz_withdraw (GdkWindow *window)
1310 gdk_window_hide (window);
1314 move_resize_window_internal (GdkWindow *window,
1320 GdkWindowObject *private = (GdkWindowObject *)window;
1321 GdkWindowImplQuartz *impl;
1322 GdkRectangle old_visible;
1323 GdkRectangle new_visible;
1324 GdkRectangle scroll_rect;
1325 cairo_region_t *old_region;
1326 cairo_region_t *expose_region;
1329 if (GDK_WINDOW_DESTROYED (window))
1332 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1334 if ((x == -1 || (x == private->x)) &&
1335 (y == -1 || (y == private->y)) &&
1336 (width == -1 || (width == private->width)) &&
1337 (height == -1 || (height == private->height)))
1342 if (!impl->toplevel)
1344 /* The previously visible area of this window in a coordinate
1345 * system rooted at the origin of this window.
1347 old_visible.x = -private->x;
1348 old_visible.y = -private->y;
1350 gdk_drawable_get_size (GDK_DRAWABLE (private->parent),
1352 &old_visible.height);
1357 delta.width = x - private->x;
1367 delta.height = y - private->y;
1376 private->width = width;
1379 private->height = height;
1381 GDK_QUARTZ_ALLOC_POOL;
1385 NSRect content_rect;
1389 _gdk_quartz_window_gdk_xy_to_xy (private->x, private->y + private->height,
1392 content_rect = NSMakeRect (gx, gy, private->width, private->height);
1394 frame_rect = [impl->toplevel frameRectForContentRect:content_rect];
1395 [impl->toplevel setFrame:frame_rect display:YES];
1399 if (!private->input_only)
1403 nsrect = NSMakeRect (private->x, private->y, private->width, private->height);
1405 /* The newly visible area of this window in a coordinate
1406 * system rooted at the origin of this window.
1408 new_visible.x = -private->x;
1409 new_visible.y = -private->y;
1410 new_visible.width = old_visible.width; /* parent has not changed size */
1411 new_visible.height = old_visible.height; /* parent has not changed size */
1413 expose_region = cairo_region_create_rectangle (&new_visible);
1414 old_region = cairo_region_create_rectangle (&old_visible);
1415 cairo_region_subtract (expose_region, old_region);
1417 /* Determine what (if any) part of the previously visible
1418 * part of the window can be copied without a redraw
1420 scroll_rect = old_visible;
1421 scroll_rect.x -= delta.width;
1422 scroll_rect.y -= delta.height;
1423 gdk_rectangle_intersect (&scroll_rect, &old_visible, &scroll_rect);
1425 if (!cairo_region_is_empty (expose_region))
1427 if (scroll_rect.width != 0 && scroll_rect.height != 0)
1429 [impl->view scrollRect:NSMakeRect (scroll_rect.x,
1436 [impl->view setFrame:nsrect];
1438 _gdk_quartz_window_set_needs_display_in_region (window, expose_region);
1442 [impl->view setFrame:nsrect];
1443 [impl->view setNeedsDisplay:YES];
1446 cairo_region_destroy (expose_region);
1447 cairo_region_destroy (old_region);
1451 GDK_QUARTZ_RELEASE_POOL;
1455 window_quartz_move (GdkWindow *window,
1459 g_return_if_fail (GDK_IS_WINDOW (window));
1461 if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN)
1464 move_resize_window_internal (window, x, y, -1, -1);
1468 window_quartz_resize (GdkWindow *window,
1472 g_return_if_fail (GDK_IS_WINDOW (window));
1474 if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN)
1482 move_resize_window_internal (window, -1, -1, width, height);
1486 window_quartz_move_resize (GdkWindow *window,
1497 move_resize_window_internal (window, x, y, width, height);
1501 gdk_window_quartz_move_resize (GdkWindow *window,
1508 if (with_move && (width < 0 && height < 0))
1509 window_quartz_move (window, x, y);
1513 window_quartz_move_resize (window, x, y, width, height);
1515 window_quartz_resize (window, width, height);
1519 /* FIXME: This might need fixing (reparenting didn't work before client-side
1523 gdk_window_quartz_reparent (GdkWindow *window,
1524 GdkWindow *new_parent,
1528 GdkWindowObject *private, *old_parent_private, *new_parent_private;
1529 GdkWindowImplQuartz *impl, *old_parent_impl, *new_parent_impl;
1530 NSView *view, *new_parent_view;
1532 if (new_parent == _gdk_root)
1534 /* Could be added, just needs implementing. */
1535 g_warning ("Reparenting to root window is not supported yet in the Mac OS X backend");
1539 private = GDK_WINDOW_OBJECT (window);
1540 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1543 new_parent_private = GDK_WINDOW_OBJECT (new_parent);
1544 new_parent_impl = GDK_WINDOW_IMPL_QUARTZ (new_parent_private->impl);
1545 new_parent_view = new_parent_impl->view;
1547 old_parent_private = GDK_WINDOW_OBJECT (private->parent);
1548 old_parent_impl = GDK_WINDOW_IMPL_QUARTZ (old_parent_private->impl);
1552 [view removeFromSuperview];
1553 [new_parent_view addSubview:view];
1557 private->parent = new_parent_private;
1559 if (old_parent_private)
1561 old_parent_impl->sorted_children = g_list_remove (old_parent_impl->sorted_children, window);
1564 new_parent_impl->sorted_children = g_list_prepend (new_parent_impl->sorted_children, window);
1569 /* Get the toplevel ordering from NSApp and update our own list. We do
1570 * this on demand since the NSApp's list is not up to date directly
1571 * after we get windowDidBecomeMain.
1574 update_toplevel_order (void)
1576 GdkWindowObject *root;
1577 GdkWindowImplQuartz *root_impl;
1578 NSEnumerator *enumerator;
1580 GList *toplevels = NULL;
1582 root = GDK_WINDOW_OBJECT (_gdk_root);
1583 root_impl = GDK_WINDOW_IMPL_QUARTZ (root->impl);
1585 if (root_impl->sorted_children)
1588 GDK_QUARTZ_ALLOC_POOL;
1590 enumerator = [[NSApp orderedWindows] objectEnumerator];
1591 while ((nswindow = [enumerator nextObject]))
1595 if (![[nswindow contentView] isKindOfClass:[GdkQuartzView class]])
1598 window = [(GdkQuartzView *)[nswindow contentView] gdkWindow];
1599 toplevels = g_list_prepend (toplevels, window);
1602 GDK_QUARTZ_RELEASE_POOL;
1604 root_impl->sorted_children = g_list_reverse (toplevels);
1608 clear_toplevel_order (void)
1610 GdkWindowObject *root;
1611 GdkWindowImplQuartz *root_impl;
1613 root = GDK_WINDOW_OBJECT (_gdk_root);
1614 root_impl = GDK_WINDOW_IMPL_QUARTZ (root->impl);
1616 g_list_free (root_impl->sorted_children);
1617 root_impl->sorted_children = NULL;
1621 gdk_window_quartz_raise (GdkWindow *window)
1623 if (GDK_WINDOW_DESTROYED (window))
1626 if (WINDOW_IS_TOPLEVEL (window))
1628 GdkWindowImplQuartz *impl;
1630 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1631 [impl->toplevel orderFront:impl->toplevel];
1633 clear_toplevel_order ();
1637 GdkWindowObject *parent = GDK_WINDOW_OBJECT (window)->parent;
1641 GdkWindowImplQuartz *impl;
1643 impl = (GdkWindowImplQuartz *)parent->impl;
1645 impl->sorted_children = g_list_remove (impl->sorted_children, window);
1646 impl->sorted_children = g_list_prepend (impl->sorted_children, window);
1652 gdk_window_quartz_lower (GdkWindow *window)
1654 if (GDK_WINDOW_DESTROYED (window))
1657 if (WINDOW_IS_TOPLEVEL (window))
1659 GdkWindowImplQuartz *impl;
1661 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1662 [impl->toplevel orderBack:impl->toplevel];
1664 clear_toplevel_order ();
1668 GdkWindowObject *parent = GDK_WINDOW_OBJECT (window)->parent;
1672 GdkWindowImplQuartz *impl;
1674 impl = (GdkWindowImplQuartz *)parent->impl;
1676 impl->sorted_children = g_list_remove (impl->sorted_children, window);
1677 impl->sorted_children = g_list_append (impl->sorted_children, window);
1683 gdk_window_quartz_restack_toplevel (GdkWindow *window,
1687 /* FIXME: Implement this */
1691 gdk_window_quartz_set_background (GdkWindow *window,
1692 const GdkColor *color)
1694 /* FIXME: We could theoretically set the background color for toplevels
1695 * here. (Currently we draw the background before emitting expose events)
1700 gdk_window_quartz_set_back_pixmap (GdkWindow *window,
1703 /* FIXME: Could theoretically set some background image here. (Currently
1704 * the back pixmap is drawn before emitting expose events.
1709 gdk_window_quartz_set_device_cursor (GdkWindow *window,
1713 GdkCursorPrivate *cursor_private;
1716 cursor_private = (GdkCursorPrivate *)cursor;
1718 if (GDK_WINDOW_DESTROYED (window))
1722 nscursor = [NSCursor arrowCursor];
1724 nscursor = cursor_private->nscursor;
1730 gdk_window_quartz_get_geometry (GdkWindow *window,
1737 GdkWindowImplQuartz *impl;
1738 GdkWindowObject *private;
1741 if (GDK_WINDOW_DESTROYED (window))
1744 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1745 private = GDK_WINDOW_OBJECT (window);
1746 if (window == _gdk_root)
1754 *width = private->width;
1756 *height = private->height;
1758 else if (WINDOW_IS_TOPLEVEL (window))
1760 ns_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]];
1762 /* This doesn't work exactly as in X. There doesn't seem to be a
1763 * way to get the coords relative to the parent window (usually
1764 * the window frame), but that seems useless except for
1765 * borderless windows where it's relative to the root window. So
1766 * we return (0, 0) (should be something like (0, 22)) for
1767 * windows with borders and the root relative coordinates
1770 if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
1772 _gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x,
1773 ns_rect.origin.y + ns_rect.size.height,
1785 *width = ns_rect.size.width;
1787 *height = ns_rect.size.height;
1791 ns_rect = [impl->view frame];
1794 *x = ns_rect.origin.x;
1796 *y = ns_rect.origin.y;
1798 *width = ns_rect.size.width;
1800 *height = ns_rect.size.height;
1804 *depth = gdk_drawable_get_depth (window);
1808 gdk_window_quartz_get_root_coords (GdkWindow *window,
1814 GdkWindowObject *private;
1815 int tmp_x = 0, tmp_y = 0;
1816 GdkWindow *toplevel;
1817 NSRect content_rect;
1818 GdkWindowImplQuartz *impl;
1820 if (GDK_WINDOW_DESTROYED (window))
1830 if (window == _gdk_root)
1840 private = GDK_WINDOW_OBJECT (window);
1842 toplevel = gdk_window_get_toplevel (window);
1843 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl);
1845 content_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]];
1847 _gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x,
1848 content_rect.origin.y + content_rect.size.height,
1854 while (private != GDK_WINDOW_OBJECT (toplevel))
1856 if (_gdk_window_has_impl ((GdkWindow *)private))
1858 tmp_x += private->x;
1859 tmp_y += private->y;
1862 private = private->parent;
1874 gdk_window_quartz_get_deskrelative_origin (GdkWindow *window,
1878 return gdk_window_get_origin (window, x, y);
1882 gdk_window_get_root_origin (GdkWindow *window,
1891 gdk_window_get_frame_extents (window, &rect);
1900 /* Returns coordinates relative to the passed in window. */
1902 gdk_window_quartz_get_device_state_helper (GdkWindow *window,
1906 GdkModifierType *mask)
1908 GdkWindowObject *toplevel;
1909 GdkWindowObject *private;
1912 GdkWindow *found_window;
1914 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
1916 if (GDK_WINDOW_DESTROYED (window))
1924 toplevel = GDK_WINDOW_OBJECT (gdk_window_get_toplevel (window));
1926 *mask = _gdk_quartz_events_get_current_event_mask ();
1928 /* Get the y coordinate, needs to be flipped. */
1929 if (window == _gdk_root)
1931 point = [NSEvent mouseLocation];
1932 _gdk_quartz_window_nspoint_to_gdk_xy (point, &x_tmp, &y_tmp);
1936 GdkWindowImplQuartz *impl;
1939 impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl);
1940 private = GDK_WINDOW_OBJECT (toplevel);
1941 nswindow = impl->toplevel;
1943 point = [nswindow mouseLocationOutsideOfEventStream];
1946 y_tmp = private->height - point.y;
1948 window = (GdkWindow *)toplevel;
1951 found_window = _gdk_quartz_window_find_child (window, x_tmp, y_tmp,
1954 /* We never return the root window. */
1955 if (found_window == _gdk_root)
1956 found_window = NULL;
1961 return found_window;
1965 gdk_window_quartz_get_device_state (GdkWindow *window,
1969 GdkModifierType *mask)
1971 return gdk_window_quartz_get_device_state_helper (window,
1973 x, y, mask) != NULL;
1976 /* Returns coordinates relative to the root. */
1978 _gdk_windowing_get_device_state (GdkDisplay *display,
1983 GdkModifierType *mask)
1985 g_return_if_fail (display == _gdk_display);
1987 *screen = _gdk_screen;
1988 gdk_window_quartz_get_device_state_helper (_gdk_root, device, x, y, mask);
1992 gdk_display_warp_pointer (GdkDisplay *display,
1997 CGDisplayMoveCursorToPoint (CGMainDisplayID (), CGPointMake (x, y));
2000 /* Returns coordinates relative to the found window. */
2002 _gdk_windowing_window_at_pointer (GdkDisplay *display,
2005 GdkModifierType *mask,
2006 gboolean get_toplevel)
2008 GdkWindow *found_window;
2010 GdkModifierType tmp_mask = 0;
2012 found_window = gdk_window_quartz_get_device_state_helper (_gdk_root,
2013 display->core_pointer,
2018 GdkWindowObject *private;
2020 /* The coordinates returned above are relative the root, we want
2021 * coordinates relative the window here.
2023 private = GDK_WINDOW_OBJECT (found_window);
2024 while (private != GDK_WINDOW_OBJECT (_gdk_root))
2029 private = private->parent;
2037 /* Mimic the X backend here, -1,-1 for unknown windows. */
2047 GdkWindowObject *w = (GdkWindowObject *)found_window;
2048 /* Requested toplevel, find it. */
2049 /* TODO: This can be implemented more efficient by never
2050 recursing into children in the first place */
2053 /* Convert to toplevel */
2054 while (w->parent != NULL &&
2055 w->parent->window_type != GDK_WINDOW_ROOT)
2061 found_window = (GdkWindow *)w;
2065 return found_window;
2069 _gdk_windowing_window_at_device_position (GdkDisplay *display,
2073 GdkModifierType *mask,
2074 gboolean get_toplevel)
2076 return GDK_DEVICE_GET_CLASS (device)->window_at_position (device,
2084 gdk_window_quartz_get_events (GdkWindow *window)
2086 if (GDK_WINDOW_DESTROYED (window))
2089 return GDK_WINDOW_OBJECT (window)->event_mask;
2093 gdk_window_quartz_set_events (GdkWindow *window,
2094 GdkEventMask event_mask)
2096 /* The mask is set in the common code. */
2100 gdk_window_set_urgency_hint (GdkWindow *window,
2103 if (GDK_WINDOW_DESTROYED (window) ||
2104 !WINDOW_IS_TOPLEVEL (window))
2107 /* FIXME: Implement */
2111 gdk_window_set_geometry_hints (GdkWindow *window,
2112 const GdkGeometry *geometry,
2113 GdkWindowHints geom_mask)
2115 GdkWindowImplQuartz *impl;
2117 g_return_if_fail (geometry != NULL);
2119 if (GDK_WINDOW_DESTROYED (window) ||
2120 !WINDOW_IS_TOPLEVEL (window))
2123 impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *) window)->impl);
2124 if (!impl->toplevel)
2127 if (geom_mask & GDK_HINT_POS)
2129 /* FIXME: Implement */
2132 if (geom_mask & GDK_HINT_USER_POS)
2134 /* FIXME: Implement */
2137 if (geom_mask & GDK_HINT_USER_SIZE)
2139 /* FIXME: Implement */
2142 if (geom_mask & GDK_HINT_MIN_SIZE)
2146 size.width = geometry->min_width;
2147 size.height = geometry->min_height;
2149 [impl->toplevel setContentMinSize:size];
2152 if (geom_mask & GDK_HINT_MAX_SIZE)
2156 size.width = geometry->max_width;
2157 size.height = geometry->max_height;
2159 [impl->toplevel setContentMaxSize:size];
2162 if (geom_mask & GDK_HINT_BASE_SIZE)
2164 /* FIXME: Implement */
2167 if (geom_mask & GDK_HINT_RESIZE_INC)
2171 size.width = geometry->width_inc;
2172 size.height = geometry->height_inc;
2174 [impl->toplevel setContentResizeIncrements:size];
2177 if (geom_mask & GDK_HINT_ASPECT)
2179 /* FIXME: Implement */
2182 if (geom_mask & GDK_HINT_WIN_GRAVITY)
2184 /* FIXME: Implement */
2189 gdk_window_set_title (GdkWindow *window,
2192 GdkWindowImplQuartz *impl;
2194 g_return_if_fail (title != NULL);
2196 if (GDK_WINDOW_DESTROYED (window) ||
2197 !WINDOW_IS_TOPLEVEL (window))
2200 impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *)window)->impl);
2204 GDK_QUARTZ_ALLOC_POOL;
2205 [impl->toplevel setTitle:[NSString stringWithUTF8String:title]];
2206 GDK_QUARTZ_RELEASE_POOL;
2211 gdk_window_set_role (GdkWindow *window,
2214 if (GDK_WINDOW_DESTROYED (window) ||
2215 WINDOW_IS_TOPLEVEL (window))
2218 /* FIXME: Implement */
2222 gdk_window_set_transient_for (GdkWindow *window,
2225 GdkWindowImplQuartz *window_impl;
2226 GdkWindowImplQuartz *parent_impl;
2228 if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (parent) ||
2229 !WINDOW_IS_TOPLEVEL (window))
2232 window_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2233 if (!window_impl->toplevel)
2236 GDK_QUARTZ_ALLOC_POOL;
2238 if (window_impl->transient_for)
2240 _gdk_quartz_window_detach_from_parent (window);
2242 g_object_unref (window_impl->transient_for);
2243 window_impl->transient_for = NULL;
2246 parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (parent)->impl);
2247 if (parent_impl->toplevel)
2249 /* We save the parent because it needs to be unset/reset when
2250 * hiding and showing the window.
2253 /* We don't set transients for tooltips, they are already
2254 * handled by the window level being the top one. If we do, then
2255 * the parent window will be brought to the top just because the
2256 * tooltip is, which is not what we want.
2258 if (gdk_window_get_type_hint (window) != GDK_WINDOW_TYPE_HINT_TOOLTIP)
2260 window_impl->transient_for = g_object_ref (parent);
2262 /* We only add the window if it is shown, otherwise it will
2263 * be shown unconditionally here. If it is not shown, the
2264 * window will be added in show() instead.
2266 if (!(GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_WITHDRAWN))
2267 _gdk_quartz_window_attach_to_parent (window);
2271 GDK_QUARTZ_RELEASE_POOL;
2275 gdk_window_quartz_shape_combine_region (GdkWindow *window,
2276 const cairo_region_t *shape,
2280 /* FIXME: Implement */
2284 gdk_window_quartz_input_shape_combine_region (GdkWindow *window,
2285 const cairo_region_t *shape_region,
2289 /* FIXME: Implement */
2293 gdk_window_set_override_redirect (GdkWindow *window,
2294 gboolean override_redirect)
2296 /* FIXME: Implement */
2300 gdk_window_set_accept_focus (GdkWindow *window,
2301 gboolean accept_focus)
2303 GdkWindowObject *private;
2305 private = (GdkWindowObject *)window;
2307 private->accept_focus = accept_focus != FALSE;
2311 gdk_window_quartz_set_static_gravities (GdkWindow *window,
2312 gboolean use_static)
2314 if (GDK_WINDOW_DESTROYED (window) ||
2315 !WINDOW_IS_TOPLEVEL (window))
2318 /* FIXME: Implement */
2323 gdk_window_set_focus_on_map (GdkWindow *window,
2324 gboolean focus_on_map)
2326 GdkWindowObject *private;
2328 private = (GdkWindowObject *)window;
2330 private->focus_on_map = focus_on_map != FALSE;
2334 gdk_window_set_icon (GdkWindow *window,
2335 GdkWindow *icon_window,
2339 /* FIXME: Implement */
2343 gdk_window_set_icon_name (GdkWindow *window,
2346 /* FIXME: Implement */
2350 gdk_window_focus (GdkWindow *window,
2353 GdkWindowObject *private;
2354 GdkWindowImplQuartz *impl;
2356 private = (GdkWindowObject*) window;
2357 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2359 if (GDK_WINDOW_DESTROYED (window) ||
2360 !WINDOW_IS_TOPLEVEL (window))
2363 if (private->accept_focus && private->window_type != GDK_WINDOW_TEMP)
2365 GDK_QUARTZ_ALLOC_POOL;
2366 [impl->toplevel makeKeyAndOrderFront:impl->toplevel];
2367 clear_toplevel_order ();
2368 GDK_QUARTZ_RELEASE_POOL;
2373 gint window_type_hint_to_level (GdkWindowTypeHint hint)
2377 case GDK_WINDOW_TYPE_HINT_DOCK:
2378 case GDK_WINDOW_TYPE_HINT_UTILITY:
2379 return NSFloatingWindowLevel;
2381 case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */
2382 case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU: /* Menu from menubar */
2383 return NSTornOffMenuWindowLevel;
2385 case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
2386 case GDK_WINDOW_TYPE_HINT_TOOLTIP:
2387 return NSStatusWindowLevel;
2389 case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
2390 case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
2391 case GDK_WINDOW_TYPE_HINT_COMBO:
2392 case GDK_WINDOW_TYPE_HINT_DND:
2393 return NSPopUpMenuWindowLevel;
2395 case GDK_WINDOW_TYPE_HINT_NORMAL: /* Normal toplevel window */
2396 case GDK_WINDOW_TYPE_HINT_DIALOG: /* Dialog window */
2397 case GDK_WINDOW_TYPE_HINT_TOOLBAR: /* Window used to implement toolbars */
2398 case GDK_WINDOW_TYPE_HINT_DESKTOP: /* N/A */
2405 return NSNormalWindowLevel;
2409 window_type_hint_to_shadow (GdkWindowTypeHint hint)
2413 case GDK_WINDOW_TYPE_HINT_NORMAL: /* Normal toplevel window */
2414 case GDK_WINDOW_TYPE_HINT_DIALOG: /* Dialog window */
2415 case GDK_WINDOW_TYPE_HINT_DOCK:
2416 case GDK_WINDOW_TYPE_HINT_UTILITY:
2417 case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */
2418 case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU: /* Menu from menubar */
2419 case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
2420 case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
2421 case GDK_WINDOW_TYPE_HINT_COMBO:
2422 case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
2423 case GDK_WINDOW_TYPE_HINT_TOOLTIP:
2426 case GDK_WINDOW_TYPE_HINT_TOOLBAR: /* Window used to implement toolbars */
2427 case GDK_WINDOW_TYPE_HINT_DESKTOP: /* N/A */
2428 case GDK_WINDOW_TYPE_HINT_DND:
2440 gdk_window_set_type_hint (GdkWindow *window,
2441 GdkWindowTypeHint hint)
2443 GdkWindowImplQuartz *impl;
2445 if (GDK_WINDOW_DESTROYED (window) ||
2446 !WINDOW_IS_TOPLEVEL (window))
2449 impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *) window)->impl);
2451 impl->type_hint = hint;
2453 /* Match the documentation, only do something if we're not mapped yet. */
2454 if (GDK_WINDOW_IS_MAPPED (window))
2457 [impl->toplevel setHasShadow: window_type_hint_to_shadow (hint)];
2458 [impl->toplevel setLevel: window_type_hint_to_level (hint)];
2462 gdk_window_get_type_hint (GdkWindow *window)
2464 if (GDK_WINDOW_DESTROYED (window) ||
2465 !WINDOW_IS_TOPLEVEL (window))
2466 return GDK_WINDOW_TYPE_HINT_NORMAL;
2468 return GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *) window)->impl)->type_hint;
2472 gdk_window_set_modal_hint (GdkWindow *window,
2475 if (GDK_WINDOW_DESTROYED (window) ||
2476 !WINDOW_IS_TOPLEVEL (window))
2479 /* FIXME: Implement */
2483 gdk_window_set_skip_taskbar_hint (GdkWindow *window,
2484 gboolean skips_taskbar)
2486 if (GDK_WINDOW_DESTROYED (window) ||
2487 !WINDOW_IS_TOPLEVEL (window))
2490 /* FIXME: Implement */
2494 gdk_window_set_skip_pager_hint (GdkWindow *window,
2495 gboolean skips_pager)
2497 if (GDK_WINDOW_DESTROYED (window) ||
2498 !WINDOW_IS_TOPLEVEL (window))
2501 /* FIXME: Implement */
2505 gdk_window_begin_resize_drag (GdkWindow *window,
2512 GdkWindowObject *private;
2513 GdkWindowImplQuartz *impl;
2515 g_return_if_fail (GDK_IS_WINDOW (window));
2517 if (edge != GDK_WINDOW_EDGE_SOUTH_EAST)
2519 g_warning ("Resizing is only implemented for GDK_WINDOW_EDGE_SOUTH_EAST on Mac OS");
2523 if (GDK_WINDOW_DESTROYED (window))
2526 private = GDK_WINDOW_OBJECT (window);
2527 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2529 if (!impl->toplevel)
2531 g_warning ("Can't call gdk_window_begin_resize_drag on non-toplevel window");
2535 [(GdkQuartzWindow *)impl->toplevel beginManualResize];
2539 gdk_window_begin_move_drag (GdkWindow *window,
2545 GdkWindowObject *private;
2546 GdkWindowImplQuartz *impl;
2548 if (GDK_WINDOW_DESTROYED (window) ||
2549 !WINDOW_IS_TOPLEVEL (window))
2552 private = GDK_WINDOW_OBJECT (window);
2553 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2555 if (!impl->toplevel)
2557 g_warning ("Can't call gdk_window_begin_move_drag on non-toplevel window");
2561 [(GdkQuartzWindow *)impl->toplevel beginManualMove];
2565 gdk_window_set_icon_list (GdkWindow *window,
2568 /* FIXME: Implement */
2572 gdk_window_get_frame_extents (GdkWindow *window,
2575 GdkWindowObject *private;
2576 GdkWindow *toplevel;
2577 GdkWindowImplQuartz *impl;
2580 g_return_if_fail (rect != NULL);
2582 private = GDK_WINDOW_OBJECT (window);
2589 toplevel = gdk_window_get_toplevel (window);
2590 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl);
2592 ns_rect = [impl->toplevel frame];
2594 _gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x,
2595 ns_rect.origin.y + ns_rect.size.height,
2596 &rect->x, &rect->y);
2598 rect->width = ns_rect.size.width;
2599 rect->height = ns_rect.size.height;
2603 gdk_window_set_decorations (GdkWindow *window,
2604 GdkWMDecoration decorations)
2606 GdkWindowImplQuartz *impl;
2607 NSUInteger old_mask, new_mask;
2610 if (GDK_WINDOW_DESTROYED (window) ||
2611 !WINDOW_IS_TOPLEVEL (window))
2614 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2616 if (decorations == 0 || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP ||
2617 impl->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN )
2619 new_mask = NSBorderlessWindowMask;
2623 /* FIXME: Honor other GDK_DECOR_* flags. */
2624 new_mask = (NSTitledWindowMask | NSClosableWindowMask |
2625 NSMiniaturizableWindowMask | NSResizableWindowMask);
2628 GDK_QUARTZ_ALLOC_POOL;
2630 old_mask = [impl->toplevel styleMask];
2632 /* Note, there doesn't seem to be a way to change this without
2633 * recreating the toplevel. There might be bad side-effects of doing
2634 * that, but it seems alright.
2636 if (old_mask != new_mask)
2640 old_view = [impl->toplevel contentView];
2642 rect = [impl->toplevel frame];
2644 /* Properly update the size of the window when the titlebar is
2647 if (old_mask == NSBorderlessWindowMask &&
2648 new_mask != NSBorderlessWindowMask)
2650 rect = [NSWindow frameRectForContentRect:rect styleMask:new_mask];
2653 else if (old_mask != NSBorderlessWindowMask &&
2654 new_mask == NSBorderlessWindowMask)
2656 rect = [NSWindow contentRectForFrameRect:rect styleMask:old_mask];
2659 impl->toplevel = [impl->toplevel initWithContentRect:rect
2661 backing:NSBackingStoreBuffered
2664 [impl->toplevel setHasShadow: window_type_hint_to_shadow (impl->type_hint)];
2665 [impl->toplevel setLevel: window_type_hint_to_level (impl->type_hint)];
2667 [impl->toplevel setContentView:old_view];
2668 [impl->toplevel setFrame:rect display:YES];
2670 /* Invalidate the window shadow for non-opaque views that have shadow
2671 * enabled, to get the shadow shape updated.
2673 if (![old_view isOpaque] && [impl->toplevel hasShadow])
2674 [(GdkQuartzView*)old_view setNeedsInvalidateShadow:YES];
2677 GDK_QUARTZ_RELEASE_POOL;
2681 gdk_window_get_decorations (GdkWindow *window,
2682 GdkWMDecoration *decorations)
2684 GdkWindowImplQuartz *impl;
2686 if (GDK_WINDOW_DESTROYED (window) ||
2687 !WINDOW_IS_TOPLEVEL (window))
2690 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2694 /* Borderless is 0, so we can't check it as a bit being set. */
2695 if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
2701 /* FIXME: Honor the other GDK_DECOR_* flags. */
2702 *decorations = GDK_DECOR_ALL;
2710 gdk_window_set_functions (GdkWindow *window,
2711 GdkWMFunction functions)
2713 g_return_if_fail (GDK_IS_WINDOW (window));
2715 /* FIXME: Implement */
2719 _gdk_windowing_window_queue_antiexpose (GdkWindow *window,
2720 cairo_region_t *area)
2726 gdk_window_stick (GdkWindow *window)
2728 if (GDK_WINDOW_DESTROYED (window) ||
2729 !WINDOW_IS_TOPLEVEL (window))
2734 gdk_window_unstick (GdkWindow *window)
2736 if (GDK_WINDOW_DESTROYED (window) ||
2737 !WINDOW_IS_TOPLEVEL (window))
2742 gdk_window_maximize (GdkWindow *window)
2744 GdkWindowImplQuartz *impl;
2746 if (GDK_WINDOW_DESTROYED (window) ||
2747 !WINDOW_IS_TOPLEVEL (window))
2750 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2752 if (GDK_WINDOW_IS_MAPPED (window))
2754 GDK_QUARTZ_ALLOC_POOL;
2756 if (impl->toplevel && ![impl->toplevel isZoomed])
2757 [impl->toplevel zoom:nil];
2759 GDK_QUARTZ_RELEASE_POOL;
2763 gdk_synthesize_window_state (window,
2765 GDK_WINDOW_STATE_MAXIMIZED);
2770 gdk_window_unmaximize (GdkWindow *window)
2772 GdkWindowImplQuartz *impl;
2774 if (GDK_WINDOW_DESTROYED (window) ||
2775 !WINDOW_IS_TOPLEVEL (window))
2778 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2780 if (GDK_WINDOW_IS_MAPPED (window))
2782 GDK_QUARTZ_ALLOC_POOL;
2784 if (impl->toplevel && [impl->toplevel isZoomed])
2785 [impl->toplevel zoom:nil];
2787 GDK_QUARTZ_RELEASE_POOL;
2791 gdk_synthesize_window_state (window,
2792 GDK_WINDOW_STATE_MAXIMIZED,
2798 gdk_window_iconify (GdkWindow *window)
2800 GdkWindowImplQuartz *impl;
2802 if (GDK_WINDOW_DESTROYED (window) ||
2803 !WINDOW_IS_TOPLEVEL (window))
2806 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2808 if (GDK_WINDOW_IS_MAPPED (window))
2810 GDK_QUARTZ_ALLOC_POOL;
2813 [impl->toplevel miniaturize:nil];
2815 GDK_QUARTZ_RELEASE_POOL;
2819 gdk_synthesize_window_state (window,
2821 GDK_WINDOW_STATE_ICONIFIED);
2826 gdk_window_deiconify (GdkWindow *window)
2828 GdkWindowImplQuartz *impl;
2830 if (GDK_WINDOW_DESTROYED (window) ||
2831 !WINDOW_IS_TOPLEVEL (window))
2834 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2836 if (GDK_WINDOW_IS_MAPPED (window))
2838 GDK_QUARTZ_ALLOC_POOL;
2841 [impl->toplevel deminiaturize:nil];
2843 GDK_QUARTZ_RELEASE_POOL;
2847 gdk_synthesize_window_state (window,
2848 GDK_WINDOW_STATE_ICONIFIED,
2853 static FullscreenSavedGeometry *
2854 get_fullscreen_geometry (GdkWindow *window)
2856 return g_object_get_data (G_OBJECT (window), FULLSCREEN_DATA);
2860 gdk_window_fullscreen (GdkWindow *window)
2862 FullscreenSavedGeometry *geometry;
2863 GdkWindowObject *private = (GdkWindowObject *) window;
2866 if (GDK_WINDOW_DESTROYED (window) ||
2867 !WINDOW_IS_TOPLEVEL (window))
2870 geometry = get_fullscreen_geometry (window);
2873 geometry = g_new (FullscreenSavedGeometry, 1);
2875 geometry->x = private->x;
2876 geometry->y = private->y;
2877 geometry->width = private->width;
2878 geometry->height = private->height;
2880 if (!gdk_window_get_decorations (window, &geometry->decor))
2881 geometry->decor = GDK_DECOR_ALL;
2883 g_object_set_data_full (G_OBJECT (window),
2884 FULLSCREEN_DATA, geometry,
2887 gdk_window_set_decorations (window, 0);
2889 frame = [[NSScreen mainScreen] frame];
2890 move_resize_window_internal (window,
2892 frame.size.width, frame.size.height);
2895 SetSystemUIMode (kUIModeAllHidden, kUIOptionAutoShowMenuBar);
2897 gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
2901 gdk_window_unfullscreen (GdkWindow *window)
2903 FullscreenSavedGeometry *geometry;
2905 if (GDK_WINDOW_DESTROYED (window) ||
2906 !WINDOW_IS_TOPLEVEL (window))
2909 geometry = get_fullscreen_geometry (window);
2912 SetSystemUIMode (kUIModeNormal, 0);
2914 move_resize_window_internal (window,
2920 gdk_window_set_decorations (window, geometry->decor);
2922 g_object_set_data (G_OBJECT (window), FULLSCREEN_DATA, NULL);
2924 gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
2929 gdk_window_set_keep_above (GdkWindow *window, gboolean setting)
2931 GdkWindowObject *private = (GdkWindowObject *) window;
2932 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2935 g_return_if_fail (GDK_IS_WINDOW (window));
2937 if (GDK_WINDOW_DESTROYED (window) ||
2938 !WINDOW_IS_TOPLEVEL (window))
2941 level = window_type_hint_to_level (gdk_window_get_type_hint (window));
2943 /* Adjust normal window level by one if necessary. */
2944 [impl->toplevel setLevel: level + (setting ? 1 : 0)];
2948 gdk_window_set_keep_below (GdkWindow *window, gboolean setting)
2950 GdkWindowObject *private = (GdkWindowObject *) window;
2951 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2954 g_return_if_fail (GDK_IS_WINDOW (window));
2956 if (GDK_WINDOW_DESTROYED (window) ||
2957 !WINDOW_IS_TOPLEVEL (window))
2960 level = window_type_hint_to_level (gdk_window_get_type_hint (window));
2962 /* Adjust normal window level by one if necessary. */
2963 [impl->toplevel setLevel: level - (setting ? 1 : 0)];
2967 gdk_window_get_group (GdkWindow *window)
2969 g_return_val_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD, NULL);
2971 if (GDK_WINDOW_DESTROYED (window) ||
2972 !WINDOW_IS_TOPLEVEL (window))
2975 /* FIXME: Implement */
2981 gdk_window_set_group (GdkWindow *window,
2984 /* FIXME: Implement */
2988 gdk_window_foreign_new_for_display (GdkDisplay *display,
2989 GdkNativeWindow anid)
2991 /* Foreign windows aren't supported in Mac OS X */
2996 gdk_window_lookup (GdkNativeWindow anid)
2998 /* Foreign windows aren't supported in Mac OS X */
3003 gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
3005 /* Foreign windows aren't supported in Mac OS X */
3010 gdk_window_enable_synchronized_configure (GdkWindow *window)
3015 gdk_window_configure_finished (GdkWindow *window)
3020 gdk_window_destroy_notify (GdkWindow *window)
3022 check_grab_destroy (window);
3026 _gdk_windowing_window_beep (GdkWindow *window)
3028 g_return_if_fail (GDK_IS_WINDOW (window));
3030 gdk_display_beep (_gdk_display);
3034 gdk_window_set_opacity (GdkWindow *window,
3037 GdkWindowObject *private = (GdkWindowObject *) window;
3038 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
3040 g_return_if_fail (GDK_IS_WINDOW (window));
3041 g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
3043 if (GDK_WINDOW_DESTROYED (window) ||
3044 !WINDOW_IS_TOPLEVEL (window))
3049 else if (opacity > 1)
3052 [impl->toplevel setAlphaValue: opacity];
3056 _gdk_windowing_window_set_composited (GdkWindow *window, gboolean composited)
3061 _gdk_windowing_get_shape_for_mask (GdkBitmap *mask)
3063 /* FIXME: implement */
3068 _gdk_windowing_window_get_shape (GdkWindow *window)
3070 /* FIXME: implement */
3075 _gdk_windowing_window_get_input_shape (GdkWindow *window)
3077 /* FIXME: implement */
3082 gdk_window_impl_iface_init (GdkWindowImplIface *iface)
3084 iface->show = gdk_window_quartz_show;
3085 iface->hide = gdk_window_quartz_hide;
3086 iface->withdraw = gdk_window_quartz_withdraw;
3087 iface->set_events = gdk_window_quartz_set_events;
3088 iface->get_events = gdk_window_quartz_get_events;
3089 iface->raise = gdk_window_quartz_raise;
3090 iface->lower = gdk_window_quartz_lower;
3091 iface->restack_toplevel = gdk_window_quartz_restack_toplevel;
3092 iface->move_resize = gdk_window_quartz_move_resize;
3093 iface->set_background = gdk_window_quartz_set_background;
3094 iface->set_back_pixmap = gdk_window_quartz_set_back_pixmap;
3095 iface->reparent = gdk_window_quartz_reparent;
3096 iface->set_device_cursor = gdk_window_quartz_set_device_cursor;
3097 iface->get_geometry = gdk_window_quartz_get_geometry;
3098 iface->get_root_coords = gdk_window_quartz_get_root_coords;
3099 iface->get_device_state = gdk_window_quartz_get_device_state;
3100 iface->get_deskrelative_origin = gdk_window_quartz_get_deskrelative_origin;
3101 iface->shape_combine_region = gdk_window_quartz_shape_combine_region;
3102 iface->input_shape_combine_region = gdk_window_quartz_input_shape_combine_region;
3103 iface->set_static_gravities = gdk_window_quartz_set_static_gravities;
3104 iface->queue_antiexpose = _gdk_quartz_window_queue_antiexpose;
3105 iface->translate = _gdk_quartz_window_translate;
3106 iface->destroy = _gdk_quartz_window_destroy;