summaryrefslogtreecommitdiff
path: root/gtk/gtkwindow.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-09-25 00:47:33 -0400
committerMatthias Clasen <mclasen@redhat.com>2014-09-25 14:54:49 -0400
commitd20fdd18eb334ed8aea607dfc91746c4660cd4ca (patch)
tree8be824108cd14b0937000c50a8b160c365634672 /gtk/gtkwindow.c
parent6604f002366eba2d659afa2e1b72c4ff0d5148c6 (diff)
downloadgtk+-d20fdd18eb334ed8aea607dfc91746c4660cd4ca.tar.gz
Factor out titlebar click actions
So they can be made configurable. https://bugzilla.gnome.org/show_bug.cgi?id=729782
Diffstat (limited to 'gtk/gtkwindow.c')
-rw-r--r--gtk/gtkwindow.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 35832c5fc1..e6dbb12815 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1354,6 +1354,32 @@ popover_destroy (GtkWindowPopover *popover)
g_free (popover);
}
+static gboolean
+gtk_window_titlebar_action (GtkWindow *window,
+ const GdkEvent *event,
+ guint button,
+ gint n_press)
+{
+ switch (button)
+ {
+ case GDK_BUTTON_PRIMARY:
+ if (n_press == 2)
+ {
+ _gtk_window_toggle_maximized (window);
+ return TRUE;
+ }
+ return FALSE;
+ case GDK_BUTTON_MIDDLE:
+ gdk_window_lower (gtk_widget_get_window (GTK_WIDGET (window)));
+ return TRUE;
+ case GDK_BUTTON_SECONDARY:
+ gtk_window_do_popup (window, (GdkEventButton*) event);
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
static void
multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
gint n_press,
@@ -1383,16 +1409,16 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
if (button == GDK_BUTTON_SECONDARY && region == GTK_WINDOW_REGION_TITLE)
{
- gtk_window_do_popup (window, (GdkEventButton*) event);
- gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
- sequence, GTK_EVENT_SEQUENCE_CLAIMED);
+ if (gtk_window_titlebar_action (window, event, button, n_press))
+ gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
+ sequence, GTK_EVENT_SEQUENCE_CLAIMED);
return;
}
else if (button == GDK_BUTTON_MIDDLE && region == GTK_WINDOW_REGION_TITLE)
{
- gdk_window_lower (gtk_widget_get_window (GTK_WIDGET (window)));
- gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
- sequence, GTK_EVENT_SEQUENCE_CLAIMED);
+ if (gtk_window_titlebar_action (window, event, button, n_press))
+ gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
+ sequence, GTK_EVENT_SEQUENCE_CLAIMED);
return;
}
else if (button != GDK_BUTTON_PRIMARY)
@@ -1404,8 +1430,7 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
{
case GTK_WINDOW_REGION_CONTENT:
if (event_widget != widget)
- gtk_widget_style_get (event_widget, "window-dragging",
- &window_drag, NULL);
+ gtk_widget_style_get (event_widget, "window-dragging", &window_drag, NULL);
if (!window_drag)
{
@@ -1416,7 +1441,7 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
/* fall thru */
case GTK_WINDOW_REGION_TITLE:
if (n_press == 2)
- _gtk_window_toggle_maximized (window);
+ gtk_window_titlebar_action (window, event, button, n_press);
if (n_press == 1)
priv->drag_possible = TRUE;
break;