Skip to content

Commit 809fb2e

Browse files
committed
Add API for making monitor label via wayland protocol
1 parent 629d158 commit 809fb2e

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

protocol/pantheon-desktop-shell-v1.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@
119119
</description>
120120
</request>
121121

122+
<request name="make_monitor_label">
123+
<description summary="makes the surface a monitor label for the given monitor">
124+
Request to make the surface a monitor label for the given monitor. The surface will be placed
125+
in the top left corner of the monitor and will be kept above other surfaces.
126+
</description>
127+
128+
<arg name="monitor_index" type="int" summary="the index of the monitor this surface should label"/>
129+
</request>
130+
122131
<request name="focus">
123132
<description summary="request keyboard focus">
124133
Request keyboard focus, taking it away from any other window.

protocol/pantheon-desktop-shell.vapi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace Pantheon.Desktop {
5757
public Destroy destroy;
5858
public SetKeepAbove set_keep_above;
5959
public MakeCentered make_centered;
60+
public MakeMonitorLabel make_monitor_label;
6061
public Focus focus;
6162
}
6263

@@ -79,5 +80,7 @@ namespace Pantheon.Desktop {
7980
[CCode (has_target = false, has_typedef = false)]
8081
public delegate void MakeCentered (Wl.Client client, Wl.Resource resource);
8182
[CCode (has_target = false, has_typedef = false)]
83+
public delegate void MakeMonitorLabel (Wl.Client client, Wl.Resource resource, int monitor_index);
84+
[CCode (has_target = false, has_typedef = false)]
8285
public delegate void Destroy (Wl.Client client, Wl.Resource resource);
8386
}

src/PantheonShell.vala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ namespace Gala {
4949
destroy_extended_behavior_surface,
5050
set_keep_above,
5151
make_centered,
52+
make_monitor_label,
5253
focus_extended_behavior,
5354
};
5455

@@ -322,6 +323,21 @@ namespace Gala {
322323
ShellClientsManager.get_instance ().make_centered (window);
323324
}
324325

326+
internal static void make_monitor_label (Wl.Client client, Wl.Resource resource, int monitor_index) {
327+
unowned ExtendedBehaviorSurface? eb_surface = resource.get_user_data<ExtendedBehaviorSurface> ();
328+
if (eb_surface.wayland_surface == null) {
329+
return;
330+
}
331+
332+
Meta.Window? window;
333+
eb_surface.wayland_surface.get ("window", out window, null);
334+
if (window == null) {
335+
return;
336+
}
337+
338+
ShellClientsManager.get_instance ().make_monitor_label (window, monitor_index);
339+
}
340+
325341
internal static void destroy_panel_surface (Wl.Client client, Wl.Resource resource) {
326342
resource.destroy ();
327343
}

src/ShellClients/ShellClientsManager.vala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
192192
window.unmanaging.connect_after ((_window) => positioned_windows.remove (_window));
193193
}
194194

195+
public void make_monitor_label (Meta.Window window, int monitor_index) requires (!is_itself_positioned (window)) {
196+
if (monitor_index < 0 || monitor_index > wm.get_display ().get_n_monitors ()) {
197+
warning ("Invalid monitor index provided: %d", monitor_index);
198+
return;
199+
}
200+
201+
positioned_windows[window] = new ShellWindow (window, MONITOR_LABEL, monitor_index);
202+
203+
// connect_after so we make sure that any queued move is unqueued
204+
window.unmanaging.connect_after ((_window) => positioned_windows.remove (_window));
205+
}
206+
195207
public override void propagate (UpdateType update_type, GestureAction action, double progress) {
196208
foreach (var window in positioned_windows.get_values ()) {
197209
window.propagate (update_type, action, progress);

0 commit comments

Comments
 (0)