diff options
author | Richard Hult <richard@imendio.com> | 2008-02-16 00:27:29 +0000 |
---|---|---|
committer | Richard Hult <rhult@src.gnome.org> | 2008-02-16 00:27:29 +0000 |
commit | 2dd5dd634051363fd3d17c3badb1b78a76011bf6 (patch) | |
tree | 30fa616c446e0c896c85531301e408a569fd01c2 /gdk | |
parent | 45e33fe9c2e10ffd0784e684f7ab73c103dd152e (diff) | |
download | gtk+-2dd5dd634051363fd3d17c3badb1b78a76011bf6.tar.gz |
Add debugging code to highlight a gdkwindow.
2008-02-16 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkprivate-quartz.h:
* gdk/quartz/gdkwindow-quartz.c: Add debugging code to highlight a
gdkwindow.
svn path=/trunk/; revision=19587
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/quartz/gdkprivate-quartz.h | 1 | ||||
-rw-r--r-- | gdk/quartz/gdkwindow-quartz.c | 82 |
2 files changed, 83 insertions, 0 deletions
diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h index e322e43405..b79663baa6 100644 --- a/gdk/quartz/gdkprivate-quartz.h +++ b/gdk/quartz/gdkprivate-quartz.h @@ -144,6 +144,7 @@ void _gdk_quartz_window_attach_to_parent (GdkWindow *window); void _gdk_quartz_window_detach_from_parent (GdkWindow *window); void _gdk_quartz_window_did_become_main (GdkWindow *window); void _gdk_quartz_window_did_resign_main (GdkWindow *window); +void _gdk_quartz_window_debug_highlight (GdkWindow *window); /* Events */ void _gdk_quartz_events_update_focus_window (GdkWindow *new_window, diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index 6349ebc44f..bbcc18199a 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -478,6 +478,87 @@ get_default_title (void) return title; } +static void +get_ancestor_coordinates_from_child (GdkWindow *child_window, + gint child_x, + gint child_y, + GdkWindow *ancestor_window, + gint *ancestor_x, + gint *ancestor_y) +{ + GdkWindowObject *child_private = GDK_WINDOW_OBJECT (child_window); + GdkWindowObject *ancestor_private = GDK_WINDOW_OBJECT (ancestor_window); + + while (child_private != ancestor_private) + { + child_x += child_private->x; + child_y += child_private->y; + + child_private = child_private->parent; + } + + *ancestor_x = child_x; + *ancestor_y = child_y; +} + +void +_gdk_quartz_window_debug_highlight (GdkWindow *window) +{ + GdkWindowObject *private = GDK_WINDOW_OBJECT (window); + GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); + gint x, y; + GdkWindow *toplevel; + gint tx, ty; + static NSWindow *debug_window; + static NSRect old_rect; + NSRect rect; + + if (window == _gdk_root) + return; + + if (window == NULL) + return; + + toplevel = gdk_window_get_toplevel (window); + get_ancestor_coordinates_from_child (window, 0, 0, toplevel, &x, &y); + + gdk_window_get_origin (toplevel, &tx, &ty); + x += tx; + y += ty; + + rect = NSMakeRect (x, + _gdk_quartz_window_get_inverted_screen_y (y + impl->height), + impl->width, impl->height); + + if (debug_window && + rect.origin.x == old_rect.origin.x && + rect.origin.y == old_rect.origin.y && + rect.size.width == old_rect.size.width && + rect.size.height == old_rect.size.height) + { + return; + } + + old_rect = rect; + + if (debug_window) + [debug_window close]; + + debug_window = [[NSWindow alloc] initWithContentRect:rect + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:NO]; + + [debug_window setBackgroundColor:[NSColor redColor]]; + [debug_window setAlphaValue:0.4]; + [debug_window setOpaque:NO]; + [debug_window setReleasedWhenClosed:YES]; + [debug_window setIgnoresMouseEvents:YES]; + [debug_window setLevel:NSFloatingWindowLevel]; + + [debug_window orderFront:nil]; +} + gboolean _gdk_quartz_window_is_ancestor (GdkWindow *ancestor, GdkWindow *window) @@ -2525,6 +2606,7 @@ gdk_window_set_decorations (GdkWindow *window, new_mask != NSBorderlessWindowMask) { rect = [NSWindow frameRectForContentRect:rect styleMask:new_mask]; + } else if (old_mask != NSBorderlessWindowMask && new_mask == NSBorderlessWindowMask) |