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
=== modified file 'os/os-pager.c'
--- os/os-pager.c 2011-03-16 16:42:33 +0000
+++ os/os-pager.c 2011-03-18 16:34:27 +0000
@@ -93,6 +93,10 @@
9393
94 gdk_window_set_transient_for (priv->pager_window,94 gdk_window_set_transient_for (priv->pager_window,
95 gtk_widget_get_window (priv->parent));95 gtk_widget_get_window (priv->parent));
96
97 gdk_window_input_shape_combine_region (priv->pager_window,
98 gdk_region_new (),
99 0, 0);
96 }100 }
97}101}
98102
99103
=== modified file 'os/os-scrollbar.c'
--- os/os-scrollbar.c 2011-03-17 19:50:36 +0000
+++ os/os-scrollbar.c 2011-03-18 16:34:27 +0000
@@ -71,6 +71,7 @@
71};71};
7272
73static gboolean os_scrollbar_expose_event (GtkWidget *widget, GdkEventExpose *event);73static gboolean os_scrollbar_expose_event (GtkWidget *widget, GdkEventExpose *event);
74static void os_scrollbar_grab_notify (GtkWidget *widget, gboolean was_grabbed);
74static void os_scrollbar_hide (GtkWidget *widget);75static void os_scrollbar_hide (GtkWidget *widget);
75static void os_scrollbar_map (GtkWidget *widget);76static void os_scrollbar_map (GtkWidget *widget);
76static void os_scrollbar_parent_set (GtkWidget *widget, GtkWidget *old_parent);77static void os_scrollbar_parent_set (GtkWidget *widget, GtkWidget *old_parent);
@@ -101,6 +102,7 @@
101static gboolean thumb_enter_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);102static gboolean thumb_enter_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
102static gboolean thumb_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);103static gboolean thumb_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
103static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);104static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);
105static void thumb_unmap_cb (GtkWidget *widget, gpointer user_data);
104static void pager_move (OsScrollbar *scrollbar);106static void pager_move (OsScrollbar *scrollbar);
105static void pager_set_state (OsScrollbar *scrollbar);107static void pager_set_state (OsScrollbar *scrollbar);
106static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data);108static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
@@ -598,6 +600,8 @@
598 thumb_leave_notify_event_cb, scrollbar);600 thumb_leave_notify_event_cb, scrollbar);
599 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->thumb),601 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->thumb),
600 thumb_motion_notify_event_cb, scrollbar);602 thumb_motion_notify_event_cb, scrollbar);
603 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->thumb),
604 thumb_unmap_cb, scrollbar);
601605
602 g_object_unref (priv->thumb);606 g_object_unref (priv->thumb);
603 }607 }
@@ -618,6 +622,8 @@
618 G_CALLBACK (thumb_leave_notify_event_cb), scrollbar);622 G_CALLBACK (thumb_leave_notify_event_cb), scrollbar);
619 g_signal_connect (G_OBJECT (priv->thumb), "motion-notify-event",623 g_signal_connect (G_OBJECT (priv->thumb), "motion-notify-event",
620 G_CALLBACK (thumb_motion_notify_event_cb), scrollbar);624 G_CALLBACK (thumb_motion_notify_event_cb), scrollbar);
625 g_signal_connect (G_OBJECT (priv->thumb), "unmap",
626 G_CALLBACK (thumb_unmap_cb), scrollbar);
621 }627 }
622}628}
623629
@@ -841,6 +847,21 @@
841 return FALSE;847 return FALSE;
842}848}
843849
850static void
851thumb_unmap_cb (GtkWidget *widget,
852 gpointer user_data)
853{
854 OsScrollbar *scrollbar;
855 OsScrollbarPrivate *priv;
856
857 scrollbar = OS_SCROLLBAR (user_data);
858 priv = scrollbar->priv;
859
860 priv->button_press_event = FALSE;
861 priv->motion_notify_event = FALSE;
862 priv->enter_notify_event = FALSE;
863}
864
844/* Move the pager to the right position. */865/* Move the pager to the right position. */
845static void866static void
846pager_move (OsScrollbar *scrollbar)867pager_move (OsScrollbar *scrollbar)
@@ -1225,6 +1246,7 @@
1225 widget_class = GTK_WIDGET_CLASS (class);1246 widget_class = GTK_WIDGET_CLASS (class);
12261247
1227 widget_class->expose_event = os_scrollbar_expose_event;1248 widget_class->expose_event = os_scrollbar_expose_event;
1249 widget_class->grab_notify = os_scrollbar_grab_notify;
1228 widget_class->hide = os_scrollbar_hide;1250 widget_class->hide = os_scrollbar_hide;
1229 widget_class->map = os_scrollbar_map;1251 widget_class->map = os_scrollbar_map;
1230 widget_class->realize = os_scrollbar_realize;1252 widget_class->realize = os_scrollbar_realize;
@@ -1301,6 +1323,12 @@
1301}1323}
13021324
1303static void1325static void
1326os_scrollbar_grab_notify (GtkWidget *widget,
1327 gboolean was_grabbed)
1328{
1329}
1330
1331static void
1304os_scrollbar_hide (GtkWidget *widget)1332os_scrollbar_hide (GtkWidget *widget)
1305{1333{
1306 GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->hide (widget);1334 GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->hide (widget);
13071335
=== modified file 'os/os-thumb.c'
--- os/os-thumb.c 2011-03-17 04:00:04 +0000
+++ os/os-thumb.c 2011-03-18 16:34:27 +0000
@@ -32,10 +32,9 @@
3232
33struct _OsThumbPrivate {33struct _OsThumbPrivate {
34 GtkOrientation orientation;34 GtkOrientation orientation;
35 GtkWidget *grabbed_widget;
35 gboolean button_press_event;36 gboolean button_press_event;
36 gboolean enter_notify_event;
37 gboolean motion_notify_event;37 gboolean motion_notify_event;
38 gboolean can_hide;
39 gboolean can_rgba;38 gboolean can_rgba;
40 gint pointer_x;39 gint pointer_x;
41 gint pointer_y;40 gint pointer_y;
@@ -50,9 +49,7 @@
50static gboolean os_thumb_button_press_event (GtkWidget *widget, GdkEventButton *event);49static gboolean os_thumb_button_press_event (GtkWidget *widget, GdkEventButton *event);
51static gboolean os_thumb_button_release_event (GtkWidget *widget, GdkEventButton *event);50static gboolean os_thumb_button_release_event (GtkWidget *widget, GdkEventButton *event);
52static void os_thumb_composited_changed (GtkWidget *widget);51static void os_thumb_composited_changed (GtkWidget *widget);
53static gboolean os_thumb_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event);
54static gboolean os_thumb_expose (GtkWidget *widget, GdkEventExpose *event);52static gboolean os_thumb_expose (GtkWidget *widget, GdkEventExpose *event);
55static gboolean os_thumb_leave_notify_event (GtkWidget *widget, GdkEventCrossing *event);
56static gboolean os_thumb_motion_notify_event (GtkWidget *widget, GdkEventMotion *event);53static gboolean os_thumb_motion_notify_event (GtkWidget *widget, GdkEventMotion *event);
57static void os_thumb_map (GtkWidget *widget);54static void os_thumb_map (GtkWidget *widget);
58static void os_thumb_screen_changed (GtkWidget *widget, GdkScreen *old_screen);55static void os_thumb_screen_changed (GtkWidget *widget, GdkScreen *old_screen);
@@ -106,9 +103,7 @@
106 widget_class->button_press_event = os_thumb_button_press_event;103 widget_class->button_press_event = os_thumb_button_press_event;
107 widget_class->button_release_event = os_thumb_button_release_event;104 widget_class->button_release_event = os_thumb_button_release_event;
108 widget_class->composited_changed = os_thumb_composited_changed;105 widget_class->composited_changed = os_thumb_composited_changed;
109 widget_class->enter_notify_event = os_thumb_enter_notify_event;
110 widget_class->expose_event = os_thumb_expose;106 widget_class->expose_event = os_thumb_expose;
111 widget_class->leave_notify_event = os_thumb_leave_notify_event;
112 widget_class->map = os_thumb_map;107 widget_class->map = os_thumb_map;
113 widget_class->motion_notify_event = os_thumb_motion_notify_event;108 widget_class->motion_notify_event = os_thumb_motion_notify_event;
114 widget_class->screen_changed = os_thumb_screen_changed;109 widget_class->screen_changed = os_thumb_screen_changed;
@@ -141,7 +136,6 @@
141 OsThumbPrivate);136 OsThumbPrivate);
142 priv = thumb->priv;137 priv = thumb->priv;
143138
144 priv->can_hide = TRUE;
145 priv->can_rgba = FALSE;139 priv->can_rgba = FALSE;
146140
147 gtk_window_set_skip_pager_hint (GTK_WINDOW (thumb), TRUE);141 gtk_window_set_skip_pager_hint (GTK_WINDOW (thumb), TRUE);
@@ -215,6 +209,8 @@
215 thumb = OS_THUMB (widget);209 thumb = OS_THUMB (widget);
216 priv = thumb->priv;210 priv = thumb->priv;
217211
212 gtk_grab_remove (widget);
213
218 priv->button_press_event = FALSE;214 priv->button_press_event = FALSE;
219 priv->motion_notify_event = FALSE;215 priv->motion_notify_event = FALSE;
220216
@@ -246,22 +242,6 @@
246}242}
247243
248static gboolean244static gboolean
249os_thumb_enter_notify_event (GtkWidget *widget,
250 GdkEventCrossing *event)
251{
252 OsThumb *thumb;
253 OsThumbPrivate *priv;
254
255 thumb = OS_THUMB (widget);
256 priv = thumb->priv;
257
258 priv->enter_notify_event = TRUE;
259 priv->can_hide = FALSE;
260
261 return TRUE;
262}
263
264static gboolean
265os_thumb_expose (GtkWidget *widget,245os_thumb_expose (GtkWidget *widget,
266 GdkEventExpose *event)246 GdkEventExpose *event)
267{247{
@@ -447,7 +427,7 @@
447 4,427 4,
448 height - 8,428 height - 8,
449 height - 8);429 height - 8);
450 430
451 gtk_paint_arrow (gtk_widget_get_style (widget),431 gtk_paint_arrow (gtk_widget_get_style (widget),
452 gtk_widget_get_window (widget),432 gtk_widget_get_window (widget),
453 state_type_down,433 state_type_down,
@@ -468,28 +448,19 @@
468 return FALSE;448 return FALSE;
469}449}
470450
471static gboolean
472os_thumb_leave_notify_event (GtkWidget *widget,
473 GdkEventCrossing *event)
474{
475 OsThumb *thumb;
476 OsThumbPrivate *priv;
477
478 thumb = OS_THUMB (widget);
479 priv = thumb->priv;
480
481 if (!priv->button_press_event)
482 priv->can_hide = TRUE;
483
484/* g_timeout_add (TIMEOUT_HIDE, os_thumb_hide, widget);*/
485
486 return TRUE;
487}
488
489static void451static void
490os_thumb_map (GtkWidget *widget)452os_thumb_map (GtkWidget *widget)
491{453{
492 gtk_grab_add (widget);454 OsThumb *thumb;
455 OsThumbPrivate *priv;
456
457 thumb = OS_THUMB (widget);
458 priv = thumb->priv;
459
460 priv->grabbed_widget = gtk_grab_get_current ();
461
462 if (priv->grabbed_widget != NULL)
463 gtk_grab_remove (priv->grabbed_widget);
493464
494 GTK_WIDGET_CLASS (os_thumb_parent_class)->map (widget);465 GTK_WIDGET_CLASS (os_thumb_parent_class)->map (widget);
495}466}
@@ -512,7 +483,7 @@
512 priv->motion_notify_event = TRUE;483 priv->motion_notify_event = TRUE;
513 }484 }
514485
515 return TRUE;486 return FALSE;
516}487}
517488
518static void489static void
@@ -532,7 +503,17 @@
532static void503static void
533os_thumb_unmap (GtkWidget *widget)504os_thumb_unmap (GtkWidget *widget)
534{505{
535 gtk_grab_remove (widget);506 OsThumb *thumb;
507 OsThumbPrivate *priv;
508
509 thumb = OS_THUMB (widget);
510 priv = thumb->priv;
511
512 priv->button_press_event = FALSE;
513 priv->motion_notify_event = FALSE;
514
515 if (priv->grabbed_widget != NULL)
516 gtk_grab_add (priv->grabbed_widget);
536517
537 GTK_WIDGET_CLASS (os_thumb_parent_class)->unmap (widget);518 GTK_WIDGET_CLASS (os_thumb_parent_class)->unmap (widget);
538}519}

Subscribers

People subscribed via source and target branches