[gnome-shell/wip/exalm/gestures2: 6/7] workspaceAnimation: Group sticky windows and moving window
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/exalm/gestures2: 6/7] workspaceAnimation: Group sticky windows and moving window
- Date: Sat, 20 Jun 2020 23:09:00 +0000 (UTC)
commit 21f15fa5882be0e0ed1e435a464945ffb397a59e
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sat Jun 20 23:44:24 2020 +0500
workspaceAnimation: Group sticky windows and moving window
js/ui/workspaceAnimation.js | 102 +++++++++++++++++++++++++++++++-------------
1 file changed, 73 insertions(+), 29 deletions(-)
---
diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js
index 0cf7871e84..3c62aeb812 100644
--- a/js/ui/workspaceAnimation.js
+++ b/js/ui/workspaceAnimation.js
@@ -90,6 +90,75 @@ class WorkspaceGroup extends Clutter.Actor {
}
});
+const StickyGroup = GObject.registerClass(
+class StickyGroup extends Clutter.Actor {
+ _init(controller) {
+ super._init();
+
+ this._controller = controller;
+ this._windows = [];
+
+ this._refreshWindows();
+
+ this.connect('destroy', this._onDestroy.bind(this));
+ this._restackedId = global.display.connect('restacked',
+ this._refreshWindows.bind(this));
+ }
+
+ _shouldShowWindow(window) {
+ if (!window.showing_on_its_workspace())
+ return false;
+
+ return window.is_on_all_workspaces() || window === this._controller.movingWindow;
+ }
+
+ _refreshWindows() {
+ if (this._windows.length > 0)
+ this._removeWindows();
+
+ let windows = global.get_window_actors();
+ windows = windows.filter(w => this._shouldShowWindow(w.meta_window));
+
+ for (let window of windows) {
+ let clone = new Clutter.Clone({
+ source: window,
+ x: window.x,
+ y: window.y,
+ });
+
+ this.add_actor(clone);
+ window.hide();
+
+ let record = { window, clone };
+
+ record.windowDestroyId = window.connect('destroy', () => {
+ clone.destroy();
+ this._windows.splice(this._windows.indexOf(record), 1);
+ });
+
+ this._windows.push(record);
+ }
+ }
+
+ _removeWindows() {
+ for (let i = 0; i < this._windows.length; i++) {
+ let w = this._windows[i];
+
+ w.window.disconnect(w.windowDestroyId);
+ w.clone.destroy();
+
+ w.window.show();
+ }
+
+ this._windows = [];
+ }
+
+ _onDestroy() {
+ global.display.disconnect(this._restackedId);
+ this._removeWindows();
+ }
+});
+
var WorkspaceAnimationController = class {
constructor() {
this._movingWindow = null;
@@ -126,15 +195,14 @@ var WorkspaceAnimationController = class {
let switchData = {};
this._switchData = switchData;
- switchData.movingWindowBin = new Clutter.Actor();
- switchData.movingWindow = null;
+ switchData.stickyGroup = new StickyGroup(this);
switchData.workspaces = [];
switchData.gestureActivated = false;
switchData.inProgress = false;
switchData.container = new Clutter.Actor();
- wgroup.add_actor(switchData.movingWindowBin);
+ wgroup.add_actor(switchData.stickyGroup);
wgroup.add_actor(switchData.container);
let x = 0;
@@ -179,38 +247,14 @@ var WorkspaceAnimationController = class {
x += global.screen_width;
}
- wgroup.set_child_above_sibling(switchData.movingWindowBin, null);
-
- if (this.movingWindow) {
- let actor = this.movingWindow.get_compositor_private();
-
- switchData.movingWindow = {
- window: actor,
- parent: actor.get_parent(),
- };
-
- switchData.movingWindow.parent.remove_child(actor);
- switchData.movingWindowBin.add_child(actor);
- switchData.movingWindow.windowDestroyId = actor.connect('destroy', () => {
- switchData.movingWindow = null;
- });
- }
+ wgroup.set_child_above_sibling(switchData.stickyGroup, null);
}
_finishWorkspaceSwitch(switchData) {
this._switchData = null;
- if (switchData.movingWindow) {
- let record = switchData.movingWindow;
- record.window.disconnect(record.windowDestroyId);
- record.window.get_parent().remove_child(record.window);
- record.parent.add_child(record.window);
-
- switchData.movingWindow = null;
- }
-
switchData.container.destroy();
- switchData.movingWindowBin.destroy();
+ switchData.stickyGroup.destroy();
this.movingWindow = null;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]