Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a wayland/x11 mutter hints protocol for monitor labels #2084

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions daemon-gtk3/DBus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ public interface Gala.WMDBus : GLib.Object {
public abstract void perform_action (Gala.ActionType type) throws DBusError, IOError;
}

public struct Gala.Daemon.MonitorLabelInfo {
public int monitor;
public string label;
public string background_color;
public string text_color;
public int x;
public int y;
}

[DBus (name = "org.pantheon.gala.daemon")]
public class Gala.Daemon.DBus : GLib.Object {
private const string DBUS_NAME = "org.pantheon.gala";
Expand All @@ -30,8 +21,6 @@ public class Gala.Daemon.DBus : GLib.Object {
private WindowMenu? window_menu;
private BackgroundMenu? background_menu;

private List<MonitorLabel> monitor_labels = new List<MonitorLabel> ();

construct {
Bus.watch_name (BusType.SESSION, DBUS_NAME, BusNameWatcherFlags.NONE, gala_appeared, lost_gala);
}
Expand Down Expand Up @@ -113,21 +102,4 @@ public class Gala.Daemon.DBus : GLib.Object {
});
}
}

public void show_monitor_labels (MonitorLabelInfo[] label_infos) throws GLib.DBusError, GLib.IOError {
hide_monitor_labels ();

monitor_labels = new List<MonitorLabel> ();
foreach (var info in label_infos) {
var label = new MonitorLabel (info);
monitor_labels.append (label);
label.present ();
}
}

public void hide_monitor_labels () throws GLib.DBusError, GLib.IOError {
foreach (var monitor_label in monitor_labels) {
monitor_label.close ();
}
}
}
62 changes: 0 additions & 62 deletions daemon-gtk3/MonitorLabel.vala

This file was deleted.

1 change: 0 additions & 1 deletion daemon-gtk3/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
gala_daemon_sources = files(
'Main.vala',
'DBus.vala',
'MonitorLabel.vala',
'Window.vala',
'WindowMenu.vala',
'BackgroundMenu.vala',
Expand Down
28 changes: 0 additions & 28 deletions daemon/DBus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ public interface Gala.WMDBus : GLib.Object {
public abstract void perform_action (Gala.ActionType type) throws DBusError, IOError;
}

public struct Gala.Daemon.MonitorLabelInfo {
public int monitor;
public string label;
public string background_color;
public string text_color;
public int x;
public int y;
}

[DBus (name = "org.pantheon.gala.daemon")]
public class Gala.Daemon.DBus : GLib.Object {
private const string DBUS_NAME = "org.pantheon.gala";
Expand All @@ -70,8 +61,6 @@ public class Gala.Daemon.DBus : GLib.Object {
private WindowMenu? window_menu;
private Gtk.PopoverMenu background_menu;

private List<MonitorLabel> monitor_labels = new List<MonitorLabel> ();

construct {
Bus.watch_name (BusType.SESSION, DBUS_NAME, BusNameWatcherFlags.NONE, gala_appeared, lost_gala);

Expand Down Expand Up @@ -182,23 +171,6 @@ public class Gala.Daemon.DBus : GLib.Object {
});
}

public void show_monitor_labels (MonitorLabelInfo[] label_infos) throws GLib.DBusError, GLib.IOError {
hide_monitor_labels ();

monitor_labels = new List<MonitorLabel> ();
foreach (var info in label_infos) {
var label = new MonitorLabel (info);
monitor_labels.append (label);
label.present ();
}
}

public void hide_monitor_labels () throws GLib.DBusError, GLib.IOError {
foreach (var monitor_label in monitor_labels) {
monitor_label.close ();
}
}

private static void action_launch (SimpleAction action, Variant? variant) {
try {
AppInfo.launch_default_for_uri (variant.get_string (), null);
Expand Down
49 changes: 0 additions & 49 deletions daemon/MonitorLabel.vala

This file was deleted.

1 change: 0 additions & 1 deletion daemon/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
gala_daemon_sources = files(
'Main.vala',
'DBus.vala',
'MonitorLabel.vala',
'Window.vala',
'WindowMenu.vala',
)
Expand Down
10 changes: 0 additions & 10 deletions data/gala-daemon.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,3 @@
daemon-window {
background: transparent;
}

.monitor-label {
border-radius: 9px;
font-weight: 600;
}

.monitor-label label {
margin: 1em;
text-shadow: 0 1px 1px alpha(white, 0.1);
}
9 changes: 9 additions & 0 deletions protocol/pantheon-desktop-shell-v1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@
</description>
</request>

<request name="make_monitor_label">
<description summary="makes the surface a monitor label for the given monitor">
Request to make the surface a monitor label for the given monitor. The surface will be placed
in the top left corner of the monitor and will be kept above other surfaces.
</description>

<arg name="monitor_index" type="int" summary="the index of the monitor this surface should label"/>
</request>

<request name="focus">
<description summary="request keyboard focus">
Request keyboard focus, taking it away from any other window.
Expand Down
3 changes: 3 additions & 0 deletions protocol/pantheon-desktop-shell.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace Pantheon.Desktop {
public Destroy destroy;
public SetKeepAbove set_keep_above;
public MakeCentered make_centered;
public MakeMonitorLabel make_monitor_label;
public Focus focus;
}

Expand All @@ -79,5 +80,7 @@ namespace Pantheon.Desktop {
[CCode (has_target = false, has_typedef = false)]
public delegate void MakeCentered (Wl.Client client, Wl.Resource resource);
[CCode (has_target = false, has_typedef = false)]
public delegate void MakeMonitorLabel (Wl.Client client, Wl.Resource resource, int monitor_index);
[CCode (has_target = false, has_typedef = false)]
public delegate void Destroy (Wl.Client client, Wl.Resource resource);
}
12 changes: 0 additions & 12 deletions src/DaemonManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,6 @@ public class Gala.DaemonManager : GLib.Object {
}

switch (info[0]) {
case "LABEL":
if (info.length < 2) {
return;
}

var index = int.parse (info[1]);

var monitor_geometry = display.get_monitor_geometry (index);
window.move_frame (false, monitor_geometry.x + SPACING, monitor_geometry.y + SPACING);
window.make_above ();
break;

case "MODAL":
#if HAS_MUTTER46
daemon_client.make_dock (window);
Expand Down
16 changes: 16 additions & 0 deletions src/PantheonShell.vala
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace Gala {
destroy_extended_behavior_surface,
set_keep_above,
make_centered,
make_monitor_label,
focus_extended_behavior,
};

Expand Down Expand Up @@ -359,6 +360,21 @@ namespace Gala {
ShellClientsManager.get_instance ().make_centered (window);
}

internal static void make_monitor_label (Wl.Client client, Wl.Resource resource, int monitor_index) {
unowned ExtendedBehaviorSurface? eb_surface = resource.get_user_data<ExtendedBehaviorSurface> ();
if (eb_surface.wayland_surface == null) {
return;
}

Meta.Window? window;
eb_surface.wayland_surface.get ("window", out window, null);
if (window == null) {
return;
}

ShellClientsManager.get_instance ().make_monitor_label (window, monitor_index);
}

internal static void destroy_panel_surface (Wl.Client client, Wl.Resource resource) {
resource.destroy ();
}
Expand Down
Loading