diff options
author | Bastien Nocera <hadess@hadess.net> | 2009-12-15 19:32:05 +0000 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2009-12-15 19:32:05 +0000 |
commit | 63e3be640eafce6678e87d6a592981597fac7f09 (patch) | |
tree | c07a051d3bd56a9c97d1bc35cbe9f9b8cbdbfd03 /src | |
parent | 14e7f8e172446cf90d1d7f5f228ba20d16f073de (diff) | |
download | totem-63e3be640eafce6678e87d6a592981597fac7f09.tar.gz |
Make 'Escape' pass the focus away from the playlist
To the video widget. We need some hacking to avoid pinching
key release events when pressing escape to dismiss a menu,
or the type-ahead popup.
https://bugzilla.gnome.org/show_bug.cgi?id=313343
Diffstat (limited to 'src')
-rw-r--r-- | src/totem-object.c | 19 | ||||
-rw-r--r-- | src/totem-sidebar.c | 23 | ||||
-rw-r--r-- | src/totem-sidebar.h | 2 |
3 files changed, 40 insertions, 4 deletions
diff --git a/src/totem-object.c b/src/totem-object.c index 20fc37fa6..6b0eed750 100644 --- a/src/totem-object.c +++ b/src/totem-object.c @@ -3817,11 +3817,26 @@ totem_action_handle_scroll (Totem *totem, GdkScrollDirection direction) gboolean window_key_press_event_cb (GtkWidget *win, GdkEventKey *event, Totem *totem) { - if (totem_sidebar_is_focused (totem) != FALSE) - return FALSE; + gboolean sidebar_handles_kbd; + + /* Shortcuts disabled? */ if (totem->disable_kbd_shortcuts != FALSE) return FALSE; + /* Check whether the sidebar needs the key events */ + if (event->type == GDK_KEY_PRESS) { + if (totem_sidebar_is_focused (totem, &sidebar_handles_kbd) != FALSE) { + /* Make Escape pass the focus to the video widget */ + if (sidebar_handles_kbd == FALSE && + event->keyval == GDK_Escape) + gtk_widget_grab_focus (GTK_WIDGET (totem->bvw)); + return FALSE; + } + } else { + if (totem_sidebar_is_focused (totem, NULL) != FALSE) + return FALSE; + } + /* Special case Eject, Open, Open URI and * seeking keyboard shortcuts */ if (event->state != 0 diff --git a/src/totem-sidebar.c b/src/totem-sidebar.c index 0ffd62ccf..9e370b1d4 100644 --- a/src/totem-sidebar.c +++ b/src/totem-sidebar.c @@ -95,11 +95,32 @@ totem_sidebar_is_visible (Totem *totem) return totem->sidebar_shown; } +static gboolean +has_popup (void) +{ + GList *list, *l; + gboolean retval = FALSE; + + list = gtk_window_list_toplevels (); + for (l = list; l != NULL; l = l->next) { + GtkWindow *window = GTK_WINDOW (l->data); + if (GTK_WIDGET_VISIBLE (window) && gtk_window_get_window_type (window) == GTK_WINDOW_POPUP) { + retval = TRUE; + break; + } + } + g_list_free (list); + return retval; +} + gboolean -totem_sidebar_is_focused (Totem *totem) +totem_sidebar_is_focused (Totem *totem, gboolean *handles_kbd) { GtkWidget *focused; + if (handles_kbd != NULL) + *handles_kbd = has_popup (); + focused = gtk_window_get_focus (GTK_WINDOW (totem->win)); if (focused != NULL && gtk_widget_is_ancestor (focused, GTK_WIDGET (totem->sidebar)) != FALSE) { diff --git a/src/totem-sidebar.h b/src/totem-sidebar.h index ad85496d9..611cc06d6 100644 --- a/src/totem-sidebar.h +++ b/src/totem-sidebar.h @@ -30,7 +30,7 @@ void totem_sidebar_setup (Totem *totem, gboolean visible, void totem_sidebar_toggle (Totem *totem, gboolean state); void totem_sidebar_set_visibility (Totem *totem, gboolean visible); gboolean totem_sidebar_is_visible (Totem *totem); -gboolean totem_sidebar_is_focused (Totem *totem); +gboolean totem_sidebar_is_focused (Totem *totem, gboolean *handles_kbd); char *totem_sidebar_get_current_page (Totem *totem); void totem_sidebar_set_current_page (Totem *totem, const char *name, |