Merge lp:~cimi/overlay-scrollbar/new-colorization into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Approved by: Ted Gould
Approved revision: 186
Merged at revision: 187
Proposed branch: lp:~cimi/overlay-scrollbar/new-colorization
Merge into: lp:overlay-scrollbar
Diff against target: 213 lines (+67/-21)
2 files modified
os/os-pager.c (+2/-0)
os/os-scrollbar.c (+65/-21)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/new-colorization
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+55822@code.launchpad.net

Description of the change

Colorize the pager while moving the mouse, instead reading the state of the window

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-pager.c'
2--- os/os-pager.c 2011-03-18 12:31:41 +0000
3+++ os/os-pager.c 2011-03-31 20:12:34 +0000
4@@ -111,6 +111,8 @@
5
6 style = gtk_widget_get_style (priv->parent);
7
8+ gdk_window_invalidate_rect (gtk_widget_get_window (priv->parent), &priv->allocation, TRUE);
9+
10 gdk_window_set_background (priv->pager_window,
11 priv->active ? &style->base[GTK_STATE_SELECTED] :
12 &style->base[GTK_STATE_INSENSITIVE]);
13
14=== modified file 'os/os-scrollbar.c'
15--- os/os-scrollbar.c 2011-03-31 14:52:02 +0000
16+++ os/os-scrollbar.c 2011-03-31 20:12:34 +0000
17@@ -55,6 +55,7 @@
18 gboolean fullsize;
19 gboolean proximity;
20 gboolean filter;
21+ gboolean can_deactivate_pager;
22 gboolean can_hide;
23 gint win_x;
24 gint win_y;
25@@ -78,6 +79,8 @@
26 static void os_scrollbar_calc_layout_pager (OsScrollbar *scrollbar, gdouble adjustment_value);
27 static void os_scrollbar_calc_layout_slider (OsScrollbar *scrollbar, gdouble adjustment_value);
28 static gdouble os_scrollbar_coord_to_value (OsScrollbar *scrollbar, gint coord);
29+static void os_scrollbar_deactivate_pager (OsScrollbar *scrollbar);
30+static gboolean os_scrollbar_deactivate_pager_cb (gpointer user_data);
31 static void os_scrollbar_hide_thumb (OsScrollbar *scrollbar);
32 static gboolean os_scrollbar_hide_thumb_cb (gpointer user_data);
33 static void os_scrollbar_move (OsScrollbar *scrollbar, gint mouse_x, gint mouse_y);
34@@ -97,7 +100,7 @@
35 static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);
36 static void thumb_unmap_cb (GtkWidget *widget, gpointer user_data);
37 static void pager_move (OsScrollbar *scrollbar);
38-static void pager_set_state (OsScrollbar *scrollbar);
39+static void pager_set_state_from_pointer (OsScrollbar *scrollbar, gint x, gint y);
40 static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
41 static void adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
42 static gboolean toplevel_configure_event_cb (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data);
43@@ -329,6 +332,29 @@
44 return value;
45 }
46
47+/* Deactivate pager if it's ok to make it inactive. */
48+static void
49+os_scrollbar_deactivate_pager (OsScrollbar *scrollbar)
50+{
51+ OsScrollbarPrivate *priv;
52+
53+ priv = scrollbar->priv;
54+
55+ if (priv->can_deactivate_pager)
56+ os_pager_set_active (OS_PAGER (priv->pager), FALSE);
57+}
58+
59+static gboolean
60+os_scrollbar_deactivate_pager_cb (gpointer user_data)
61+{
62+ OsScrollbar *scrollbar = OS_SCROLLBAR (user_data);
63+
64+ os_scrollbar_deactivate_pager (scrollbar);
65+ g_object_unref (scrollbar);
66+
67+ return FALSE;
68+}
69+
70 /* Hide if it's ok to hide. */
71 static void
72 os_scrollbar_hide_thumb (OsScrollbar *scrollbar)
73@@ -679,6 +705,7 @@
74 priv = scrollbar->priv;
75
76 priv->enter_notify_event = TRUE;
77+ priv->can_deactivate_pager = FALSE;
78 priv->can_hide = FALSE;
79
80 return FALSE;
81@@ -696,8 +723,13 @@
82 priv = scrollbar->priv;
83
84 if (!priv->button_press_event)
85- priv->can_hide = TRUE;
86+ {
87+ priv->can_deactivate_pager = TRUE;
88+ priv->can_hide = TRUE;
89+ }
90
91+ g_timeout_add (TIMEOUT_HIDE, os_scrollbar_deactivate_pager_cb,
92+ g_object_ref (scrollbar));
93 g_timeout_add (TIMEOUT_HIDE, os_scrollbar_hide_thumb_cb,
94 g_object_ref (scrollbar));
95
96@@ -914,17 +946,28 @@
97 }
98
99 static void
100-pager_set_state (OsScrollbar *scrollbar)
101+pager_set_state_from_pointer (OsScrollbar *scrollbar,
102+ gint x,
103+ gint y)
104 {
105+ GtkAllocation allocation;
106 OsScrollbarPrivate *priv;
107
108 priv = scrollbar->priv;
109
110- if (gdk_screen_get_active_window (gtk_widget_get_screen (GTK_WIDGET (scrollbar))) !=
111- gtk_widget_get_window (GTK_WIDGET (scrollbar)))
112- os_pager_set_active (OS_PAGER (priv->pager), FALSE);
113+ gtk_widget_get_allocation (gtk_widget_get_parent (GTK_WIDGET (scrollbar)), &allocation);
114+
115+ if ((x > allocation.x && x < allocation.x + allocation.width) &&
116+ (y > allocation.y && y < allocation.y + allocation.height))
117+ {
118+ priv->can_deactivate_pager = FALSE;
119+ os_pager_set_active (OS_PAGER (priv->pager), TRUE);
120+ }
121 else
122- os_pager_set_active (OS_PAGER (priv->pager), TRUE);
123+ {
124+ priv->can_deactivate_pager = TRUE;
125+ os_scrollbar_deactivate_pager (scrollbar);
126+ }
127 }
128
129 static void
130@@ -995,10 +1038,15 @@
131 {
132 OsScrollbar *scrollbar;
133 OsScrollbarPrivate *priv;
134+ gint x, y;
135
136 scrollbar = OS_SCROLLBAR (user_data);
137 priv = scrollbar->priv;
138
139+ gtk_widget_get_pointer (widget, &x, &y);
140+
141+ pager_set_state_from_pointer (scrollbar, x, y);
142+
143 gtk_widget_hide (GTK_WIDGET (priv->thumb));
144
145 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
146@@ -1034,6 +1082,8 @@
147 /* get the motion_notify_event trough XEvent */
148 if (xevent->type == MotionNotify)
149 {
150+ pager_set_state_from_pointer (scrollbar, xevent->xmotion.x, xevent->xmotion.y);
151+
152 /* proximity area */
153 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
154 {
155@@ -1112,19 +1162,6 @@
156 return GDK_FILTER_CONTINUE;
157 }
158
159- /* code to check if the window is active */
160- if (xevent->type == PropertyNotify)
161- {
162- if (gdk_screen_get_active_window (gtk_widget_get_screen (GTK_WIDGET (scrollbar))) !=
163- gtk_widget_get_window (GTK_WIDGET (scrollbar)))
164- {
165- gtk_widget_hide (GTK_WIDGET (priv->thumb));
166- os_pager_set_active (OS_PAGER (priv->pager), FALSE);
167- }
168- else
169- os_pager_set_active (OS_PAGER (priv->pager), TRUE);
170- }
171-
172 return GDK_FILTER_CONTINUE;
173 }
174
175@@ -1140,8 +1177,11 @@
176 scrollbar = OS_SCROLLBAR (user_data);
177 priv = scrollbar->priv;
178
179+ priv->can_deactivate_pager = TRUE;
180 priv->can_hide = TRUE;
181
182+ g_timeout_add (TIMEOUT_HIDE, os_scrollbar_deactivate_pager_cb,
183+ g_object_ref (scrollbar));
184 g_timeout_add (TIMEOUT_HIDE, os_scrollbar_hide_thumb_cb,
185 g_object_ref (scrollbar));
186
187@@ -1187,6 +1227,7 @@
188 OsScrollbarPrivate);
189 priv = scrollbar->priv;
190
191+ priv->can_deactivate_pager = TRUE;
192 priv->can_hide = TRUE;
193 priv->fullsize = FALSE;
194 priv->proximity = FALSE;
195@@ -1252,6 +1293,7 @@
196 {
197 OsScrollbar *scrollbar;
198 OsScrollbarPrivate *priv;
199+ gint x, y;
200
201 scrollbar = OS_SCROLLBAR (widget);
202 priv = scrollbar->priv;
203@@ -1260,7 +1302,9 @@
204
205 priv->proximity = TRUE;
206
207- pager_set_state (scrollbar);
208+ gtk_widget_get_pointer (gtk_widget_get_toplevel (widget), &x, &y);
209+
210+ pager_set_state_from_pointer (scrollbar, x, y);
211
212 if (priv->fullsize == FALSE)
213 os_pager_show (OS_PAGER (priv->pager));

Subscribers

People subscribed via source and target branches