Merge lp:~cimi/overlay-scrollbar/move-leave-notify into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Merged at revision: 232
Proposed branch: lp:~cimi/overlay-scrollbar/move-leave-notify
Merge into: lp:overlay-scrollbar
Diff against target: 118 lines (+32/-49)
1 file modified
os/os-scrollbar.c (+32/-49)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/move-leave-notify
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+58536@code.launchpad.net

Description of the change

just move the leave notify event for the toplevel in the filter func, because the callback applied to the toplevel is called also when moving the mouse in a textview, and that could potentially expose issues

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
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 2011-04-13 13:34:44 +0000
3+++ os/os-scrollbar.c 2011-04-20 17:14:30 +0000
4@@ -127,7 +127,6 @@
5 static void root_gfunc (gpointer data, gpointer user_data);
6 static gboolean toplevel_configure_event_cb (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data);
7 static GdkFilterReturn toplevel_filter_func (GdkXEvent *gdkxevent, GdkEvent *event, gpointer user_data);
8-static gboolean toplevel_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
9
10 /* Private functions. */
11
12@@ -1354,6 +1353,38 @@
13 if (!priv->active_window && xevent->type == EnterNotify)
14 pager_set_state_from_pointer (scrollbar, xevent->xcrossing.x, xevent->xcrossing.y);
15
16+ if (xevent->type == LeaveNotify)
17+ {
18+ /* never deactivate the pager in an active window. */
19+ if (!priv->active_window)
20+ {
21+ priv->can_deactivate_pager = TRUE;
22+
23+ if (priv->source_deactivate_pager_id != 0)
24+ g_source_remove (priv->source_deactivate_pager_id);
25+
26+ priv->source_deactivate_pager_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
27+ os_scrollbar_deactivate_pager_cb,
28+ scrollbar);
29+ }
30+
31+ priv->can_hide = TRUE;
32+
33+ if (priv->source_hide_thumb_id != 0)
34+ g_source_remove (priv->source_hide_thumb_id);
35+
36+ priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
37+ os_scrollbar_hide_thumb_cb,
38+ scrollbar);
39+
40+ if (priv->source_unlock_thumb_id != 0)
41+ g_source_remove (priv->source_unlock_thumb_id);
42+
43+ priv->source_unlock_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
44+ os_scrollbar_unlock_thumb_cb,
45+ scrollbar);
46+ }
47+
48 /* get the motion_notify_event trough XEvent */
49 if (xevent->type == MotionNotify)
50 {
51@@ -1447,50 +1478,6 @@
52 return GDK_FILTER_CONTINUE;
53 }
54
55-/* Hide the OsScrollbar, when the pointer leaves the toplevel GtkWindow. */
56-static gboolean
57-toplevel_leave_notify_event_cb (GtkWidget *widget,
58- GdkEventCrossing *event,
59- gpointer user_data)
60-{
61- OsScrollbar *scrollbar;
62- OsScrollbarPrivate *priv;
63-
64- scrollbar = OS_SCROLLBAR (user_data);
65- priv = scrollbar->priv;
66-
67- /* never deactivate the pager in an active window. */
68- if (!priv->active_window)
69- {
70- priv->can_deactivate_pager = TRUE;
71-
72- if (priv->source_deactivate_pager_id != 0)
73- g_source_remove (priv->source_deactivate_pager_id);
74-
75- priv->source_deactivate_pager_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
76- os_scrollbar_deactivate_pager_cb,
77- scrollbar);
78- }
79-
80- priv->can_hide = TRUE;
81-
82- if (priv->source_hide_thumb_id != 0)
83- g_source_remove (priv->source_hide_thumb_id);
84-
85- priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
86- os_scrollbar_hide_thumb_cb,
87- scrollbar);
88-
89- if (priv->source_unlock_thumb_id != 0)
90- g_source_remove (priv->source_unlock_thumb_id);
91-
92- priv->source_unlock_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
93- os_scrollbar_unlock_thumb_cb,
94- scrollbar);
95-
96- return FALSE;
97-}
98-
99 /* Type definition. */
100
101 G_DEFINE_TYPE (OsScrollbar, os_scrollbar, GTK_TYPE_SCROLLBAR);
102@@ -1723,8 +1710,6 @@
103
104 g_signal_connect (G_OBJECT (gtk_widget_get_toplevel (widget)), "configure-event",
105 G_CALLBACK (toplevel_configure_event_cb), scrollbar);
106- g_signal_connect (G_OBJECT (gtk_widget_get_toplevel (widget)), "leave-notify-event",
107- G_CALLBACK (toplevel_leave_notify_event_cb), scrollbar);
108
109 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
110
111@@ -1842,8 +1827,6 @@
112
113 g_signal_handlers_disconnect_by_func (G_OBJECT (gtk_widget_get_toplevel (widget)),
114 G_CALLBACK (toplevel_configure_event_cb), scrollbar);
115- g_signal_handlers_disconnect_by_func (G_OBJECT (gtk_widget_get_toplevel (widget)),
116- G_CALLBACK (toplevel_leave_notify_event_cb), scrollbar);
117
118 os_pager_set_parent (OS_PAGER (priv->pager), NULL);
119

Subscribers

People subscribed via source and target branches