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:
Florian Müllner 2023-05-27 03:19:39 +02:00 committed by Marge Bot
parent a53d7faf9d
commit 2416e4eec0
2 changed files with 14 additions and 15 deletions

View File

@ -12,7 +12,7 @@ async function run() {
/* eslint-disable no-await-in-loop */
/* Make created windows remain visible during exit. */
Scripting.disableHelperAutoExit();
await Scripting.disableHelperAutoExit();
const seat = Clutter.get_default_backend().get_default_seat();
const virtualDevice_ =

View File

@ -64,14 +64,13 @@ function waitLeisure() {
const PerfHelperIface = loadInterfaceXML('org.gnome.Shell.PerfHelper');
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;
function _getPerfHelper() {
/** private */
async function _getPerfHelper() {
if (_perfHelper == null) {
_perfHelper = new PerfHelper();
_perfHelper = await PerfHelperProxy.newAsync(
Gio.DBus.session, 'org.gnome.Shell.PerfHelper', '/org/gnome/Shell/PerfHelper');
_perfHelper._autoExit = true;
}
@ -100,7 +99,7 @@ function _spawnPerfHelper() {
* because of the normal X asynchronous mapping process, to actually wait
* until the window has been mapped and exposed, use waitTestWindows().
*/
function createTestWindow(params) {
async function createTestWindow(params) {
params = Params.parse(params, {
width: 640,
height: 480,
@ -110,7 +109,7 @@ function createTestWindow(params) {
textInput: false,
});
let perfHelper = _getPerfHelper();
let perfHelper = await _getPerfHelper();
perfHelper.CreateWindowAsync(
params.width, params.height,
params.alpha, params.maximized,
@ -124,8 +123,8 @@ function createTestWindow(params) {
* Used within an automation script to pause until all windows previously
* created with createTestWindow have been mapped and exposed.
*/
function waitTestWindows() {
let perfHelper = _getPerfHelper();
async function waitTestWindows() {
let perfHelper = await _getPerfHelper();
return perfHelper.WaitWindowsAsync().catch(logError);
}
@ -139,8 +138,8 @@ function waitTestWindows() {
* this doesn't guarantee that Mutter has actually finished the destroy
* process because of normal X asynchronicity.
*/
function destroyTestWindows() {
let perfHelper = _getPerfHelper();
async function destroyTestWindows() {
let perfHelper = await _getPerfHelper();
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
* running until something else makes it exit, e.g. the Wayland socket closing.
*/
function disableHelperAutoExit() {
let perfHelper = _getPerfHelper();
async function disableHelperAutoExit() {
let perfHelper = await _getPerfHelper();
perfHelper._autoExit = false;
}
@ -301,7 +300,7 @@ async function _runPerfScript(scriptModule, outputFile) {
}
try {
const perfHelper = _getPerfHelper();
const perfHelper = await _getPerfHelper();
if (perfHelper._autoExit)
perfHelper.ExitSync();
} catch (err) {