Commit 2b3ab3ec authored by Marco Trevisan's avatar Marco Trevisan 🎺

windowMenu: Do actions requiring grab once ungrabbed

Resizing or moving a window needs starting a keyboard grab. However, if the
action is triggered by a menu entry activation it might not work as we already
have already an active grab on input devices to manage the menu itself.

So, possibly wait maximum 100ms for the current grab operation to be completed
before trying go start a new one.

Needs mutter!596
Fixes #1326

!557
parent 759120b9
Pipeline #85048 passed with stages
in 3 minutes and 32 seconds
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*
const { Meta, St } = imports.gi;
const { GLib, Meta, St } = imports.gi;
const BoxPointer = imports.ui.boxpointer;
const Main = imports.ui.main;
......@@ -42,13 +42,13 @@ var WindowMenu = class extends PopupMenu.PopupMenu {
item.setSensitive(false);
item = this.addAction(_("Move"), event => {
window.begin_grab_op(Meta.GrabOp.KEYBOARD_MOVING, true, event.get_time());
this._grabAction(window, Meta.GrabOp.KEYBOARD_MOVING, event.get_time());
});
if (!window.allows_move())
item.setSensitive(false);
item = this.addAction(_("Resize"), event => {
window.begin_grab_op(Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, true, event.get_time());
this._grabAction(window, Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, event.get_time());
});
if (!window.allows_resize())
item.setSensitive(false);
......@@ -169,6 +169,26 @@ var WindowMenu = class extends PopupMenu.PopupMenu {
if (!window.can_close())
item.setSensitive(false);
}
_grabAction(window, grabOp, time) {
if (global.display.get_grab_op() == Meta.GrabOp.NONE) {
window.begin_grab_op(grabOp, true, time);
return;
}
let waitId = 0;
let id = global.display.connect('grab-op-end', (display) => {
display.disconnect(id);
GLib.source_remove(waitId);
window.begin_grab_op(grabOp, true, time);
});
waitId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 100, () => {
global.display.disconnect(id);
return GLib.SOURCE_REMOVE;
});
}
};
var WindowMenuManager = class {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment