diff options
author | Cody Russell <bratsche@gnome.org> | 2007-07-12 23:38:30 +0000 |
---|---|---|
committer | Cody Russell <bratsche@src.gnome.org> | 2007-07-12 23:38:30 +0000 |
commit | e992008541678e809ad99a4a7d6c854023814411 (patch) | |
tree | 0212afd5b4db98864778770fe9b82e8671da31ec /gdk | |
parent | 34dfd591dafa2047cb7d894777d3a8656e373229 (diff) | |
download | gtk+-e992008541678e809ad99a4a7d6c854023814411.tar.gz |
gdk/win32/gdkevents-win32.c Fix transient windows on Win32 so that when a
2007-07-12 Cody Russell <bratsche@gnome.org>
* gdk/win32/gdkevents-win32.c
* gdk/win32/gdkwindow-win32.[ch]: Fix transient windows on Win32
so that when a transient child window is closed (particularly when
there are 3 or more levels of transient windows), the correct window
receives focus rather than a seemingly random window. (#112404)
svn path=/trunk/; revision=18461
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/win32/gdkevents-win32.c | 20 | ||||
-rw-r--r-- | gdk/win32/gdkwindow-win32.c | 50 | ||||
-rw-r--r-- | gdk/win32/gdkwindow-win32.h | 2 |
3 files changed, 58 insertions, 14 deletions
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 5059a88993..1115513932 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -1,6 +1,7 @@ /* GDK - The GIMP Drawing Kit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald * Copyright (C) 1998-2002 Tor Lillqvist + * Copyright (C) 2007 Cody Russell * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -2816,7 +2817,17 @@ gdk_event_translate (MSG *msg, event->any.window = window; append_event (event); - + + if (event->any.type == GDK_UNMAP) + { + impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl); + + if (impl->transient_owner && GetForegroundWindow () == GDK_WINDOW_HWND (window)) + { + SetForegroundWindow (GDK_WINDOW_HWND (impl->transient_owner)); + } + } + if (event->any.type == GDK_UNMAP && p_grab_window == window) gdk_pointer_ungrab (msg->time); @@ -3213,6 +3224,13 @@ gdk_event_translate (MSG *msg, append_event (event); + impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl); + + if (impl->transient_owner && GetForegroundWindow() == GDK_WINDOW_HWND (window)) + { + SetForegroundWindow (GDK_WINDOW_HWND (impl->transient_owner)); + } + return_val = TRUE; break; diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index b3baab5afe..d0e2ee6cba 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -2,6 +2,7 @@ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald * Copyright (C) 1998-2004 Tor Lillqvist * Copyright (C) 2001-2004 Hans Breuer + * Copyright (C) 2007 Cody Russell * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -105,6 +106,7 @@ gdk_window_impl_win32_init (GdkWindowImplWin32 *impl) impl->hint_flags = 0; impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL; impl->extension_events_selected = FALSE; + impl->transient_owner = NULL; } static void @@ -828,6 +830,7 @@ _gdk_windowing_window_destroy (GdkWindow *window, gboolean foreign_destroy) { GdkWindowObject *private = (GdkWindowObject *)window; + GdkWindowImplWin32 *window_impl = GDK_WINDOW_IMPL_WIN32 (private->impl); g_return_if_fail (GDK_IS_WINDOW (window)); @@ -837,6 +840,11 @@ _gdk_windowing_window_destroy (GdkWindow *window, if (private->extension_events != 0) _gdk_input_window_destroy (window); + /* Remove ourself from our transient owner */ + if (window_impl->transient_owner != NULL) + { + gdk_window_set_transient_for (window, NULL); + } if (!recursing && !foreign_destroy) { @@ -845,6 +853,7 @@ _gdk_windowing_window_destroy (GdkWindow *window, private->destroyed = TRUE; DestroyWindow (GDK_WINDOW_HWND (window)); } + gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window)); } @@ -1181,7 +1190,9 @@ gdk_window_move (GdkWindow *window, * windows! Especially in the case of gtkplug/socket. */ if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ()) - _gdk_window_move_resize_child (window, x, y, impl->width, impl->height); + { + _gdk_window_move_resize_child (window, x, y, impl->width, impl->height); + } else { RECT outer_rect; @@ -1228,7 +1239,9 @@ gdk_window_resize (GdkWindow *window, return; if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ()) - _gdk_window_move_resize_child (window, private->x, private->y, width, height); + { + _gdk_window_move_resize_child (window, private->x, private->y, width, height); + } else { RECT outer_rect; @@ -1280,7 +1293,9 @@ gdk_window_move_resize (GdkWindow *window, width, height, x, y)); if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ()) - _gdk_window_move_resize_child (window, x, y, width, height); + { + _gdk_window_move_resize_child (window, x, y, width, height); + } else { RECT outer_rect; @@ -1908,29 +1923,35 @@ gdk_window_set_role (GdkWindow *window, /* XXX */ } -void +void gdk_window_set_transient_for (GdkWindow *window, GdkWindow *parent) { HWND window_id, parent_id; + GdkWindowImplWin32 *window_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl); g_return_if_fail (GDK_IS_WINDOW (window)); - - GDK_NOTE (MISC, g_print ("gdk_window_set_transient_for: %p: %p\n", - GDK_WINDOW_HWND (window), - GDK_WINDOW_HWND (parent))); - if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (parent)) - return; + window_id = GDK_WINDOW_HWND (window); + parent_id = parent != NULL ? GDK_WINDOW_HWND (parent) : NULL; + + if (GDK_WINDOW_DESTROYED (window) || (parent && GDK_WINDOW_DESTROYED (parent))) + { + if (GDK_WINDOW_DESTROYED (window)) + GDK_NOTE (MISC, g_print ("... destroyed!\n")); + else + GDK_NOTE (MISC, g_print ("... owner destroyed!\n")); + + return; + } if (((GdkWindowObject *) window)->window_type == GDK_WINDOW_CHILD) { GDK_NOTE (MISC, g_print ("... a child window!\n")); return; } - - window_id = GDK_WINDOW_HWND (window); - parent_id = GDK_WINDOW_HWND (parent); + + window_impl->transient_owner = parent; /* This changes the *owner* of the window, despite the misleading * name. (Owner and parent are unrelated concepts.) At least that's @@ -3386,11 +3407,14 @@ gdk_window_set_modal_hint (GdkWindow *window, private->modal_hint = modal; +#if 0 + /* Not sure about this one.. -- Cody */ if (GDK_WINDOW_IS_MAPPED (window)) API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), modal ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)); +#endif } void diff --git a/gdk/win32/gdkwindow-win32.h b/gdk/win32/gdkwindow-win32.h index 892110b5a1..8a697565a4 100644 --- a/gdk/win32/gdkwindow-win32.h +++ b/gdk/win32/gdkwindow-win32.h @@ -86,6 +86,8 @@ struct _GdkWindowImplWin32 GdkWindowTypeHint type_hint; gboolean extension_events_selected; + + GdkWindow *transient_owner; }; struct _GdkWindowImplWin32Class |