Skip to content

Commit bc131ee

Browse files
committed
Add the make_modal method
1 parent 6d112be commit bc131ee

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

protocol/pantheon-desktop-shell-v1.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,13 @@
128128
by the compositor.
129129
</description>
130130
</request>
131+
132+
<request name="make_modal">
133+
<description summary="requests to make a surface system modal">
134+
This will block all user input outside the surface and most system shortcuts.
135+
</description>
136+
137+
<arg name="dim" type="uint" summary="1 to dim, 0 to not dim"/>
138+
</request>
131139
</interface>
132140
</protocol>

protocol/pantheon-desktop-shell.vapi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ namespace PantheonDesktop {
7070
public void set_keep_above ();
7171
public void make_centered ();
7272
public void focus ();
73+
public void make_modal (uint dim);
7374
}
7475
}

src/ExtendedBehavior.vala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,21 @@ public interface PantheonWayland.ExtendedBehavior : Gtk.Widget, Gtk.Native {
8484
warning ("Couldn't focus: ExtendedBehavior surface was null. Did you forget to call connect_to_shell?");
8585
}
8686
}
87+
88+
/**
89+
* Tells the wm to make this window modal. The window will be displayed above
90+
* all other windows. All user input outside this window and most system shortcuts
91+
* will be blocked until this window is closed.
92+
* If dim is true the background will be dimmed.
93+
* This should only be called after {@link connect_to_shell}.
94+
* This is only allowed for centered windows, so {@link make_centered} has to be called first.
95+
*/
96+
public void make_modal (bool dim) {
97+
unowned PantheonDesktop.ExtendedBehavior? extended_behavior = get_data ("-pantheon-wayland-extended-behavior");
98+
if (extended_behavior != null) {
99+
extended_behavior.make_modal ((uint) dim);
100+
} else {
101+
warning ("Couldn't make modal: ExtendedBehavior surface was null. Did you forget to call connect_to_shell?");
102+
}
103+
}
87104
}

0 commit comments

Comments
 (0)