[gtk+/gestures: 77/92] window: update to gesture widget-level API changes
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gestures: 77/92] window: update to gesture widget-level API changes
- Date: Tue, 8 Apr 2014 19:46:53 +0000 (UTC)
commit a0129eba1a4c234f559f6516fd361f39c39f2798
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Apr 8 21:03:07 2014 +0200
window: update to gesture widget-level API changes
gtk/gtkmain.c | 6 ++++++
gtk/gtkwindow.c | 46 ++++++++++++++++++++++++++++++++++++++--------
2 files changed, 44 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index dfcc906..9e8fea5 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1546,6 +1546,12 @@ gtk_main_do_event (GdkEvent *event)
event_widget = gtk_get_event_widget (event);
}
+ if (GTK_IS_WINDOW (event_widget))
+ {
+ if (_gtk_window_check_handle_wm_event (event))
+ return;
+ }
+
window_group = gtk_main_get_window_group (event_widget);
device = gdk_event_get_device (event);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 77d1d6c..62f317a 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1364,22 +1364,26 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
priv = gtk_window_get_instance_private (window);
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
-
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
+ if (!event)
+ return;
+
region = get_active_region_type (window, (GdkEventAny*) event, x, y);
priv->drag_possible = FALSE;
if (button == GDK_BUTTON_SECONDARY && region == GTK_WINDOW_REGION_TITLE)
{
gtk_window_do_popup (window, (GdkEventButton*) event);
- gtk_widget_set_sequence_state (widget, sequence, GTK_EVENT_SEQUENCE_CLAIMED);
+ 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_widget_set_sequence_state (widget, sequence, GTK_EVENT_SEQUENCE_CLAIMED);
+ gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
+ sequence, GTK_EVENT_SEQUENCE_CLAIMED);
return;
}
else if (button != GDK_BUTTON_PRIMARY)
@@ -1397,8 +1401,8 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
case GTK_WINDOW_REGION_TITLE:
if (!window_drag && event_widget != widget)
{
- gtk_widget_set_sequence_state (widget, sequence,
- GTK_EVENT_SEQUENCE_DENIED);
+ gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
+ sequence, GTK_EVENT_SEQUENCE_DENIED);
return;
}
@@ -1422,10 +1426,12 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
x_root, y_root,
gdk_event_get_time (event));
}
+
break;
}
- gtk_widget_set_sequence_state (widget, sequence, GTK_EVENT_SEQUENCE_CLAIMED);
+ gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
+ sequence, GTK_EVENT_SEQUENCE_CLAIMED);
}
static void
@@ -1460,6 +1466,7 @@ multipress_gesture_stopped_cb (GtkGestureMultiPress *gesture,
gdk_event_get_time (event));
}
+ gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
priv->drag_possible = FALSE;
}
@@ -1534,13 +1541,15 @@ gtk_window_init (GtkWindow *window)
priv->scale = gtk_widget_get_scale_factor (widget);
priv->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (window));
+ gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->multipress_gesture),
+ GTK_PHASE_CAPTURE);
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->multipress_gesture), FALSE);
g_signal_connect (priv->multipress_gesture, "pressed",
G_CALLBACK (multipress_gesture_pressed_cb), window);
g_signal_connect (priv->multipress_gesture, "stopped",
G_CALLBACK (multipress_gesture_stopped_cb), window);
- gtk_widget_add_gesture (GTK_WIDGET (window), priv->multipress_gesture,
- GTK_PHASE_CAPTURE);
+ gtk_widget_add_controller (GTK_WIDGET (window),
+ GTK_EVENT_CONTROLLER (priv->multipress_gesture));
}
static void
@@ -7817,6 +7826,27 @@ get_active_region_type (GtkWindow *window, GdkEventAny *event, gint x, gint y)
return GTK_WINDOW_REGION_CONTENT;
}
+gboolean
+_gtk_window_check_handle_wm_event (GdkEvent *event)
+{
+ GtkWindowPrivate *priv;
+ GtkWidget *widget;
+
+ widget = gtk_get_event_widget (event);
+
+ if (GTK_IS_WINDOW (widget) &&
+ (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE ||
+ event->type == GDK_TOUCH_BEGIN || event->type == GDK_TOUCH_UPDATE ||
+ event->type == GDK_MOTION_NOTIFY || event->type == GDK_TOUCH_END))
+ {
+ priv = GTK_WINDOW (widget)->priv;
+ return gtk_event_controller_handle_event (GTK_EVENT_CONTROLLER (priv->multipress_gesture),
+ (const GdkEvent*) event);
+ }
+
+ return FALSE;
+}
+
static void
gtk_window_real_activate_default (GtkWindow *window)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]