Unable to restore window streams
I'm unable to restore streams when sharing just an application window. This is because the list of windows in ShellIntrospect
gets destroyed when the last listener goes away, in this case ScreenCastWidget.
This is because:
- You create a new
ShellIntrospect
object inscreen_cast_init()
call, but you don't list it as a listener. - First portal dialog is created where
ScreenCastWidget
is used and listed as listener inShellIntrospect
object. - User confirms the dialog and
ScreenCastWidget
gets destroyed, callingshell_introspect_unref_listeners()
causing the list of windows to be cleared when there are no other listeners - Trying again to share a screen using the restoration option to get the previously shared windows back, you will get an empty list from
shell_introspect_get_windows()
as the list was cleared when the previous portal dialog was destroyed and therefore there is no matching window to be restored.
I don't know what would be the best fix to this, I just tried avoiding to clear the list of windows and it makes it work for me.
Solutions that come to my mind:
- Do not clear the list of windows (this worked for me). But we would need to make sure to sync it everytime for newly created portal dialogs as the list wouldn't be updated, but it is perfectly fine to keep it outdated for the restoration option as we will be looking for a window that was already present in the list.
diff --git a/src/shellintrospect.c b/src/shellintrospect.c
index 6b007b4..e6cb798 100644
--- a/src/shellintrospect.c
+++ b/src/shellintrospect.c
@@ -170,12 +170,6 @@ shell_introspect_unref_listeners (ShellIntrospect *shell_introspect)
g_return_if_fail (shell_introspect->num_listeners > 0);
shell_introspect->num_listeners--;
- if (shell_introspect->num_listeners == 0)
- {
- g_list_free_full (shell_introspect->windows,
- (GDestroyNotify) window_free);
- shell_introspect->windows = NULL;
- }
}
gboolean
- When creating
ShellIntrospect
inscreen_cast_init()
increment number of listeners. - Sync the state before we try to find matching window, but given it's an async call, it wouldn't probably work.
I'm leaving the fix to you as you know the internals better than me.
Thanks.
Edited by Jan Grulich