[gnome-initial-setup/shell/4765: 218/362] window: eat all right click events on the titlebar
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/shell/4765: 218/362] window: eat all right click events on the titlebar
- Date: Thu, 19 Mar 2015 01:39:24 +0000 (UTC)
commit 9501939cff053c3a8593d01ff37cde395f83815d
Author: Cosimo Cecchi <cosimo endlessm com>
Date: Mon Sep 15 14:57:23 2014 -0700
window: eat all right click events on the titlebar
Since we run in a special session that does not have all the window
management features, we don't want the WM actions menu to pop up on
right click.
[endlessm/eos-shell#3683]
gnome-initial-setup/gis-window.c | 51 ++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/gnome-initial-setup/gis-window.c b/gnome-initial-setup/gis-window.c
index f454173..bbb0930 100644
--- a/gnome-initial-setup/gis-window.c
+++ b/gnome-initial-setup/gis-window.c
@@ -35,6 +35,56 @@ typedef struct _GisWindowPrivate GisWindowPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(GisWindow, gis_window, GTK_TYPE_APPLICATION_WINDOW)
+static gboolean
+is_event_on_title (GisWindow *window,
+ GdkEventButton *event)
+{
+ GisWindowPrivate *priv = gis_window_get_instance_private (window);
+ GtkAllocation allocation;
+ GtkWidget *titlebar, *src;
+ gint x, y;
+
+ titlebar = gis_assistant_get_titlebar (priv->assistant);
+
+ gdk_window_get_user_data (event->window, (gpointer *)&src);
+ if (src && src != GTK_WIDGET (window))
+ {
+ gtk_widget_translate_coordinates (src, GTK_WIDGET (window),
+ 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
+gis_window_button_press_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ GisWindow *window = GIS_WINDOW (widget);
+
+ /* eat all the right clicks on the titlebar, since we run in a special session */
+ if (is_event_on_title (window, event) &&
+ event->button == GDK_BUTTON_SECONDARY)
+ return TRUE;
+
+ return GTK_WIDGET_CLASS (gis_window_parent_class)->button_press_event (widget, event);
+}
+
static void
gis_window_realize (GtkWidget *widget)
{
@@ -52,6 +102,7 @@ gis_window_class_init (GisWindowClass *klass)
{
GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
+ wclass->button_press_event = gis_window_button_press_event;
wclass->realize = gis_window_realize;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]