[xdg-desktop-portal-gnome/gbsneto/window-restore: 5/6] shellintrospection: Handle multiple calls to sync_state()
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [xdg-desktop-portal-gnome/gbsneto/window-restore: 5/6] shellintrospection: Handle multiple calls to sync_state()
- Date: Fri, 5 Aug 2022 01:41:28 +0000 (UTC)
commit f8ea902c4219d11ed424734875ff14282f26882e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Aug 4 22:37:40 2022 -0300
shellintrospection: Handle multiple calls to sync_state()
Internally, whenever multiple callers call into sync_state(),
ShellIntrospection would perform as many separate operations
as the number of calls. This is not optimal.
Cancel ongoing calls to GetWindows() before calling it again.
src/shellintrospect.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/shellintrospect.c b/src/shellintrospect.c
index 8922d4e..8a81086 100644
--- a/src/shellintrospect.c
+++ b/src/shellintrospect.c
@@ -83,12 +83,15 @@ get_windows_cb (GObject *source_object,
uint64_t id;
GVariant *params = NULL;
+ g_clear_object (&shell_introspect->cancellable);
+
if (!org_gnome_shell_introspect_call_get_windows_finish (shell_introspect->proxy,
&windows_variant,
res,
&error))
{
- g_warning ("Failed to get window list: %s", error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to get window list: %s", error->message);
return;
}
@@ -128,6 +131,10 @@ sync_state (ShellIntrospect *shell_introspect)
{
g_clear_pointer (&shell_introspect->windows, g_ptr_array_unref);
+ g_cancellable_cancel (shell_introspect->cancellable);
+ g_clear_object (&shell_introspect->cancellable);
+ shell_introspect->cancellable = g_cancellable_new ();
+
org_gnome_shell_introspect_call_get_windows (shell_introspect->proxy,
shell_introspect->cancellable,
get_windows_cb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]