[gnome-initial-setup/shell/4765: 311/362] keyboard: use a CSD titlebar and disable events on it
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/shell/4765: 311/362] keyboard: use a CSD titlebar and disable events on it
- Date: Thu, 19 Mar 2015 01:47:13 +0000 (UTC)
commit abdd1c225d349c1addccd064eee75832c838a710
Author: Cosimo Cecchi <cosimo endlesm com>
Date: Tue Dec 16 19:13:36 2014 +0800
keyboard: use a CSD titlebar and disable events on it
Since the FBE window is special, we can't let the right click menu show
up. Use the same technique we use for the main window.
.../pages/keyboard/cc-keyboard-query.c | 51 ++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/gnome-initial-setup/pages/keyboard/cc-keyboard-query.c
b/gnome-initial-setup/pages/keyboard/cc-keyboard-query.c
index d457340..4570817 100644
--- a/gnome-initial-setup/pages/keyboard/cc-keyboard-query.c
+++ b/gnome-initial-setup/pages/keyboard/cc-keyboard-query.c
@@ -251,6 +251,55 @@ cc_keyboard_query_layout_result (CcKeyboardQuery *self,
g_free (result_message);
}
+static gboolean
+is_event_on_title (CcKeyboardQuery *self,
+ GdkEventButton *event)
+{
+ GtkAllocation allocation;
+ GtkWidget *titlebar, *src;
+ gint x, y;
+
+ titlebar = gtk_dialog_get_header_bar (GTK_DIALOG (self));
+
+ gdk_window_get_user_data (event->window, (gpointer *)&src);
+ if (src && src != GTK_WIDGET (self))
+ {
+ gtk_widget_translate_coordinates (src, GTK_WIDGET (self),
+ event->x, event->y, &x, &y);
+ }
+ else
+ {
+ x = event->x;
+ y = event->y;
+ }
+
+ if (titlebar != NULL &&
+ gtk_widget_get_visible (titlebar) &&
+ gtk_widget_get_child_visible (titlebar))
+ {
+ gtk_widget_get_allocation (titlebar, &allocation);
+ if (allocation.x <= x && allocation.x + allocation.width > x &&
+ allocation.y <= y && allocation.y + allocation.height > y)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+cc_keyboard_query_button_press_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ CcKeyboardQuery *self = CC_KEYBOARD_QUERY (widget);
+
+ /* eat all the right clicks on the titlebar, since we run in a special session */
+ if (is_event_on_title (self, event) &&
+ event->button == GDK_BUTTON_SECONDARY)
+ return TRUE;
+
+ return GTK_WIDGET_CLASS (cc_keyboard_query_parent_class)->button_press_event (widget, event);
+}
+
static void
cc_keyboard_query_realize (GtkWidget *widget)
{
@@ -305,6 +354,7 @@ cc_keyboard_query_class_init (CcKeyboardQueryClass *klass)
gtk_widget_class_bind_template_callback (widget_class, key_press_event);
widget_class->realize = cc_keyboard_query_realize;
+ widget_class->button_press_event = cc_keyboard_query_button_press_event;
klass->layout_result = cc_keyboard_query_layout_result;
}
@@ -329,6 +379,7 @@ cc_keyboard_query_new (GtkWindow *main_window,
return g_object_new (CC_TYPE_KEYBOARD_QUERY,
"transient-for", main_window,
"xkb-data", xkb_data,
+ "use-header-bar", TRUE,
NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]