def destroy_window(self, wid, window): #override so we can cleanup the group-leader if needed: GTKXpraClient.destroy_window(self, wid, window) group_leader = window.group_leader if group_leader is None or len(self._group_leader_wids)==0: return wids = self._group_leader_wids.get(group_leader) if wids is None: #not recorded any window ids on this group leader #means it is another managed window, leave it alone return if wid in wids: wids.remove(wid) if len(wids)>0: #still has another window pointing to it return #the last window has gone, we can remove the group leader, #find all the references to this group leader: refs = [] for ref, gl in self._ref_to_group_leader.items(): if gl==group_leader: refs.append(ref) for ref in refs: del self._ref_to_group_leader[ref] log("last window for refs %s is gone, destroying the group leader %s", refs, group_leader) group_leader.destroy()
def destroy_window(self, wid, window): #override so we can cleanup the group-leader if needed: GTKXpraClient.destroy_window(self, wid, window) group_leader = window.group_leader if group_leader is None or len(self._group_leader_wids) == 0: return wids = self._group_leader_wids.get(group_leader) if wids is None: #not recorded any window ids on this group leader #means it is another managed window, leave it alone return if wid in wids: wids.remove(wid) if len(wids) > 0: #still has another window pointing to it return #the last window has gone, we can remove the group leader, #find all the references to this group leader: refs = [] for ref, gl in self._ref_to_group_leader.items(): if gl == group_leader: refs.append(ref) for ref in refs: del self._ref_to_group_leader[ref] log("last window for refs %s is gone, destroying the group leader %s", refs, group_leader) group_leader.destroy()
def init(self, opts): GTKXpraClient.init(self, opts) if opts.window_layout: assert opts.window_layout in WINDOW_LAYOUTS self.ClientWindowClass = WINDOW_LAYOUTS.get(opts.window_layout) else: self.ClientWindowClass = ClientWindow log("init(..) ClientWindowClass=%s", self.ClientWindowClass)
def __init__(self): GTKXpraClient.__init__(self) self.border = None self.local_clipboard_requests = 0 self.remote_clipboard_requests = 0 self._ref_to_group_leader = {} self._group_leader_wids = {}
def init(self, opts): GTKXpraClient.init(self, opts) self.ClientWindowClass = BorderClientWindow self.remote_clipboard = opts.remote_clipboard self.local_clipboard = opts.local_clipboard log("init(..) ClientWindowClass=%s", self.ClientWindowClass) from xpra.platform.ui_thread_watcher import get_UI_watcher self.UI_watcher = get_UI_watcher(self.timeout_add)
def __init__(self): GTKXpraClient.__init__(self) self.UI_watcher = None self.border = None self.local_clipboard_requests = 0 self.remote_clipboard_requests = 0 #only used with the translated clipboard class: self.local_clipboard = "" self.remote_clipboard = ""
def process_ui_capabilities(self): GTKXpraClient.process_ui_capabilities(self) self.UI_watcher.start() #if server supports it, enable UI thread monitoring workaround when needed: def UI_resumed(): self.send("resume", True, self._id_to_window.keys()) def UI_failed(): self.send("suspend", True, self._id_to_window.keys()) self.UI_watcher.add_resume_callback(UI_resumed) self.UI_watcher.add_fail_callback(UI_failed)
def init(self, opts): GTKXpraClient.init(self, opts) if opts.window_layout: assert opts.window_layout in WINDOW_LAYOUTS self.ClientWindowClass = WINDOW_LAYOUTS.get(opts.window_layout) if self.ClientWindowClass: log.info("window layout '%s' specified, disabling OpenGL", opts.window_layout) opts.opengl = False else: self.ClientWindowClass = BorderClientWindow log("init(..) ClientWindowClass=%s", self.ClientWindowClass)
def __init__(self): GTKXpraClient.__init__(self) self.GLClientWindowClass = None self.local_clipboard_requests = 0 self.remote_clipboard_requests = 0 #avoid ugly "not implemented" warning on win32 self.supports_group_leader = not sys.platform.startswith("win") self._ref_to_group_leader = {} self._group_leader_wids = {}
def make_hello(self): capabilities = GTKXpraClient.make_hello(self) capabilities["encoding.supports_delta"] = [ x for x in ("png", "rgb24", "rgb32") if x in self.get_core_encodings() ] capabilities["pointer.grabs"] = True return capabilities
def get_notifier_classes(self): ncs = GTKXpraClient.get_notifier_classes(self) try: from xpra.client.gtk3.gtk3_notifier import GTK3_Notifier ncs.append(GTK3_Notifier) except Exception, e: log("cannot load GTK3 notifier: %s", e)
def get_notifier_classes(self): ncs = GTKXpraClient.get_notifier_classes(self) try: from xpra.client.gtk2.gtk2_notifier import GTK2_Notifier ncs.append(GTK2_Notifier) except Exception, e: log.warn("cannot load GTK2 notifier: %s", e)
def get_notifier_classes(self): ncs = GTKXpraClient.get_notifier_classes(self) try: from xpra.client.gtk2.gtk2_notifier import GTK2_Notifier ncs.append(GTK2_Notifier) except Exception as e: log.warn("cannot load GTK2 notifier: %s", e) return ncs
def process_ui_capabilities(self, capabilities): GTKXpraClient.process_ui_capabilities(self, capabilities) if self.server_randr: display = gdk.display_get_default() i=0 while i<display.get_n_screens(): screen = display.get_screen(i) screen.connect("size-changed", self._screen_size_changed) i += 1 #if server supports it, enable UI thread monitoring workaround when needed: if self.suspend_resume and (sys.platform.startswith("darwin") or FAKE_UI_LOCKUPS>0): self.start_UI_thread_polling() if FAKE_UI_LOCKUPS>0: def sleep_in_ui_thread(*args): time.sleep(FAKE_UI_LOCKUPS) return True gobject.timeout_add((10+FAKE_UI_LOCKUPS)*1000, sleep_in_ui_thread)
def make_hello(self, challenge_response=None): capabilities = GTKXpraClient.make_hello(self, challenge_response) if xor_str is not None: capabilities["encoding.supports_delta"] = [ x for x in ("rgb24", "rgb32") if x in self.get_core_encodings() ] return capabilities
def do_get_core_encodings(self): cencs = GTKXpraClient.do_get_core_encodings(self) for x in ("webp", ): if x in cencs: cencs.remove(x) #for some reason, the cairo_workaround does not work for ARGB32 #cencs.append("rgb32") return cencs
def do_get_core_encodings(self): encodings = GTKXpraClient.do_get_core_encodings(self) #we can handle rgb32 format (but not necessarily transparency!) def add(x): if x in self.allowed_encodings and x not in encodings: encodings.append(x) add("rgb32") return encodings
def make_hello(self): #see http://xpra.org/trac/ticket/640#comment:43 log.error("this client is fundamentally broken - do not use") capabilities = GTKXpraClient.make_hello(self) capabilities["encoding.supports_delta"] = [ x for x in ("rgb24", "rgb32") if x in self.get_core_encodings() ] return capabilities
def get_notifier_classes(self): ncs = GTKXpraClient.get_notifier_classes(self) if not WIN32: #for some reason, not included in win32 builds? try: from xpra.client.gtk3.gtk3_notifier import GTK3_Notifier ncs.append(GTK3_Notifier) except Exception, e: log("failed to load the GTK3 notification class: %s", e)
def get_notifier_classes(self): ncs = GTKXpraClient.get_notifier_classes(self) if not OSX: try: from xpra.client.gtk3.gtk3_notifier import GTK3_Notifier ncs.append(GTK3_Notifier) except Exception as e: log.warn("Warning: failed to load the GTK3 notification class") log.warn(" %s", e) return ncs
def process_ui_capabilities(self, capabilities): GTKXpraClient.process_ui_capabilities(self, capabilities) if self.server_randr: display = gdk.display_get_default() i=0 while i<display.get_n_screens(): screen = display.get_screen(i) screen.connect("size-changed", self.screen_size_changed) i += 1 global UI_watcher UI_watcher.start() #if server supports it, enable UI thread monitoring workaround when needed: if self.suspend_resume: def UI_resumed(): self.send("resume", True, self._id_to_window.keys()) def UI_failed(): self.send("suspend", True, self._id_to_window.keys()) UI_watcher.add_resume_callback(UI_resumed) UI_watcher.add_fail_callback(UI_failed)
def process_ui_capabilities(self, capabilities): GTKXpraClient.process_ui_capabilities(self, capabilities) if self.server_randr: display = gdk.display_get_default() i = 0 while i < display.get_n_screens(): screen = display.get_screen(i) screen.connect("size-changed", self.screen_size_changed) i += 1 global UI_watcher UI_watcher.start() #if server supports it, enable UI thread monitoring workaround when needed: if self.suspend_resume: def UI_resumed(): self.send("resume", True, self._id_to_window.keys()) def UI_failed(): self.send("suspend", True, self._id_to_window.keys()) UI_watcher.add_resume_callback(UI_resumed) UI_watcher.add_fail_callback(UI_failed)
def do_get_core_encodings(self): encodings = GTKXpraClient.do_get_core_encodings(self) if self.has_transparency(): try: #to unpremultiply rgb32 data from xpra.codecs.argb.argb import unpremultiply_argb_in_place #@UnresolvedImport assert unpremultiply_argb_in_place encodings.append("rgb32") except: pass #gtk2 can handle 'png' and 'jpeg' natively (without PIL) #(though using PIL is better since we can do that in the decode thread) for x in ("png", "jpeg"): if x not in encodings: encodings.append(x) return encodings
def get_core_encodings(self): encodings = GTKXpraClient.get_core_encodings(self) if gdk.screen_get_default().get_rgba_visual() is not None: try: #check for bytearray which is used by PixmapBacking #to unpremultiply rgb32 data bytearray("") from xpra.codecs.argb.argb import unpremultiply_argb_in_place assert unpremultiply_argb_in_place encodings.append("rgb32") except: pass #gtk2 can handle 'png' and 'jpeg' natively (without PIL) #(though using PIL is better since we can do that in the decode thread) for x in ("png", "jpeg"): if x not in encodings: encodings.append(x) return encodings
def make_new_window(self, *args): w = GTKXpraClient.make_new_window(self, *args) if w: w.border = self.border return w
def cleanup(self): uw = self.UI_watcher if uw: self.UI_watcher = None uw.stop() GTKXpraClient.cleanup(self)
def set_windows_cursor(self, windows, cursor_data): #avoid buggy win32 version: if not WIN32: GTKXpraClient.set_windows_cursor(self, windows, cursor_data)
def get_tray_menu_helper_classes(self): tmhc = GTKXpraClient.get_tray_menu_helper_classes(self) tmhc.append(GTK3TrayMenu) return tmhc
def get_ydpi(self): ydpi = GTKXpraClient.get_ydpi(self) if ydpi > 0: return ydpi return Gdk.Screen.get_default().get_resolution()
def _startup_complete(self, *args): GTKXpraClient._startup_complete(self, *args) gdk.notify_startup_complete()
def get_tray_menu_helper_classes(self): tmhc = GTKXpraClient.get_tray_menu_helper_classes(self) tmhc.append(GTK2TrayMenu) return tmhc
def do_get_core_encodings(self): cencs = GTKXpraClient.do_get_core_encodings(self) for x in ("webp", ): if x in cencs: cencs.remove(x) return cencs
def init_packet_handlers(self): GTKXpraClient.init_packet_handlers(self) self._ui_packet_handlers["pointer-grab"] = self._process_pointer_grab self._ui_packet_handlers[ "pointer-ungrab"] = self._process_pointer_ungrab
def cleanup(self): global UI_watcher UI_watcher.stop() GTKXpraClient.cleanup(self)
def set_windows_cursor(self, windows, cursor_data): #avoid buggy win32 version: if not sys.platform.startswith("win"): GTKXpraClient.set_windows_cursor(self, windows, cursor_data)
def _startup_complete(self, *args): GTKXpraClient._startup_complete(self, *args) gtk.gdk.notify_startup_complete()
def do_get_core_encodings(self): cencs = GTKXpraClient.do_get_core_encodings(self) #we can now paint with alpha via pixbufs: cencs.append("rgb32") return cencs
def init_packet_handlers(self): GTKXpraClient.init_packet_handlers(self) self._ui_packet_handlers["pointer-grab"] = self._process_pointer_grab self._ui_packet_handlers["pointer-ungrab"] = self._process_pointer_ungrab
def make_hello(self): capabilities = GTKXpraClient.make_hello(self) if xor_str is not None: capabilities["encoding.supports_delta"] = [x for x in ("png", "rgb24", "rgb32") if x in self.get_core_encodings()] return capabilities