[gnome-shell-extensions/wip/jimmac/duller-classic-mode: 10/19] window-list: Turn workspace thumbs into drop targets



commit 631811686989650b35c6041f2f953d861125bd71
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jun 11 23:01:20 2019 +0000

    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 9896a60..d669507 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() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]