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
This commit is contained in:
Dylan McCall 2018-02-05 10:46:22 -08:00 committed by Dylan McCall
parent 5520bb3890
commit 03117d65b2

View File

@ -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
});
}
});