Merge lp:~diego-rocha-comp/gala/multitasking-view-fixes into lp:gala

Proposed by Diego Rocha
Status: Superseded
Proposed branch: lp:~diego-rocha-comp/gala/multitasking-view-fixes
Merge into: lp:gala
Diff against target: 313 lines (+93/-43)
2 files modified
src/ShadowEffect.vala (+14/-4)
src/Widgets/WindowClone.vala (+79/-39)
To merge this branch: bzr merge lp:~diego-rocha-comp/gala/multitasking-view-fixes
Reviewer Review Type Date Requested Status
Rico Tzschichholz Needs Fixing
Review via email: mp+285962@code.launchpad.net

Description of the change

Fixed some overview/multitasking view bugs.

- Fixed window shadow that didn't resize and fade properly with its window clone
- Fixed window icons being shown and hidden harshly
- Fixed window close button being hidden harshly when leaving multitasking view
- Fixed animation of window clone and icon when dragging window from a neighboor workspace
- Fixed window shadow being faded in every time a window is dragged

To post a comment you must log in.
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Please drop all no-change/whitespace changes.
Don't add superfluous empty lines at top of methods.
Use gobject-style construction.

Please try to split your changes into logical commits addressing the issues you are fixing.

review: Needs Fixing
Revision history for this message
Diego Rocha (diego-rocha-comp) wrote :

Rico, I made all those changes and resubmitted :)

Unmerged revisions

504. By Diego Rocha

Fixed some overview/multitasking view bugs.

- Fixed window shadow that didn't resize and fade properly with its window clone
- Fixed window icons being shown and hidden harshly
- Fixed window close button being hidden harshly when leaving multitasking view
- Fixed animation of window clone and icon when dragging window from a neighboor workspace
- Fixed window shadow being faded in every time a window is dragged

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ShadowEffect.vala'
2--- src/ShadowEffect.vala 2014-07-18 05:37:33 +0000
3+++ src/ShadowEffect.vala 2016-02-13 05:55:01 +0000
4@@ -122,21 +122,31 @@
5 shadow_cache.unset (key);
6 }
7
8+ public virtual ActorBox get_bounding_box ()
9+ {
10+ var size = shadow_size * scale_factor;
11+ var bounding_box = ActorBox ();
12+
13+ bounding_box.set_origin (-size, -size);
14+ bounding_box.set_size (actor.width + size * 2, actor.height + size * 2);
15+
16+ return bounding_box;
17+ }
18+
19 public override void paint (EffectPaintFlags flags)
20 {
21- var size = shadow_size * scale_factor;
22-
23 var opacity = actor.get_paint_opacity () * shadow_opacity / 255;
24 var alpha = Cogl.Color.from_4ub (255, 255, 255, opacity);
25 alpha.premultiply ();
26
27 material.set_color (alpha);
28
29+ var bounding_box = get_bounding_box ();
30+
31 Cogl.set_source (material);
32- Cogl.rectangle (-size, -size, actor.width + size, actor.height + size);
33+ Cogl.rectangle (bounding_box.x1, bounding_box.y1, bounding_box.x2, bounding_box.y2);
34
35 actor.continue_paint ();
36 }
37 }
38 }
39-
40
41=== modified file 'src/Widgets/WindowClone.vala'
42--- src/Widgets/WindowClone.vala 2015-11-12 08:33:24 +0000
43+++ src/Widgets/WindowClone.vala 2016-02-13 05:55:01 +0000
44@@ -20,6 +20,37 @@
45
46 namespace Gala
47 {
48+
49+ private class WindowCloneShadowEffect : ShadowEffect
50+ {
51+ public WindowActor window_actor { get; set; }
52+
53+ public WindowCloneShadowEffect (WindowActor window_actor, int shadow_size, int shadow_spread)
54+ {
55+ base((int)window_actor.width, (int)window_actor.height, shadow_size, shadow_spread);
56+
57+ this.window_actor = window_actor;
58+ }
59+
60+ public override ActorBox get_bounding_box ()
61+ {
62+
63+ var size = shadow_size * scale_factor;
64+
65+ var window = window_actor.get_meta_window();
66+ var input_rect = window.get_buffer_rect ();
67+ var outer_rect = window.get_frame_rect ();
68+
69+ // Occupy only window frame area plus shadow size
70+ var bounding_box = ActorBox ();
71+ bounding_box.set_origin (-(input_rect.x - outer_rect.x) - size, -(input_rect.y - outer_rect.y) - size);
72+ bounding_box.set_size (outer_rect.width + size * 2, outer_rect.height + size * 2);
73+
74+ return bounding_box;
75+ }
76+
77+ }
78+
79 /**
80 * A container for a clone of the texture of a MetaWindow, a WindowIcon,
81 * a close button and a shadow. Used together with the WindowCloneContainer.
82@@ -88,7 +119,7 @@
83
84 DragDropAction? drag_action = null;
85 Clone? clone = null;
86- ShadowEffect? shadow_effect = null;
87+ WindowCloneShadowEffect? shadow_effect = null;
88
89 Actor prev_parent = null;
90 int prev_index = -1;
91@@ -139,7 +170,8 @@
92
93 window_icon = new WindowIcon (window, WINDOW_ICON_SIZE);
94 window_icon.opacity = 0;
95- window_icon.set_pivot_point (0.5f, 0.5f);
96+ window_icon.set_scale (0, 0);
97+ window_icon.set_pivot_point (0.5f, 0.75f);
98
99 active_shape = new Clutter.Actor ();
100 active_shape.background_color = { 255, 255, 255, 200 };
101@@ -165,12 +197,12 @@
102
103 /**
104 * Waits for the texture of a new WindowActor to be available
105- * and makes a close of it. If it was already was assigned a slot
106+ * and makes a clone of it. If it was already was assigned a slot
107 * at this point it will animate to it. Otherwise it will just place
108 * itself at the location of the original window. Also adds the shadow
109 * effect and makes sure the shadow is updated on size changes.
110 *
111- * @param was_waiting Internal argument used to indicate that we had to
112+ * @param was_waiting Internal argument used to indicate that we had to
113 * wait before the window's texture became available.
114 */
115 void load_clone (bool was_waiting = false)
116@@ -198,9 +230,10 @@
117
118 transition_to_original_state (false);
119
120- var outer_rect = window.get_frame_rect ();
121- shadow_effect = new ShadowEffect (outer_rect.width, outer_rect.height, 40, 5);
122- add_effect_with_name ("shadow", shadow_effect);
123+ shadow_effect = new WindowCloneShadowEffect (actor, 40, 5);
124+ shadow_effect.shadow_opacity = 0;
125+ clone.add_effect_with_name ("shadow", shadow_effect);
126+
127 window.size_changed.connect (update_shadow_size);
128
129 if (should_fade ())
130@@ -241,8 +274,8 @@
131
132 shadow_update_timeout = Timeout.add (500, () => {
133 var rect = window.get_frame_rect ();
134- var effect = get_effect ("shadow") as ShadowEffect;
135- effect.update_size (rect.width, rect.height);
136+
137+ shadow_effect.update_size (rect.width, rect.height);
138
139 shadow_update_timeout = 0;
140
141@@ -284,7 +317,14 @@
142 if (animate)
143 toggle_shadow (false);
144
145+ window_icon.save_easing_state ();
146+ window_icon.set_easing_duration (MultitaskingView.ANIMATION_DURATION);
147+ window_icon.set_easing_mode (MultitaskingView.ANIMATION_MODE);
148 window_icon.opacity = 0;
149+ window_icon.set_scale (0, 0);
150+ window_icon.restore_easing_state ();
151+
152+ close_button.opacity = 0;
153
154 if (should_fade ())
155 opacity = 0;
156@@ -303,9 +343,14 @@
157
158 set_size (rect.width, rect.height);
159 set_position (rect.x, rect.y);
160+ restore_easing_state ();
161
162+ window_icon.save_easing_state ();
163+ window_icon.set_easing_duration (MultitaskingView.ANIMATION_DURATION);
164+ window_icon.set_easing_mode (MultitaskingView.ANIMATION_MODE);
165 window_icon.opacity = 255;
166- restore_easing_state ();
167+ window_icon.set_scale (1, 1);
168+ window_icon.restore_easing_state ();
169
170 toggle_shadow (true);
171
172@@ -351,15 +396,16 @@
173 var outer_rect = window.get_frame_rect ();
174 var scale_factor = (float)width / outer_rect.width;
175
176- var shadow_effect = get_effect ("shadow") as ShadowEffect;
177- shadow_effect.scale_factor = scale_factor;
178-
179 var alloc = ActorBox ();
180- alloc.set_origin ((input_rect.x - outer_rect.x) * scale_factor,
181- (input_rect.y - outer_rect.y) * scale_factor);
182- alloc.set_size (actor.width * scale_factor, actor.height * scale_factor);
183-
184- clone.allocate (alloc, flags);
185+ alloc.set_size (actor.width, actor.height);
186+ alloc.set_origin((input_rect.x - outer_rect.x) * scale_factor, (input_rect.y - outer_rect.y) * scale_factor);
187+
188+ if (!dragging) {
189+ clone.allocate (alloc, flags);
190+ clone.set_scale (scale_factor, scale_factor);
191+
192+ place_widgets ((int)width, (int)height);
193+ }
194 }
195
196 public override bool button_press_event (Clutter.ButtonEvent event)
197@@ -367,14 +413,14 @@
198 return true;
199 }
200
201- public override bool enter_event (Clutter.CrossingEvent event)
202+ public override bool enter_event (Clutter.CrossingEvent event)
203 {
204 close_button.opacity = 255;
205
206 return false;
207 }
208-
209- public override bool leave_event (Clutter.CrossingEvent event)
210+
211+ public override bool leave_event (Clutter.CrossingEvent event)
212 {
213 close_button.opacity = 0;
214
215@@ -387,6 +433,7 @@
216 */
217 public void place_widgets (int dest_width, int dest_height)
218 {
219+
220 Granite.CloseButtonPosition pos;
221 Granite.Widgets.Utils.get_default_close_button_position (out pos);
222
223@@ -426,9 +473,9 @@
224 shadow_transition.progress_mode = MultitaskingView.ANIMATION_MODE;
225
226 if (show)
227- shadow_transition.interval = new Clutter.Interval (typeof (uint8), 0, 255);
228+ shadow_transition.interval = new Clutter.Interval (typeof (uint8), shadow_effect.shadow_opacity, 255);
229 else
230- shadow_transition.interval = new Clutter.Interval (typeof (uint8), 255, 0);
231+ shadow_transition.interval = new Clutter.Interval (typeof (uint8), shadow_effect.shadow_opacity, 0);
232
233 add_transition ("shadow-opacity", shadow_transition);
234 }
235@@ -505,25 +552,26 @@
236 Actor drag_begin (float click_x, float click_y)
237 {
238 float abs_x, abs_y;
239+ float prev_parent_x, prev_parent_y;
240
241 prev_parent = get_parent ();
242 prev_index = prev_parent.get_children ().index (this);
243
244+ prev_parent.get_transformed_position (out prev_parent_x, out prev_parent_y);
245+
246 var stage = get_stage ();
247 prev_parent.remove_child (this);
248 stage.add_child (this);
249
250 var scale = window_icon.width / clone.width;
251
252- ((ShadowEffect) get_effect ("shadow")).shadow_opacity = 0;
253-
254 clone.get_transformed_position (out abs_x, out abs_y);
255- clone.set_pivot_point ((click_x - abs_x) / clone.width, (click_y - abs_y) / clone.height);
256 clone.save_easing_state ();
257 clone.set_easing_duration (200);
258 clone.set_easing_mode (AnimationMode.EASE_IN_CUBIC);
259 clone.set_scale (scale, scale);
260 clone.opacity = 0;
261+ clone.set_pivot_point ((click_x - abs_x) / clone.width, (click_y - abs_y) / clone.height);
262 clone.restore_easing_state ();
263
264 request_reposition ();
265@@ -532,12 +580,12 @@
266
267 save_easing_state ();
268 set_easing_duration (0);
269- set_position (abs_x, abs_y);
270+ set_position (abs_x + prev_parent_x, abs_y + prev_parent_y);
271
272 window_icon.save_easing_state ();
273 window_icon.set_easing_duration (200);
274 window_icon.set_easing_mode (AnimationMode.EASE_IN_OUT_CUBIC);
275- window_icon.set_position (click_x - abs_x - window_icon.width / 2, click_y - abs_y - window_icon.height / 2);
276+ window_icon.set_position (click_x - (abs_x + prev_parent_x) - window_icon.width / 2, click_y - (abs_y + prev_parent_y) - window_icon.height / 2);
277 window_icon.restore_easing_state ();
278
279 close_button.opacity = 0;
280@@ -549,7 +597,7 @@
281
282 /**
283 * When we cross an IconGroup, we animate to an even smaller size and slightly
284- * less opacity and add ourselves as temporary window to the group. When left,
285+ * less opacity and add ourselves as temporary window to the group. When left,
286 * we reverse those steps.
287 */
288 void drag_destination_crossed (Actor destination, bool hovered)
289@@ -670,22 +718,14 @@
290 get_parent ().remove_child (this);
291 prev_parent.insert_child_at_index (this, prev_index);
292
293+ clone.set_pivot_point (0, 0);
294 clone.save_easing_state ();
295 clone.set_easing_duration (250);
296 clone.set_easing_mode (AnimationMode.EASE_OUT_QUAD);
297+
298 clone.set_scale (1, 1);
299 clone.opacity = 255;
300
301- Clutter.Callback finished = () => {
302- ((ShadowEffect) get_effect ("shadow")).shadow_opacity = 255;
303- };
304-
305- var transition = clone.get_transition ("scale-x");
306- if (transition != null)
307- transition.completed.connect (() => finished (this));
308- else
309- finished (this);
310-
311 clone.restore_easing_state ();
312
313 request_reposition ();

Subscribers

People subscribed via source and target branches