Skip to content

Commit 924991e

Browse files
committed
Send DND info to windows that requested visible in MultitaskingView
1 parent 1edf44b commit 924991e

File tree

7 files changed

+90
-5
lines changed

7 files changed

+90
-5
lines changed

lib/DragDropAction.vala

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ namespace Gala {
6868
*/
6969
public signal void destination_crossed (Actor destination, bool hovered);
7070

71+
/**
72+
* Emitted on the source when we are hovering over a destination.
73+
*
74+
* @param destination The destination actor that we are hovering over
75+
* @param x The x coordinate relative to the destination actor
76+
* @param y The y coordinate relative to the destination actor
77+
*/
78+
public signal void destination_motion (Actor destination, float x, float y);
79+
7180
/**
7281
* The source has been clicked, but the movement was not larger than
7382
* the drag threshold. Useful if the source is also activable.
@@ -354,7 +363,7 @@ namespace Gala {
354363
last_y = y;
355364

356365
var stage = actor.get_stage ();
357-
var actor = stage.get_actor_at_pos (PickMode.REACTIVE, (int) x, (int) y);
366+
var actor = stage.get_actor_at_pos (PickMode.NONE, (int) x, (int) y);
358367
DragDropAction action = null;
359368
// if we're allowed to bubble and this actor is not a destination, check its parents
360369
if (actor != null && (action = get_drag_drop_action (actor)) == null && allow_bubbling) {
@@ -365,8 +374,12 @@ namespace Gala {
365374
}
366375

367376
// didn't change, no need to do anything
368-
if (actor == hovered)
377+
if (actor == hovered) {
378+
if (hovered != null) {
379+
destination_motion (hovered, x - hovered.x, y - hovered.y);
380+
}
369381
return Clutter.EVENT_STOP;
382+
}
370383

371384
if (action == null) {
372385
// apparently we left ours if we had one before
@@ -449,12 +462,12 @@ namespace Gala {
449462
}
450463

451464
private void finish () {
465+
drag_end (hovered);
466+
452467
// make sure they reset the style or whatever they changed when hovered
453468
emit_crossed (hovered, false);
454469

455470
cleanup ();
456-
457-
drag_end (hovered);
458471
}
459472

460473
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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
114114
} else {
115115
drag_action = new DragDropAction (DragDropActionType.SOURCE, "multitaskingview-window");
116116
drag_action.drag_begin.connect (drag_begin);
117+
drag_action.destination_crossed.connect (destination_crossed);
118+
drag_action.destination_motion.connect (destination_motion);
117119
drag_action.drag_end.connect (drag_end);
118120
drag_action.drag_canceled.connect (drag_canceled);
119121
drag_action.actor_clicked.connect (actor_clicked);
@@ -506,6 +508,20 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
506508
return this;
507509
}
508510

511+
private void destination_crossed (Clutter.Actor destination, bool hovered) {
512+
if (destination is Meta.WindowActor) {
513+
if (hovered) {
514+
WindowDragProvider.get_instance ().notify_enter (window.get_id ());
515+
} else {
516+
WindowDragProvider.get_instance ().notify_leave ();
517+
}
518+
}
519+
}
520+
521+
private void destination_motion (Clutter.Actor destination, float x, float y) {
522+
WindowDragProvider.get_instance ().notify_motion (x, y);
523+
}
524+
509525
/**
510526
* Depending on the destination we have different ways to find the correct destination.
511527
* After we found one we destroy ourselves so the dragged clone immediately disappears,
@@ -533,6 +549,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
533549
}
534550

535551
return;
552+
} else if (destination is Meta.WindowActor) {
553+
WindowDragProvider.get_instance ().notify_dropped ();
536554
}
537555

538556
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
@@ -15,6 +15,7 @@ gala_bin_sources = files(
1515
'SessionManager.vala',
1616
'SuperScrollAction.vala',
1717
'WindowAttentionTracker.vala',
18+
'WindowDragProvider.vala',
1819
'WindowListener.vala',
1920
'WindowManager.vala',
2021
'WindowStateSaver.vala',

0 commit comments

Comments
 (0)