From 5a4ed10fae63098ae33d6a13edd8b88fb6acdc9c Mon Sep 17 00:00:00 2001 From: Richard Hult Date: Fri, 6 Jul 2007 19:49:42 +0000 Subject: [PATCH] Fix (de)miniaturizing transient windows, by (un)setting the parent before 2007-07-06 Richard Hult * gdk/quartz/gdkprivate-quartz.h: * gdk/quartz/gdkwindow-quartz.c: * gdk/quartz/GdkQuartzWindow.c: Fix (de)miniaturizing transient windows, by (un)setting the parent before and after miniaturizing. svn path=/trunk/; revision=18388 --- ChangeLog | 7 ++++ gdk/quartz/GdkQuartzWindow.c | 9 +++++ gdk/quartz/gdkprivate-quartz.h | 3 ++ gdk/quartz/gdkwindow-quartz.c | 65 +++++++++++++++++++++++----------- 4 files changed, 63 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8710a99533..5888cf0671 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-07-06 Richard Hult + + * gdk/quartz/gdkprivate-quartz.h: + * gdk/quartz/gdkwindow-quartz.c: + * gdk/quartz/GdkQuartzWindow.c: Fix (de)miniaturizing transient + windows, by (un)setting the parent before and after miniaturizing. + 2007-07-06 Richard Hult * gdk/quartz/gdkkeys-quartz.c (gdk_keymap_have_bidi_layouts): Add diff --git a/gdk/quartz/GdkQuartzWindow.c b/gdk/quartz/GdkQuartzWindow.c index d86c21ddd2..0ffefc5d6c 100644 --- a/gdk/quartz/GdkQuartzWindow.c +++ b/gdk/quartz/GdkQuartzWindow.c @@ -39,6 +39,13 @@ return NO; } +-(void)windowWillMiniaturize:(NSNotification *)aNotification +{ + GdkWindow *window = [[self contentView] gdkWindow]; + + _gdk_quartz_window_detach_from_parent (window); +} + -(void)windowDidMiniaturize:(NSNotification *)aNotification { GdkWindow *window = [[self contentView] gdkWindow]; @@ -51,6 +58,8 @@ { GdkWindow *window = [[self contentView] gdkWindow]; + _gdk_quartz_window_attach_to_parent (window); + gdk_synthesize_window_state (window, GDK_WINDOW_STATE_ICONIFIED, 0); } diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h index aebc1b4de4..b201ca7a4d 100644 --- a/gdk/quartz/gdkprivate-quartz.h +++ b/gdk/quartz/gdkprivate-quartz.h @@ -138,6 +138,9 @@ gint _gdk_quartz_window_get_inverted_screen_y (gint y); GdkWindow *_gdk_quartz_window_find_child (GdkWindow *window, gint x, gint y); +void _gdk_quartz_window_attach_to_parent (GdkWindow *window); +void _gdk_quartz_window_detach_from_parent (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 0ab71281b1..e7ab47868b 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -834,6 +834,47 @@ show_window_internal (GdkWindow *window, if (private->state & GDK_WINDOW_STATE_ICONIFIED) gdk_window_iconify (window); + if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for)) + _gdk_quartz_window_attach_to_parent (window); + + GDK_QUARTZ_RELEASE_POOL; +} + +/* Temporarily unsets the parent window, if the window is a + * transient. + */ +void +_gdk_quartz_window_detach_from_parent (GdkWindow *window) +{ + GdkWindowImplQuartz *impl; + + g_return_if_fail (GDK_IS_WINDOW (window)); + + impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); + + g_return_if_fail (impl->toplevel != NULL); + + if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for)) + { + GdkWindowImplQuartz *parent_impl; + + parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (impl->transient_for)->impl); + [parent_impl->toplevel removeChildWindow:impl->toplevel]; + } +} + +/* Re-sets the parent window, if the window is a transient. */ +void +_gdk_quartz_window_attach_to_parent (GdkWindow *window) +{ + GdkWindowImplQuartz *impl; + + g_return_if_fail (GDK_IS_WINDOW (window)); + + impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); + + g_return_if_fail (impl->toplevel != NULL); + if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for)) { GdkWindowImplQuartz *parent_impl; @@ -841,8 +882,6 @@ show_window_internal (GdkWindow *window, parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (impl->transient_for)->impl); [parent_impl->toplevel addChildWindow:impl->toplevel ordered:NSWindowAbove]; } - - GDK_QUARTZ_RELEASE_POOL; } void @@ -883,19 +922,8 @@ gdk_window_hide (GdkWindow *window) if (impl->toplevel) { - /* We must unset the transient while it is hidden, otherwise - * quartz won't hide the window. - */ if (impl->transient_for) - { - if (!GDK_WINDOW_DESTROYED (impl->transient_for)) - { - GdkWindowImplQuartz *parent_impl; - - parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (impl->transient_for)->impl); - [parent_impl->toplevel removeChildWindow:impl->toplevel]; - } - } + _gdk_quartz_window_detach_from_parent (window); [impl->toplevel orderOut:nil]; } @@ -955,7 +983,6 @@ move_resize_window_internal (GdkWindow *window, NSRect frame_rect = [impl->toplevel frameRectForContentRect:content_rect]; frame_rect.origin.y -= frame_rect.size.height; - [impl->toplevel setFrame:frame_rect display:YES]; } else @@ -1563,11 +1590,7 @@ gdk_window_set_transient_for (GdkWindow *window, if (window_impl->transient_for) { - if (!GDK_WINDOW_DESTROYED (window_impl->transient_for)) - { - parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window_impl->transient_for)->impl); - [parent_impl->toplevel removeChildWindow:window_impl->toplevel]; - } + _gdk_quartz_window_detach_from_parent (window); g_object_unref (window_impl->transient_for); window_impl->transient_for = NULL; @@ -1594,7 +1617,7 @@ gdk_window_set_transient_for (GdkWindow *window, * window will be added in show() instead. */ if (!(GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_WITHDRAWN)) - [parent_impl->toplevel addChildWindow:window_impl->toplevel ordered:NSWindowAbove]; + _gdk_quartz_window_attach_to_parent (window); } }