[gnome-shell] panel: Drag topmost maximized window



commit 03117d65b279f7a6721393d3f84277ba1790c6a7
Author: Dylan McCall <dylan dylanmccall com>
Date:   Mon Feb 5 10:46:22 2018 -0800

    panel: Drag topmost maximized window
    
    This makes it possible to drag a window which appears connected with the
    panel, even if it is not in focus. As a result, it should be easier to
    manipulate side-by-side windows.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679290

 js/ui/panel.js | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 7fe09fe50..5d3d779a0 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -971,22 +971,11 @@ class Panel extends St.Widget {
         if (isPress && button != 1)
             return Clutter.EVENT_PROPAGATE;
 
-        let focusWindow = global.display.focus_window;
-        if (!focusWindow)
-            return Clutter.EVENT_PROPAGATE;
-
-        let dragWindow = focusWindow.is_attached_dialog() ? focusWindow.get_transient_for()
-                                                          : focusWindow;
-        if (!dragWindow)
-            return Clutter.EVENT_PROPAGATE;
-
-        let rect = dragWindow.get_frame_rect();
         let [stageX, stageY] = event.get_coords();
 
-        let allowDrag = dragWindow.maximized_vertically &&
-                        stageX > rect.x && stageX < rect.x + rect.width;
+        let dragWindow = this._getDraggableWindowForPosition(stageX);
 
-        if (!allowDrag)
+        if (!dragWindow)
             return Clutter.EVENT_PROPAGATE;
 
         global.display.begin_grab_op(dragWindow,
@@ -1196,4 +1185,21 @@ class Panel extends St.Widget {
                     Main.messageTray.bannerBlocked = isOpen;
             });
     }
+
+    _getDraggableWindowForPosition(stageX) {
+        let workspaceManager = global.workspace_manager;
+        let workspace = workspaceManager.get_active_workspace()
+        let allWindowsByStacking = global.display.sort_windows_by_stacking(
+            workspace.list_windows()
+        ).reverse();
+
+        return allWindowsByStacking.find(metaWindow => {
+            let rect = metaWindow.get_frame_rect();
+            return metaWindow.is_on_primary_monitor() &&
+                   metaWindow.showing_on_its_workspace() &&
+                   metaWindow.get_window_type() != Meta.WindowType.DESKTOP &&
+                   metaWindow.maximized_vertically &&
+                   stageX > rect.x && stageX < rect.x + rect.width
+        });
+    }
 });


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