Merge lp:~ricotz/plank/clipping into lp:plank
- clipping
- Merge into trunk
Proposed by
Rico Tzschichholz
Status: | Work in progress | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~ricotz/plank/clipping | ||||
Merge into: | lp:plank | ||||
Diff against target: |
664 lines (+299/-103) 5 files modified
lib/DockRenderer.vala (+236/-99) lib/Drawing/AnimatedRenderer.vala (+34/-0) lib/Items/DockItem.vala (+8/-1) lib/PositionManager.vala (+20/-2) lib/Widgets/DockWindow.vala (+1/-1) |
||||
To merge this branch: | bzr merge lp:~ricotz/plank/clipping | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Docky Core | Pending | ||
Review via email: mp+245581@code.launchpad.net |
Commit message
Description of the change
Use clipped drawing to avoid a refresh/redraw of the whole window.
To post a comment you must log in.
lp:~ricotz/plank/clipping
updated
- 1152. By Rico Tzschichholz
-
Move plank.gresource.xml to data
- 1153. By Rico Tzschichholz
-
prefswindow: Fix some sensitivity assignments
- 1154. By Rico Tzschichholz
-
abstractmain: Output information for more enabled features
- 1158. By Rico Tzschichholz
-
WIP: Some clean up
Unmerged revisions
- 1158. By Rico Tzschichholz
-
WIP: Some clean up
- 1157. By Rico Tzschichholz
-
WIP: Fix animation-
corruptions - 1156. By Rico Tzschichholz
-
WIP: Add clipped drawing support
- 1155. By Rico Tzschichholz
-
renderer: Be able to draw item-shadow only
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/DockRenderer.vala' |
2 | --- lib/DockRenderer.vala 2015-01-05 10:54:40 +0000 |
3 | +++ lib/DockRenderer.vala 2015-01-14 12:22:05 +0000 |
4 | @@ -53,11 +53,14 @@ |
5 | |
6 | int64 last_hide = 0; |
7 | int64 frame_time = 0; |
8 | + int64 last_frame_time = 0; |
9 | + |
10 | + Gdk.Rectangle last_dock_extents; |
11 | + Cairo.Region cleanup_clip_region; |
12 | |
13 | bool screen_is_composited = false; |
14 | uint reset_position_manager_timer = 0; |
15 | int window_scale_factor = 1; |
16 | - bool is_first_frame = true; |
17 | |
18 | ulong gtk_theme_name_changed_id = 0; |
19 | |
20 | @@ -150,6 +153,7 @@ |
21 | reset_position_manager_timer = Gdk.threads_add_timeout (50, () => { |
22 | reset_position_manager_timer = 0; |
23 | controller.position_manager.update (theme); |
24 | + animated_draw_full (); |
25 | |
26 | return false; |
27 | }); |
28 | @@ -193,7 +197,7 @@ |
29 | urgent_indicator_buffer = null; |
30 | urgent_glow_buffer = null; |
31 | |
32 | - animated_draw (); |
33 | + animated_draw_full (); |
34 | } |
35 | |
36 | /** |
37 | @@ -205,12 +209,14 @@ |
38 | |
39 | controller.reset_buffers (); |
40 | |
41 | - animated_draw (); |
42 | + animated_draw_full (); |
43 | } |
44 | |
45 | void init_current_frame () |
46 | requires (theme != null) |
47 | { |
48 | + last_frame_time = frame_time; |
49 | + |
50 | frame_time = GLib.get_monotonic_time (); |
51 | screen_is_composited = controller.position_manager.screen_is_composited; |
52 | |
53 | @@ -235,22 +241,34 @@ |
54 | * |
55 | * @param cr the context to use for drawing |
56 | */ |
57 | - public void draw_dock (Cairo.Context cr) |
58 | + public override void draw_widget (Cairo.Context cr) |
59 | { |
60 | + unowned PositionManager position_manager = controller.position_manager; |
61 | + unowned DockItem dragged_item = controller.drag_manager.DragItem; |
62 | + var full_redraw_needed = full_redraw; |
63 | + |
64 | #if HAVE_HIDPI |
65 | window_scale_factor = controller.window.get_window ().get_scale_factor (); |
66 | #endif |
67 | // take the previous frame values into account to decide if we |
68 | // can bail a full draw to not miss a finishing animation-frame |
69 | - var no_full_draw_needed = (!is_first_frame && hide_progress == 1.0 && opacity == 1.0); |
70 | + var no_draw_needed = (!full_redraw_needed && hide_progress == 1.0 && opacity == 1.0); |
71 | + var dock_redraw_needed = dock_redraw_needed (frame_time); |
72 | |
73 | init_current_frame (); |
74 | |
75 | - unowned PositionManager position_manager = controller.position_manager; |
76 | - unowned DockItem dragged_item = controller.drag_manager.DragItem; |
77 | var win_rect = position_manager.get_dock_window_region (); |
78 | var items = controller.Items; |
79 | |
80 | + Cairo.Region clip_region = new Cairo.Region (); |
81 | + |
82 | + if (!dock_redraw_needed |
83 | + && cleanup_clip_region != null |
84 | + && !cleanup_clip_region.is_empty ()) |
85 | + clip_region.union (cleanup_clip_region); |
86 | + |
87 | + cleanup_clip_region = new Cairo.Region (); |
88 | + |
89 | if (main_buffer == null) { |
90 | main_buffer = new DockSurface.with_surface (win_rect.width, win_rect.height, cr.get_target ()); |
91 | #if HAVE_HIDPI |
92 | @@ -268,7 +286,7 @@ |
93 | // if the dock is completely hidden and not transparently drawn |
94 | // only draw ugent-glow indicators and bail since there is no need |
95 | // for further things |
96 | - if (no_full_draw_needed && hide_progress == 1.0 && opacity == 1.0) { |
97 | + if (no_draw_needed && hide_progress == 1.0 && opacity == 1.0) { |
98 | // we still need to clear out the previous output |
99 | cr.save (); |
100 | cr.set_source_rgba (0, 0, 0, 0); |
101 | @@ -299,16 +317,45 @@ |
102 | benchmark.add ("background render time - %f ms".printf (end2.difference (start2) / 1000.0)); |
103 | #endif |
104 | |
105 | + var draw_neighbours = (position_manager.ItemPadding < position_manager.IconShadowSize); |
106 | + var draw_neighbours_shadow = (position_manager.ItemPadding / 2 < position_manager.IconShadowSize); |
107 | + unowned DockItem? previous_item = null; |
108 | + var draw_next_item = false; |
109 | |
110 | - // draw each item onto the dock buffer |
111 | + // draw needed items onto the main buffer |
112 | foreach (var item in items) |
113 | { |
114 | #if BENCHMARK |
115 | start2 = new DateTime.now_local (); |
116 | #endif |
117 | - // Do not draw the currently dragged item |
118 | - if (dragged_item != item) |
119 | - draw_item (item); |
120 | + if (full_redraw_needed || dock_redraw_needed) { |
121 | + // Do not draw the currently dragged item |
122 | + if (dragged_item != item) |
123 | + draw_item (item); |
124 | + } else if (item_redraw_needed (item, last_frame_time) |
125 | + || item_redraw_needed (item, frame_time)) { |
126 | + if (previous_item != null && dragged_item != previous_item) |
127 | + draw_item (previous_item, !draw_neighbours); |
128 | + |
129 | + // Do not draw the currently dragged item |
130 | + if (dragged_item != item) { |
131 | + var touched_region = draw_item (item); |
132 | + clip_region.union_rectangle (touched_region); |
133 | + if (item_in_transition (item, frame_time)) |
134 | + cleanup_clip_region.union_rectangle (touched_region); |
135 | + } else { |
136 | + clip_region.union_rectangle (position_manager.get_draw_value_for_item (item).hover_region); |
137 | + } |
138 | + |
139 | + previous_item = null; |
140 | + draw_next_item = draw_neighbours_shadow; |
141 | + } else if (draw_next_item) { |
142 | + if (dragged_item != item) |
143 | + draw_item (item, !draw_neighbours); |
144 | + draw_next_item = false; |
145 | + } else if (draw_neighbours_shadow) { |
146 | + previous_item = item; |
147 | + } |
148 | #if BENCHMARK |
149 | end2 = new DateTime.now_local (); |
150 | benchmark.add ("item render time - %f ms".printf (end2.difference (start2) / 1000.0)); |
151 | @@ -317,8 +364,21 @@ |
152 | |
153 | // calculate drawing offset |
154 | var x_offset = 0, y_offset = 0; |
155 | - if (opacity == 1.0) |
156 | + if (opacity == 1.0) { |
157 | position_manager.get_dock_draw_position (out x_offset, out y_offset); |
158 | + clip_region.translate (x_offset, y_offset); |
159 | + } |
160 | + |
161 | + // draw the whole previously/currently visible dock-area if needed |
162 | + if (dock_redraw_needed && !full_redraw_needed) { |
163 | + clip_region.union_rectangle (last_dock_extents); |
164 | + last_dock_extents = position_manager.get_dock_extents (); |
165 | + clip_region.union_rectangle (last_dock_extents); |
166 | + } |
167 | + |
168 | + // restrict drawing to the actual visible window-area |
169 | + clip_region.intersect_rectangle ({ 0, 0, win_rect.width, win_rect.height }); |
170 | + var clipped_redraw = !clip_region.is_empty (); |
171 | |
172 | // composite dock layers and make sure to draw onto the window's context with one operation |
173 | unowned Cairo.Context composite_cr = shadow_buffer.Context; |
174 | @@ -331,15 +391,25 @@ |
175 | composite_cr.set_operator (Cairo.Operator.SOURCE); |
176 | composite_cr.set_source_rgba (0, 0, 0, 0); |
177 | composite_cr.paint_with_alpha (1 - opacity); |
178 | + } else if (!full_redraw_needed && clipped_redraw) { |
179 | + for (int i = 0; i < clip_region.num_rectangles (); i++) { |
180 | + var rect = clip_region.get_rectangle (i); |
181 | + cr.rectangle (rect.x, rect.y, rect.width, rect.height); |
182 | + } |
183 | + cr.clip (); |
184 | } |
185 | |
186 | - // draw the dock on the window |
187 | - cr.set_operator (Cairo.Operator.SOURCE); |
188 | - cr.set_source_surface (shadow_buffer.Internal, x_offset, y_offset); |
189 | - cr.paint (); |
190 | + if (full_redraw_needed || clipped_redraw) { |
191 | + // draw the dock on the window |
192 | + cr.set_operator (Cairo.Operator.SOURCE); |
193 | + cr.set_source_surface (shadow_buffer.Internal, x_offset, y_offset); |
194 | + cr.paint (); |
195 | + } |
196 | |
197 | // draw urgent-glow if dock is completely hidden |
198 | if (hide_progress == 1.0) { |
199 | + if (!full_redraw_needed && clipped_redraw) |
200 | + cr.reset_clip (); |
201 | foreach (var item in items) |
202 | draw_urgent_glow (item, cr); |
203 | } |
204 | @@ -352,8 +422,6 @@ |
205 | message (" " + s); |
206 | message ("render time - %f ms", diff); |
207 | #endif |
208 | - |
209 | - is_first_frame = false; |
210 | } |
211 | |
212 | void draw_dock_background () |
213 | @@ -377,42 +445,18 @@ |
214 | cr.paint (); |
215 | } |
216 | |
217 | - void draw_item (DockItem item) |
218 | + Gdk.Rectangle draw_item (DockItem item, bool shadow_only = false) |
219 | { |
220 | unowned PositionManager position_manager = controller.position_manager; |
221 | unowned DockItem hovered_item = controller.window.HoveredItem; |
222 | unowned DragManager drag_manager = controller.drag_manager; |
223 | |
224 | unowned Cairo.Context main_cr = main_buffer.Context; |
225 | - unowned Cairo.Context shadow_cr = shadow_buffer.Context; |
226 | var icon_size = position_manager.IconSize; |
227 | var shadow_size = position_manager.IconShadowSize; |
228 | var position = position_manager.Position; |
229 | |
230 | - // load the icon |
231 | -#if BENCHMARK |
232 | - var start = new DateTime.now_local (); |
233 | -#endif |
234 | - var icon_surface = item.get_surface_copy (icon_size * window_scale_factor, icon_size * window_scale_factor, main_buffer); |
235 | - unowned Cairo.Context icon_cr = icon_surface.Context; |
236 | - |
237 | - DockSurface? icon_shadow_surface = null; |
238 | - if (shadow_size > 0) |
239 | - icon_shadow_surface = item.get_background_surface (draw_item_shadow); |
240 | - |
241 | - DockSurface? icon_overlay_surface = null; |
242 | - if (item.CountVisible || item.ProgressVisible) |
243 | - icon_overlay_surface = item.get_foreground_surface (draw_item_overlay); |
244 | - |
245 | - if (icon_overlay_surface != null) { |
246 | - icon_cr.set_source_surface (icon_overlay_surface.Internal, 0, 0); |
247 | - icon_cr.paint (); |
248 | - } |
249 | - |
250 | -#if BENCHMARK |
251 | - var end = new DateTime.now_local (); |
252 | - benchmark.add (" item.get_surface time - %f ms".printf (end.difference (start) / 1000.0)); |
253 | -#endif |
254 | + Cairo.Region touched_region = new Cairo.Region (); |
255 | |
256 | // get item's draw-value |
257 | var draw_value = position_manager.get_draw_value_for_item (item); |
258 | @@ -495,23 +539,6 @@ |
259 | && !drag_manager.drop_is_accepted_by (item)) |
260 | darken += 0.6; |
261 | |
262 | - // glow the icon |
263 | - if (lighten > 0) { |
264 | - icon_cr.set_operator (Cairo.Operator.ADD); |
265 | - icon_cr.paint_with_alpha (lighten); |
266 | - icon_cr.set_operator (Cairo.Operator.OVER); |
267 | - } |
268 | - |
269 | - // darken the icon |
270 | - if (darken > 0) { |
271 | - icon_cr.rectangle (0, 0, icon_surface.Width, icon_surface.Height); |
272 | - icon_cr.set_source_rgba (0, 0, 0, darken); |
273 | - |
274 | - icon_cr.set_operator (Cairo.Operator.ATOP); |
275 | - icon_cr.fill (); |
276 | - icon_cr.set_operator (Cairo.Operator.OVER); |
277 | - } |
278 | - |
279 | // bounce icon on urgent state |
280 | if (screen_is_composited && (item.State & ItemState.URGENT) != 0) { |
281 | var urgent_time = frame_time - item.LastUrgent; |
282 | @@ -533,7 +560,7 @@ |
283 | item.unset_move_state (); |
284 | } |
285 | } |
286 | - |
287 | + |
288 | // draw active glow |
289 | var active_time = frame_time - item.LastActive; |
290 | var opacity = double.min (1, active_time / (double) (theme.ActiveTime * 1000)); |
291 | @@ -541,34 +568,107 @@ |
292 | opacity = 1 - opacity; |
293 | if (opacity > 0) { |
294 | theme.draw_active_glow (main_buffer, background_rect, draw_value.background_region, item.AverageIconColor, opacity, position); |
295 | - } |
296 | - |
297 | - // draw the icon shadow |
298 | - if (icon_shadow_surface != null) { |
299 | - if (window_scale_factor > 1) { |
300 | - shadow_cr.save (); |
301 | - shadow_cr.scale (1.0 / window_scale_factor, 1.0 / window_scale_factor); |
302 | - } |
303 | - shadow_cr.set_operator (Cairo.Operator.OVER); |
304 | - shadow_cr.set_source_surface (icon_shadow_surface.Internal, (draw_value.draw_region.x - shadow_size) * window_scale_factor, (draw_value.draw_region.y - shadow_size) * window_scale_factor); |
305 | - shadow_cr.paint (); |
306 | - if (window_scale_factor > 1) |
307 | - shadow_cr.restore (); |
308 | - } |
309 | - |
310 | + touched_region.union_rectangle (draw_value.background_region); |
311 | + } |
312 | + |
313 | + // draw shadow and bail early |
314 | + if (shadow_only) { |
315 | + if (shadow_size > 0) |
316 | + touched_region.union_rectangle (draw_item_shadow (item, draw_value)); |
317 | + |
318 | + return (Gdk.Rectangle) touched_region.get_extents (); |
319 | + } |
320 | + |
321 | + // load the icon |
322 | +#if BENCHMARK |
323 | + var start = new DateTime.now_local (); |
324 | +#endif |
325 | + var icon_surface = item.get_surface_copy (icon_size * window_scale_factor, icon_size * window_scale_factor, main_buffer); |
326 | + unowned Cairo.Context icon_cr = icon_surface.Context; |
327 | + |
328 | + DockSurface? icon_overlay_surface = null; |
329 | + if (item.CountVisible || item.ProgressVisible) |
330 | + icon_overlay_surface = item.get_foreground_surface (draw_item_overlay); |
331 | + |
332 | + if (icon_overlay_surface != null) { |
333 | + icon_cr.set_source_surface (icon_overlay_surface.Internal, 0, 0); |
334 | + icon_cr.paint (); |
335 | + } |
336 | + |
337 | +#if BENCHMARK |
338 | + var end = new DateTime.now_local (); |
339 | + benchmark.add (" item.get_surface time - %f ms".printf (end.difference (start) / 1000.0)); |
340 | +#endif |
341 | + |
342 | + // glow the icon |
343 | + if (lighten > 0) { |
344 | + icon_cr.set_operator (Cairo.Operator.ADD); |
345 | + icon_cr.paint_with_alpha (lighten); |
346 | + icon_cr.set_operator (Cairo.Operator.OVER); |
347 | + } |
348 | + |
349 | + // darken the icon |
350 | + if (darken > 0) { |
351 | + icon_cr.rectangle (0, 0, icon_surface.Width, icon_surface.Height); |
352 | + icon_cr.set_source_rgba (0, 0, 0, darken); |
353 | + |
354 | + icon_cr.set_operator (Cairo.Operator.ATOP); |
355 | + icon_cr.fill (); |
356 | + icon_cr.set_operator (Cairo.Operator.OVER); |
357 | + } |
358 | + |
359 | // draw the icon |
360 | if (window_scale_factor > 1) { |
361 | main_cr.save (); |
362 | main_cr.scale (1.0 / window_scale_factor, 1.0 / window_scale_factor); |
363 | } |
364 | - main_cr.set_source_surface (icon_surface.Internal, draw_value.draw_region.x * window_scale_factor, draw_value.draw_region.y * window_scale_factor); |
365 | + var draw_region = draw_value.draw_region; |
366 | + var hover_region = draw_value.hover_region; |
367 | + touched_region.union_rectangle (hover_region); |
368 | + main_cr.set_source_surface (icon_surface.Internal, draw_region.x * window_scale_factor, draw_region.y * window_scale_factor); |
369 | main_cr.paint (); |
370 | if (window_scale_factor > 1) |
371 | main_cr.restore (); |
372 | |
373 | // draw indicators |
374 | if (item.Indicator != IndicatorState.NONE) |
375 | - draw_indicator_state (draw_value.hover_region, item.Indicator, item.State); |
376 | + draw_indicator_state (hover_region, item.Indicator, item.State); |
377 | + |
378 | + // draw shadow |
379 | + if (shadow_size > 0) |
380 | + touched_region.union_rectangle (draw_item_shadow (item, draw_value)); |
381 | + |
382 | + return (Gdk.Rectangle) touched_region.get_extents (); |
383 | + } |
384 | + |
385 | + Gdk.Rectangle draw_item_shadow (DockItem item, PositionManager.DockItemDrawValue draw_value) |
386 | + { |
387 | + unowned PositionManager position_manager = controller.position_manager; |
388 | + var shadow_size = position_manager.IconShadowSize; |
389 | + unowned Cairo.Context shadow_cr = shadow_buffer.Context; |
390 | + |
391 | + // load and draw the icon shadow |
392 | + DockSurface? icon_shadow_surface = null; |
393 | + if (shadow_size > 0) |
394 | + icon_shadow_surface = item.get_background_surface (draw_item_background); |
395 | + |
396 | + if (icon_shadow_surface != null) { |
397 | + if (window_scale_factor > 1) { |
398 | + shadow_cr.save (); |
399 | + shadow_cr.scale (1.0 / window_scale_factor, 1.0 / window_scale_factor); |
400 | + } |
401 | + var draw_region = draw_value.draw_region; |
402 | + shadow_cr.set_operator (Cairo.Operator.OVER); |
403 | + shadow_cr.set_source_surface (icon_shadow_surface.Internal, (draw_region.x - shadow_size) * window_scale_factor, (draw_region.y - shadow_size) * window_scale_factor); |
404 | + shadow_cr.paint (); |
405 | + if (window_scale_factor > 1) |
406 | + shadow_cr.restore (); |
407 | + |
408 | + return { draw_region.x - shadow_size, draw_region.y - shadow_size, |
409 | + icon_shadow_surface.Width, icon_shadow_surface.Height }; |
410 | + } |
411 | + |
412 | + return {0}; |
413 | } |
414 | |
415 | DockSurface draw_item_overlay (DockItem item, DockSurface icon_surface, DockSurface? current_surface) |
416 | @@ -599,7 +699,7 @@ |
417 | return surface; |
418 | } |
419 | |
420 | - DockSurface draw_item_shadow (DockItem item, DockSurface icon_surface, DockSurface? current_surface) |
421 | + DockSurface draw_item_background (DockItem item, DockSurface icon_surface, DockSurface? current_surface) |
422 | { |
423 | unowned PositionManager position_manager = controller.position_manager; |
424 | var shadow_size = position_manager.IconShadowSize * window_scale_factor; |
425 | @@ -759,6 +859,18 @@ |
426 | */ |
427 | protected override bool animation_needed (int64 render_time) |
428 | { |
429 | + if (dock_redraw_needed (render_time)) |
430 | + return true; |
431 | + |
432 | + foreach (var item in controller.Items) |
433 | + if (item_redraw_needed (item, render_time)) |
434 | + return true; |
435 | + |
436 | + return false; |
437 | + } |
438 | + |
439 | + bool dock_redraw_needed (int64 render_time) |
440 | + { |
441 | if (theme.FadeOpacity == 1.0) { |
442 | if (render_time - last_hide <= theme.HideTime * 1000) |
443 | return true; |
444 | @@ -767,24 +879,49 @@ |
445 | return true; |
446 | } |
447 | |
448 | - foreach (var item in controller.Items) { |
449 | - if (item.ClickedAnimation != Animation.NONE |
450 | - && render_time - item.LastClicked <= (item.ClickedAnimation == Animation.BOUNCE ? theme.LaunchBounceTime : theme.ClickTime) * 1000) |
451 | - return true; |
452 | - if (item.HoveredAnimation != Animation.NONE |
453 | - && render_time - item.LastHovered <= 150 * 1000) |
454 | - return true; |
455 | - if (item.ScrolledAnimation != Animation.NONE |
456 | - && render_time - item.LastScrolled <= 300 * 1000) |
457 | - return true; |
458 | - if (render_time - item.LastActive <= theme.ActiveTime * 1000) |
459 | - return true; |
460 | - if (render_time - item.LastUrgent <= (hide_progress == 1.0 ? theme.GlowTime : theme.UrgentBounceTime) * 1000) |
461 | - return true; |
462 | - if (render_time - item.LastMove <= theme.ItemMoveTime * 1000) |
463 | - return true; |
464 | - } |
465 | - |
466 | + return false; |
467 | + } |
468 | + |
469 | + bool item_redraw_needed (DockItem item, int64 render_time) |
470 | + { |
471 | + if ((item.State & ItemState.REDRAW) != 0) |
472 | + return true; |
473 | + if (item.ClickedAnimation != Animation.NONE |
474 | + && render_time - item.LastClicked <= (item.ClickedAnimation == Animation.BOUNCE ? theme.LaunchBounceTime : theme.ClickTime) * 1000) |
475 | + return true; |
476 | + if (item.HoveredAnimation != Animation.NONE |
477 | + && render_time - item.LastHovered <= 150 * 1000) |
478 | + return true; |
479 | + if (item.ScrolledAnimation != Animation.NONE |
480 | + && render_time - item.LastScrolled <= 300 * 1000) |
481 | + return true; |
482 | + if (render_time - item.LastActive <= theme.ActiveTime * 1000) |
483 | + return true; |
484 | + if (render_time - item.LastUrgent <= (hide_progress == 1.0 ? theme.GlowTime : theme.UrgentBounceTime) * 1000) |
485 | + return true; |
486 | + if (render_time - item.LastMove <= theme.ItemMoveTime * 1000) |
487 | + return true; |
488 | + |
489 | + return false; |
490 | + } |
491 | + |
492 | + bool item_in_transition (DockItem item, int64 render_time) |
493 | + { |
494 | + if (render_time - item.LastMove <= theme.ItemMoveTime * 1000) |
495 | + return true; |
496 | + if (item.ClickedAnimation == Animation.BOUNCE |
497 | + && render_time - item.LastClicked <= theme.LaunchBounceTime * 1000) |
498 | + return true; |
499 | + if (item.HoveredAnimation == Animation.BOUNCE |
500 | + && render_time - item.LastHovered <= 150 * 1000) |
501 | + return true; |
502 | + if (item.ScrolledAnimation == Animation.BOUNCE |
503 | + && render_time - item.LastScrolled <= 300 * 1000) |
504 | + return true; |
505 | + if (hide_progress < 1.0 |
506 | + && render_time - item.LastUrgent <= theme.UrgentBounceTime * 1000) |
507 | + return true; |
508 | + |
509 | return false; |
510 | } |
511 | } |
512 | |
513 | === modified file 'lib/Drawing/AnimatedRenderer.vala' |
514 | --- lib/Drawing/AnimatedRenderer.vala 2014-07-20 15:18:51 +0000 |
515 | +++ lib/Drawing/AnimatedRenderer.vala 2015-01-14 12:22:05 +0000 |
516 | @@ -30,6 +30,9 @@ |
517 | |
518 | public Gtk.Widget widget { get; construct; } |
519 | |
520 | + [CCode (notify = false)] |
521 | + public bool full_redraw { get; private set; } |
522 | + |
523 | uint animation_timer = 0; |
524 | |
525 | /** |
526 | @@ -57,6 +60,27 @@ |
527 | protected abstract bool animation_needed (int64 render_time); |
528 | |
529 | /** |
530 | + * Draws the widget onto the given context. |
531 | + * |
532 | + * @param cr the context to use for drawing |
533 | + */ |
534 | + protected abstract void draw_widget (Cairo.Context cr); |
535 | + |
536 | + /** |
537 | + * Draws the widget onto the given context. |
538 | + * This will call the implementation of draw_widget (). |
539 | + * |
540 | + * @param cr the context to use for drawing |
541 | + */ |
542 | + public void draw (Cairo.Context cr) |
543 | + { |
544 | + draw_widget (cr); |
545 | + |
546 | + if (full_redraw) |
547 | + full_redraw = false; |
548 | + } |
549 | + |
550 | + /** |
551 | * Request re-drawing. |
552 | */ |
553 | public void animated_draw () |
554 | @@ -70,6 +94,16 @@ |
555 | animation_timer = Gdk.threads_add_timeout (1000 / FPS, draw_timeout); |
556 | } |
557 | |
558 | + /** |
559 | + * Request full re-drawing. |
560 | + */ |
561 | + public void animated_draw_full () |
562 | + { |
563 | + full_redraw = true; |
564 | + |
565 | + animated_draw (); |
566 | + } |
567 | + |
568 | bool draw_timeout () |
569 | { |
570 | widget.queue_draw (); |
571 | |
572 | === modified file 'lib/Items/DockItem.vala' |
573 | --- lib/Items/DockItem.vala 2014-11-19 14:06:10 +0000 |
574 | +++ lib/Items/DockItem.vala 2015-01-14 12:22:05 +0000 |
575 | @@ -72,7 +72,11 @@ |
576 | /** |
577 | * The item is currently moved to its new position. |
578 | */ |
579 | - MOVE = 1 << 3 |
580 | + MOVE = 1 << 3, |
581 | + /** |
582 | + * The item is about to be redrawn. |
583 | + */ |
584 | + REDRAW = 1 << 4 |
585 | } |
586 | |
587 | /** |
588 | @@ -248,6 +252,8 @@ |
589 | background_surface = null; |
590 | foreground_surface = null; |
591 | |
592 | + State |= ItemState.REDRAW; |
593 | + |
594 | needs_redraw (); |
595 | } |
596 | |
597 | @@ -324,6 +330,7 @@ |
598 | draw_icon (surface); |
599 | |
600 | AverageIconColor = surface.average_color (); |
601 | + State &= ~ItemState.REDRAW; |
602 | } |
603 | |
604 | return surface; |
605 | |
606 | === modified file 'lib/PositionManager.vala' |
607 | --- lib/PositionManager.vala 2014-11-27 13:52:08 +0000 |
608 | +++ lib/PositionManager.vala 2015-01-14 12:22:05 +0000 |
609 | @@ -329,7 +329,7 @@ |
610 | |
611 | var scaled_icon_size = IconSize / 10.0; |
612 | |
613 | - IconShadowSize = (int) Math.ceil (theme.IconShadowSize * scaled_icon_size); |
614 | + IconShadowSize = (int) (theme.IconShadowSize * scaled_icon_size); |
615 | IndicatorSize = (int) (theme.IndicatorSize * scaled_icon_size); |
616 | GlowSize = (int) (theme.GlowSize * scaled_icon_size); |
617 | HorizPadding = (int) (theme.HorizPadding * scaled_icon_size); |
618 | @@ -611,7 +611,7 @@ |
619 | // With active compositing support update_size_and_position () won't trigger a redraw |
620 | // (a changed static_dock_region doesn't implicate the window-size changed) |
621 | if (screen_is_composited) |
622 | - controller.renderer.animated_draw (); |
623 | + controller.renderer.animated_draw_full (); |
624 | } else { |
625 | controller.renderer.animated_draw (); |
626 | } |
627 | @@ -1061,6 +1061,24 @@ |
628 | return { x, y, DockBackgroundWidth, DockBackgroundHeight }; |
629 | } |
630 | |
631 | + public Gdk.Rectangle get_dock_extents () |
632 | + { |
633 | + var cursor_region = get_cursor_region (); |
634 | + |
635 | + if (extra_hide_offset > 0) |
636 | + rectangle_inflate (ref cursor_region, extra_hide_offset); |
637 | + |
638 | + return cursor_region; |
639 | + } |
640 | + |
641 | + static void rectangle_inflate (ref Gdk.Rectangle rect, int size) |
642 | + { |
643 | + rect.x -= size; |
644 | + rect.y -= size; |
645 | + rect.width += 2 * size; |
646 | + rect.height += 2 * size; |
647 | + } |
648 | + |
649 | /** |
650 | * Get the item's icon geometry for the dock. |
651 | * |
652 | |
653 | === modified file 'lib/Widgets/DockWindow.vala' |
654 | --- lib/Widgets/DockWindow.vala 2014-10-24 07:15:41 +0000 |
655 | +++ lib/Widgets/DockWindow.vala 2015-01-14 12:22:05 +0000 |
656 | @@ -308,7 +308,7 @@ |
657 | return base.draw (cr); |
658 | } |
659 | |
660 | - controller.renderer.draw_dock (cr); |
661 | + controller.renderer.draw (cr); |
662 | set_input_mask (); |
663 | |
664 | return true; |