[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 86/473: Simplify handling of keyboard focus.
noreply at xfce.org
noreply at xfce.org
Mon Feb 16 23:54:16 CET 2015
This is an automated email from the git hooks/post-receive script.
gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.
commit ade6b8ee072e2072f74265b3967661ecf5591e38
Author: Graeme Gott <graeme at gottcode.org>
Date: Fri Jul 12 11:45:05 2013 -0400
Simplify handling of keyboard focus.
---
src/menu.cpp | 24 ++++++++++++++----------
src/menu.hpp | 1 +
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/menu.cpp b/src/menu.cpp
index e2e0a40..d452083 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -75,6 +75,7 @@ Menu::Menu(XfceRc* settings) :
g_signal_connect(m_window, "leave-notify-event", SLOT_CALLBACK(Menu::on_leave_notify_event), this);
g_signal_connect(m_window, "button-press-event", SLOT_CALLBACK(Menu::on_button_press_event), this);
g_signal_connect(m_window, "key-press-event", SLOT_CALLBACK(Menu::on_key_press_event), this);
+ g_signal_connect_after(m_window, "key-press-event", SLOT_CALLBACK(Menu::on_key_press_event_after), this);
g_signal_connect(m_window, "map-event", SLOT_CALLBACK(Menu::on_map_event), this);
g_signal_connect(m_window, "configure-event", SLOT_CALLBACK(Menu::on_configure_event), this);
@@ -571,24 +572,27 @@ gboolean Menu::on_key_press_event(GtkWidget* widget, GdkEventKey* event)
{
view = m_applications->get_view()->get_widget();
}
- if (!gtk_widget_has_focus(view))
+
+ if ((widget != view) && (gtk_window_get_focus(m_window) != view))
{
gtk_widget_grab_focus(view);
}
- return false;
}
- // Pass other key presses to search entry
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+
+gboolean Menu::on_key_press_event_after(GtkWidget* widget, GdkEventKey* event)
+{
+ // Pass unhandled key presses to search entry
GtkWidget* search_entry = GTK_WIDGET(m_search_entry);
- if (!gtk_widget_has_focus(search_entry) && (search_entry != widget)
- && (event->keyval != GDK_Shift_L) && (event->keyval != GDK_Shift_R)
- && (event->keyval != GDK_Control_L) && (event->keyval != GDK_Control_R)
- && !(event->state & GDK_SHIFT_MASK) && !(event->state & GDK_CONTROL_MASK)
- && (event->keyval != GDK_Tab) && (event->keyval != GDK_Return)
- && (event->keyval != GDK_Page_Up) && (event->keyval != GDK_Page_Down)
- && (event->keyval != GDK_KEY_Menu))
+ if ((widget != search_entry) && (gtk_window_get_focus(m_window) != search_entry))
{
gtk_widget_grab_focus(search_entry);
+ gtk_window_propagate_key_event(m_window, event);
+ return true;
}
return false;
}
diff --git a/src/menu.hpp b/src/menu.hpp
index 9394e79..03f015b 100644
--- a/src/menu.hpp
+++ b/src/menu.hpp
@@ -89,6 +89,7 @@ private:
SLOT_2(gboolean, Menu, on_leave_notify_event, GtkWidget*, GdkEventCrossing*);
SLOT_2(gboolean, Menu, on_button_press_event, GtkWidget*, GdkEventButton*);
SLOT_2(gboolean, Menu, on_key_press_event, GtkWidget*, GdkEventKey*);
+ SLOT_2(gboolean, Menu, on_key_press_event_after, GtkWidget*, GdkEventKey*);
SLOT_2(gboolean, Menu, on_map_event, GtkWidget*, GdkEventAny*);
SLOT_2(gboolean, Menu, on_configure_event, GtkWidget*, GdkEventConfigure*);
SLOT_0(void, Menu, favorites_toggled);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list