Skip to content

Commit

Permalink
* ui client should not know anything about gtk
Browse files Browse the repository at this point in the history
* rely on MRO to use gobject's emit + connect builtin methods (and not our dummy ones in the mixin stub)
* fix clipboard: must send the tokens on start
* consistency: use "hidden" underscore method name for clipboard packet handler

git-svn-id: https://xpra.org/svn/Xpra/trunk@18598 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Feb 25, 2018
1 parent 79daf65 commit 5f8909d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
11 changes: 9 additions & 2 deletions src/xpra/client/gtk_base/gtk_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
get_default_root_window, get_root_size, get_xwindow, image_new_from_stock, \
INTERP_BILINEAR, WINDOW_TOPLEVEL, DIALOG_MODAL, DESTROY_WITH_PARENT, MESSAGE_INFO, BUTTONS_CLOSE, ICON_SIZE_BUTTON, GRAB_STATUS_STRING, \
BUTTON_PRESS_MASK, BUTTON_RELEASE_MASK, POINTER_MOTION_MASK, POINTER_MOTION_HINT_MASK, ENTER_NOTIFY_MASK, LEAVE_NOTIFY_MASK
from xpra.gtk_common.gobject_util import no_arg_signal
from xpra.client.ui_client_base import UIXpraClient
from xpra.client.gobject_client_base import GObjectXpraClient
from xpra.client.client_base import PASSWORD_PROMPT
Expand All @@ -59,8 +60,14 @@
EXPORT_ICON_DATA = envbool("XPRA_EXPORT_ICON_DATA", True)


class GTKXpraClient(UIXpraClient, GObjectXpraClient):
__gsignals__ = UIXpraClient.__gsignals__
class GTKXpraClient(GObjectXpraClient, UIXpraClient):
__gsignals__ = {
"first-ui-received" : no_arg_signal,
"keyboard-sync-toggled" : no_arg_signal,
}
#add signals from super classes (all no-arg signals)
for signal_name in UIXpraClient.__signals__:
__gsignals__[signal_name] = no_arg_signal

ClientWindowClass = None
GLClientWindowClass = None
Expand Down
33 changes: 18 additions & 15 deletions src/xpra/client/mixins/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ def parse_server_capabilities(self):
return True

def process_ui_capabilities(self):
log("process_ui_capabilities() clipboard_enabled=%s", self.clipboard_enabled)
if self.clipboard_enabled:
self.clipboard_helper = self.make_clipboard_helper()
self.clipboard_enabled = self.clipboard_helper is not None
log("clipboard helper=%s", self.clipboard_helper)
if self.clipboard_enabled and self.server_clipboard_enable_selections:
#tell the server about which selections we really want to sync with
#(could have been translated, or limited if the client only has one, etc)
log("clipboard enabled clipboard helper=%s", self.clipboard_helper)
self.send_clipboard_selections(self.clipboard_helper.remote_clipboards)
ch = self.make_clipboard_helper()
self.clipboard_helper = ch
self.clipboard_enabled = ch is not None
log("clipboard helper=%s", ch)
if self.clipboard_enabled:
if self.server_clipboard_enable_selections:
#tell the server about which selections we really want to sync with
#(could have been translated, or limited if the client only has one, etc)
self.send_clipboard_selections(ch.remote_clipboards)
ch.send_all_tokens()
#ui may want to know this is now set:
self.emit("clipboard-toggled")
if self.server_clipboard:
Expand All @@ -118,12 +121,12 @@ def process_ui_capabilities(self):
def init_authenticated_packet_handlers(self):
self.set_packet_handlers(self._ui_packet_handlers, {
"set-clipboard-enabled": self._process_clipboard_enabled_status,
"clipboard-token": self.process_clipboard_packet,
"clipboard-request": self.process_clipboard_packet,
"clipboard-contents": self.process_clipboard_packet,
"clipboard-contents-none": self.process_clipboard_packet,
"clipboard-pending-requests": self.process_clipboard_packet,
"clipboard-enable-selections": self.process_clipboard_packet,
"clipboard-token": self._process_clipboard_packet,
"clipboard-request": self._process_clipboard_packet,
"clipboard-contents": self._process_clipboard_packet,
"clipboard-contents-none": self._process_clipboard_packet,
"clipboard-pending-requests": self._process_clipboard_packet,
"clipboard-enable-selections": self._process_clipboard_packet,
})

def get_clipboard_helper_classes(self):
Expand All @@ -147,7 +150,7 @@ def make_clipboard_helper(self):
log.error("cannot instantiate %s", helperclass, exc_info=True)
return None

def process_clipboard_packet(self, packet):
def _process_clipboard_packet(self, packet):
ch = self.clipboard_helper
log("process_clipboard_packet: %s, helper=%s", packet[0], ch)
if ch:
Expand Down
11 changes: 3 additions & 8 deletions src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
keylog = Logger("client", "keyboard")


from xpra.gtk_common.gobject_util import no_arg_signal
from xpra.client.client_base import XpraClientBase
from xpra.client.keyboard_helper import KeyboardHelper
from xpra.platform import set_name
Expand Down Expand Up @@ -50,14 +49,10 @@ class UIXpraClient(XpraClientBase, DisplayClient, WindowClient, WebcamForwarder,
#NOTE: these signals aren't registered here because this class
#does not extend GObject,
#the gtk client subclasses will take care of it.
__gsignals__ = {
"first-ui-received" : no_arg_signal,
"keyboard-sync-toggled" : no_arg_signal,
}
#add signals from super classes (all no-arg signals)
#these are all "no-arg" signals
__signals__ = ["first-ui-received", "keyboard-sync-toggled"]
for c in (DisplayClient, WindowClient, WebcamForwarder, AudioClient, ClipboardClient, NotificationClient, RPCClient, MmapClient, RemoteLogging, NetworkState, Encodings, TrayClient):
for signal_name in c.__signals__:
__gsignals__[signal_name] = no_arg_signal
__signals__ += c.__signals__

def __init__(self):
log.info("Xpra %s client version %s %i-bit", self.client_toolkit(), full_version_str(), BITS)
Expand Down

0 comments on commit 5f8909d

Please sign in to comment.