win32: Fix modal_hint handling

Modal hints are not really a stack. All windows that are modal
are allowed to get input, not just the top one.

This fixes bug #604156
This commit is contained in:
Alexander Larsson 2011-10-27 22:13:54 +02:00
parent 6d1b818560
commit 4b5b28b64f
3 changed files with 33 additions and 31 deletions

View File

@ -98,8 +98,6 @@ static gboolean gdk_event_dispatch (GSource *source,
GSourceFunc callback, GSourceFunc callback,
gpointer user_data); gpointer user_data);
static gboolean is_modally_blocked (GdkWindow *window);
/* Private variable declarations /* Private variable declarations
*/ */
@ -2761,17 +2759,12 @@ gdk_event_translate (MSG *msg,
return_val = TRUE; return_val = TRUE;
} }
tmp = _gdk_modal_current (); if (_gdk_modal_blocked (gdk_window_get_toplevel (window)))
if (tmp != NULL)
{
if (gdk_window_get_toplevel (window) != tmp)
{ {
*ret_valp = MA_NOACTIVATEANDEAT; *ret_valp = MA_NOACTIVATEANDEAT;
return_val = TRUE; return_val = TRUE;
} }
} }
}
break; break;
@ -3441,7 +3434,7 @@ gdk_event_translate (MSG *msg,
* but we still need to deal with alt-tab, or with SetActiveWindow() type * but we still need to deal with alt-tab, or with SetActiveWindow() type
* situations. * situations.
*/ */
if (is_modally_blocked (window) && LOWORD (msg->wParam) == WA_ACTIVE) if (_gdk_modal_blocked (window) && LOWORD (msg->wParam) == WA_ACTIVE)
{ {
GdkWindow *modal_current = _gdk_modal_current (); GdkWindow *modal_current = _gdk_modal_current ();
SetActiveWindow (GDK_WINDOW_HWND (modal_current)); SetActiveWindow (GDK_WINDOW_HWND (modal_current));
@ -3607,13 +3600,6 @@ gdk_win32_set_modal_dialog_libgtk_only (HWND window)
modal_win32_dialog = window; modal_win32_dialog = window;
} }
static gboolean
is_modally_blocked (GdkWindow *window)
{
GdkWindow *modal_current = _gdk_modal_current ();
return modal_current != NULL ? gdk_window_get_toplevel (window) != modal_current : FALSE;
}
static void static void
check_for_too_much_data (GdkEvent *event) check_for_too_much_data (GdkEvent *event)
{ {

View File

@ -305,7 +305,7 @@ void _gdk_wchar_text_handle (GdkFont *font,
void _gdk_push_modal_window (GdkWindow *window); void _gdk_push_modal_window (GdkWindow *window);
void _gdk_remove_modal_window (GdkWindow *window); void _gdk_remove_modal_window (GdkWindow *window);
GdkWindow *_gdk_modal_current (void); GdkWindow *_gdk_modal_current (void);
gboolean _gdk_modal_blocked (GdkWindow *window);
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
gchar *_gdk_win32_color_to_string (const GdkColor *color); gchar *_gdk_win32_color_to_string (const GdkColor *color);

View File

@ -2135,24 +2135,40 @@ _gdk_remove_modal_window (GdkWindow *window)
} }
} }
gboolean
_gdk_modal_blocked (GdkWindow *window)
{
GSList *l;
gboolean found_any = FALSE;
for (l = modal_window_stack; l != NULL; l = l->next)
{
GdkWindow *modal = l->data;
if (modal == window)
return FALSE;
if (GDK_WINDOW_IS_MAPPED (modal))
found_any = TRUE;
}
return found_any;
}
GdkWindow * GdkWindow *
_gdk_modal_current (void) _gdk_modal_current (void)
{ {
if (modal_window_stack != NULL) GSList *l;
{
GSList *tmp = modal_window_stack;
while (tmp != NULL && !GDK_WINDOW_IS_MAPPED (tmp->data)) for (l = modal_window_stack; l != NULL; l = l->next)
{ {
tmp = g_slist_next (tmp); GdkWindow *modal = l->data;
if (GDK_WINDOW_IS_MAPPED (modal))
return modal;
} }
return tmp != NULL ? tmp->data : NULL;
}
else
{
return NULL; return NULL;
}
} }
static void static void