Skip to content

Commit d0c8477

Browse files
committed
Send DND info to windows that requested visible in MultitaskingView
1 parent 94e18f8 commit d0c8477

File tree

7 files changed

+92
-5
lines changed

7 files changed

+92
-5
lines changed

lib/DragDropAction.vala

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ namespace Gala {
5555
*/
5656
public signal void destination_crossed (Clutter.Actor destination, bool hovered);
5757

58+
/**
59+
* Emitted on the source when we are hovering over a destination.
60+
*
61+
* @param destination The destination actor that we are hovering over
62+
* @param x The x coordinate relative to the destination actor
63+
* @param y The y coordinate relative to the destination actor
64+
*/
65+
public signal void destination_motion (Clutter.Actor destination, float x, float y);
66+
5867
/**
5968
* The source has been clicked, but the movement was not larger than
6069
* the drag threshold. Useful if the source is also activatable.
@@ -341,7 +350,7 @@ namespace Gala {
341350
last_y = y;
342351

343352
var stage = actor.get_stage ();
344-
var actor = stage.get_actor_at_pos (Clutter.PickMode.REACTIVE, (int) x, (int) y);
353+
var actor = stage.get_actor_at_pos (NONE, (int) x, (int) y);
345354
DragDropAction action = null;
346355
// if we're allowed to bubble and this actor is not a destination, check its parents
347356
if (actor != null && (action = get_drag_drop_action (actor)) == null && allow_bubbling) {
@@ -352,8 +361,12 @@ namespace Gala {
352361
}
353362

354363
// didn't change, no need to do anything
355-
if (actor == hovered)
364+
if (actor == hovered) {
365+
if (hovered != null) {
366+
destination_motion (hovered, x - hovered.x, y - hovered.y);
367+
}
356368
return Clutter.EVENT_STOP;
369+
}
357370

358371
if (action == null) {
359372
// apparently we left ours if we had one before
@@ -436,12 +449,12 @@ namespace Gala {
436449
}
437450

438451
private void finish () {
452+
drag_end (hovered);
453+
439454
// make sure they reset the style or whatever they changed when hovered
440455
emit_crossed (hovered, false);
441456

442457
cleanup ();
443-
444-
drag_end (hovered);
445458
}
446459

447460
private void cleanup () {

src/DBus.vala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ public class Gala.DBus {
1414
public static void init (WindowManagerGala _wm, NotificationsManager notifications_manager, ScreenshotManager screenshot_manager) {
1515
wm = _wm;
1616

17+
Bus.own_name (
18+
SESSION, "io.elementary.gala", NONE,
19+
(connection) => {
20+
try {
21+
connection.register_object ("/io/elementary/gala", WindowDragProvider.get_instance ());
22+
} catch (Error e) {
23+
warning (e.message);
24+
}
25+
},
26+
() => {},
27+
() => critical ("Could not acquire name")
28+
);
29+
1730
Bus.own_name (BusType.SESSION, "org.pantheon.gala", BusNameOwnerFlags.NONE,
1831
(connection) => {
1932
if (instance == null)

src/ShellClients/PanelWindow.vala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public class Gala.PanelWindow : ShellWindow, RootTarget {
6161
hide_tracker.show.connect (show);
6262
}
6363

64+
public void request_visible_in_multitasking_view () {
65+
visible_in_multitasking_view = true;
66+
actor.add_action (new DragDropAction (DESTINATION, "multitaskingview-window"));
67+
}
68+
6469
private void hide () {
6570
gesture_controller.goto (1);
6671
}

src/ShellClients/ShellClientsManager.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
191191
return;
192192
}
193193

194-
panel_windows[window].visible_in_multitasking_view = true;
194+
panel_windows[window].request_visible_in_multitasking_view ();
195195
}
196196

197197
public void make_centered (Meta.Window window) requires (!is_itself_positioned (window)) {

src/Widgets/MultitaskingView/WindowClone.vala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
117117
} else {
118118
drag_action = new DragDropAction (DragDropActionType.SOURCE, "multitaskingview-window");
119119
drag_action.drag_begin.connect (drag_begin);
120+
drag_action.destination_crossed.connect (destination_crossed);
121+
drag_action.destination_motion.connect (destination_motion);
120122
drag_action.drag_end.connect (drag_end);
121123
drag_action.drag_canceled.connect (drag_canceled);
122124
drag_action.actor_clicked.connect (actor_clicked);
@@ -511,6 +513,22 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
511513
return this;
512514
}
513515

516+
private void destination_crossed (Clutter.Actor destination, bool hovered) {
517+
if (!(destination is Meta.WindowActor)) {
518+
return;
519+
}
520+
521+
if (hovered) {
522+
WindowDragProvider.get_instance ().notify_enter (window.get_id ());
523+
} else {
524+
WindowDragProvider.get_instance ().notify_leave ();
525+
}
526+
}
527+
528+
private void destination_motion (Clutter.Actor destination, float x, float y) {
529+
WindowDragProvider.get_instance ().notify_motion (x, y);
530+
}
531+
514532
/**
515533
* Depending on the destination we have different ways to find the correct destination.
516534
* After we found one we destroy ourselves so the dragged clone immediately disappears,
@@ -538,6 +556,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
538556
}
539557

540558
return;
559+
} else if (destination is Meta.WindowActor) {
560+
WindowDragProvider.get_instance ().notify_dropped ();
541561
}
542562

543563
bool did_move = false;

src/WindowDragProvider.vala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2025 elementary, Inc. (https://elementary.io)
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*
5+
* Authored by: Leonhard Kargl <[email protected]>
6+
*/
7+
8+
[DBus (name = "io.elementary.desktop.wm.WindowDragProvider")]
9+
public class Gala.WindowDragProvider : Object {
10+
private static GLib.Once<WindowDragProvider> instance;
11+
public static WindowDragProvider get_instance () {
12+
return instance.once (() => { return new WindowDragProvider (); });
13+
}
14+
15+
public signal void enter (uint64 window_id);
16+
public signal void motion (int x, int y);
17+
public signal void leave ();
18+
public signal void dropped ();
19+
20+
internal void notify_enter (uint64 window_id) {
21+
enter (window_id);
22+
}
23+
24+
internal void notify_motion (float x, float y) {
25+
motion ((int) x, (int) y);
26+
}
27+
28+
internal void notify_leave () {
29+
leave ();
30+
}
31+
32+
internal void notify_dropped () {
33+
dropped ();
34+
}
35+
}

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ gala_bin_sources = files(
1616
'SessionManager.vala',
1717
'SuperScrollAction.vala',
1818
'WindowAttentionTracker.vala',
19+
'WindowDragProvider.vala',
1920
'WindowListener.vala',
2021
'WindowManager.vala',
2122
'WindowStateSaver.vala',

0 commit comments

Comments
 (0)