~zenomat/dwm-gnome

291f8aa75675ca6f34284db1fbbcbb0fd2efc572 — zeno 8 months ago e433d6a main
workspaces: handle move to workspace
1 files changed, 28 insertions(+), 0 deletions(-)

M extension.js
M extension.js => extension.js +28 -0
@@ 211,8 211,33 @@ class WindowManager {
		}
		this.activeWorkspace = this.workspaces.get(newWorkspace);
		this.computeAndPosition();
	}

	windowChangedWorkspace(win) {
		log('Window changed workspace')

		let currentWorkspace = this.activeWorkspace;
		let newWorkspace = win.get_workspace().index();

		if (!this.workspaces.has(newWorkspace)) {
			this.workspaces.set(newWorkspace, new Workspace(newWorkspace));
		}

		// TODO: this is a dirty workaround
		// we have to do this, because the delete event somehow only gets called on the first workspace
		// and not on the others, so we have to do this manually
		if (currentWorkspace.workspaceIndex >= 1) {
			this.windowDestroyed(null, win);
		}

		// TODO: this is a dirty workaround
		// we can't add windows to workspaces,
		// other than the active one, directly, so we change the
		// active workspace under the hood and switching back, after adding
		this.activeWorkspace = this.workspaces.get(newWorkspace);
		this.windowCreated(null, win);

		this.activeWorkspace = currentWorkspace;
		this.computeAndPosition();
	}



@@ 232,6 257,9 @@ class WindowManager {
			this.computeAndPosition();
			act.disconnect(id);
		});

		// TODO: clean this up and disconnect
		const winWorkspaceChangeHandler = window.win.connect('workspace-changed', this.windowChangedWorkspace.bind(this));
		
		// this.computeAndPosition();
	}