mirror of
https://github.com/elementary/gala.git
synced 2024-09-11 15:15:39 +03:00
Improve window dragging between workspaces (#1874)
This commit is contained in:
parent
585f565a46
commit
331e05907c
30
src/WindowGrabTracker.vala
Normal file
30
src/WindowGrabTracker.vala
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io)
|
||||
*/
|
||||
|
||||
public class Gala.WindowGrabTracker : GLib.Object {
|
||||
public Meta.Display display { get; construct; }
|
||||
public Meta.Window? current_window { get; private set; }
|
||||
|
||||
public WindowGrabTracker (Meta.Display display) {
|
||||
Object (display: display);
|
||||
}
|
||||
|
||||
construct {
|
||||
display.grab_op_begin.connect (on_grab_op_begin);
|
||||
display.grab_op_end.connect (on_grab_op_end);
|
||||
}
|
||||
|
||||
private void on_grab_op_begin (Meta.Window window, Meta.GrabOp op) {
|
||||
if (op != MOVING) {
|
||||
return;
|
||||
}
|
||||
|
||||
current_window = window;
|
||||
}
|
||||
|
||||
private void on_grab_op_end (Meta.Window window, Meta.GrabOp op) {
|
||||
current_window = null;
|
||||
}
|
||||
}
|
@ -83,6 +83,8 @@ namespace Gala {
|
||||
|
||||
private DaemonManager daemon_manager;
|
||||
|
||||
private WindowGrabTracker window_grab_tracker;
|
||||
|
||||
private NotificationStack notification_stack;
|
||||
|
||||
private Gee.LinkedList<ModalProxy> modal_stack = new Gee.LinkedList<ModalProxy> ();
|
||||
@ -139,6 +141,7 @@ namespace Gala {
|
||||
|
||||
public override void start () {
|
||||
daemon_manager = new DaemonManager (get_display ());
|
||||
window_grab_tracker = new WindowGrabTracker (get_display ());
|
||||
|
||||
show_stage ();
|
||||
|
||||
@ -1915,21 +1918,37 @@ namespace Gala {
|
||||
clutter_actor_reparent (moving_actor, static_windows);
|
||||
}
|
||||
|
||||
unowned var grabbed_window = window_grab_tracker.current_window;
|
||||
|
||||
if (grabbed_window != null) {
|
||||
unowned var moving_actor = (Meta.WindowActor) grabbed_window.get_compositor_private ();
|
||||
|
||||
windows.prepend (moving_actor);
|
||||
parents.prepend (moving_actor.get_parent ());
|
||||
|
||||
moving_actor.set_translation (-clone_offset_x, -clone_offset_y, 0);
|
||||
clutter_actor_reparent (moving_actor, static_windows);
|
||||
}
|
||||
|
||||
var to_has_fullscreened = false;
|
||||
var from_has_fullscreened = false;
|
||||
var docks = new List<Meta.WindowActor> ();
|
||||
|
||||
// collect all windows and put them in the appropriate containers
|
||||
foreach (unowned Meta.WindowActor actor in display.get_window_actors ()) {
|
||||
if (actor.is_destroyed ())
|
||||
if (actor.is_destroyed ()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unowned Meta.Window window = actor.get_meta_window ();
|
||||
unowned var window = actor.get_meta_window ();
|
||||
|
||||
if (!window.showing_on_its_workspace () ||
|
||||
(move_primary_only && !window.is_on_primary_monitor ()) ||
|
||||
(moving != null && window == moving))
|
||||
move_primary_only && !window.is_on_primary_monitor () ||
|
||||
window == moving ||
|
||||
window == grabbed_window) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (window.on_all_workspaces) {
|
||||
// only collect docks here that need to be displayed on both workspaces
|
||||
|
@ -13,6 +13,7 @@ gala_bin_sources = files(
|
||||
'ScreenSaverManager.vala',
|
||||
'ScreenshotManager.vala',
|
||||
'SessionManager.vala',
|
||||
'WindowGrabTracker.vala',
|
||||
'WindowListener.vala',
|
||||
'WindowManager.vala',
|
||||
'WindowStateSaver.vala',
|
||||
|
Loading…
Reference in New Issue
Block a user