# HG changeset patch
# User Goffi <goffi@goffi.org>
# Date 1705617089 -3600
# Node ID 644a8d165e5a10e15c32fe357b5f959b070b5681
# Parent  290b405940b592abcbfb41da915a1d70a4931ad9
plugin calls: use the new binding feature of webrtc module:

the new binding feature is used to update the "Desktop" button if sharing is cancelled by
user, or stopped somehow.

rel 434

diff -r 290b405940b5 -r 644a8d165e5a libervia/desktop_kivy/plugins/plugin_wid_calls.py
--- a/libervia/desktop_kivy/plugins/plugin_wid_calls.py	Tue Jan 16 15:00:23 2024 +0100
+++ b/libervia/desktop_kivy/plugins/plugin_wid_calls.py	Thu Jan 18 23:31:29 2024 +0100
@@ -106,7 +106,7 @@
     PROXIED_PROPERTIES = {
         'audio_muted', 'callee', 'desktop_sharing', 'sid', 'video_muted', 'desktop_sharing_data'
     }
-    PROXIED_METHODS = {'answer_call', 'end_call', 'on_accepted_call', 'on_ice_candidates_new', 'setup_call', 'start_pipeline'}
+    PROXIED_METHODS = {'answer_call', 'bind', 'end_call', 'on_accepted_call', 'on_ice_candidates_new', 'setup_call', 'start_pipeline'}
 
     def __init__(self, parent_calls: "Calls", profile: str) -> None:
         self.parent_calls = parent_calls
@@ -243,6 +243,7 @@
             if buf is not None and mapinfo is not None:
                 buf.unmap(mapinfo)
 
+
 class WindowSelectButton(Button):
     pass
 
@@ -301,6 +302,9 @@
         )
         self.header_input_add_extra(call_btn)
         self.webrtc = WebRTC(self, self.profile)
+        self.webrtc.bind(
+            desktop_sharing=partial(setattr, self, "desktop_sharing")
+        )
         self.previous_fullscreen = None
         self.reset_instance()
 
@@ -419,7 +423,10 @@
         if self.desktop_sharing:
             self.desktop_sharing = False
         else:
-            DesktopScreenDialog(self).open()
+            if display_servers.detect() == display_servers.X11:
+                DesktopScreenDialog(self).open()
+            else:
+                self.desktop_sharing = True
 
     def on_desktop_sharing(self, instance, active: bool) -> None:
         self.webrtc.desktop_sharing = active