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

Proposed by Andrea Cimitan
Status: Merged
Approved by: Ted Gould
Approved revision: 297
Merged at revision: 297
Proposed branch: lp:~cimi/overlay-scrollbar/fix-822806
Merge into: lp:overlay-scrollbar
Diff against target: 539 lines (+280/-221)
1 file modified
os/os-scrollbar.c (+280/-221)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/fix-822806
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+70796@code.launchpad.net
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
=== modified file 'os/os-scrollbar.c'
--- os/os-scrollbar.c 2011-07-14 14:35:59 +0000
+++ os/os-scrollbar.c 2011-08-08 21:52:33 +0000
@@ -1953,7 +1953,7 @@
1953 OsScrollbarPrivate *priv;1953 OsScrollbarPrivate *priv;
19541954
1955 priv = scrollbar->priv;1955 priv = scrollbar->priv;
1956 1956
1957 switch (priv->side)1957 switch (priv->side)
1958 {1958 {
1959 case OS_SIDE_RIGHT:1959 case OS_SIDE_RIGHT:
@@ -1989,6 +1989,15 @@
19891989
1990/* filter function applied to the toplevel window */1990/* filter function applied to the toplevel window */
1991#ifdef USE_GTK31991#ifdef USE_GTK3
1992typedef enum
1993{
1994 OS_XEVENT_NONE,
1995 OS_XEVENT_BUTTON_PRESS,
1996 OS_XEVENT_BUTTON_RELEASE,
1997 OS_XEVENT_LEAVE,
1998 OS_XEVENT_MOTION
1999} OsXEvent;
2000
1992static GdkFilterReturn2001static GdkFilterReturn
1993window_filter_func (GdkXEvent *gdkxevent,2002window_filter_func (GdkXEvent *gdkxevent,
1994 GdkEvent *event,2003 GdkEvent *event,
@@ -2010,93 +2019,144 @@
20102019
2011 if (!priv->fullsize)2020 if (!priv->fullsize)
2012 {2021 {
2022 OsXEvent os_xevent;
2023 gdouble event_x, event_y;
2024
2025 os_xevent = OS_XEVENT_NONE;
2026
2013 if (xev->type == GenericEvent)2027 if (xev->type == GenericEvent)
2014 {2028 {
2029 /* Deal with XInput 2 events */
2015 XIDeviceEvent *xiev;2030 XIDeviceEvent *xiev;
20162031
2017 xiev = xev->xcookie.data;2032 xiev = xev->xcookie.data;
20182033
2019 if (xiev->evtype == XI_ButtonPress)2034 if (xiev->evtype == XI_ButtonPress)
2020 {2035 os_xevent = OS_XEVENT_BUTTON_PRESS;
2021 priv->toplevel_button_press = TRUE;2036
2022 gtk_widget_hide (priv->thumb);2037 if (xiev->evtype == XI_ButtonRelease)
2023 }2038 {
20242039 os_xevent = OS_XEVENT_BUTTON_RELEASE;
2025 if (priv->toplevel_button_press && xiev->evtype == XI_ButtonRelease)2040 event_x = xiev->event_x;
2026 {2041 event_y = xiev->event_y;
2027 priv->toplevel_button_press = FALSE;2042 }
20282043
2029 /* proximity area */2044 if (xiev->evtype == XI_Leave)
2030 if (priv->orientation == GTK_ORIENTATION_VERTICAL)2045 os_xevent = OS_XEVENT_LEAVE;
2031 {2046
2032 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y))2047 if (xiev->evtype == XI_Motion)
2033 {2048 {
2034 priv->can_hide = FALSE;2049 os_xevent = OS_XEVENT_MOTION;
20352050 event_x = xiev->event_x;
2036 if (priv->lock_position)2051 event_y = xiev->event_y;
2037 return GDK_FILTER_CONTINUE;2052 }
20382053 }
2039 if (priv->overlay.height > priv->slider.height)2054 else
2040 {2055 {
2041 gint x, y, x_pos, y_pos;2056 /* Deal with X core events, when apps (like rhythmbox),
20422057 * are using gdk_disable_miltidevice () */
2043 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);2058 if (xev->type == ButtonPress)
20442059 os_xevent = OS_XEVENT_BUTTON_PRESS;
2045 x = priv->thumb_all.x;2060
2046 y = CLAMP (xiev->event_y - priv->slider.height / 2,2061 if (xev->type == ButtonRelease)
2047 priv->thumb_all.y + priv->overlay.y,2062 {
2048 priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);2063 os_xevent = OS_XEVENT_BUTTON_RELEASE;
20492064 event_x = xev->xbutton.x;
2050 move_thumb (scrollbar, x_pos + x, y_pos + y);2065 event_y = xev->xbutton.y;
2051 }2066 }
2052 else2067
2053 {2068 if (xev->type == LeaveNotify)
2054 move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);2069 os_xevent = OS_XEVENT_LEAVE;
2055 }2070
20562071 if (xev->type == MotionNotify)
2057 gtk_widget_show (priv->thumb);2072 {
2058 }2073 os_xevent = OS_XEVENT_MOTION;
2059 }2074 event_x = xev->xmotion.x;
2060 else2075 event_y = xev->xmotion.y;
2061 {2076 }
2062 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y))2077 }
2063 {2078
2064 priv->can_hide = FALSE;2079 if (os_xevent == OS_XEVENT_BUTTON_PRESS)
20652080 {
2066 if (priv->lock_position)2081 priv->toplevel_button_press = TRUE;
2067 return GDK_FILTER_CONTINUE;2082 gtk_widget_hide (priv->thumb);
20682083 }
2069 if (priv->overlay.width > priv->slider.width)2084
2070 {2085 if (priv->toplevel_button_press && os_xevent == OS_XEVENT_BUTTON_RELEASE)
2071 gint x, y, x_pos, y_pos;2086 {
20722087 priv->toplevel_button_press = FALSE;
2073 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);2088
20742089 /* proximity area */
2075 x = CLAMP (xiev->event_x - priv->slider.width / 2,2090 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
2076 priv->thumb_all.x + priv->overlay.x,2091 {
2077 priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);2092 if (check_proximity (scrollbar, event_x, event_y))
2078 y = priv->thumb_all.y;2093 {
20792094 priv->can_hide = FALSE;
2080 move_thumb (scrollbar, x_pos + x, y_pos + y);2095
2081 }2096 if (priv->lock_position)
2082 else2097 return GDK_FILTER_CONTINUE;
2083 {2098
2084 move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);2099 if (priv->overlay.height > priv->slider.height)
2085 }2100 {
20862101 gint x, y, x_pos, y_pos;
2087 gtk_widget_show (priv->thumb);2102
2088 }2103 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
2089 }2104
2090 }2105 x = priv->thumb_all.x;
20912106 y = CLAMP (event_y - priv->slider.height / 2,
2092 /* after a scroll-event, without motion,2107 priv->thumb_all.y + priv->overlay.y,
2093 * pager becomes inactive because the timeout in2108 priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);
2094 * leave-notify-event starts,2109
2095 * this call checks the pointer after the scroll-event,2110 move_thumb (scrollbar, x_pos + x, y_pos + y);
2096 * since it enters the window,2111 }
2097 * then sets the state accordingly. */2112 else
20982113 {
2099 /* FIXME(Cimi) code commented out until I find what and where is wrong. */2114 move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
2115 }
2116
2117 gtk_widget_show (priv->thumb);
2118 }
2119 }
2120 else
2121 {
2122 if (check_proximity (scrollbar, event_x, event_y))
2123 {
2124 priv->can_hide = FALSE;
2125
2126 if (priv->lock_position)
2127 return GDK_FILTER_CONTINUE;
2128
2129 if (priv->overlay.width > priv->slider.width)
2130 {
2131 gint x, y, x_pos, y_pos;
2132
2133 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
2134
2135 x = CLAMP (event_x - priv->slider.width / 2,
2136 priv->thumb_all.x + priv->overlay.x,
2137 priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);
2138 y = priv->thumb_all.y;
2139
2140 move_thumb (scrollbar, x_pos + x, y_pos + y);
2141 }
2142 else
2143 {
2144 move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
2145 }
2146
2147 gtk_widget_show (priv->thumb);
2148 }
2149 }
2150 }
2151
2152 /* after a scroll-event, without motion,
2153 * pager becomes inactive because the timeout in
2154 * leave-notify-event starts,
2155 * this call checks the pointer after the scroll-event,
2156 * since it enters the window,
2157 * then sets the state accordingly. */
2158
2159 /* FIXME(Cimi) code commented out until I find what and where is wrong. */
2100// if (!priv->active_window && xiev->evtype == XI_Enter)2160// if (!priv->active_window && xiev->evtype == XI_Enter)
2101// {2161// {
2102// XIEnterEvent *xiee = xev->xcookie.data;2162// XIEnterEvent *xiee = xev->xcookie.data;
@@ -2106,147 +2166,146 @@
2106// pager_set_state_from_pointer (scrollbar, xiee->event_x, xiee->event_y);2166// pager_set_state_from_pointer (scrollbar, xiee->event_x, xiee->event_y);
2107// }2167// }
21082168
2109 if (xiev->evtype == XI_Leave)2169 if (os_xevent == OS_XEVENT_LEAVE)
2110 {2170 {
2111 /* never deactivate the pager in an active window. */2171 /* never deactivate the pager in an active window. */
2112 if (!priv->active_window)2172 if (!priv->active_window)
2113 {2173 {
2114 priv->can_deactivate_pager = TRUE;2174 priv->can_deactivate_pager = TRUE;
21152175
2116 if (priv->source_deactivate_pager_id != 0)2176 if (priv->source_deactivate_pager_id != 0)
2117 g_source_remove (priv->source_deactivate_pager_id);2177 g_source_remove (priv->source_deactivate_pager_id);
21182178
2119 priv->source_deactivate_pager_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,2179 priv->source_deactivate_pager_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
2120 deactivate_pager_cb,2180 deactivate_pager_cb,
2121 scrollbar);2181 scrollbar);
2122 }2182 }
21232183
2124 priv->toplevel_button_press = FALSE;2184 priv->toplevel_button_press = FALSE;
2125 priv->can_hide = TRUE;2185 priv->can_hide = TRUE;
21262186
2127 if (priv->source_hide_thumb_id != 0)2187 if (priv->source_hide_thumb_id != 0)
2128 g_source_remove (priv->source_hide_thumb_id);2188 g_source_remove (priv->source_hide_thumb_id);
21292189
2130 priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,2190 priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
2131 hide_thumb_cb,2191 hide_thumb_cb,
2192 scrollbar);
2193
2194 if (priv->source_unlock_thumb_id != 0)
2195 g_source_remove (priv->source_unlock_thumb_id);
2196
2197 priv->source_unlock_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
2198 unlock_thumb_cb,
2132 scrollbar);2199 scrollbar);
21332200 }
2134 if (priv->source_unlock_thumb_id != 0)2201
2135 g_source_remove (priv->source_unlock_thumb_id);2202 /* get the motion_notify_event trough XEvent */
21362203 if (!priv->toplevel_button_press && os_xevent == OS_XEVENT_MOTION)
2137 priv->source_unlock_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,2204 {
2138 unlock_thumb_cb,2205 /* react to motion_notify_event
2139 scrollbar);2206 * and set the state accordingly. */
2140 }2207 if (!is_insensitive (scrollbar) && !priv->active_window)
21412208 pager_set_state_from_pointer (scrollbar, event_x, event_y);
2142 /* get the motion_notify_event trough XEvent */2209
2143 if (!priv->toplevel_button_press && xiev->evtype == XI_Motion)2210 /* proximity area */
2144 {2211 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
2145 /* react to motion_notify_event2212 {
2146 * and set the state accordingly. */2213 if (check_proximity (scrollbar, event_x, event_y))
2147 if (!is_insensitive (scrollbar) && !priv->active_window)2214 {
2148 pager_set_state_from_pointer (scrollbar, xiev->event_x, xiev->event_y);2215 priv->can_hide = FALSE;
21492216
2150 /* proximity area */2217 if (priv->source_hide_thumb_id != 0)
2151 if (priv->orientation == GTK_ORIENTATION_VERTICAL)2218 {
2152 {2219 g_source_remove (priv->source_hide_thumb_id);
2153 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y))2220 priv->source_hide_thumb_id = 0;
2154 {2221 }
2155 priv->can_hide = FALSE;2222
21562223 if (priv->lock_position)
2157 if (priv->source_hide_thumb_id != 0)2224 return GDK_FILTER_CONTINUE;
2158 {2225
2159 g_source_remove (priv->source_hide_thumb_id);2226 if (priv->overlay.height > priv->slider.height)
2160 priv->source_hide_thumb_id = 0;2227 {
2161 }2228 gint x, y, x_pos, y_pos;
21622229
2163 if (priv->lock_position)2230 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
2164 return GDK_FILTER_CONTINUE;2231
21652232 x = priv->thumb_all.x;
2166 if (priv->overlay.height > priv->slider.height)2233 y = CLAMP (event_y - priv->slider.height / 2,
2167 {2234 priv->thumb_all.y + priv->overlay.y,
2168 gint x, y, x_pos, y_pos;2235 priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);
21692236
2170 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);2237 move_thumb (scrollbar, x_pos + x, y_pos + y);
21712238 }
2172 x = priv->thumb_all.x;2239 else
2173 y = CLAMP (xiev->event_y - priv->slider.height / 2,2240 {
2174 priv->thumb_all.y + priv->overlay.y,2241 move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
2175 priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);2242 }
21762243
2177 move_thumb (scrollbar, x_pos + x, y_pos + y);2244 os_pager_set_detached (priv->pager, FALSE);
2178 }2245 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
2179 else2246 gtk_widget_show (priv->thumb);
2180 {2247 }
2181 move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);2248 else
2182 }2249 {
21832250 priv->can_hide = TRUE;
2184 os_pager_set_detached (priv->pager, FALSE);2251 priv->lock_position = FALSE;
2185 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);2252
2186 gtk_widget_show (priv->thumb);2253 if (gtk_widget_get_mapped (priv->thumb) &&
2187 }2254 priv->source_hide_thumb_id == 0)
2188 else2255 priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE,
2189 {2256 hide_thumb_cb,
2190 priv->can_hide = TRUE;2257 scrollbar);
2191 priv->lock_position = FALSE;2258 }
21922259 }
2193 if (gtk_widget_get_mapped (priv->thumb) &&2260 else
2194 priv->source_hide_thumb_id == 0)2261 {
2195 priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE,2262 if (check_proximity (scrollbar, event_x, event_y))
2196 hide_thumb_cb,2263 {
2197 scrollbar);2264 priv->can_hide = FALSE;
2198 }2265
2199 }2266 if (priv->source_hide_thumb_id != 0)
2200 else2267 {
2201 {2268 g_source_remove (priv->source_hide_thumb_id);
2202 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y))2269 priv->source_hide_thumb_id = 0;
2203 {2270 }
2204 priv->can_hide = FALSE;2271
22052272 if (priv->lock_position)
2206 if (priv->source_hide_thumb_id != 0)2273 return GDK_FILTER_CONTINUE;
2207 {2274
2208 g_source_remove (priv->source_hide_thumb_id);2275 if (priv->overlay.width > priv->slider.width)
2209 priv->source_hide_thumb_id = 0;2276 {
2210 }2277 gint x, y, x_pos, y_pos;
22112278
2212 if (priv->lock_position)2279 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
2213 return GDK_FILTER_CONTINUE;2280
22142281 x = CLAMP (event_x - priv->slider.width / 2,
2215 if (priv->overlay.width > priv->slider.width)2282 priv->thumb_all.x + priv->overlay.x,
2216 {2283 priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);
2217 gint x, y, x_pos, y_pos;2284 y = priv->thumb_all.y;
22182285
2219 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);2286 move_thumb (scrollbar, x_pos + x, y_pos + y);
22202287 }
2221 x = CLAMP (xiev->event_x - priv->slider.width / 2,2288 else
2222 priv->thumb_all.x + priv->overlay.x,2289 {
2223 priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);2290 move_thumb (scrollbar, priv->win_x + priv->slider.x, priv->win_y);
2224 y = priv->thumb_all.y;2291 }
22252292
2226 move_thumb (scrollbar, x_pos + x, y_pos + y);2293 os_pager_set_detached (priv->pager, FALSE);
2227 }2294 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
2228 else2295 gtk_widget_show (priv->thumb);
2229 {2296 }
2230 move_thumb (scrollbar, priv->win_x + priv->slider.x, priv->win_y);2297 else
2231 }2298 {
22322299 priv->can_hide = TRUE;
2233 os_pager_set_detached (priv->pager, FALSE);2300 priv->lock_position = FALSE;
2234 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);2301
2235 gtk_widget_show (priv->thumb);2302 if (gtk_widget_get_mapped (priv->thumb) &&
2236 }2303 priv->source_hide_thumb_id == 0)
2237 else2304 priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE,
2238 {2305 hide_thumb_cb,
2239 priv->can_hide = TRUE;2306 scrollbar);
2240 priv->lock_position = FALSE;2307 }
22412308 }
2242 if (gtk_widget_get_mapped (priv->thumb) &&
2243 priv->source_hide_thumb_id == 0)
2244 priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE,
2245 hide_thumb_cb,
2246 scrollbar);
2247 }
2248 }
2249 }
2250 }2309 }
2251 }2310 }
22522311

Subscribers

People subscribed via source and target branches