Skip to content

Commit aec7c2d

Browse files
authored
Merge branch 'main' into lenemter/use-gnome-animations
2 parents 5d9dc0d + 9f63c52 commit aec7c2d

File tree

2 files changed

+138
-136
lines changed

2 files changed

+138
-136
lines changed

lib/Utils.vala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,14 @@ namespace Gala {
325325
return null;
326326
}
327327

328-
var container = new Clutter.Actor ();
329-
container.set_size (inner_rect.width, inner_rect.height);
330-
container.content = content;
328+
var container = new Clutter.Actor () {
329+
content = content,
330+
offscreen_redirect = Clutter.OffscreenRedirect.ALWAYS,
331+
x = inner_rect.x,
332+
y = inner_rect.y,
333+
width = inner_rect.width,
334+
height = inner_rect.height
335+
};
331336

332337
return container;
333338
}

src/WindowManager.vala

Lines changed: 130 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,14 +1210,12 @@ namespace Gala {
12101210
return;
12111211
}
12121212

1213-
Meta.SizeChange? which_change_local = which_change;
1214-
which_change = null;
1215-
12161213
unowned var window = actor.get_meta_window ();
12171214
var new_rect = window.get_frame_rect ();
12181215

1219-
switch (which_change_local) {
1216+
switch (which_change) {
12201217
case Meta.SizeChange.MAXIMIZE:
1218+
case Meta.SizeChange.FULLSCREEN:
12211219
// don't animate resizing of two tiled windows with mouse drag
12221220
if (window.get_tile_match () != null && !window.maximized_horizontally) {
12231221
var old_end = old_rect_size_change.x + old_rect_size_change.width;
@@ -1228,21 +1226,18 @@ namespace Gala {
12281226
break;
12291227
}
12301228
}
1229+
12311230
maximize (actor, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
12321231
break;
12331232
case Meta.SizeChange.UNMAXIMIZE:
1234-
unmaximize (actor, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1235-
break;
1236-
case Meta.SizeChange.FULLSCREEN:
1237-
maximize (actor, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1238-
break;
12391233
case Meta.SizeChange.UNFULLSCREEN:
12401234
unmaximize (actor, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
12411235
break;
12421236
default:
12431237
break;
12441238
}
12451239

1240+
which_change = null;
12461241
size_change_completed (actor);
12471242
}
12481243

@@ -1317,91 +1312,93 @@ namespace Gala {
13171312
}
13181313

13191314
private void maximize (Meta.WindowActor actor, int ex, int ey, int ew, int eh) {
1320-
if (!Meta.Prefs.get_gnome_animations ()) {
1321-
return;
1322-
}
1323-
1324-
var duration = AnimationDuration.SNAP;
1325-
1326-
kill_window_effects (actor);
1327-
13281315
unowned var window = actor.get_meta_window ();
13291316
if (window.maximized_horizontally && behavior_settings.get_boolean ("move-maximized-workspace")
13301317
|| window.fullscreen && behavior_settings.get_boolean ("move-fullscreened-workspace")) {
13311318
move_window_to_next_ws (window);
13321319
}
13331320

1334-
if (window.window_type == Meta.WindowType.NORMAL) {
1335-
if (latest_window_snapshot == null) {
1336-
return;
1337-
}
1321+
kill_window_effects (actor);
13381322

1339-
maximizing.add (actor);
1340-
latest_window_snapshot.set_position (old_rect_size_change.x, old_rect_size_change.y);
1341-
1342-
ui_group.add_child (latest_window_snapshot);
1343-
1344-
// FIMXE that's a hacky part. There is a short moment right after maximized_completed
1345-
// where the texture is screwed up and shows things it's not supposed to show,
1346-
// resulting in flashing. Waiting here transparently shortly fixes that issue. There
1347-
// appears to be no signal that would inform when that moment happens.
1348-
// We can't spend arbitrary amounts of time transparent since the overlay fades away,
1349-
// about a third has proven to be a solid time. So this fix will only apply for
1350-
// durations >= FLASH_PREVENT_TIMEOUT*3
1351-
const int FLASH_PREVENT_TIMEOUT = 80;
1352-
var delay = 0;
1353-
if (FLASH_PREVENT_TIMEOUT <= duration / 3) {
1354-
actor.opacity = 0;
1355-
delay = FLASH_PREVENT_TIMEOUT;
1356-
Timeout.add (FLASH_PREVENT_TIMEOUT, () => {
1357-
actor.opacity = 255;
1358-
return false;
1359-
});
1360-
}
1323+
if (!Meta.Prefs.get_gnome_animations () ||
1324+
latest_window_snapshot == null ||
1325+
window.window_type != Meta.WindowType.NORMAL) {
1326+
return;
1327+
}
1328+
1329+
var duration = AnimationDuration.SNAP;
13611330

1362-
var scale_x = (double) ew / old_rect_size_change.width;
1363-
var scale_y = (double) eh / old_rect_size_change.height;
1364-
1365-
latest_window_snapshot.save_easing_state ();
1366-
latest_window_snapshot.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1367-
latest_window_snapshot.set_easing_duration (duration);
1368-
latest_window_snapshot.set_position (ex, ey);
1369-
latest_window_snapshot.set_scale (scale_x, scale_y);
1370-
1371-
// the opacity animation is special, since we have to wait for the
1372-
// FLASH_PREVENT_TIMEOUT to be done before we can safely fade away
1373-
latest_window_snapshot.save_easing_state ();
1374-
latest_window_snapshot.set_easing_delay (delay);
1375-
latest_window_snapshot.set_easing_duration (duration - delay);
1376-
latest_window_snapshot.opacity = 0;
1377-
latest_window_snapshot.restore_easing_state ();
1378-
1379-
ulong maximize_old_handler_id = 0UL;
1380-
maximize_old_handler_id = latest_window_snapshot.transitions_completed.connect ((snapshot) => {
1381-
snapshot.disconnect (maximize_old_handler_id);
1382-
snapshot.destroy ();
1383-
actor.set_translation (0.0f, 0.0f, 0.0f);
1331+
maximizing.add (actor);
1332+
latest_window_snapshot.set_position (old_rect_size_change.x, old_rect_size_change.y);
1333+
1334+
ui_group.add_child (latest_window_snapshot);
1335+
1336+
// FIMXE that's a hacky part. There is a short moment right after maximized_completed
1337+
// where the texture is screwed up and shows things it's not supposed to show,
1338+
// resulting in flashing. Waiting here transparently shortly fixes that issue. There
1339+
// appears to be no signal that would inform when that moment happens.
1340+
// We can't spend arbitrary amounts of time transparent since the overlay fades away,
1341+
// about a third has proven to be a solid time. So this fix will only apply for
1342+
// durations >= FLASH_PREVENT_TIMEOUT*3
1343+
const int FLASH_PREVENT_TIMEOUT = 80;
1344+
var delay = 0;
1345+
if (FLASH_PREVENT_TIMEOUT <= duration / 3) {
1346+
actor.opacity = 0;
1347+
delay = FLASH_PREVENT_TIMEOUT;
1348+
Timeout.add (FLASH_PREVENT_TIMEOUT, () => {
1349+
actor.opacity = 255;
1350+
return false;
13841351
});
1352+
}
13851353

1386-
latest_window_snapshot = null;
1354+
var scale_x = (double) ew / old_rect_size_change.width;
1355+
var scale_y = (double) eh / old_rect_size_change.height;
13871356

1388-
actor.set_pivot_point (0.0f, 0.0f);
1389-
actor.set_translation (old_rect_size_change.x - ex, old_rect_size_change.y - ey, 0.0f);
1390-
actor.set_scale (1.0f / scale_x, 1.0f / scale_y);
1357+
latest_window_snapshot.save_easing_state ();
1358+
latest_window_snapshot.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1359+
latest_window_snapshot.set_easing_duration (duration);
1360+
latest_window_snapshot.set_position (ex, ey);
1361+
latest_window_snapshot.set_scale (scale_x, scale_y);
1362+
latest_window_snapshot.restore_easing_state ();
1363+
1364+
// the opacity animation is special, since we have to wait for the
1365+
// FLASH_PREVENT_TIMEOUT to be done before we can safely fade away
1366+
latest_window_snapshot.save_easing_state ();
1367+
latest_window_snapshot.set_easing_delay (delay);
1368+
latest_window_snapshot.set_easing_duration (duration - delay);
1369+
latest_window_snapshot.opacity = 0;
1370+
latest_window_snapshot.restore_easing_state ();
1371+
1372+
ulong maximize_old_handler_id = 0;
1373+
maximize_old_handler_id = latest_window_snapshot.transition_stopped.connect ((snapshot, name, is_finished) => {
1374+
snapshot.disconnect (maximize_old_handler_id);
13911375

1392-
actor.save_easing_state ();
1393-
actor.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1394-
actor.set_easing_duration (duration);
1395-
actor.set_scale (1.0f, 1.0f);
13961376
actor.set_translation (0.0f, 0.0f, 0.0f);
1397-
actor.restore_easing_state ();
13981377

1399-
ulong handler_id = 0UL;
1400-
handler_id = actor.transitions_completed.connect (() => {
1401-
actor.disconnect (handler_id);
1402-
maximizing.remove (actor);
1403-
});
1404-
}
1378+
unowned var parent = snapshot.get_parent ();
1379+
if (parent != null) {
1380+
parent.remove_child (snapshot);
1381+
}
1382+
});
1383+
1384+
latest_window_snapshot = null;
1385+
1386+
actor.set_pivot_point (0.0f, 0.0f);
1387+
actor.set_translation (old_rect_size_change.x - ex, old_rect_size_change.y - ey, 0.0f);
1388+
actor.set_scale (1.0f / scale_x, 1.0f / scale_y);
1389+
1390+
actor.save_easing_state ();
1391+
actor.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1392+
actor.set_easing_duration (duration);
1393+
actor.set_scale (1.0f, 1.0f);
1394+
actor.set_translation (0.0f, 0.0f, 0.0f);
1395+
actor.restore_easing_state ();
1396+
1397+
ulong handler_id = 0UL;
1398+
handler_id = actor.transitions_completed.connect (() => {
1399+
actor.disconnect (handler_id);
1400+
maximizing.remove (actor);
1401+
});
14051402
}
14061403

14071404
public override void unminimize (Meta.WindowActor actor) {
@@ -1693,76 +1690,76 @@ namespace Gala {
16931690
}
16941691

16951692
private void unmaximize (Meta.WindowActor actor, int ex, int ey, int ew, int eh) {
1696-
if (!Meta.Prefs.get_gnome_animations ()) {
1693+
unowned var window = actor.get_meta_window ();
1694+
move_window_to_old_ws (window);
1695+
1696+
kill_window_effects (actor);
1697+
1698+
if (!Meta.Prefs.get_gnome_animations () ||
1699+
latest_window_snapshot == null ||
1700+
window.window_type != Meta.WindowType.NORMAL) {
16971701
return;
16981702
}
16991703

17001704
var duration = AnimationDuration.SNAP;
17011705

1702-
kill_window_effects (actor);
1703-
unowned var window = actor.get_meta_window ();
1704-
1705-
move_window_to_old_ws (window);
1706-
1707-
if (window.window_type == Meta.WindowType.NORMAL) {
1708-
float offset_x, offset_y;
1709-
var unmaximized_window_geometry = WindowListener.get_default ().get_unmaximized_state_geometry (window);
1706+
float offset_x, offset_y;
1707+
var unmaximized_window_geometry = WindowListener.get_default ().get_unmaximized_state_geometry (window);
17101708

1711-
if (unmaximized_window_geometry != null) {
1712-
offset_x = unmaximized_window_geometry.outer.x - unmaximized_window_geometry.inner.x;
1713-
offset_y = unmaximized_window_geometry.outer.y - unmaximized_window_geometry.inner.y;
1714-
} else {
1715-
offset_x = 0;
1716-
offset_y = 0;
1717-
}
1709+
if (unmaximized_window_geometry != null) {
1710+
offset_x = unmaximized_window_geometry.outer.x - unmaximized_window_geometry.inner.x;
1711+
offset_y = unmaximized_window_geometry.outer.y - unmaximized_window_geometry.inner.y;
1712+
} else {
1713+
offset_x = 0;
1714+
offset_y = 0;
1715+
}
17181716

1719-
if (latest_window_snapshot == null) {
1720-
return;
1721-
}
1717+
unmaximizing.add (actor);
17221718

1723-
unmaximizing.add (actor);
1719+
latest_window_snapshot.set_position (old_rect_size_change.x, old_rect_size_change.y);
17241720

1725-
latest_window_snapshot.set_position (old_rect_size_change.x, old_rect_size_change.y);
1721+
ui_group.add_child (latest_window_snapshot);
17261722

1727-
ui_group.add_child (latest_window_snapshot);
1723+
var scale_x = (float) ew / old_rect_size_change.width;
1724+
var scale_y = (float) eh / old_rect_size_change.height;
17281725

1729-
var scale_x = (float) ew / old_rect_size_change.width;
1730-
var scale_y = (float) eh / old_rect_size_change.height;
1726+
latest_window_snapshot.save_easing_state ();
1727+
latest_window_snapshot.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1728+
latest_window_snapshot.set_easing_duration (duration);
1729+
latest_window_snapshot.set_position (ex, ey);
1730+
latest_window_snapshot.set_scale (scale_x, scale_y);
1731+
latest_window_snapshot.opacity = 0U;
1732+
latest_window_snapshot.restore_easing_state ();
17311733

1732-
latest_window_snapshot.save_easing_state ();
1733-
latest_window_snapshot.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1734-
latest_window_snapshot.set_easing_duration (duration);
1735-
latest_window_snapshot.set_position (ex, ey);
1736-
latest_window_snapshot.set_scale (scale_x, scale_y);
1737-
latest_window_snapshot.opacity = 0U;
1738-
latest_window_snapshot.restore_easing_state ();
1734+
ulong unmaximize_old_handler_id = 0;
1735+
unmaximize_old_handler_id = latest_window_snapshot.transition_stopped.connect ((snapshot, name, is_finished) => {
1736+
snapshot.disconnect (unmaximize_old_handler_id);
17391737

1740-
ulong unmaximize_old_handler_id = 0UL;
1741-
unmaximize_old_handler_id = latest_window_snapshot.transitions_completed.connect ((snapshot) => {
1742-
snapshot.disconnect (unmaximize_old_handler_id);
1743-
snapshot.destroy ();
1744-
});
1738+
unowned var parent = snapshot.get_parent ();
1739+
if (parent != null) {
1740+
parent.remove_child (snapshot);
1741+
}
1742+
});
17451743

1746-
latest_window_snapshot = null;
1744+
latest_window_snapshot = null;
17471745

1748-
actor.set_pivot_point (0.0f, 0.0f);
1749-
actor.set_position (ex, ey);
1750-
actor.set_translation (-ex + offset_x * (1.0f / scale_x - 1.0f) + old_rect_size_change.x, -ey + offset_y * (1.0f / scale_y - 1.0f) + old_rect_size_change.y, 0.0f);
1751-
actor.set_scale (1.0f / scale_x, 1.0f / scale_y);
1746+
actor.set_pivot_point (0.0f, 0.0f);
1747+
actor.set_position (ex, ey);
1748+
actor.set_translation (-ex + offset_x * (1.0f / scale_x - 1.0f) + old_rect_size_change.x, -ey + offset_y * (1.0f / scale_y - 1.0f) + old_rect_size_change.y, 0.0f);
1749+
actor.set_scale (1.0f / scale_x, 1.0f / scale_y);
17521750

1753-
actor.save_easing_state ();
1754-
actor.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1755-
actor.set_easing_duration (duration);
1756-
actor.set_scale (1.0f, 1.0f);
1757-
actor.set_translation (0.0f, 0.0f, 0.0f);
1758-
actor.restore_easing_state ();
1751+
actor.save_easing_state ();
1752+
actor.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1753+
actor.set_easing_duration (duration);
1754+
actor.set_scale (1.0f, 1.0f);
1755+
actor.set_translation (0.0f, 0.0f, 0.0f);
1756+
actor.restore_easing_state ();
17591757

1760-
ulong handler_id = 0UL;
1761-
handler_id = actor.transitions_completed.connect (() => {
1762-
actor.disconnect (handler_id);
1763-
unmaximizing.remove (actor);
1764-
});
1765-
}
1758+
ulong handler_id = 0UL;
1759+
handler_id = actor.transitions_completed.connect (() => {
1760+
actor.disconnect (handler_id);
1761+
unmaximizing.remove (actor);
1762+
});
17661763
}
17671764

17681765
private void move_window_to_next_ws (Meta.Window window) {

0 commit comments

Comments
 (0)