diff --git a/protocol/pantheon-desktop-shell-v1.xml b/protocol/pantheon-desktop-shell-v1.xml index bedbcaf..d8bdad7 100644 --- a/protocol/pantheon-desktop-shell-v1.xml +++ b/protocol/pantheon-desktop-shell-v1.xml @@ -128,5 +128,13 @@ by the compositor. + + + + This will block all user input outside the surface and most system shortcuts. + + + + diff --git a/protocol/pantheon-desktop-shell.vapi b/protocol/pantheon-desktop-shell.vapi index 5a6fd47..ec547e7 100644 --- a/protocol/pantheon-desktop-shell.vapi +++ b/protocol/pantheon-desktop-shell.vapi @@ -70,5 +70,6 @@ namespace PantheonDesktop { public void set_keep_above (); public void make_centered (); public void focus (); + public void make_modal (uint dim); } } diff --git a/src/ExtendedBehavior.vala b/src/ExtendedBehavior.vala index 2ebb717..54bb6ba 100644 --- a/src/ExtendedBehavior.vala +++ b/src/ExtendedBehavior.vala @@ -84,4 +84,21 @@ public interface PantheonWayland.ExtendedBehavior : Gtk.Widget, Gtk.Native { warning ("Couldn't focus: ExtendedBehavior surface was null. Did you forget to call connect_to_shell?"); } } + + /** + * Tells the wm to make this window modal. The window will be displayed above + * all other windows. All user input outside this window and most system shortcuts + * will be blocked until this window is closed. + * If dim is true the background will be dimmed. + * This should only be called after {@link connect_to_shell}. + * This is only allowed for centered windows, so {@link make_centered} has to be called first. + */ + public void make_modal (bool dim) { + unowned PantheonDesktop.ExtendedBehavior? extended_behavior = get_data ("-pantheon-wayland-extended-behavior"); + if (extended_behavior != null) { + extended_behavior.make_modal ((uint) dim); + } else { + warning ("Couldn't make modal: ExtendedBehavior surface was null. Did you forget to call connect_to_shell?"); + } + } }