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
=== modified file 'src/gripgesturemanager.c'
--- src/gripgesturemanager.c 2014-02-25 16:37:30 +0000
+++ src/gripgesturemanager.c 2015-07-29 16:03:15 +0000
@@ -535,8 +535,77 @@
535}535}
536536
537537
538static void538/**
539process_gesture_events(GripGestureManager *manager, GeisEvent geis_event)539 * Gets the extents of a widget in root window coordinates.
540 */
541static void
542get_absolute_widget_extents (GtkWidget *widget, gint *left, gint *right, gint *top, gint *bottom)
543{
544 GdkWindow* widget_window = gtk_widget_get_window (widget);
545
546 gdk_window_get_origin (widget_window, left, top);
547
548 gint window_width = gdk_window_get_width (widget_window);
549 gint window_height = gdk_window_get_height (widget_window);
550 gdk_window_get_root_coords (widget_window, window_width, window_height, right, bottom);
551}
552
553
554/**
555 * Gets the focus of a gesture frame in root window coordinates.
556 */
557static void
558get_absolute_frame_focus (GeisFrame frame, gint *x, gint *y)
559{
560 *x = 0;
561 *y = 0;
562
563 GeisAttr focus_x_attr = geis_frame_attr_by_name (frame, GEIS_GESTURE_ATTRIBUTE_FOCUS_X);
564 if (focus_x_attr)
565 {
566 *x = (int)geis_attr_value_to_float(focus_x_attr);
567 }
568
569 GeisAttr focus_y_attr = geis_frame_attr_by_name (frame, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y);
570 if (focus_y_attr)
571 {
572 *y = (int)geis_attr_value_to_float(focus_y_attr);
573 }
574}
575
576
577/**
578 * Indicates if the focus of a gesture frame is inside a widget.
579 */
580static gboolean
581is_frame_focus_in_widget (GeisFrame frame, GtkWidget *widget)
582{
583 gboolean frame_focus_is_in_widget = FALSE;
584
585 GtkWidget *toplevel_widget = gtk_widget_get_toplevel (widget);
586 guint toplevel_widget_window_id = GDK_WINDOW_XID (gtk_widget_get_window (toplevel_widget));
587
588 GeisAttr window_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_EVENT_WINDOW_ID);
589 guint window_id = geis_attr_value_to_integer(window_attr);
590
591 if (window_id == toplevel_widget_window_id)
592 {
593 gint widget_left, widget_top, widget_right, widget_bottom;
594 get_absolute_widget_extents (widget, &widget_left, &widget_right, &widget_top, &widget_bottom);
595
596 gint focus_x, focus_y;
597 get_absolute_frame_focus (frame, &focus_x, &focus_y);
598
599 frame_focus_is_in_widget = (focus_x >= widget_left && focus_x <= widget_right
600 && focus_y >= widget_top && focus_y <= widget_bottom);
601 }
602
603 return frame_focus_is_in_widget;
604}
605
606
607static void
608process_gesture_events (GripGestureManager *manager, GeisEvent geis_event)
540{609{
541 GripGestureManagerPrivate *priv = manager->priv;610 GripGestureManagerPrivate *priv = manager->priv;
542611
@@ -564,9 +633,6 @@
564 GeisFrame frame = geis_group_frame(group, j);633 GeisFrame frame = geis_group_frame(group, j);
565 g_return_if_fail (frame);634 g_return_if_fail (frame);
566635
567 GeisAttr window_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_EVENT_WINDOW_ID);
568 guint window_id = geis_attr_value_to_integer(window_attr);
569
570 GeisAttr device_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID);636 GeisAttr device_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID);
571 guint device_id = geis_attr_value_to_integer(device_attr);637 guint device_id = geis_attr_value_to_integer(device_attr);
572 GripInputDevice *input_device = device_id_to_input_device (manager, device_id);638 GripInputDevice *input_device = device_id_to_input_device (manager, device_id);
@@ -575,8 +641,7 @@
575 for (l = priv->bindings; l != NULL; l = l->next)641 for (l = priv->bindings; l != NULL; l = l->next)
576 {642 {
577 GripGestureBinding *binding = (GripGestureBinding *)l->data;643 GripGestureBinding *binding = (GripGestureBinding *)l->data;
578 guint widget_window_id = GDK_WINDOW_XID (gtk_widget_get_window (binding->widget));644 if (is_frame_focus_in_widget(frame, binding->widget))
579 if (widget_window_id == window_id)
580 {645 {
581 GList *class_list;646 GList *class_list;
582 for (class_list = priv->classes; class_list != NULL; class_list = class_list->next)647 for (class_list = priv->classes; class_list != NULL; class_list = class_list->next)

Subscribers

People subscribed via source and target branches