Make dimming optional

This commit is contained in:
Leonhard Kargl 2024-07-07 17:19:00 +02:00
parent dd03b3afde
commit 7481383314
5 changed files with 21 additions and 4 deletions

View File

@ -115,6 +115,8 @@
<description summary="requests to make a surface system modal">
This will block all user input outside the surface and most system shortcuts.
</description>
<arg name="dim" type="uint" summary="1 to dim, 0 to not dim"/>
</request>
</interface>
</protocol>

View File

@ -76,7 +76,7 @@ namespace Pantheon.Desktop {
[CCode (has_target = false, has_typedef = false)]
public delegate void SetKeepAbove (Wl.Client client, Wl.Resource resource);
[CCode (has_target = false, has_typedef = false)]
public delegate void MakeModal (Wl.Client client, Wl.Resource resource);
public delegate void MakeModal (Wl.Client client, Wl.Resource resource, uint dim);
[CCode (has_target = false, has_typedef = false)]
public delegate void Destroy (Wl.Client client, Wl.Resource resource);
}

View File

@ -328,7 +328,7 @@ namespace Gala {
window.make_above ();
}
internal static void make_modal (Wl.Client client, Wl.Resource resource) {
internal static void make_modal (Wl.Client client, Wl.Resource resource, uint dim) {
unowned ExtendedBehaviorSurface? eb_surface = resource.get_user_data<ExtendedBehaviorSurface> ();
if (eb_surface.wayland_surface == null) {
warning ("Window tried to make modal but wayland surface is null.");
@ -342,7 +342,7 @@ namespace Gala {
return;
}
ShellClientsManager.get_instance ().make_modal (window);
ShellClientsManager.get_instance ().make_modal (window, dim == 1);
}
internal static void destroy_panel_surface (Wl.Client client, Wl.Resource resource) {

View File

@ -144,7 +144,8 @@ public class Gala.ShellClientsManager : Object {
windows[window].set_hide_mode (hide_mode);
}
public void make_modal (Meta.Window window) {
public void make_modal (Meta.Window window, bool dim) {
wm.modal_actor.make_modal (window);
wm.modal_actor.dim = dim;
}
}

View File

@ -14,6 +14,16 @@
public class Gala.ModalActor : Clutter.Actor {
public Meta.Display display { get; construct; }
public bool dim {
set {
if (value) {
background_color = { 0, 0, 0, 200 };
} else {
background_color = { 0, 0, 0, 0 };
}
}
}
private int modal_dialogs = 0;
public ModalActor (Meta.Display display) {
@ -59,6 +69,10 @@
private void check_visible () {
visible = modal_dialogs > 0;
if (visible) {
get_parent ().set_child_above_sibling (this, null);
}
}
public bool is_modal () {