Merge lp:~cimi/overlay-scrollbar/fix-951121 into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Approved by: Charles Kerr
Approved revision: 339
Merged at revision: 339
Proposed branch: lp:~cimi/overlay-scrollbar/fix-951121
Merge into: lp:overlay-scrollbar
Diff against target: 112 lines (+54/-6)
2 files modified
os/os-scrollbar.c (+51/-6)
os/os-thumb.c (+3/-0)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/fix-951121
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+97086@code.launchpad.net

Description of the change

Deal with XI2 new event handling

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

Looks okay.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'os/os-scrollbar.c'
2--- os/os-scrollbar.c 2012-02-21 17:06:16 +0000
3+++ os/os-scrollbar.c 2012-03-13 14:25:23 +0000
4@@ -1794,15 +1794,11 @@
5 return FALSE;
6 }
7
8-static gboolean
9-thumb_enter_notify_event_cb (GtkWidget *widget,
10- GdkEventCrossing *event,
11- gpointer user_data)
12+static void
13+enter_event (OsScrollbar *scrollbar)
14 {
15- OsScrollbar *scrollbar;
16 OsScrollbarPrivate *priv;
17
18- scrollbar = OS_SCROLLBAR (user_data);
19 priv = scrollbar->priv;
20
21 priv->event |= OS_EVENT_ENTER_NOTIFY;
22@@ -1812,6 +1808,29 @@
23
24 if (priv->state & OS_STATE_INTERNAL)
25 priv->state |= OS_STATE_LOCKED;
26+}
27+
28+static gboolean
29+thumb_enter_notify_event_cb (GtkWidget *widget,
30+ GdkEventCrossing *event,
31+ gpointer user_data)
32+{
33+ OsScrollbar *scrollbar;
34+ OsScrollbarPrivate *priv;
35+
36+ scrollbar = OS_SCROLLBAR (user_data);
37+ priv = scrollbar->priv;
38+
39+#ifdef USE_GTK3
40+ /* Gtk+ 3.3.18 emits more GdkEventCrossing
41+ * with touch devices, skip few events. */
42+ if (event->mode == GDK_CROSSING_TOUCH_BEGIN ||
43+ event->mode == GDK_CROSSING_TOUCH_END ||
44+ event->mode == GDK_CROSSING_DEVICE_SWITCH)
45+ return FALSE;
46+#endif
47+
48+ enter_event (scrollbar);
49
50 return FALSE;
51 }
52@@ -1827,6 +1846,22 @@
53 scrollbar = OS_SCROLLBAR (user_data);
54 priv = scrollbar->priv;
55
56+#ifdef USE_GTK3
57+ /* Gtk+ 3.3.18 emits more GdkEventCrossing
58+ * with touch devices, skip few events.
59+ * Last line skips the event if the pointer is still in the window:
60+ * this happens with touch devices because Gtk+ emits
61+ * GDK_CROSSING_UNGRAB to the touch device, thus calling leave-notify,
62+ * and we want to skip those events.
63+ *
64+ * FIXME the logic of this event should be rewritten. */
65+ if (event->mode == GDK_CROSSING_TOUCH_BEGIN ||
66+ event->mode == GDK_CROSSING_TOUCH_END ||
67+ event->mode == GDK_CROSSING_DEVICE_SWITCH ||
68+ window_at_pointer (event->window, NULL, NULL) == event->window)
69+ return FALSE;
70+#endif
71+
72 /* When exiting the thumb horizontally (or vertically),
73 * in LOCKED state, remove the lock. */
74 if ((priv->state & OS_STATE_LOCKED) &&
75@@ -1853,6 +1888,8 @@
76 scrollbar);
77 }
78
79+ priv->event &= ~(OS_EVENT_ENTER_NOTIFY);
80+
81 priv->hidable_thumb = TRUE;
82
83 if (priv->source_hide_thumb_id != 0)
84@@ -1982,6 +2019,14 @@
85 scrollbar = OS_SCROLLBAR (user_data);
86 priv = scrollbar->priv;
87
88+#ifdef USE_GTK3
89+ /* On touch devices with XI2 and Gtk+ >= 3.3.18,
90+ * the event enter-notify is not emitted.
91+ * Deal with it in motion-notify. */
92+ if (!(priv->event & OS_EVENT_ENTER_NOTIFY))
93+ enter_event (scrollbar);
94+#endif
95+
96 if (priv->event & OS_EVENT_BUTTON_PRESS)
97 {
98 gint x, y;
99
100=== modified file 'os/os-thumb.c'
101--- os/os-thumb.c 2012-01-18 17:30:27 +0000
102+++ os/os-thumb.c 2012-03-13 14:25:23 +0000
103@@ -945,6 +945,9 @@
104 thumb = OS_THUMB (widget);
105 priv = thumb->priv;
106
107+ /* This event is called more times with Gtk+ 3 and XI2 devices,
108+ * let's accept that because the overhead is still minimal. */
109+
110 /* If we exit the thumb when a button is pressed,
111 * there's no need to stop the animation, it should
112 * already be stopped.

Subscribers

People subscribed via source and target branches