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;
33 static gpointer root_window_parent_class;
35 static GSList *update_nswindows;
36 static gboolean in_process_all_updates = FALSE;
38 static GSList *main_window_stack;
40 #define FULLSCREEN_DATA "fullscreen-data"
46 GdkWMDecoration decor;
47 } FullscreenSavedGeometry;
50 static void update_toplevel_order (void);
51 static void clear_toplevel_order (void);
53 static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window);
55 #define WINDOW_IS_TOPLEVEL(window) \
56 (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
57 GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
58 GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
60 static void gdk_window_impl_iface_init (GdkWindowImplIface *iface);
63 gdk_quartz_window_get_nsview (GdkWindow *window)
65 GdkWindowObject *private = (GdkWindowObject *)window;
67 if (GDK_WINDOW_DESTROYED (window))
70 return ((GdkWindowImplQuartz *)private->impl)->view;
74 gdk_quartz_window_get_nswindow (GdkWindow *window)
76 GdkWindowObject *private = (GdkWindowObject *)window;
78 if (GDK_WINDOW_DESTROYED (window))
81 return ((GdkWindowImplQuartz *)private->impl)->toplevel;
85 gdk_window_impl_quartz_get_context (GdkDrawable *drawable,
88 GdkDrawableImplQuartz *drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable);
89 GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (drawable);
90 CGContextRef cg_context;
92 if (GDK_WINDOW_DESTROYED (drawable_impl->wrapper))
95 /* Lock focus when not called as part of a drawRect call. This
96 * is needed when called from outside "real" expose events, for
97 * example for synthesized expose events when realizing windows
98 * and for widgets that send fake expose events like the arrow
99 * buttons in spinbuttons or the position marker in rulers.
101 if (window_impl->in_paint_rect_count == 0)
103 if (![window_impl->view lockFocusIfCanDraw])
107 cg_context = [[NSGraphicsContext currentContext] graphicsPort];
108 CGContextSaveGState (cg_context);
109 CGContextSetAllowsAntialiasing (cg_context, antialias);
111 /* We'll emulate the clipping caused by double buffering here */
112 if (window_impl->begin_paint_count != 0)
118 n_rects = cairo_region_num_rectangles (window_impl->paint_clip_region);
123 cg_rects = g_new (CGRect, n_rects);
125 for (i = 0; i < n_rects; i++)
127 cairo_rectangle_int_t cairo_rect;
128 cairo_region_get_rectangle (window_impl->paint_clip_region,
130 cg_rects[i].origin.x = cairo_rect.x;
131 cg_rects[i].origin.y = cairo_rect.y;
132 cg_rects[i].size.width = cairo_rect.width;
133 cg_rects[i].size.height = cairo_rect.height;
136 CGContextClipToRects (cg_context, cg_rects, n_rects);
138 if (cg_rects != &rect)
146 gdk_window_impl_quartz_release_context (GdkDrawable *drawable,
147 CGContextRef cg_context)
149 GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (drawable);
151 CGContextRestoreGState (cg_context);
152 CGContextSetAllowsAntialiasing (cg_context, TRUE);
154 /* See comment in gdk_quartz_drawable_get_context(). */
155 if (window_impl->in_paint_rect_count == 0)
157 _gdk_quartz_drawable_flush (drawable);
158 [window_impl->view unlockFocus];
163 check_grab_unmap (GdkWindow *window)
166 GdkDisplay *display = gdk_window_get_display (window);
167 GdkDeviceManager *device_manager;
169 device_manager = gdk_display_get_device_manager (display);
170 list = gdk_device_manager_list_devices (device_manager,
171 GDK_DEVICE_TYPE_FLOATING);
172 for (l = list; l; l = l->next)
174 _gdk_display_end_device_grab (display, l->data, 0, window, TRUE);
181 check_grab_destroy (GdkWindow *window)
184 GdkDisplay *display = gdk_window_get_display (window);
185 GdkDeviceManager *device_manager;
187 /* Make sure there is no lasting grab in this native window */
188 device_manager = gdk_display_get_device_manager (display);
189 list = gdk_device_manager_list_devices (device_manager,
190 GDK_DEVICE_TYPE_MASTER);
192 for (l = list; l; l = l->next)
194 GdkDeviceGrabInfo *grab;
196 grab = _gdk_display_get_last_device_grab (display, l->data);
197 if (grab && grab->native_window == window)
199 /* Serials are always 0 in quartz, but for clarity: */
200 grab->serial_end = grab->serial_start;
201 grab->implicit_ungrab = TRUE;
209 gdk_window_impl_quartz_finalize (GObject *object)
211 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (object);
213 check_grab_destroy (GDK_DRAWABLE_IMPL_QUARTZ (object)->wrapper);
215 if (impl->paint_clip_region)
216 cairo_region_destroy (impl->paint_clip_region);
218 if (impl->transient_for)
219 g_object_unref (impl->transient_for);
221 G_OBJECT_CLASS (parent_class)->finalize (object);
225 gdk_window_impl_quartz_class_init (GdkWindowImplQuartzClass *klass)
227 GObjectClass *object_class = G_OBJECT_CLASS (klass);
228 GdkDrawableImplQuartzClass *drawable_quartz_class = GDK_DRAWABLE_IMPL_QUARTZ_CLASS (klass);
230 parent_class = g_type_class_peek_parent (klass);
232 object_class->finalize = gdk_window_impl_quartz_finalize;
234 drawable_quartz_class->get_context = gdk_window_impl_quartz_get_context;
235 drawable_quartz_class->release_context = gdk_window_impl_quartz_release_context;
239 gdk_window_impl_quartz_init (GdkWindowImplQuartz *impl)
241 impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
245 gdk_window_impl_quartz_begin_paint_region (GdkPaintable *paintable,
247 const cairo_region_t *region)
249 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable);
250 GdkWindowObject *private = (GdkWindowObject*) window;
251 cairo_region_t *clipped_and_offset_region;
254 clipped_and_offset_region = cairo_region_copy (region);
256 cairo_region_intersect (clipped_and_offset_region,
257 private->clip_region_with_children);
258 cairo_region_translate (clipped_and_offset_region,
259 private->abs_x, private->abs_y);
261 if (impl->begin_paint_count == 0)
262 impl->paint_clip_region = cairo_region_reference (clipped_and_offset_region);
264 cairo_region_union (impl->paint_clip_region, clipped_and_offset_region);
266 impl->begin_paint_count++;
268 if (cairo_region_is_empty (clipped_and_offset_region))
271 cr = gdk_cairo_create (window);
273 cairo_translate (cr, -private->abs_x, -private->abs_y);
275 gdk_cairo_region (cr, clipped_and_offset_region);
278 while (private->background == NULL && private->parent)
280 cairo_translate (cr, -private->x, private->y);
281 private = private->parent;
284 if (private->background)
285 cairo_set_source (cr, private->background);
287 cairo_set_source_rgba (cr, 0, 0, 0, 0);
289 /* Can use cairo_paint() here, we clipped above */
295 cairo_region_destroy (clipped_and_offset_region);
299 gdk_window_impl_quartz_end_paint (GdkPaintable *paintable)
301 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable);
303 impl->begin_paint_count--;
305 if (impl->begin_paint_count == 0)
307 cairo_region_destroy (impl->paint_clip_region);
308 impl->paint_clip_region = NULL;
313 _gdk_quartz_window_set_needs_display_in_region (GdkWindow *window,
314 cairo_region_t *region)
316 GdkWindowObject *private;
317 GdkWindowImplQuartz *impl;
320 private = GDK_WINDOW_OBJECT (window);
321 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
323 if (!impl->needs_display_region)
324 impl->needs_display_region = cairo_region_create ();
326 cairo_region_union (impl->needs_display_region, region);
328 n_rects = cairo_region_num_rectangles (region);
329 for (i = 0; i < n_rects; i++)
331 cairo_rectangle_int_t rect;
332 cairo_region_get_rectangle (region, i, &rect);
333 [impl->view setNeedsDisplayInRect:NSMakeRect (rect.x, rect.y,
334 rect.width, rect.height)];
339 _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
340 cairo_region_t *region)
342 /* Make sure to only flush each toplevel at most once if we're called
343 * from process_all_updates.
345 if (in_process_all_updates)
349 toplevel = gdk_window_get_effective_toplevel (window);
350 if (toplevel && WINDOW_IS_TOPLEVEL (toplevel))
352 GdkWindowObject *toplevel_private;
353 GdkWindowImplQuartz *toplevel_impl;
356 toplevel_private = (GdkWindowObject *)toplevel;
357 toplevel_impl = (GdkWindowImplQuartz *)toplevel_private->impl;
358 nswindow = toplevel_impl->toplevel;
360 /* In theory, we could skip the flush disabling, since we only
363 if (nswindow && ![nswindow isFlushWindowDisabled])
366 [nswindow disableFlushWindow];
367 update_nswindows = g_slist_prepend (update_nswindows, nswindow);
372 if (WINDOW_IS_TOPLEVEL (window))
373 _gdk_quartz_window_set_needs_display_in_region (window, region);
375 _gdk_window_process_updates_recurse (window, region);
377 /* NOTE: I'm not sure if we should displayIfNeeded here. It slows down a
378 * lot (since it triggers the beam syncing) and things seem to work
384 _gdk_windowing_before_process_all_updates (void)
386 in_process_all_updates = TRUE;
388 NSDisableScreenUpdates ();
392 _gdk_windowing_after_process_all_updates (void)
394 GSList *old_update_nswindows = update_nswindows;
395 GSList *tmp_list = update_nswindows;
397 update_nswindows = NULL;
401 NSWindow *nswindow = tmp_list->data;
403 [[nswindow contentView] displayIfNeeded];
405 _gdk_quartz_drawable_flush (NULL);
407 [nswindow enableFlushWindow];
408 [nswindow flushWindow];
411 tmp_list = tmp_list->next;
414 g_slist_free (old_update_nswindows);
416 in_process_all_updates = FALSE;
418 NSEnableScreenUpdates ();
422 gdk_window_impl_quartz_paintable_init (GdkPaintableIface *iface)
424 iface->begin_paint_region = gdk_window_impl_quartz_begin_paint_region;
425 iface->end_paint = gdk_window_impl_quartz_end_paint;
429 _gdk_window_impl_quartz_get_type (void)
431 static GType object_type = 0;
435 const GTypeInfo object_info =
437 sizeof (GdkWindowImplQuartzClass),
438 (GBaseInitFunc) NULL,
439 (GBaseFinalizeFunc) NULL,
440 (GClassInitFunc) gdk_window_impl_quartz_class_init,
441 NULL, /* class_finalize */
442 NULL, /* class_data */
443 sizeof (GdkWindowImplQuartz),
445 (GInstanceInitFunc) gdk_window_impl_quartz_init,
448 const GInterfaceInfo paintable_info =
450 (GInterfaceInitFunc) gdk_window_impl_quartz_paintable_init,
455 const GInterfaceInfo window_impl_info =
457 (GInterfaceInitFunc) gdk_window_impl_iface_init,
462 object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_QUARTZ,
463 "GdkWindowImplQuartz",
465 g_type_add_interface_static (object_type,
468 g_type_add_interface_static (object_type,
469 GDK_TYPE_WINDOW_IMPL,
477 _gdk_window_impl_get_type (void)
479 return _gdk_window_impl_quartz_get_type ();
483 get_default_title (void)
487 title = g_get_application_name ();
489 title = g_get_prgname ();
495 get_ancestor_coordinates_from_child (GdkWindow *child_window,
498 GdkWindow *ancestor_window,
502 GdkWindowObject *child_private = GDK_WINDOW_OBJECT (child_window);
503 GdkWindowObject *ancestor_private = GDK_WINDOW_OBJECT (ancestor_window);
505 while (child_private != ancestor_private)
507 child_x += child_private->x;
508 child_y += child_private->y;
510 child_private = child_private->parent;
513 *ancestor_x = child_x;
514 *ancestor_y = child_y;
518 _gdk_quartz_window_debug_highlight (GdkWindow *window, gint number)
520 GdkWindowObject *private = GDK_WINDOW_OBJECT (window);
525 static NSWindow *debug_window[10];
526 static NSRect old_rect[10];
530 g_return_if_fail (number >= 0 && number <= 9);
532 if (window == _gdk_root)
537 if (debug_window[number])
538 [debug_window[number] close];
539 debug_window[number] = NULL;
544 toplevel = gdk_window_get_toplevel (window);
545 get_ancestor_coordinates_from_child (window, 0, 0, toplevel, &x, &y);
547 gdk_window_get_origin (toplevel, &tx, &ty);
551 _gdk_quartz_window_gdk_xy_to_xy (x, y + private->height,
554 rect = NSMakeRect (gx, gy, private->width, private->height);
556 if (debug_window[number] && NSEqualRects (rect, old_rect[number]))
559 old_rect[number] = rect;
561 if (debug_window[number])
562 [debug_window[number] close];
564 debug_window[number] = [[NSWindow alloc] initWithContentRect:rect
565 styleMask:NSBorderlessWindowMask
566 backing:NSBackingStoreBuffered
572 color = [NSColor redColor];
575 color = [NSColor blueColor];
578 color = [NSColor greenColor];
581 color = [NSColor yellowColor];
584 color = [NSColor brownColor];
587 color = [NSColor purpleColor];
590 color = [NSColor blackColor];
594 [debug_window[number] setBackgroundColor:color];
595 [debug_window[number] setAlphaValue:0.4];
596 [debug_window[number] setOpaque:NO];
597 [debug_window[number] setReleasedWhenClosed:YES];
598 [debug_window[number] setIgnoresMouseEvents:YES];
599 [debug_window[number] setLevel:NSFloatingWindowLevel];
601 [debug_window[number] orderFront:nil];
605 _gdk_quartz_window_is_ancestor (GdkWindow *ancestor,
608 if (ancestor == NULL || window == NULL)
611 return (gdk_window_get_parent (window) == ancestor ||
612 _gdk_quartz_window_is_ancestor (ancestor,
613 gdk_window_get_parent (window)));
617 /* See notes on top of gdkscreen-quartz.c */
619 _gdk_quartz_window_gdk_xy_to_xy (gint gdk_x,
624 GdkScreenQuartz *screen_quartz = GDK_SCREEN_QUARTZ (_gdk_screen);
627 *ns_y = screen_quartz->height - gdk_y + screen_quartz->min_y;
630 *ns_x = gdk_x + screen_quartz->min_x;
634 _gdk_quartz_window_xy_to_gdk_xy (gint ns_x,
639 GdkScreenQuartz *screen_quartz = GDK_SCREEN_QUARTZ (_gdk_screen);
642 *gdk_y = screen_quartz->height - ns_y + screen_quartz->min_y;
645 *gdk_x = ns_x - screen_quartz->min_x;
649 _gdk_quartz_window_nspoint_to_gdk_xy (NSPoint point,
653 _gdk_quartz_window_xy_to_gdk_xy (point.x, point.y,
658 find_child_window_helper (GdkWindow *window,
663 gboolean get_toplevel)
665 GdkWindowImplQuartz *impl;
668 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
670 if (window == _gdk_root)
671 update_toplevel_order ();
673 for (l = impl->sorted_children; l; l = l->next)
675 GdkWindowObject *child_private = l->data;
676 GdkWindowImplQuartz *child_impl = GDK_WINDOW_IMPL_QUARTZ (child_private->impl);
679 if (!GDK_WINDOW_IS_MAPPED (child_private))
682 temp_x = x_offset + child_private->x;
683 temp_y = y_offset + child_private->y;
685 /* Special-case the root window. We have to include the title
686 * bar in the checks, otherwise the window below the title bar
687 * will be found i.e. events punch through. (If we can find a
688 * better way to deal with the events in gdkevents-quartz, this
689 * might not be needed.)
691 if (window == _gdk_root)
693 NSRect frame = NSMakeRect (0, 0, 100, 100);
698 mask = [child_impl->toplevel styleMask];
700 /* Get the title bar height. */
701 content = [NSWindow contentRectForFrameRect:frame
703 titlebar_height = frame.size.height - content.size.height;
705 if (titlebar_height > 0 &&
706 x >= temp_x && y >= temp_y - titlebar_height &&
707 x < temp_x + child_private->width && y < temp_y)
709 /* The root means "unknown" i.e. a window not managed by
712 return (GdkWindow *)_gdk_root;
716 if ((!get_toplevel || (get_toplevel && window == _gdk_root)) &&
717 x >= temp_x && y >= temp_y &&
718 x < temp_x + child_private->width && y < temp_y + child_private->height)
720 /* Look for child windows. */
721 return find_child_window_helper (l->data,
731 /* Given a GdkWindow and coordinates relative to it, returns the
732 * innermost subwindow that contains the point. If the coordinates are
733 * outside the passed in window, NULL is returned.
736 _gdk_quartz_window_find_child (GdkWindow *window,
739 gboolean get_toplevel)
741 GdkWindowObject *private = GDK_WINDOW_OBJECT (window);
743 if (x >= 0 && y >= 0 && x < private->width && y < private->height)
744 return find_child_window_helper (window, x, y, 0, 0, get_toplevel);
751 _gdk_quartz_window_did_become_main (GdkWindow *window)
753 main_window_stack = g_slist_remove (main_window_stack, window);
755 if (GDK_WINDOW_OBJECT (window)->window_type != GDK_WINDOW_TEMP)
756 main_window_stack = g_slist_prepend (main_window_stack, window);
758 clear_toplevel_order ();
762 _gdk_quartz_window_did_resign_main (GdkWindow *window)
764 GdkWindow *new_window = NULL;
766 if (main_window_stack)
767 new_window = main_window_stack->data;
772 toplevels = gdk_screen_get_toplevel_windows (gdk_screen_get_default ());
774 new_window = toplevels->data;
775 g_list_free (toplevels);
779 new_window != window &&
780 GDK_WINDOW_IS_MAPPED (new_window) &&
781 WINDOW_IS_TOPLEVEL (new_window))
783 GdkWindowObject *private = (GdkWindowObject *) new_window;
784 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
786 [impl->toplevel makeKeyAndOrderFront:impl->toplevel];
789 clear_toplevel_order ();
793 get_nsscreen_for_point (gint x, gint y)
797 NSScreen *screen = NULL;
799 GDK_QUARTZ_ALLOC_POOL;
801 screens = [NSScreen screens];
803 for (i = 0; i < [screens count]; i++)
805 NSRect rect = [[screens objectAtIndex:i] frame];
807 if (x >= rect.origin.x && x <= rect.origin.x + rect.size.width &&
808 y >= rect.origin.y && y <= rect.origin.y + rect.size.height)
810 screen = [screens objectAtIndex:i];
815 GDK_QUARTZ_RELEASE_POOL;
821 _gdk_window_impl_new (GdkWindow *window,
822 GdkWindow *real_parent,
824 GdkEventMask event_mask,
825 GdkWindowAttr *attributes,
826 gint attributes_mask)
828 GdkWindowObject *private;
829 GdkWindowImplQuartz *impl;
830 GdkDrawableImplQuartz *draw_impl;
831 GdkWindowImplQuartz *parent_impl;
833 GDK_QUARTZ_ALLOC_POOL;
835 private = (GdkWindowObject *)window;
837 impl = g_object_new (_gdk_window_impl_get_type (), NULL);
838 private->impl = (GdkDrawable *)impl;
839 draw_impl = GDK_DRAWABLE_IMPL_QUARTZ (impl);
840 draw_impl->wrapper = GDK_DRAWABLE (window);
842 parent_impl = GDK_WINDOW_IMPL_QUARTZ (private->parent->impl);
844 switch (private->window_type)
846 case GDK_WINDOW_TOPLEVEL:
847 case GDK_WINDOW_TEMP:
848 if (GDK_WINDOW_TYPE (private->parent) != GDK_WINDOW_ROOT)
850 /* The common code warns for this case */
851 parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl);
855 /* Maintain the z-ordered list of children. */
856 if (private->parent != (GdkWindowObject *)_gdk_root)
857 parent_impl->sorted_children = g_list_prepend (parent_impl->sorted_children, window);
859 clear_toplevel_order ();
861 gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
862 (attributes->cursor) :
867 switch (attributes->window_type)
869 case GDK_WINDOW_TOPLEVEL:
870 case GDK_WINDOW_TEMP:
875 NSUInteger style_mask;
879 /* initWithContentRect will place on the mainScreen by default.
880 * We want to select the screen to place on ourselves. We need
881 * to find the screen the window will be on and correct the
882 * content_rect coordinates to be relative to that screen.
884 _gdk_quartz_window_gdk_xy_to_xy (private->x, private->y, &nx, &ny);
886 screen = get_nsscreen_for_point (nx, ny);
887 screen_rect = [screen frame];
888 nx -= screen_rect.origin.x;
889 ny -= screen_rect.origin.y;
891 content_rect = NSMakeRect (nx, ny - private->height,
895 if (attributes->window_type == GDK_WINDOW_TEMP ||
896 attributes->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN)
898 style_mask = NSBorderlessWindowMask;
902 style_mask = (NSTitledWindowMask |
903 NSClosableWindowMask |
904 NSMiniaturizableWindowMask |
905 NSResizableWindowMask);
908 impl->toplevel = [[GdkQuartzWindow alloc] initWithContentRect:content_rect
910 backing:NSBackingStoreBuffered
914 if (attributes_mask & GDK_WA_TITLE)
915 title = attributes->title;
917 title = get_default_title ();
919 gdk_window_set_title (window, title);
921 if (gdk_window_get_visual (window) == gdk_screen_get_rgba_visual (_gdk_screen))
923 [impl->toplevel setOpaque:NO];
924 [impl->toplevel setBackgroundColor:[NSColor clearColor]];
927 content_rect.origin.x = 0;
928 content_rect.origin.y = 0;
930 impl->view = [[GdkQuartzView alloc] initWithFrame:content_rect];
931 [impl->view setGdkWindow:window];
932 [impl->toplevel setContentView:impl->view];
933 [impl->view release];
937 case GDK_WINDOW_CHILD:
939 GdkWindowImplQuartz *parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (private->parent)->impl);
941 if (!private->input_only)
943 NSRect frame_rect = NSMakeRect (private->x + private->parent->abs_x,
944 private->y + private->parent->abs_y,
948 impl->view = [[GdkQuartzView alloc] initWithFrame:frame_rect];
950 [impl->view setGdkWindow:window];
952 /* GdkWindows should be hidden by default */
953 [impl->view setHidden:YES];
954 [parent_impl->view addSubview:impl->view];
955 [impl->view release];
961 g_assert_not_reached ();
964 GDK_QUARTZ_RELEASE_POOL;
966 if (attributes_mask & GDK_WA_TYPE_HINT)
967 gdk_window_set_type_hint (window, attributes->type_hint);
971 _gdk_quartz_window_update_position (GdkWindow *window)
975 GdkWindowObject *private = (GdkWindowObject *)window;
976 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
978 GDK_QUARTZ_ALLOC_POOL;
980 frame_rect = [impl->toplevel frame];
981 content_rect = [impl->toplevel contentRectForFrameRect:frame_rect];
983 _gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x,
984 content_rect.origin.y + content_rect.size.height,
985 &private->x, &private->y);
988 GDK_QUARTZ_RELEASE_POOL;
992 _gdk_windowing_update_window_sizes (GdkScreen *screen)
994 GList *windows, *list;
995 GdkWindowObject *private = (GdkWindowObject *)_gdk_root;
997 /* The size of the root window is so that it can contain all
998 * monitors attached to this machine. The monitors are laid out
999 * within this root window. We calculate the size of the root window
1000 * and the positions of the different monitors in gdkscreen-quartz.c.
1002 * This data is updated when the monitor configuration is changed.
1008 private->width = gdk_screen_get_width (screen);
1009 private->height = gdk_screen_get_height (screen);
1011 windows = gdk_screen_get_toplevel_windows (screen);
1013 for (list = windows; list; list = list->next)
1014 _gdk_quartz_window_update_position (list->data);
1016 g_list_free (windows);
1020 _gdk_windowing_window_init (void)
1022 GdkWindowObject *private;
1023 GdkWindowImplQuartz *impl;
1024 GdkDrawableImplQuartz *drawable_impl;
1026 g_assert (_gdk_root == NULL);
1028 _gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL);
1030 private = (GdkWindowObject *)_gdk_root;
1031 private->impl = g_object_new (_gdk_root_window_impl_quartz_get_type (), NULL);
1032 private->impl_window = private;
1033 private->visual = gdk_screen_get_system_visual (_gdk_screen);
1035 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl);
1037 _gdk_windowing_update_window_sizes (_gdk_screen);
1039 private->state = 0; /* We don't want GDK_WINDOW_STATE_WITHDRAWN here */
1040 private->window_type = GDK_WINDOW_ROOT;
1041 private->depth = 24;
1042 private->viewable = TRUE;
1044 drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (private->impl);
1046 drawable_impl->wrapper = GDK_DRAWABLE (private);
1050 _gdk_quartz_window_destroy (GdkWindow *window,
1052 gboolean foreign_destroy)
1054 GdkWindowObject *private;
1055 GdkWindowImplQuartz *impl;
1056 GdkWindowObject *parent;
1058 private = GDK_WINDOW_OBJECT (window);
1059 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1061 main_window_stack = g_slist_remove (main_window_stack, window);
1063 g_list_free (impl->sorted_children);
1064 impl->sorted_children = NULL;
1066 parent = private->parent;
1069 GdkWindowImplQuartz *parent_impl = GDK_WINDOW_IMPL_QUARTZ (parent->impl);
1071 parent_impl->sorted_children = g_list_remove (parent_impl->sorted_children, window);
1074 _gdk_quartz_drawable_finish (GDK_DRAWABLE (impl));
1076 if (!recursing && !foreign_destroy)
1078 GDK_QUARTZ_ALLOC_POOL;
1081 [impl->toplevel close];
1082 else if (impl->view)
1083 [impl->view removeFromSuperview];
1085 GDK_QUARTZ_RELEASE_POOL;
1089 static cairo_surface_t *
1090 gdk_window_quartz_resize_cairo_surface (GdkWindow *window,
1091 cairo_surface_t *surface,
1095 /* Quartz surfaces cannot be resized */
1096 cairo_surface_destroy (surface);
1102 _gdk_windowing_window_destroy_foreign (GdkWindow *window)
1104 /* Foreign windows aren't supported in OSX. */
1107 /* FIXME: This might be possible to simplify with client-side windows. Also
1108 * note that already_mapped is not used yet, see the x11 backend.
1111 gdk_window_quartz_show (GdkWindow *window, gboolean already_mapped)
1113 GdkWindowObject *private = (GdkWindowObject *)window;
1114 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1115 gboolean focus_on_map;
1117 GDK_QUARTZ_ALLOC_POOL;
1119 if (!GDK_WINDOW_IS_MAPPED (window))
1120 focus_on_map = private->focus_on_map;
1122 focus_on_map = TRUE;
1124 if (WINDOW_IS_TOPLEVEL (window) && impl->toplevel)
1128 make_key = (private->accept_focus && focus_on_map &&
1129 private->window_type != GDK_WINDOW_TEMP);
1131 [(GdkQuartzWindow*)impl->toplevel showAndMakeKey:make_key];
1132 clear_toplevel_order ();
1134 _gdk_quartz_events_send_map_event (window);
1138 [impl->view setHidden:NO];
1141 [impl->view setNeedsDisplay:YES];
1143 gdk_synthesize_window_state (window, GDK_WINDOW_STATE_WITHDRAWN, 0);
1145 if (private->state & GDK_WINDOW_STATE_MAXIMIZED)
1146 gdk_window_maximize (window);
1148 if (private->state & GDK_WINDOW_STATE_ICONIFIED)
1149 gdk_window_iconify (window);
1151 if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
1152 _gdk_quartz_window_attach_to_parent (window);
1154 GDK_QUARTZ_RELEASE_POOL;
1157 /* Temporarily unsets the parent window, if the window is a
1161 _gdk_quartz_window_detach_from_parent (GdkWindow *window)
1163 GdkWindowImplQuartz *impl;
1165 g_return_if_fail (GDK_IS_WINDOW (window));
1167 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1169 g_return_if_fail (impl->toplevel != NULL);
1171 if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
1173 GdkWindowImplQuartz *parent_impl;
1175 parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (impl->transient_for)->impl);
1176 [parent_impl->toplevel removeChildWindow:impl->toplevel];
1177 clear_toplevel_order ();
1181 /* Re-sets the parent window, if the window is a transient. */
1183 _gdk_quartz_window_attach_to_parent (GdkWindow *window)
1185 GdkWindowImplQuartz *impl;
1187 g_return_if_fail (GDK_IS_WINDOW (window));
1189 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1191 g_return_if_fail (impl->toplevel != NULL);
1193 if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
1195 GdkWindowImplQuartz *parent_impl;
1197 parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (impl->transient_for)->impl);
1198 [parent_impl->toplevel addChildWindow:impl->toplevel ordered:NSWindowAbove];
1199 clear_toplevel_order ();
1204 gdk_window_quartz_hide (GdkWindow *window)
1206 GdkWindowObject *private = (GdkWindowObject *)window;
1207 GdkWindowImplQuartz *impl;
1209 /* Make sure we're not stuck in fullscreen mode. */
1210 if (get_fullscreen_geometry (window))
1211 SetSystemUIMode (kUIModeNormal, 0);
1213 check_grab_unmap (window);
1215 _gdk_window_clear_update_area (window);
1217 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1219 if (WINDOW_IS_TOPLEVEL (window))
1221 /* Update main window. */
1222 main_window_stack = g_slist_remove (main_window_stack, window);
1223 if ([NSApp mainWindow] == impl->toplevel)
1224 _gdk_quartz_window_did_resign_main (window);
1226 if (impl->transient_for)
1227 _gdk_quartz_window_detach_from_parent (window);
1229 [(GdkQuartzWindow*)impl->toplevel hide];
1231 else if (impl->view)
1233 [impl->view setHidden:YES];
1238 gdk_window_quartz_withdraw (GdkWindow *window)
1240 gdk_window_hide (window);
1244 move_resize_window_internal (GdkWindow *window,
1250 GdkWindowObject *private = (GdkWindowObject *)window;
1251 GdkWindowImplQuartz *impl;
1252 GdkRectangle old_visible;
1253 GdkRectangle new_visible;
1254 GdkRectangle scroll_rect;
1255 cairo_region_t *old_region;
1256 cairo_region_t *expose_region;
1259 if (GDK_WINDOW_DESTROYED (window))
1262 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1264 if ((x == -1 || (x == private->x)) &&
1265 (y == -1 || (y == private->y)) &&
1266 (width == -1 || (width == private->width)) &&
1267 (height == -1 || (height == private->height)))
1272 if (!impl->toplevel)
1274 /* The previously visible area of this window in a coordinate
1275 * system rooted at the origin of this window.
1277 old_visible.x = -private->x;
1278 old_visible.y = -private->y;
1280 old_visible.width = private->width;
1281 old_visible.height = private->height;
1286 delta.width = x - private->x;
1296 delta.height = y - private->y;
1305 private->width = width;
1308 private->height = height;
1310 GDK_QUARTZ_ALLOC_POOL;
1314 NSRect content_rect;
1318 _gdk_quartz_window_gdk_xy_to_xy (private->x, private->y + private->height,
1321 content_rect = NSMakeRect (gx, gy, private->width, private->height);
1323 frame_rect = [impl->toplevel frameRectForContentRect:content_rect];
1324 [impl->toplevel setFrame:frame_rect display:YES];
1328 if (!private->input_only)
1332 nsrect = NSMakeRect (private->x, private->y, private->width, private->height);
1334 /* The newly visible area of this window in a coordinate
1335 * system rooted at the origin of this window.
1337 new_visible.x = -private->x;
1338 new_visible.y = -private->y;
1339 new_visible.width = old_visible.width; /* parent has not changed size */
1340 new_visible.height = old_visible.height; /* parent has not changed size */
1342 expose_region = cairo_region_create_rectangle (&new_visible);
1343 old_region = cairo_region_create_rectangle (&old_visible);
1344 cairo_region_subtract (expose_region, old_region);
1346 /* Determine what (if any) part of the previously visible
1347 * part of the window can be copied without a redraw
1349 scroll_rect = old_visible;
1350 scroll_rect.x -= delta.width;
1351 scroll_rect.y -= delta.height;
1352 gdk_rectangle_intersect (&scroll_rect, &old_visible, &scroll_rect);
1354 if (!cairo_region_is_empty (expose_region))
1356 if (scroll_rect.width != 0 && scroll_rect.height != 0)
1358 [impl->view scrollRect:NSMakeRect (scroll_rect.x,
1365 [impl->view setFrame:nsrect];
1367 _gdk_quartz_window_set_needs_display_in_region (window, expose_region);
1371 [impl->view setFrame:nsrect];
1372 [impl->view setNeedsDisplay:YES];
1375 cairo_region_destroy (expose_region);
1376 cairo_region_destroy (old_region);
1380 GDK_QUARTZ_RELEASE_POOL;
1384 window_quartz_move (GdkWindow *window,
1388 g_return_if_fail (GDK_IS_WINDOW (window));
1390 if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN)
1393 move_resize_window_internal (window, x, y, -1, -1);
1397 window_quartz_resize (GdkWindow *window,
1401 g_return_if_fail (GDK_IS_WINDOW (window));
1403 if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN)
1411 move_resize_window_internal (window, -1, -1, width, height);
1415 window_quartz_move_resize (GdkWindow *window,
1426 move_resize_window_internal (window, x, y, width, height);
1430 gdk_window_quartz_move_resize (GdkWindow *window,
1437 if (with_move && (width < 0 && height < 0))
1438 window_quartz_move (window, x, y);
1442 window_quartz_move_resize (window, x, y, width, height);
1444 window_quartz_resize (window, width, height);
1448 /* FIXME: This might need fixing (reparenting didn't work before client-side
1452 gdk_window_quartz_reparent (GdkWindow *window,
1453 GdkWindow *new_parent,
1457 GdkWindowObject *private, *old_parent_private, *new_parent_private;
1458 GdkWindowImplQuartz *impl, *old_parent_impl, *new_parent_impl;
1459 NSView *view, *new_parent_view;
1461 if (new_parent == _gdk_root)
1463 /* Could be added, just needs implementing. */
1464 g_warning ("Reparenting to root window is not supported yet in the Mac OS X backend");
1468 private = GDK_WINDOW_OBJECT (window);
1469 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
1472 new_parent_private = GDK_WINDOW_OBJECT (new_parent);
1473 new_parent_impl = GDK_WINDOW_IMPL_QUARTZ (new_parent_private->impl);
1474 new_parent_view = new_parent_impl->view;
1476 old_parent_private = GDK_WINDOW_OBJECT (private->parent);
1477 old_parent_impl = GDK_WINDOW_IMPL_QUARTZ (old_parent_private->impl);
1481 [view removeFromSuperview];
1482 [new_parent_view addSubview:view];
1486 private->parent = new_parent_private;
1488 if (old_parent_private)
1490 old_parent_impl->sorted_children = g_list_remove (old_parent_impl->sorted_children, window);
1493 new_parent_impl->sorted_children = g_list_prepend (new_parent_impl->sorted_children, window);
1498 /* Get the toplevel ordering from NSApp and update our own list. We do
1499 * this on demand since the NSApp's list is not up to date directly
1500 * after we get windowDidBecomeMain.
1503 update_toplevel_order (void)
1505 GdkWindowObject *root;
1506 GdkWindowImplQuartz *root_impl;
1507 NSEnumerator *enumerator;
1509 GList *toplevels = NULL;
1511 root = GDK_WINDOW_OBJECT (_gdk_root);
1512 root_impl = GDK_WINDOW_IMPL_QUARTZ (root->impl);
1514 if (root_impl->sorted_children)
1517 GDK_QUARTZ_ALLOC_POOL;
1519 enumerator = [[NSApp orderedWindows] objectEnumerator];
1520 while ((nswindow = [enumerator nextObject]))
1524 if (![[nswindow contentView] isKindOfClass:[GdkQuartzView class]])
1527 window = [(GdkQuartzView *)[nswindow contentView] gdkWindow];
1528 toplevels = g_list_prepend (toplevels, window);
1531 GDK_QUARTZ_RELEASE_POOL;
1533 root_impl->sorted_children = g_list_reverse (toplevels);
1537 clear_toplevel_order (void)
1539 GdkWindowObject *root;
1540 GdkWindowImplQuartz *root_impl;
1542 root = GDK_WINDOW_OBJECT (_gdk_root);
1543 root_impl = GDK_WINDOW_IMPL_QUARTZ (root->impl);
1545 g_list_free (root_impl->sorted_children);
1546 root_impl->sorted_children = NULL;
1550 gdk_window_quartz_raise (GdkWindow *window)
1552 if (GDK_WINDOW_DESTROYED (window))
1555 if (WINDOW_IS_TOPLEVEL (window))
1557 GdkWindowImplQuartz *impl;
1559 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1560 [impl->toplevel orderFront:impl->toplevel];
1562 clear_toplevel_order ();
1566 GdkWindowObject *parent = GDK_WINDOW_OBJECT (window)->parent;
1570 GdkWindowImplQuartz *impl;
1572 impl = (GdkWindowImplQuartz *)parent->impl;
1574 impl->sorted_children = g_list_remove (impl->sorted_children, window);
1575 impl->sorted_children = g_list_prepend (impl->sorted_children, window);
1581 gdk_window_quartz_lower (GdkWindow *window)
1583 if (GDK_WINDOW_DESTROYED (window))
1586 if (WINDOW_IS_TOPLEVEL (window))
1588 GdkWindowImplQuartz *impl;
1590 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1591 [impl->toplevel orderBack:impl->toplevel];
1593 clear_toplevel_order ();
1597 GdkWindowObject *parent = GDK_WINDOW_OBJECT (window)->parent;
1601 GdkWindowImplQuartz *impl;
1603 impl = (GdkWindowImplQuartz *)parent->impl;
1605 impl->sorted_children = g_list_remove (impl->sorted_children, window);
1606 impl->sorted_children = g_list_append (impl->sorted_children, window);
1612 gdk_window_quartz_restack_toplevel (GdkWindow *window,
1616 /* FIXME: Implement this */
1620 gdk_window_quartz_set_background (GdkWindow *window,
1621 cairo_pattern_t *pattern)
1623 /* FIXME: We could theoretically set the background color for toplevels
1624 * here. (Currently we draw the background before emitting expose events)
1629 gdk_window_quartz_set_device_cursor (GdkWindow *window,
1633 GdkCursorPrivate *cursor_private;
1636 cursor_private = (GdkCursorPrivate *)cursor;
1638 if (GDK_WINDOW_DESTROYED (window))
1642 nscursor = [NSCursor arrowCursor];
1644 nscursor = cursor_private->nscursor;
1650 gdk_window_quartz_get_geometry (GdkWindow *window,
1657 GdkWindowImplQuartz *impl;
1658 GdkWindowObject *private;
1661 if (GDK_WINDOW_DESTROYED (window))
1664 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
1665 private = GDK_WINDOW_OBJECT (window);
1666 if (window == _gdk_root)
1674 *width = private->width;
1676 *height = private->height;
1678 else if (WINDOW_IS_TOPLEVEL (window))
1680 ns_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]];
1682 /* This doesn't work exactly as in X. There doesn't seem to be a
1683 * way to get the coords relative to the parent window (usually
1684 * the window frame), but that seems useless except for
1685 * borderless windows where it's relative to the root window. So
1686 * we return (0, 0) (should be something like (0, 22)) for
1687 * windows with borders and the root relative coordinates
1690 if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
1692 _gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x,
1693 ns_rect.origin.y + ns_rect.size.height,
1705 *width = ns_rect.size.width;
1707 *height = ns_rect.size.height;
1711 ns_rect = [impl->view frame];
1714 *x = ns_rect.origin.x;
1716 *y = ns_rect.origin.y;
1718 *width = ns_rect.size.width;
1720 *height = ns_rect.size.height;
1724 *depth = gdk_visual_get_depth (gdk_window_get_visual (window));
1728 gdk_window_quartz_get_root_coords (GdkWindow *window,
1734 GdkWindowObject *private;
1735 int tmp_x = 0, tmp_y = 0;
1736 GdkWindow *toplevel;
1737 NSRect content_rect;
1738 GdkWindowImplQuartz *impl;
1740 if (GDK_WINDOW_DESTROYED (window))
1750 if (window == _gdk_root)
1760 private = GDK_WINDOW_OBJECT (window);
1762 toplevel = gdk_window_get_toplevel (window);
1763 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl);
1765 content_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]];
1767 _gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x,
1768 content_rect.origin.y + content_rect.size.height,
1774 while (private != GDK_WINDOW_OBJECT (toplevel))
1776 if (_gdk_window_has_impl ((GdkWindow *)private))
1778 tmp_x += private->x;
1779 tmp_y += private->y;
1782 private = private->parent;
1794 gdk_window_get_root_origin (GdkWindow *window,
1803 gdk_window_get_frame_extents (window, &rect);
1812 /* Returns coordinates relative to the passed in window. */
1814 gdk_window_quartz_get_device_state_helper (GdkWindow *window,
1818 GdkModifierType *mask)
1820 GdkWindowObject *toplevel;
1821 GdkWindowObject *private;
1824 GdkWindow *found_window;
1826 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
1828 if (GDK_WINDOW_DESTROYED (window))
1836 toplevel = GDK_WINDOW_OBJECT (gdk_window_get_toplevel (window));
1838 *mask = _gdk_quartz_events_get_current_event_mask ();
1840 /* Get the y coordinate, needs to be flipped. */
1841 if (window == _gdk_root)
1843 point = [NSEvent mouseLocation];
1844 _gdk_quartz_window_nspoint_to_gdk_xy (point, &x_tmp, &y_tmp);
1848 GdkWindowImplQuartz *impl;
1851 impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl);
1852 private = GDK_WINDOW_OBJECT (toplevel);
1853 nswindow = impl->toplevel;
1855 point = [nswindow mouseLocationOutsideOfEventStream];
1858 y_tmp = private->height - point.y;
1860 window = (GdkWindow *)toplevel;
1863 found_window = _gdk_quartz_window_find_child (window, x_tmp, y_tmp,
1866 /* We never return the root window. */
1867 if (found_window == _gdk_root)
1868 found_window = NULL;
1873 return found_window;
1877 gdk_window_quartz_get_device_state (GdkWindow *window,
1881 GdkModifierType *mask)
1883 return gdk_window_quartz_get_device_state_helper (window,
1885 x, y, mask) != NULL;
1888 /* Returns coordinates relative to the root. */
1890 _gdk_windowing_get_device_state (GdkDisplay *display,
1895 GdkModifierType *mask)
1897 g_return_if_fail (display == _gdk_display);
1899 *screen = _gdk_screen;
1900 gdk_window_quartz_get_device_state_helper (_gdk_root, device, x, y, mask);
1904 gdk_display_warp_pointer (GdkDisplay *display,
1909 CGDisplayMoveCursorToPoint (CGMainDisplayID (), CGPointMake (x, y));
1912 /* Returns coordinates relative to the found window. */
1914 _gdk_windowing_window_at_pointer (GdkDisplay *display,
1917 GdkModifierType *mask,
1918 gboolean get_toplevel)
1920 GdkWindow *found_window;
1922 GdkModifierType tmp_mask = 0;
1924 found_window = gdk_window_quartz_get_device_state_helper (_gdk_root,
1925 display->core_pointer,
1930 GdkWindowObject *private;
1932 /* The coordinates returned above are relative the root, we want
1933 * coordinates relative the window here.
1935 private = GDK_WINDOW_OBJECT (found_window);
1936 while (private != GDK_WINDOW_OBJECT (_gdk_root))
1941 private = private->parent;
1949 /* Mimic the X backend here, -1,-1 for unknown windows. */
1959 GdkWindowObject *w = (GdkWindowObject *)found_window;
1960 /* Requested toplevel, find it. */
1961 /* TODO: This can be implemented more efficient by never
1962 recursing into children in the first place */
1965 /* Convert to toplevel */
1966 while (w->parent != NULL &&
1967 w->parent->window_type != GDK_WINDOW_ROOT)
1973 found_window = (GdkWindow *)w;
1977 return found_window;
1981 _gdk_windowing_window_at_device_position (GdkDisplay *display,
1985 GdkModifierType *mask,
1986 gboolean get_toplevel)
1988 return GDK_DEVICE_GET_CLASS (device)->window_at_position (device,
1996 gdk_window_quartz_get_events (GdkWindow *window)
1998 if (GDK_WINDOW_DESTROYED (window))
2001 return GDK_WINDOW_OBJECT (window)->event_mask;
2005 gdk_window_quartz_set_events (GdkWindow *window,
2006 GdkEventMask event_mask)
2008 /* The mask is set in the common code. */
2012 gdk_window_set_urgency_hint (GdkWindow *window,
2015 if (GDK_WINDOW_DESTROYED (window) ||
2016 !WINDOW_IS_TOPLEVEL (window))
2019 /* FIXME: Implement */
2023 gdk_window_set_geometry_hints (GdkWindow *window,
2024 const GdkGeometry *geometry,
2025 GdkWindowHints geom_mask)
2027 GdkWindowImplQuartz *impl;
2029 g_return_if_fail (geometry != NULL);
2031 if (GDK_WINDOW_DESTROYED (window) ||
2032 !WINDOW_IS_TOPLEVEL (window))
2035 impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *) window)->impl);
2036 if (!impl->toplevel)
2039 if (geom_mask & GDK_HINT_POS)
2041 /* FIXME: Implement */
2044 if (geom_mask & GDK_HINT_USER_POS)
2046 /* FIXME: Implement */
2049 if (geom_mask & GDK_HINT_USER_SIZE)
2051 /* FIXME: Implement */
2054 if (geom_mask & GDK_HINT_MIN_SIZE)
2058 size.width = geometry->min_width;
2059 size.height = geometry->min_height;
2061 [impl->toplevel setContentMinSize:size];
2064 if (geom_mask & GDK_HINT_MAX_SIZE)
2068 size.width = geometry->max_width;
2069 size.height = geometry->max_height;
2071 [impl->toplevel setContentMaxSize:size];
2074 if (geom_mask & GDK_HINT_BASE_SIZE)
2076 /* FIXME: Implement */
2079 if (geom_mask & GDK_HINT_RESIZE_INC)
2083 size.width = geometry->width_inc;
2084 size.height = geometry->height_inc;
2086 [impl->toplevel setContentResizeIncrements:size];
2089 if (geom_mask & GDK_HINT_ASPECT)
2091 /* FIXME: Implement */
2094 if (geom_mask & GDK_HINT_WIN_GRAVITY)
2096 /* FIXME: Implement */
2101 gdk_window_set_title (GdkWindow *window,
2104 GdkWindowImplQuartz *impl;
2106 g_return_if_fail (title != NULL);
2108 if (GDK_WINDOW_DESTROYED (window) ||
2109 !WINDOW_IS_TOPLEVEL (window))
2112 impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *)window)->impl);
2116 GDK_QUARTZ_ALLOC_POOL;
2117 [impl->toplevel setTitle:[NSString stringWithUTF8String:title]];
2118 GDK_QUARTZ_RELEASE_POOL;
2123 gdk_window_set_role (GdkWindow *window,
2126 if (GDK_WINDOW_DESTROYED (window) ||
2127 WINDOW_IS_TOPLEVEL (window))
2130 /* FIXME: Implement */
2134 gdk_window_set_transient_for (GdkWindow *window,
2137 GdkWindowImplQuartz *window_impl;
2138 GdkWindowImplQuartz *parent_impl;
2140 if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (parent) ||
2141 !WINDOW_IS_TOPLEVEL (window))
2144 window_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2145 if (!window_impl->toplevel)
2148 GDK_QUARTZ_ALLOC_POOL;
2150 if (window_impl->transient_for)
2152 _gdk_quartz_window_detach_from_parent (window);
2154 g_object_unref (window_impl->transient_for);
2155 window_impl->transient_for = NULL;
2158 parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (parent)->impl);
2159 if (parent_impl->toplevel)
2161 /* We save the parent because it needs to be unset/reset when
2162 * hiding and showing the window.
2165 /* We don't set transients for tooltips, they are already
2166 * handled by the window level being the top one. If we do, then
2167 * the parent window will be brought to the top just because the
2168 * tooltip is, which is not what we want.
2170 if (gdk_window_get_type_hint (window) != GDK_WINDOW_TYPE_HINT_TOOLTIP)
2172 window_impl->transient_for = g_object_ref (parent);
2174 /* We only add the window if it is shown, otherwise it will
2175 * be shown unconditionally here. If it is not shown, the
2176 * window will be added in show() instead.
2178 if (!(GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_WITHDRAWN))
2179 _gdk_quartz_window_attach_to_parent (window);
2183 GDK_QUARTZ_RELEASE_POOL;
2187 gdk_window_quartz_shape_combine_region (GdkWindow *window,
2188 const cairo_region_t *shape,
2192 /* FIXME: Implement */
2196 gdk_window_quartz_input_shape_combine_region (GdkWindow *window,
2197 const cairo_region_t *shape_region,
2201 /* FIXME: Implement */
2205 gdk_window_set_override_redirect (GdkWindow *window,
2206 gboolean override_redirect)
2208 /* FIXME: Implement */
2212 gdk_window_set_accept_focus (GdkWindow *window,
2213 gboolean accept_focus)
2215 GdkWindowObject *private;
2217 private = (GdkWindowObject *)window;
2219 private->accept_focus = accept_focus != FALSE;
2223 gdk_window_quartz_set_static_gravities (GdkWindow *window,
2224 gboolean use_static)
2226 if (GDK_WINDOW_DESTROYED (window) ||
2227 !WINDOW_IS_TOPLEVEL (window))
2230 /* FIXME: Implement */
2235 gdk_window_set_focus_on_map (GdkWindow *window,
2236 gboolean focus_on_map)
2238 GdkWindowObject *private;
2240 private = (GdkWindowObject *)window;
2242 private->focus_on_map = focus_on_map != FALSE;
2246 gdk_window_set_icon_name (GdkWindow *window,
2249 /* FIXME: Implement */
2253 gdk_window_focus (GdkWindow *window,
2256 GdkWindowObject *private;
2257 GdkWindowImplQuartz *impl;
2259 private = (GdkWindowObject*) window;
2260 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2262 if (GDK_WINDOW_DESTROYED (window) ||
2263 !WINDOW_IS_TOPLEVEL (window))
2266 if (private->accept_focus && private->window_type != GDK_WINDOW_TEMP)
2268 GDK_QUARTZ_ALLOC_POOL;
2269 [impl->toplevel makeKeyAndOrderFront:impl->toplevel];
2270 clear_toplevel_order ();
2271 GDK_QUARTZ_RELEASE_POOL;
2276 gint window_type_hint_to_level (GdkWindowTypeHint hint)
2280 case GDK_WINDOW_TYPE_HINT_DOCK:
2281 case GDK_WINDOW_TYPE_HINT_UTILITY:
2282 return NSFloatingWindowLevel;
2284 case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */
2285 case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU: /* Menu from menubar */
2286 return NSTornOffMenuWindowLevel;
2288 case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
2289 case GDK_WINDOW_TYPE_HINT_TOOLTIP:
2290 return NSStatusWindowLevel;
2292 case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
2293 case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
2294 case GDK_WINDOW_TYPE_HINT_COMBO:
2295 case GDK_WINDOW_TYPE_HINT_DND:
2296 return NSPopUpMenuWindowLevel;
2298 case GDK_WINDOW_TYPE_HINT_NORMAL: /* Normal toplevel window */
2299 case GDK_WINDOW_TYPE_HINT_DIALOG: /* Dialog window */
2300 case GDK_WINDOW_TYPE_HINT_TOOLBAR: /* Window used to implement toolbars */
2301 case GDK_WINDOW_TYPE_HINT_DESKTOP: /* N/A */
2308 return NSNormalWindowLevel;
2312 window_type_hint_to_shadow (GdkWindowTypeHint hint)
2316 case GDK_WINDOW_TYPE_HINT_NORMAL: /* Normal toplevel window */
2317 case GDK_WINDOW_TYPE_HINT_DIALOG: /* Dialog window */
2318 case GDK_WINDOW_TYPE_HINT_DOCK:
2319 case GDK_WINDOW_TYPE_HINT_UTILITY:
2320 case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */
2321 case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU: /* Menu from menubar */
2322 case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
2323 case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
2324 case GDK_WINDOW_TYPE_HINT_COMBO:
2325 case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
2326 case GDK_WINDOW_TYPE_HINT_TOOLTIP:
2329 case GDK_WINDOW_TYPE_HINT_TOOLBAR: /* Window used to implement toolbars */
2330 case GDK_WINDOW_TYPE_HINT_DESKTOP: /* N/A */
2331 case GDK_WINDOW_TYPE_HINT_DND:
2343 gdk_window_set_type_hint (GdkWindow *window,
2344 GdkWindowTypeHint hint)
2346 GdkWindowImplQuartz *impl;
2348 if (GDK_WINDOW_DESTROYED (window) ||
2349 !WINDOW_IS_TOPLEVEL (window))
2352 impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *) window)->impl);
2354 impl->type_hint = hint;
2356 /* Match the documentation, only do something if we're not mapped yet. */
2357 if (GDK_WINDOW_IS_MAPPED (window))
2360 [impl->toplevel setHasShadow: window_type_hint_to_shadow (hint)];
2361 [impl->toplevel setLevel: window_type_hint_to_level (hint)];
2365 gdk_window_get_type_hint (GdkWindow *window)
2367 if (GDK_WINDOW_DESTROYED (window) ||
2368 !WINDOW_IS_TOPLEVEL (window))
2369 return GDK_WINDOW_TYPE_HINT_NORMAL;
2371 return GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *) window)->impl)->type_hint;
2375 gdk_window_set_modal_hint (GdkWindow *window,
2378 if (GDK_WINDOW_DESTROYED (window) ||
2379 !WINDOW_IS_TOPLEVEL (window))
2382 /* FIXME: Implement */
2386 gdk_window_set_skip_taskbar_hint (GdkWindow *window,
2387 gboolean skips_taskbar)
2389 if (GDK_WINDOW_DESTROYED (window) ||
2390 !WINDOW_IS_TOPLEVEL (window))
2393 /* FIXME: Implement */
2397 gdk_window_set_skip_pager_hint (GdkWindow *window,
2398 gboolean skips_pager)
2400 if (GDK_WINDOW_DESTROYED (window) ||
2401 !WINDOW_IS_TOPLEVEL (window))
2404 /* FIXME: Implement */
2408 gdk_window_begin_resize_drag (GdkWindow *window,
2415 GdkWindowObject *private;
2416 GdkWindowImplQuartz *impl;
2418 g_return_if_fail (GDK_IS_WINDOW (window));
2420 if (edge != GDK_WINDOW_EDGE_SOUTH_EAST)
2422 g_warning ("Resizing is only implemented for GDK_WINDOW_EDGE_SOUTH_EAST on Mac OS");
2426 if (GDK_WINDOW_DESTROYED (window))
2429 private = GDK_WINDOW_OBJECT (window);
2430 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2432 if (!impl->toplevel)
2434 g_warning ("Can't call gdk_window_begin_resize_drag on non-toplevel window");
2438 [(GdkQuartzWindow *)impl->toplevel beginManualResize];
2442 gdk_window_begin_move_drag (GdkWindow *window,
2448 GdkWindowObject *private;
2449 GdkWindowImplQuartz *impl;
2451 if (GDK_WINDOW_DESTROYED (window) ||
2452 !WINDOW_IS_TOPLEVEL (window))
2455 private = GDK_WINDOW_OBJECT (window);
2456 impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2458 if (!impl->toplevel)
2460 g_warning ("Can't call gdk_window_begin_move_drag on non-toplevel window");
2464 [(GdkQuartzWindow *)impl->toplevel beginManualMove];
2468 gdk_window_set_icon_list (GdkWindow *window,
2471 /* FIXME: Implement */
2475 gdk_window_get_frame_extents (GdkWindow *window,
2478 GdkWindowObject *private;
2479 GdkWindow *toplevel;
2480 GdkWindowImplQuartz *impl;
2483 g_return_if_fail (rect != NULL);
2485 private = GDK_WINDOW_OBJECT (window);
2492 toplevel = gdk_window_get_effective_toplevel (window);
2493 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl);
2495 ns_rect = [impl->toplevel frame];
2497 _gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x,
2498 ns_rect.origin.y + ns_rect.size.height,
2499 &rect->x, &rect->y);
2501 rect->width = ns_rect.size.width;
2502 rect->height = ns_rect.size.height;
2506 gdk_window_set_decorations (GdkWindow *window,
2507 GdkWMDecoration decorations)
2509 GdkWindowImplQuartz *impl;
2510 NSUInteger old_mask, new_mask;
2513 if (GDK_WINDOW_DESTROYED (window) ||
2514 !WINDOW_IS_TOPLEVEL (window))
2517 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2519 if (decorations == 0 || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP ||
2520 impl->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN )
2522 new_mask = NSBorderlessWindowMask;
2526 /* FIXME: Honor other GDK_DECOR_* flags. */
2527 new_mask = (NSTitledWindowMask | NSClosableWindowMask |
2528 NSMiniaturizableWindowMask | NSResizableWindowMask);
2531 GDK_QUARTZ_ALLOC_POOL;
2533 old_mask = [impl->toplevel styleMask];
2535 /* Note, there doesn't seem to be a way to change this without
2536 * recreating the toplevel. There might be bad side-effects of doing
2537 * that, but it seems alright.
2539 if (old_mask != new_mask)
2543 old_view = [impl->toplevel contentView];
2545 rect = [impl->toplevel frame];
2547 /* Properly update the size of the window when the titlebar is
2550 if (old_mask == NSBorderlessWindowMask &&
2551 new_mask != NSBorderlessWindowMask)
2553 rect = [NSWindow frameRectForContentRect:rect styleMask:new_mask];
2556 else if (old_mask != NSBorderlessWindowMask &&
2557 new_mask == NSBorderlessWindowMask)
2559 rect = [NSWindow contentRectForFrameRect:rect styleMask:old_mask];
2562 impl->toplevel = [impl->toplevel initWithContentRect:rect
2564 backing:NSBackingStoreBuffered
2567 [impl->toplevel setHasShadow: window_type_hint_to_shadow (impl->type_hint)];
2568 [impl->toplevel setLevel: window_type_hint_to_level (impl->type_hint)];
2570 [impl->toplevel setContentView:old_view];
2571 [impl->toplevel setFrame:rect display:YES];
2573 /* Invalidate the window shadow for non-opaque views that have shadow
2574 * enabled, to get the shadow shape updated.
2576 if (![old_view isOpaque] && [impl->toplevel hasShadow])
2577 [(GdkQuartzView*)old_view setNeedsInvalidateShadow:YES];
2580 GDK_QUARTZ_RELEASE_POOL;
2584 gdk_window_get_decorations (GdkWindow *window,
2585 GdkWMDecoration *decorations)
2587 GdkWindowImplQuartz *impl;
2589 if (GDK_WINDOW_DESTROYED (window) ||
2590 !WINDOW_IS_TOPLEVEL (window))
2593 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2597 /* Borderless is 0, so we can't check it as a bit being set. */
2598 if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
2604 /* FIXME: Honor the other GDK_DECOR_* flags. */
2605 *decorations = GDK_DECOR_ALL;
2613 gdk_window_set_functions (GdkWindow *window,
2614 GdkWMFunction functions)
2616 g_return_if_fail (GDK_IS_WINDOW (window));
2618 /* FIXME: Implement */
2622 _gdk_windowing_window_queue_antiexpose (GdkWindow *window,
2623 cairo_region_t *area)
2629 gdk_window_stick (GdkWindow *window)
2631 if (GDK_WINDOW_DESTROYED (window) ||
2632 !WINDOW_IS_TOPLEVEL (window))
2637 gdk_window_unstick (GdkWindow *window)
2639 if (GDK_WINDOW_DESTROYED (window) ||
2640 !WINDOW_IS_TOPLEVEL (window))
2645 gdk_window_maximize (GdkWindow *window)
2647 GdkWindowImplQuartz *impl;
2649 if (GDK_WINDOW_DESTROYED (window) ||
2650 !WINDOW_IS_TOPLEVEL (window))
2653 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2655 if (GDK_WINDOW_IS_MAPPED (window))
2657 GDK_QUARTZ_ALLOC_POOL;
2659 if (impl->toplevel && ![impl->toplevel isZoomed])
2660 [impl->toplevel zoom:nil];
2662 GDK_QUARTZ_RELEASE_POOL;
2666 gdk_synthesize_window_state (window,
2668 GDK_WINDOW_STATE_MAXIMIZED);
2673 gdk_window_unmaximize (GdkWindow *window)
2675 GdkWindowImplQuartz *impl;
2677 if (GDK_WINDOW_DESTROYED (window) ||
2678 !WINDOW_IS_TOPLEVEL (window))
2681 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2683 if (GDK_WINDOW_IS_MAPPED (window))
2685 GDK_QUARTZ_ALLOC_POOL;
2687 if (impl->toplevel && [impl->toplevel isZoomed])
2688 [impl->toplevel zoom:nil];
2690 GDK_QUARTZ_RELEASE_POOL;
2694 gdk_synthesize_window_state (window,
2695 GDK_WINDOW_STATE_MAXIMIZED,
2701 gdk_window_iconify (GdkWindow *window)
2703 GdkWindowImplQuartz *impl;
2705 if (GDK_WINDOW_DESTROYED (window) ||
2706 !WINDOW_IS_TOPLEVEL (window))
2709 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2711 if (GDK_WINDOW_IS_MAPPED (window))
2713 GDK_QUARTZ_ALLOC_POOL;
2716 [impl->toplevel miniaturize:nil];
2718 GDK_QUARTZ_RELEASE_POOL;
2722 gdk_synthesize_window_state (window,
2724 GDK_WINDOW_STATE_ICONIFIED);
2729 gdk_window_deiconify (GdkWindow *window)
2731 GdkWindowImplQuartz *impl;
2733 if (GDK_WINDOW_DESTROYED (window) ||
2734 !WINDOW_IS_TOPLEVEL (window))
2737 impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
2739 if (GDK_WINDOW_IS_MAPPED (window))
2741 GDK_QUARTZ_ALLOC_POOL;
2744 [impl->toplevel deminiaturize:nil];
2746 GDK_QUARTZ_RELEASE_POOL;
2750 gdk_synthesize_window_state (window,
2751 GDK_WINDOW_STATE_ICONIFIED,
2756 static FullscreenSavedGeometry *
2757 get_fullscreen_geometry (GdkWindow *window)
2759 return g_object_get_data (G_OBJECT (window), FULLSCREEN_DATA);
2763 gdk_window_fullscreen (GdkWindow *window)
2765 FullscreenSavedGeometry *geometry;
2766 GdkWindowObject *private = (GdkWindowObject *) window;
2769 if (GDK_WINDOW_DESTROYED (window) ||
2770 !WINDOW_IS_TOPLEVEL (window))
2773 geometry = get_fullscreen_geometry (window);
2776 geometry = g_new (FullscreenSavedGeometry, 1);
2778 geometry->x = private->x;
2779 geometry->y = private->y;
2780 geometry->width = private->width;
2781 geometry->height = private->height;
2783 if (!gdk_window_get_decorations (window, &geometry->decor))
2784 geometry->decor = GDK_DECOR_ALL;
2786 g_object_set_data_full (G_OBJECT (window),
2787 FULLSCREEN_DATA, geometry,
2790 gdk_window_set_decorations (window, 0);
2792 frame = [[NSScreen mainScreen] frame];
2793 move_resize_window_internal (window,
2795 frame.size.width, frame.size.height);
2798 SetSystemUIMode (kUIModeAllHidden, kUIOptionAutoShowMenuBar);
2800 gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
2804 gdk_window_unfullscreen (GdkWindow *window)
2806 FullscreenSavedGeometry *geometry;
2808 if (GDK_WINDOW_DESTROYED (window) ||
2809 !WINDOW_IS_TOPLEVEL (window))
2812 geometry = get_fullscreen_geometry (window);
2815 SetSystemUIMode (kUIModeNormal, 0);
2817 move_resize_window_internal (window,
2823 gdk_window_set_decorations (window, geometry->decor);
2825 g_object_set_data (G_OBJECT (window), FULLSCREEN_DATA, NULL);
2827 gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
2832 gdk_window_set_keep_above (GdkWindow *window, gboolean setting)
2834 GdkWindowObject *private = (GdkWindowObject *) window;
2835 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2838 g_return_if_fail (GDK_IS_WINDOW (window));
2840 if (GDK_WINDOW_DESTROYED (window) ||
2841 !WINDOW_IS_TOPLEVEL (window))
2844 level = window_type_hint_to_level (gdk_window_get_type_hint (window));
2846 /* Adjust normal window level by one if necessary. */
2847 [impl->toplevel setLevel: level + (setting ? 1 : 0)];
2851 gdk_window_set_keep_below (GdkWindow *window, gboolean setting)
2853 GdkWindowObject *private = (GdkWindowObject *) window;
2854 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2857 g_return_if_fail (GDK_IS_WINDOW (window));
2859 if (GDK_WINDOW_DESTROYED (window) ||
2860 !WINDOW_IS_TOPLEVEL (window))
2863 level = window_type_hint_to_level (gdk_window_get_type_hint (window));
2865 /* Adjust normal window level by one if necessary. */
2866 [impl->toplevel setLevel: level - (setting ? 1 : 0)];
2870 gdk_window_get_group (GdkWindow *window)
2872 g_return_val_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD, NULL);
2874 if (GDK_WINDOW_DESTROYED (window) ||
2875 !WINDOW_IS_TOPLEVEL (window))
2878 /* FIXME: Implement */
2884 gdk_window_set_group (GdkWindow *window,
2887 /* FIXME: Implement */
2891 gdk_window_foreign_new_for_display (GdkDisplay *display,
2892 GdkNativeWindow anid)
2894 /* Foreign windows aren't supported in Mac OS X */
2899 gdk_window_lookup (GdkNativeWindow anid)
2901 /* Foreign windows aren't supported in Mac OS X */
2906 gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
2908 /* Foreign windows aren't supported in Mac OS X */
2913 gdk_window_enable_synchronized_configure (GdkWindow *window)
2918 gdk_window_configure_finished (GdkWindow *window)
2923 gdk_window_destroy_notify (GdkWindow *window)
2925 check_grab_destroy (window);
2929 _gdk_windowing_window_beep (GdkWindow *window)
2931 g_return_if_fail (GDK_IS_WINDOW (window));
2933 gdk_display_beep (_gdk_display);
2937 gdk_window_set_opacity (GdkWindow *window,
2940 GdkWindowObject *private = (GdkWindowObject *) window;
2941 GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
2943 g_return_if_fail (GDK_IS_WINDOW (window));
2944 g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
2946 if (GDK_WINDOW_DESTROYED (window) ||
2947 !WINDOW_IS_TOPLEVEL (window))
2952 else if (opacity > 1)
2955 [impl->toplevel setAlphaValue: opacity];
2959 _gdk_windowing_window_set_composited (GdkWindow *window, gboolean composited)
2964 _gdk_windowing_window_get_shape (GdkWindow *window)
2966 /* FIXME: implement */
2971 _gdk_windowing_window_get_input_shape (GdkWindow *window)
2973 /* FIXME: implement */
2978 gdk_window_impl_iface_init (GdkWindowImplIface *iface)
2980 iface->show = gdk_window_quartz_show;
2981 iface->hide = gdk_window_quartz_hide;
2982 iface->withdraw = gdk_window_quartz_withdraw;
2983 iface->set_events = gdk_window_quartz_set_events;
2984 iface->get_events = gdk_window_quartz_get_events;
2985 iface->raise = gdk_window_quartz_raise;
2986 iface->lower = gdk_window_quartz_lower;
2987 iface->restack_toplevel = gdk_window_quartz_restack_toplevel;
2988 iface->move_resize = gdk_window_quartz_move_resize;
2989 iface->set_background = gdk_window_quartz_set_background;
2990 iface->reparent = gdk_window_quartz_reparent;
2991 iface->set_device_cursor = gdk_window_quartz_set_device_cursor;
2992 iface->get_geometry = gdk_window_quartz_get_geometry;
2993 iface->get_root_coords = gdk_window_quartz_get_root_coords;
2994 iface->get_device_state = gdk_window_quartz_get_device_state;
2995 iface->shape_combine_region = gdk_window_quartz_shape_combine_region;
2996 iface->input_shape_combine_region = gdk_window_quartz_input_shape_combine_region;
2997 iface->set_static_gravities = gdk_window_quartz_set_static_gravities;
2998 iface->queue_antiexpose = _gdk_quartz_window_queue_antiexpose;
2999 iface->translate = _gdk_quartz_window_translate;
3000 iface->destroy = _gdk_quartz_window_destroy;
3001 iface->resize_cairo_surface = gdk_window_quartz_resize_cairo_surface;
3006 gdk_root_window_impl_quartz_get_context (GdkDrawable *drawable,
3009 GdkDrawableImplQuartz *drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable);
3010 CGColorSpaceRef colorspace;
3011 CGContextRef cg_context;
3013 if (GDK_WINDOW_DESTROYED (drawable_impl->wrapper))
3016 /* We do not have the notion of a root window on OS X. We fake this
3017 * by creating a 1x1 bitmap and return a context to that.
3019 colorspace = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
3020 cg_context = CGBitmapContextCreate (NULL,
3021 1, 1, 8, 4, colorspace,
3022 kCGImageAlphaPremultipliedLast);
3023 CGColorSpaceRelease (colorspace);
3029 gdk_root_window_impl_quartz_release_context (GdkDrawable *drawable,
3030 CGContextRef cg_context)
3032 CGContextRelease (cg_context);
3036 gdk_root_window_impl_quartz_class_init (GdkRootWindowImplQuartzClass *klass)
3038 GdkDrawableImplQuartzClass *drawable_quartz_class = GDK_DRAWABLE_IMPL_QUARTZ_CLASS (klass);
3040 root_window_parent_class = g_type_class_peek_parent (klass);
3042 drawable_quartz_class->get_context = gdk_root_window_impl_quartz_get_context;
3043 drawable_quartz_class->release_context = gdk_root_window_impl_quartz_release_context;
3047 gdk_root_window_impl_quartz_init (GdkRootWindowImplQuartz *impl)
3052 _gdk_root_window_impl_quartz_get_type (void)
3054 static GType object_type = 0;
3058 const GTypeInfo object_info =
3060 sizeof (GdkRootWindowImplQuartzClass),
3061 (GBaseInitFunc) NULL,
3062 (GBaseFinalizeFunc) NULL,
3063 (GClassInitFunc) gdk_root_window_impl_quartz_class_init,
3064 NULL, /* class_finalize */
3065 NULL, /* class_data */
3066 sizeof (GdkRootWindowImplQuartz),
3067 0, /* n_preallocs */
3068 (GInstanceInitFunc) gdk_root_window_impl_quartz_init,
3071 object_type = g_type_register_static (GDK_TYPE_WINDOW_IMPL_QUARTZ,
3072 "GdkRootWindowQuartz",