scripting: Make helper proxy initialization async
We are about to port the helper proxy to GApplication, which means that it will establish a display connection before exporting its D-Bus name. That means that the compositor must be able to respond to a roundtrip request to avoid locking, so don't block on the proxy becoming available. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2733>
This commit is contained in:
parent
a53d7faf9d
commit
2416e4eec0
@ -12,7 +12,7 @@ async function run() {
|
|||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
|
|
||||||
/* Make created windows remain visible during exit. */
|
/* Make created windows remain visible during exit. */
|
||||||
Scripting.disableHelperAutoExit();
|
await Scripting.disableHelperAutoExit();
|
||||||
|
|
||||||
const seat = Clutter.get_default_backend().get_default_seat();
|
const seat = Clutter.get_default_backend().get_default_seat();
|
||||||
const virtualDevice_ =
|
const virtualDevice_ =
|
||||||
|
@ -64,14 +64,13 @@ function waitLeisure() {
|
|||||||
|
|
||||||
const PerfHelperIface = loadInterfaceXML('org.gnome.Shell.PerfHelper');
|
const PerfHelperIface = loadInterfaceXML('org.gnome.Shell.PerfHelper');
|
||||||
var PerfHelperProxy = Gio.DBusProxy.makeProxyWrapper(PerfHelperIface);
|
var PerfHelperProxy = Gio.DBusProxy.makeProxyWrapper(PerfHelperIface);
|
||||||
function PerfHelper() {
|
|
||||||
return new PerfHelperProxy(Gio.DBus.session, 'org.gnome.Shell.PerfHelper', '/org/gnome/Shell/PerfHelper');
|
|
||||||
}
|
|
||||||
|
|
||||||
let _perfHelper = null;
|
let _perfHelper = null;
|
||||||
function _getPerfHelper() {
|
/** private */
|
||||||
|
async function _getPerfHelper() {
|
||||||
if (_perfHelper == null) {
|
if (_perfHelper == null) {
|
||||||
_perfHelper = new PerfHelper();
|
_perfHelper = await PerfHelperProxy.newAsync(
|
||||||
|
Gio.DBus.session, 'org.gnome.Shell.PerfHelper', '/org/gnome/Shell/PerfHelper');
|
||||||
_perfHelper._autoExit = true;
|
_perfHelper._autoExit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ function _spawnPerfHelper() {
|
|||||||
* because of the normal X asynchronous mapping process, to actually wait
|
* because of the normal X asynchronous mapping process, to actually wait
|
||||||
* until the window has been mapped and exposed, use waitTestWindows().
|
* until the window has been mapped and exposed, use waitTestWindows().
|
||||||
*/
|
*/
|
||||||
function createTestWindow(params) {
|
async function createTestWindow(params) {
|
||||||
params = Params.parse(params, {
|
params = Params.parse(params, {
|
||||||
width: 640,
|
width: 640,
|
||||||
height: 480,
|
height: 480,
|
||||||
@ -110,7 +109,7 @@ function createTestWindow(params) {
|
|||||||
textInput: false,
|
textInput: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = await _getPerfHelper();
|
||||||
perfHelper.CreateWindowAsync(
|
perfHelper.CreateWindowAsync(
|
||||||
params.width, params.height,
|
params.width, params.height,
|
||||||
params.alpha, params.maximized,
|
params.alpha, params.maximized,
|
||||||
@ -124,8 +123,8 @@ function createTestWindow(params) {
|
|||||||
* Used within an automation script to pause until all windows previously
|
* Used within an automation script to pause until all windows previously
|
||||||
* created with createTestWindow have been mapped and exposed.
|
* created with createTestWindow have been mapped and exposed.
|
||||||
*/
|
*/
|
||||||
function waitTestWindows() {
|
async function waitTestWindows() {
|
||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = await _getPerfHelper();
|
||||||
return perfHelper.WaitWindowsAsync().catch(logError);
|
return perfHelper.WaitWindowsAsync().catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,8 +138,8 @@ function waitTestWindows() {
|
|||||||
* this doesn't guarantee that Mutter has actually finished the destroy
|
* this doesn't guarantee that Mutter has actually finished the destroy
|
||||||
* process because of normal X asynchronicity.
|
* process because of normal X asynchronicity.
|
||||||
*/
|
*/
|
||||||
function destroyTestWindows() {
|
async function destroyTestWindows() {
|
||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = await _getPerfHelper();
|
||||||
return perfHelper.DestroyWindowsAsync().catch(logError);
|
return perfHelper.DestroyWindowsAsync().catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,8 +149,8 @@ function destroyTestWindows() {
|
|||||||
* Don't exixt the perf helper after running the script. Instead it will remain
|
* Don't exixt the perf helper after running the script. Instead it will remain
|
||||||
* running until something else makes it exit, e.g. the Wayland socket closing.
|
* running until something else makes it exit, e.g. the Wayland socket closing.
|
||||||
*/
|
*/
|
||||||
function disableHelperAutoExit() {
|
async function disableHelperAutoExit() {
|
||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = await _getPerfHelper();
|
||||||
perfHelper._autoExit = false;
|
perfHelper._autoExit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +300,7 @@ async function _runPerfScript(scriptModule, outputFile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const perfHelper = _getPerfHelper();
|
const perfHelper = await _getPerfHelper();
|
||||||
if (perfHelper._autoExit)
|
if (perfHelper._autoExit)
|
||||||
perfHelper.ExitSync();
|
perfHelper.ExitSync();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user