Skip to content

Commit 4f5db98

Browse files
committed
Fix initial window position
1 parent 377c397 commit 4f5db98

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

src/Widgets/WindowClone.vala

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ public class Gala.WindowClone : Clutter.Actor {
207207
set_child_above_sibling (window_icon, clone);
208208
set_child_above_sibling (window_title, clone);
209209

210-
transition_to_original_state (false);
211-
212210
check_shadow_requirements ();
213211

214212
if (should_fade ()) {
@@ -221,7 +219,7 @@ public class Gala.WindowClone : Clutter.Actor {
221219
// window was opened, so we stay at our old place.
222220
if (was_waiting && slot != null) {
223221
opacity = 0;
224-
take_slot (slot);
222+
take_slot (slot, true);
225223
opacity = 255;
226224

227225
request_reposition ();
@@ -268,7 +266,7 @@ public class Gala.WindowClone : Clutter.Actor {
268266
*
269267
* @param animate Animate the transformation of the placement
270268
*/
271-
public void transition_to_original_state (bool animate, bool with_gesture = false, bool is_cancel_animation = false) {
269+
public void transition_to_original_state (bool with_gesture = false, bool is_cancel_animation = false) {
272270
var outer_rect = window.get_frame_rect ();
273271

274272
unowned var display = window.get_display ();
@@ -314,11 +312,9 @@ public class Gala.WindowClone : Clutter.Actor {
314312
return;
315313
}
316314

317-
var duration = (animate && wm.enable_animations) ? MultitaskingView.ANIMATION_DURATION : 0;
315+
var duration = wm.enable_animations ? MultitaskingView.ANIMATION_DURATION : 0;
318316

319-
if (animate) {
320-
toggle_shadow (false);
321-
}
317+
toggle_shadow (false);
322318

323319
window_icon.save_easing_state ();
324320
window_icon.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
@@ -327,7 +323,7 @@ public class Gala.WindowClone : Clutter.Actor {
327323
window_icon.restore_easing_state ();
328324
};
329325

330-
if (!animate || gesture_tracker == null || !with_gesture || !wm.enable_animations) {
326+
if (gesture_tracker == null || !with_gesture || !wm.enable_animations) {
331327
on_animation_end (1, false, 0);
332328
} else {
333329
gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
@@ -338,25 +334,33 @@ public class Gala.WindowClone : Clutter.Actor {
338334
* Animate the window to the given slot
339335
*/
340336
#if HAS_MUTTER45
341-
public void take_slot (Mtk.Rectangle rect, bool with_gesture = false, bool is_cancel_animation = false) {
337+
public void take_slot (Mtk.Rectangle rect, bool from_window_position, bool with_gesture = false, bool is_cancel_animation = false) {
342338
#else
343-
public void take_slot (Meta.Rectangle rect, bool with_gesture = false, bool is_cancel_animation = false) {
339+
public void take_slot (Meta.Rectangle rect, bool from_window_position, bool with_gesture = false, bool is_cancel_animation = false) {
344340
#endif
345341
slot = rect;
346-
var initial_width = width;
347-
var initial_height = height;
342+
in_slot_animation = true;
348343

349344
active = false;
345+
346+
var outer_rect = window.get_frame_rect ();
347+
348+
float initial_width = from_window_position ? outer_rect.width : width;
349+
float initial_height = from_window_position ? outer_rect.height : height;
350+
350351
unowned var display = wm.get_display ();
351-
var scale = display.get_monitor_scale (display.get_monitor_index_for_rect (rect));
352352

353-
in_slot_animation = true;
353+
var monitor_geom = display.get_monitor_geometry (window.get_monitor ());
354+
float intial_x = from_window_position ? outer_rect.x - monitor_geom.x : x;
355+
float intial_y = from_window_position ? outer_rect.y - monitor_geom.y : y;
356+
357+
var scale = display.get_monitor_scale (display.get_monitor_index_for_rect (rect));
354358
place_widgets (rect.width, rect.height, scale);
355359

356-
new GesturePropertyTransition (this, gesture_tracker, "x", null, (float) rect.x).start (with_gesture);
357-
new GesturePropertyTransition (this, gesture_tracker, "y", null, (float) rect.y).start (with_gesture);
358-
new GesturePropertyTransition (this, gesture_tracker, "width", null, (float) rect.width).start (with_gesture);
359-
new GesturePropertyTransition (this, gesture_tracker, "height", null, (float) rect.height).start (with_gesture);
360+
new GesturePropertyTransition (this, gesture_tracker, "x", intial_x, (float) rect.x).start (with_gesture);
361+
new GesturePropertyTransition (this, gesture_tracker, "y", intial_y, (float) rect.y).start (with_gesture);
362+
new GesturePropertyTransition (this, gesture_tracker, "width", (float) initial_width, (float) rect.width).start (with_gesture);
363+
new GesturePropertyTransition (this, gesture_tracker, "height", (float) initial_height, (float) rect.height).start (with_gesture);
360364
new GesturePropertyTransition (this, gesture_tracker, "shadow-opacity", (uint8) 0, (uint8) 255).start (with_gesture);
361365
var opacity_transition = new GesturePropertyTransition (window_icon, gesture_tracker, "opacity", 0u, 255u);
362366
opacity_transition.start (with_gesture);

src/Widgets/WindowCloneContainer.vala

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ namespace Gala {
169169
* Recalculate the tiling positions of the windows and animate them to
170170
* the resulting spots.
171171
*/
172-
public void reflow (bool with_gesture = false, bool is_cancel_animation = false) {
172+
public void reflow (bool with_gesture = false, bool is_cancel_animation = false, bool opening = false) {
173173
if (!opened) {
174174
return;
175175
}
@@ -208,7 +208,7 @@ namespace Gala {
208208

209209
foreach (var tilable in window_positions) {
210210
unowned var clone = (WindowClone) tilable.id;
211-
clone.take_slot (tilable.rect, with_gesture, is_cancel_animation);
211+
clone.take_slot (tilable.rect, opening, with_gesture, is_cancel_animation);
212212
}
213213
}
214214

@@ -395,15 +395,7 @@ namespace Gala {
395395
current_window = null;
396396
}
397397

398-
// make sure our windows are where they belong in case they were moved
399-
// while were closed.
400-
if (gesture_tracker == null || !is_cancel_animation) {
401-
foreach (var window in get_children ()) {
402-
((WindowClone) window).transition_to_original_state (false, with_gesture, is_cancel_animation);
403-
}
404-
}
405-
406-
reflow (with_gesture, is_cancel_animation);
398+
reflow (with_gesture, is_cancel_animation, true);
407399
}
408400

409401
/**
@@ -418,7 +410,7 @@ namespace Gala {
418410
opened = false;
419411

420412
foreach (var window in get_children ()) {
421-
((WindowClone) window).transition_to_original_state (true, with_gesture, is_cancel_animation);
413+
((WindowClone) window).transition_to_original_state (with_gesture, is_cancel_animation);
422414
}
423415
}
424416
}

0 commit comments

Comments
 (0)