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

WindowManager: Allow making modal without a grab #1860

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions daemon/MenuDaemon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class Gala.Daemon.MenuDaemon : GLib.Object {
private const string DAEMON_DBUS_NAME = "org.pantheon.gala.daemon";
private const string DAEMON_DBUS_OBJECT_PATH = "/org/pantheon/gala/daemon";

public signal void pop_modal ();

private WMDBus? wm_proxy = null;

private WindowMenu? window_menu;
Expand Down Expand Up @@ -101,5 +103,7 @@ public class Gala.Daemon.MenuDaemon : GLib.Object {
return Gdk.EVENT_PROPAGATE;
});
}

window.destroy.connect (() => pop_modal ());
}
}
2 changes: 1 addition & 1 deletion lib/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace Gala {
* @return a {@link ModalProxy} which is needed to end the modal mode again and provides some
* some basic control on the behavior of the window manager while it is in modal mode.
*/
public abstract ModalProxy push_modal (Clutter.Actor actor);
public abstract ModalProxy push_modal (Clutter.Actor? actor);

/**
* May exit the modal mode again, unless another component has called {@link push_modal}
Expand Down
30 changes: 22 additions & 8 deletions src/DaemonManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ public class Gala.DaemonManager : GLib.Object {

[DBus (name = "org.pantheon.gala.daemon")]
public interface Daemon: GLib.Object {
public signal void pop_modal ();
public abstract async void show_window_menu (WindowFlags flags, int width, int height, int x, int y) throws Error;
public abstract async void show_desktop_menu (int display_width, int display_height, int x, int y) throws Error;
}

public Meta.Display display { get; construct; }
public WindowManager wm { get; construct; }

private Meta.WaylandClient daemon_client;
private Daemon? daemon_proxy = null;
private ModalProxy? modal_proxy = null;

public DaemonManager (Meta.Display display) {
Object (display: display);
public DaemonManager (WindowManager wm) {
Object (wm: wm);
}

construct {
Expand All @@ -31,7 +33,7 @@ public class Gala.DaemonManager : GLib.Object {
if (Meta.Util.is_wayland_compositor ()) {
start_wayland.begin ();

display.window_created.connect ((window) => {
wm.get_display ().window_created.connect ((window) => {
if (daemon_client.owns_window (window)) {
window.shown.connect (handle_daemon_window);
}
Expand All @@ -45,12 +47,12 @@ public class Gala.DaemonManager : GLib.Object {
var subprocess_launcher = new GLib.SubprocessLauncher (NONE);
try {
#if HAS_MUTTER44
daemon_client = new Meta.WaylandClient (display.get_context (), subprocess_launcher);
daemon_client = new Meta.WaylandClient (wm.get_display ().get_context (), subprocess_launcher);
#else
daemon_client = new Meta.WaylandClient (subprocess_launcher);
#endif
string[] args = {"gala-daemon"};
var subprocess = daemon_client.spawnv (display, args);
var subprocess = daemon_client.spawnv (wm.get_display (), args);

yield subprocess.wait_async ();

Expand Down Expand Up @@ -94,6 +96,12 @@ public class Gala.DaemonManager : GLib.Object {
Bus.get_proxy.begin<Daemon> (BusType.SESSION, DAEMON_DBUS_NAME, DAEMON_DBUS_OBJECT_PATH, 0, null, (obj, res) => {
try {
daemon_proxy = Bus.get_proxy.end (res);
daemon_proxy.pop_modal.connect (() => {
if (modal_proxy != null) {
wm.pop_modal (modal_proxy);
modal_proxy = null;
}
});
} catch (Error e) {
warning ("Failed to get Menu proxy: %s", e.message);
}
Expand All @@ -107,10 +115,13 @@ public class Gala.DaemonManager : GLib.Object {
}

int width, height;
display.get_size (out width, out height);
wm.get_display ().get_size (out width, out height);

try {
yield daemon_proxy.show_desktop_menu (width, height, x, y);
if (modal_proxy == null) {
modal_proxy = wm.push_modal (null);
}
} catch (Error e) {
warning ("Error invoking MenuManager: %s", e.message);
}
Expand All @@ -122,10 +133,13 @@ public class Gala.DaemonManager : GLib.Object {
}

int width, height;
display.get_size (out width, out height);
wm.get_display ().get_size (out width, out height);

try {
yield daemon_proxy.show_window_menu (flags, width, height, x, y);
if (modal_proxy == null) {
modal_proxy = wm.push_modal (null);
}
} catch (Error e) {
warning ("Error invoking MenuManager: %s", e.message);
}
Expand Down
13 changes: 9 additions & 4 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace Gala {
}

public override void start () {
daemon_manager = new DaemonManager (get_display ());
daemon_manager = new DaemonManager (this);

show_stage ();

Expand Down Expand Up @@ -784,7 +784,7 @@ namespace Gala {
/**
* {@inheritDoc}
*/
public ModalProxy push_modal (Clutter.Actor actor) {
public ModalProxy push_modal (Clutter.Actor? actor) {
var proxy = new ModalProxy ();

modal_stack.offer_head (proxy);
Expand All @@ -796,7 +796,10 @@ namespace Gala {
unowned Meta.Display display = get_display ();

update_input_area ();
proxy.grab = stage.grab (actor);

if (actor != null) {
proxy.grab = stage.grab (actor);
}

if (modal_stack.size == 1) {
display.disable_unredirect ();
Expand All @@ -814,7 +817,9 @@ namespace Gala {
return;
}

proxy.grab.dismiss ();
if (proxy.grab != null) {
proxy.grab.dismiss ();
}

if (is_modal ())
return;
Expand Down