mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
grabHelper: Add (promised-based) grabAsync()
Some GrabHelper uses are in the form:
doPreGrabStuff();
this._grabHelper.grab({
onUngrab: () => {
undoPreGrabStuff();
},
});
A promise-based variant allows to write this more cleanly as:
doPreGrabStuff();
await this._grabHelper.grabAsync();
undoPreGrabStuff();
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/903
This commit is contained in:
parent
35494f5d08
commit
93fa1034f5
1 changed files with 9 additions and 0 deletions
|
|
@ -194,6 +194,15 @@ var GrabHelper = class GrabHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
grabAsync(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
params.onUngrab = resolve;
|
||||
|
||||
if (!this.grab(params))
|
||||
reject(new Error('Grab failed'));
|
||||
});
|
||||
}
|
||||
|
||||
_takeModalGrab() {
|
||||
let firstGrab = this._modalCount == 0;
|
||||
if (firstGrab) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue