From 9f9dbd579b1432cbc863d4de44571db42a22b6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 11 Jun 2019 23:01:20 +0000 Subject: [PATCH] window-list: Turn workspace thumbs into drop targets It makes some sense to allow using the workspace indicator for moving windows between workspaces as well as for workspace switching. This applies particularly in GNOME classic after we disabled the overview there, so that there is again a non-shortcut way of moving windows between workspaces. https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/74 --- extensions/window-list/workspaceIndicator.js | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/extensions/window-list/workspaceIndicator.js b/extensions/window-list/workspaceIndicator.js index 9896a60a..d6695079 100644 --- a/extensions/window-list/workspaceIndicator.js +++ b/extensions/window-list/workspaceIndicator.js @@ -1,6 +1,8 @@ /* exported WorkspaceIndicator */ const { Clutter, Gio, GObject, Meta, St } = imports.gi; +const DND = imports.ui.dnd; +const Main = imports.ui.main; const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; @@ -16,6 +18,31 @@ let WorkspaceThumbnail = GObject.registerClass({ }); this._index = index; + this._delegate = this; // needed for DND + } + + acceptDrop(source) { + if (!source.realWindow) + return false; + + let window = source.realWindow.get_meta_window(); + this._moveWindow(window); + return true; + } + + handleDragOver(source) { + if (source.realWindow) + return DND.DragMotionResult.MOVE_DROP; + else + return DND.DragMotionResult.CONTINUE; + } + + + _moveWindow(window) { + let monitorIndex = Main.layoutManager.findIndexForActor(this); + if (monitorIndex != window.get_monitor()) + window.move_to_monitor(monitorIndex); + window.change_workspace_by_index(this._index, false); } on_clicked() {