Merge lp:~cimi/overlay-scrollbar/better-grab-approach into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Merged at revision: 169
Proposed branch: lp:~cimi/overlay-scrollbar/better-grab-approach
Merge into: lp:overlay-scrollbar
Diff against target: 247 lines (+58/-45)
3 files modified
os/os-pager.c (+4/-0)
os/os-scrollbar.c (+28/-0)
os/os-thumb.c (+26/-45)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/better-grab-approach
Reviewer Review Type Date Requested Status
Javier Jardón Approve
Review via email: mp+53978@code.launchpad.net

Description of the change

only concern I have is that I might need to do more checks instead a plain if priv->grabbed_widget != NULL, maybe I should check if the widget is visible or mapped or so... not sure. Please try and give your suggestions, could be a tricky branch, but here (apart from the concern) works fine in every app with modal dialog

To post a comment you must log in.
Revision history for this message
Andrea Cimitan (cimi) wrote :

requires more work, maybe using grab_notify... doesn't always fix https://bugs.launchpad.net/ayatana-scrollbar/+bug/737518

170. By Andrea Cimitan

Stop events of the thumb when it gets unmapped

171. By Andrea Cimitan

remove a return in button_press_event as it should not be required anymore

172. By Andrea Cimitan

remove grab_notify in os-thumb.c

173. By Andrea Cimitan

remove enter_notify_event in os-thumb.c, useless

174. By Andrea Cimitan

removed leave notify

Revision history for this message
Javier Jardón (jjardon) wrote :

Looks good now

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'os/os-pager.c'
2--- os/os-pager.c 2011-03-16 16:42:33 +0000
3+++ os/os-pager.c 2011-03-18 16:34:27 +0000
4@@ -93,6 +93,10 @@
5
6 gdk_window_set_transient_for (priv->pager_window,
7 gtk_widget_get_window (priv->parent));
8+
9+ gdk_window_input_shape_combine_region (priv->pager_window,
10+ gdk_region_new (),
11+ 0, 0);
12 }
13 }
14
15
16=== modified file 'os/os-scrollbar.c'
17--- os/os-scrollbar.c 2011-03-17 19:50:36 +0000
18+++ os/os-scrollbar.c 2011-03-18 16:34:27 +0000
19@@ -71,6 +71,7 @@
20 };
21
22 static gboolean os_scrollbar_expose_event (GtkWidget *widget, GdkEventExpose *event);
23+static void os_scrollbar_grab_notify (GtkWidget *widget, gboolean was_grabbed);
24 static void os_scrollbar_hide (GtkWidget *widget);
25 static void os_scrollbar_map (GtkWidget *widget);
26 static void os_scrollbar_parent_set (GtkWidget *widget, GtkWidget *old_parent);
27@@ -101,6 +102,7 @@
28 static gboolean thumb_enter_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
29 static gboolean thumb_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
30 static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);
31+static void thumb_unmap_cb (GtkWidget *widget, gpointer user_data);
32 static void pager_move (OsScrollbar *scrollbar);
33 static void pager_set_state (OsScrollbar *scrollbar);
34 static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
35@@ -598,6 +600,8 @@
36 thumb_leave_notify_event_cb, scrollbar);
37 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->thumb),
38 thumb_motion_notify_event_cb, scrollbar);
39+ g_signal_handlers_disconnect_by_func (G_OBJECT (priv->thumb),
40+ thumb_unmap_cb, scrollbar);
41
42 g_object_unref (priv->thumb);
43 }
44@@ -618,6 +622,8 @@
45 G_CALLBACK (thumb_leave_notify_event_cb), scrollbar);
46 g_signal_connect (G_OBJECT (priv->thumb), "motion-notify-event",
47 G_CALLBACK (thumb_motion_notify_event_cb), scrollbar);
48+ g_signal_connect (G_OBJECT (priv->thumb), "unmap",
49+ G_CALLBACK (thumb_unmap_cb), scrollbar);
50 }
51 }
52
53@@ -841,6 +847,21 @@
54 return FALSE;
55 }
56
57+static void
58+thumb_unmap_cb (GtkWidget *widget,
59+ gpointer user_data)
60+{
61+ OsScrollbar *scrollbar;
62+ OsScrollbarPrivate *priv;
63+
64+ scrollbar = OS_SCROLLBAR (user_data);
65+ priv = scrollbar->priv;
66+
67+ priv->button_press_event = FALSE;
68+ priv->motion_notify_event = FALSE;
69+ priv->enter_notify_event = FALSE;
70+}
71+
72 /* Move the pager to the right position. */
73 static void
74 pager_move (OsScrollbar *scrollbar)
75@@ -1225,6 +1246,7 @@
76 widget_class = GTK_WIDGET_CLASS (class);
77
78 widget_class->expose_event = os_scrollbar_expose_event;
79+ widget_class->grab_notify = os_scrollbar_grab_notify;
80 widget_class->hide = os_scrollbar_hide;
81 widget_class->map = os_scrollbar_map;
82 widget_class->realize = os_scrollbar_realize;
83@@ -1301,6 +1323,12 @@
84 }
85
86 static void
87+os_scrollbar_grab_notify (GtkWidget *widget,
88+ gboolean was_grabbed)
89+{
90+}
91+
92+static void
93 os_scrollbar_hide (GtkWidget *widget)
94 {
95 GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->hide (widget);
96
97=== modified file 'os/os-thumb.c'
98--- os/os-thumb.c 2011-03-17 04:00:04 +0000
99+++ os/os-thumb.c 2011-03-18 16:34:27 +0000
100@@ -32,10 +32,9 @@
101
102 struct _OsThumbPrivate {
103 GtkOrientation orientation;
104+ GtkWidget *grabbed_widget;
105 gboolean button_press_event;
106- gboolean enter_notify_event;
107 gboolean motion_notify_event;
108- gboolean can_hide;
109 gboolean can_rgba;
110 gint pointer_x;
111 gint pointer_y;
112@@ -50,9 +49,7 @@
113 static gboolean os_thumb_button_press_event (GtkWidget *widget, GdkEventButton *event);
114 static gboolean os_thumb_button_release_event (GtkWidget *widget, GdkEventButton *event);
115 static void os_thumb_composited_changed (GtkWidget *widget);
116-static gboolean os_thumb_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event);
117 static gboolean os_thumb_expose (GtkWidget *widget, GdkEventExpose *event);
118-static gboolean os_thumb_leave_notify_event (GtkWidget *widget, GdkEventCrossing *event);
119 static gboolean os_thumb_motion_notify_event (GtkWidget *widget, GdkEventMotion *event);
120 static void os_thumb_map (GtkWidget *widget);
121 static void os_thumb_screen_changed (GtkWidget *widget, GdkScreen *old_screen);
122@@ -106,9 +103,7 @@
123 widget_class->button_press_event = os_thumb_button_press_event;
124 widget_class->button_release_event = os_thumb_button_release_event;
125 widget_class->composited_changed = os_thumb_composited_changed;
126- widget_class->enter_notify_event = os_thumb_enter_notify_event;
127 widget_class->expose_event = os_thumb_expose;
128- widget_class->leave_notify_event = os_thumb_leave_notify_event;
129 widget_class->map = os_thumb_map;
130 widget_class->motion_notify_event = os_thumb_motion_notify_event;
131 widget_class->screen_changed = os_thumb_screen_changed;
132@@ -141,7 +136,6 @@
133 OsThumbPrivate);
134 priv = thumb->priv;
135
136- priv->can_hide = TRUE;
137 priv->can_rgba = FALSE;
138
139 gtk_window_set_skip_pager_hint (GTK_WINDOW (thumb), TRUE);
140@@ -215,6 +209,8 @@
141 thumb = OS_THUMB (widget);
142 priv = thumb->priv;
143
144+ gtk_grab_remove (widget);
145+
146 priv->button_press_event = FALSE;
147 priv->motion_notify_event = FALSE;
148
149@@ -246,22 +242,6 @@
150 }
151
152 static gboolean
153-os_thumb_enter_notify_event (GtkWidget *widget,
154- GdkEventCrossing *event)
155-{
156- OsThumb *thumb;
157- OsThumbPrivate *priv;
158-
159- thumb = OS_THUMB (widget);
160- priv = thumb->priv;
161-
162- priv->enter_notify_event = TRUE;
163- priv->can_hide = FALSE;
164-
165- return TRUE;
166-}
167-
168-static gboolean
169 os_thumb_expose (GtkWidget *widget,
170 GdkEventExpose *event)
171 {
172@@ -447,7 +427,7 @@
173 4,
174 height - 8,
175 height - 8);
176-
177+
178 gtk_paint_arrow (gtk_widget_get_style (widget),
179 gtk_widget_get_window (widget),
180 state_type_down,
181@@ -468,28 +448,19 @@
182 return FALSE;
183 }
184
185-static gboolean
186-os_thumb_leave_notify_event (GtkWidget *widget,
187- GdkEventCrossing *event)
188-{
189- OsThumb *thumb;
190- OsThumbPrivate *priv;
191-
192- thumb = OS_THUMB (widget);
193- priv = thumb->priv;
194-
195- if (!priv->button_press_event)
196- priv->can_hide = TRUE;
197-
198-/* g_timeout_add (TIMEOUT_HIDE, os_thumb_hide, widget);*/
199-
200- return TRUE;
201-}
202-
203 static void
204 os_thumb_map (GtkWidget *widget)
205 {
206- gtk_grab_add (widget);
207+ OsThumb *thumb;
208+ OsThumbPrivate *priv;
209+
210+ thumb = OS_THUMB (widget);
211+ priv = thumb->priv;
212+
213+ priv->grabbed_widget = gtk_grab_get_current ();
214+
215+ if (priv->grabbed_widget != NULL)
216+ gtk_grab_remove (priv->grabbed_widget);
217
218 GTK_WIDGET_CLASS (os_thumb_parent_class)->map (widget);
219 }
220@@ -512,7 +483,7 @@
221 priv->motion_notify_event = TRUE;
222 }
223
224- return TRUE;
225+ return FALSE;
226 }
227
228 static void
229@@ -532,7 +503,17 @@
230 static void
231 os_thumb_unmap (GtkWidget *widget)
232 {
233- gtk_grab_remove (widget);
234+ OsThumb *thumb;
235+ OsThumbPrivate *priv;
236+
237+ thumb = OS_THUMB (widget);
238+ priv = thumb->priv;
239+
240+ priv->button_press_event = FALSE;
241+ priv->motion_notify_event = FALSE;
242+
243+ if (priv->grabbed_widget != NULL)
244+ gtk_grab_add (priv->grabbed_widget);
245
246 GTK_WIDGET_CLASS (os_thumb_parent_class)->unmap (widget);
247 }

Subscribers

People subscribed via source and target branches