Skip to content

Commit

Permalink
#1761: better grouping of methods
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@18505 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Feb 21, 2018
1 parent 752d4c1 commit b750f72
Showing 1 changed file with 41 additions and 42 deletions.
83 changes: 41 additions & 42 deletions src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,39 @@ def scale_pointer(self, pointer):
return int(pointer[0]/self.xscale), int(pointer[1]/self.yscale)


def _process_cursor(self, packet):
if not self.cursors_enabled:
return
#trim packet type:
packet = packet[1:]
if len(packet)==1:
#marker telling us to use the default cursor:
new_cursor = packet[0]
else:
if len(packet)<7:
raise Exception("invalid cursor packet: %s items" % len(packet))
#newer versions include the cursor encoding as first argument,
#we know this is it because it will be a string rather than an int:
if type(packet[0]) in (str, bytes):
#we have the encoding in the packet already
new_cursor = packet
else:
#prepend "raw" which is the default
new_cursor = [b"raw"] + packet
encoding = new_cursor[0]
pixels = new_cursor[8]
if encoding==b"png":
from PIL import Image
buf = BytesIOClass(pixels)
img = Image.open(buf)
new_cursor[8] = img.tobytes("raw", "BGRA")
cursorlog("used PIL to convert png cursor to raw")
new_cursor[0] = b"raw"
elif encoding!=b"raw":
cursorlog.warn("Warning: invalid cursor encoding: %s", encoding)
return
self.set_windows_cursor(self._id_to_window.values(), new_cursor)

def reset_cursor(self):
self.set_windows_cursor(self._id_to_window.values(), [])

Expand Down Expand Up @@ -1857,6 +1890,14 @@ def _process_raise_window(self, packet):
#only implemented in gtk2 for now
pass

def _process_bell(self, packet):
if not self.bell_enabled:
return
(wid, device, percent, pitch, duration, bell_class, bell_id, bell_name) = packet[1:9]
window = self._id_to_window.get(wid)
self.window_bell(window, device, percent, pitch, duration, bell_class, bell_id, bell_name)


def _process_configure_override_redirect(self, packet):
wid, x, y, w, h = packet[1:6]
window = self._id_to_window[wid]
Expand Down Expand Up @@ -2167,48 +2208,6 @@ def record_decode_time(success, message=""):
self.idle_add(record_decode_time, False, str(e))
raise

######################################################################
# screen scaling:
def _process_cursor(self, packet):
if not self.cursors_enabled:
return
#trim packet type:
packet = packet[1:]
if len(packet)==1:
#marker telling us to use the default cursor:
new_cursor = packet[0]
else:
if len(packet)<7:
raise Exception("invalid cursor packet: %s items" % len(packet))
#newer versions include the cursor encoding as first argument,
#we know this is it because it will be a string rather than an int:
if type(packet[0]) in (str, bytes):
#we have the encoding in the packet already
new_cursor = packet
else:
#prepend "raw" which is the default
new_cursor = [b"raw"] + packet
encoding = new_cursor[0]
pixels = new_cursor[8]
if encoding==b"png":
from PIL import Image
buf = BytesIOClass(pixels)
img = Image.open(buf)
new_cursor[8] = img.tobytes("raw", "BGRA")
cursorlog("used PIL to convert png cursor to raw")
new_cursor[0] = b"raw"
elif encoding!=b"raw":
cursorlog.warn("Warning: invalid cursor encoding: %s", encoding)
return
self.set_windows_cursor(self._id_to_window.values(), new_cursor)

def _process_bell(self, packet):
if not self.bell_enabled:
return
(wid, device, percent, pitch, duration, bell_class, bell_id, bell_name) = packet[1:9]
window = self._id_to_window.get(wid)
self.window_bell(window, device, percent, pitch, duration, bell_class, bell_id, bell_name)


######################################################################
# system tray:
Expand Down

0 comments on commit b750f72

Please sign in to comment.