Merge lp:~bregma/libgrip/lp-1479353 into lp:libgrip

Proposed by Stephen M. Webb
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 102
Merged at revision: 100
Proposed branch: lp:~bregma/libgrip/lp-1479353
Merge into: lp:libgrip
Diff against target: 103 lines (+72/-7)
1 file modified
src/gripgesturemanager.c (+72/-7)
To merge this branch: bzr merge lp:~bregma/libgrip/lp-1479353
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+266259@code.launchpad.net

Commit message

matched delivered gesture events up to a widget's top level window, then dispatched down to the appropriate widget

Description of the change

Match delivered gesture events up to a widget's top level window, then dispatch down to the appropriate widget.

This fixes the problem in which gesture events were missed because gesture subscriptions were against the top level window but checked against the widget window.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gripgesturemanager.c'
2--- src/gripgesturemanager.c 2014-02-25 16:37:30 +0000
3+++ src/gripgesturemanager.c 2015-07-29 16:03:15 +0000
4@@ -535,8 +535,77 @@
5 }
6
7
8-static void
9-process_gesture_events(GripGestureManager *manager, GeisEvent geis_event)
10+/**
11+ * Gets the extents of a widget in root window coordinates.
12+ */
13+static void
14+get_absolute_widget_extents (GtkWidget *widget, gint *left, gint *right, gint *top, gint *bottom)
15+{
16+ GdkWindow* widget_window = gtk_widget_get_window (widget);
17+
18+ gdk_window_get_origin (widget_window, left, top);
19+
20+ gint window_width = gdk_window_get_width (widget_window);
21+ gint window_height = gdk_window_get_height (widget_window);
22+ gdk_window_get_root_coords (widget_window, window_width, window_height, right, bottom);
23+}
24+
25+
26+/**
27+ * Gets the focus of a gesture frame in root window coordinates.
28+ */
29+static void
30+get_absolute_frame_focus (GeisFrame frame, gint *x, gint *y)
31+{
32+ *x = 0;
33+ *y = 0;
34+
35+ GeisAttr focus_x_attr = geis_frame_attr_by_name (frame, GEIS_GESTURE_ATTRIBUTE_FOCUS_X);
36+ if (focus_x_attr)
37+ {
38+ *x = (int)geis_attr_value_to_float(focus_x_attr);
39+ }
40+
41+ GeisAttr focus_y_attr = geis_frame_attr_by_name (frame, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y);
42+ if (focus_y_attr)
43+ {
44+ *y = (int)geis_attr_value_to_float(focus_y_attr);
45+ }
46+}
47+
48+
49+/**
50+ * Indicates if the focus of a gesture frame is inside a widget.
51+ */
52+static gboolean
53+is_frame_focus_in_widget (GeisFrame frame, GtkWidget *widget)
54+{
55+ gboolean frame_focus_is_in_widget = FALSE;
56+
57+ GtkWidget *toplevel_widget = gtk_widget_get_toplevel (widget);
58+ guint toplevel_widget_window_id = GDK_WINDOW_XID (gtk_widget_get_window (toplevel_widget));
59+
60+ GeisAttr window_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_EVENT_WINDOW_ID);
61+ guint window_id = geis_attr_value_to_integer(window_attr);
62+
63+ if (window_id == toplevel_widget_window_id)
64+ {
65+ gint widget_left, widget_top, widget_right, widget_bottom;
66+ get_absolute_widget_extents (widget, &widget_left, &widget_right, &widget_top, &widget_bottom);
67+
68+ gint focus_x, focus_y;
69+ get_absolute_frame_focus (frame, &focus_x, &focus_y);
70+
71+ frame_focus_is_in_widget = (focus_x >= widget_left && focus_x <= widget_right
72+ && focus_y >= widget_top && focus_y <= widget_bottom);
73+ }
74+
75+ return frame_focus_is_in_widget;
76+}
77+
78+
79+static void
80+process_gesture_events (GripGestureManager *manager, GeisEvent geis_event)
81 {
82 GripGestureManagerPrivate *priv = manager->priv;
83
84@@ -564,9 +633,6 @@
85 GeisFrame frame = geis_group_frame(group, j);
86 g_return_if_fail (frame);
87
88- GeisAttr window_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_EVENT_WINDOW_ID);
89- guint window_id = geis_attr_value_to_integer(window_attr);
90-
91 GeisAttr device_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID);
92 guint device_id = geis_attr_value_to_integer(device_attr);
93 GripInputDevice *input_device = device_id_to_input_device (manager, device_id);
94@@ -575,8 +641,7 @@
95 for (l = priv->bindings; l != NULL; l = l->next)
96 {
97 GripGestureBinding *binding = (GripGestureBinding *)l->data;
98- guint widget_window_id = GDK_WINDOW_XID (gtk_widget_get_window (binding->widget));
99- if (widget_window_id == window_id)
100+ if (is_frame_focus_in_widget(frame, binding->widget))
101 {
102 GList *class_list;
103 for (class_list = priv->classes; class_list != NULL; class_list = class_list->next)

Subscribers

People subscribed via source and target branches