示例#1
0
 def got_contents(dtype, dformat, data):
     debug("got_contents(%s, %s, %s:%s) data=0x%s..", dtype, dformat,
           type(data), len(data or ""),
           binascii.hexlify(str(data)[:200]))
     if dtype is None or data is None:
         no_contents()
         return
     munged = self._munge_raw_selection_to_wire(target, dtype, dformat,
                                                data)
     wire_encoding, wire_data = munged
     debug("clipboard raw -> wire: %r -> %r", (dtype, dformat, data),
           munged)
     if wire_encoding is None:
         no_contents()
         return
     if len(wire_data) > 256:
         wire_data = zlib_compress(
             "clipboard: %s / %s" % (dtype, dformat), wire_data)
         if len(wire_data) > self.max_clipboard_packet_size:
             log.warn(
                 "even compressed, clipboard contents are too big and have not been sent:"
                 " %s compressed bytes dropped (maximum is %s)",
                 len(wire_data), self.max_clipboard_packet_size)
             no_contents()
             return
     self.send("clipboard-contents", request_id, selection, dtype,
               dformat, wire_encoding, wire_data)
示例#2
0
 def got_contents(dtype, dformat, data):
     debug("got_contents(%s, %s, %s:%s) data=0x%s..",
           dtype, dformat, type(data), len(data or ""), binascii.hexlify(str(data)[:200]))
     if dtype is None or data is None:
         no_contents()
         return
     munged = self._munge_raw_selection_to_wire(target, dtype, dformat, data)
     wire_encoding, wire_data = munged
     debug("clipboard raw -> wire: %r -> %r", (dtype, dformat, data), munged)
     if wire_encoding is None:
         no_contents()
         return
     if len(wire_data)>256:
         wire_data = zlib_compress("clipboard: %s / %s" % (dtype, dformat), wire_data)
         if len(wire_data)>self.max_clipboard_packet_size:
             log.warn("even compressed, clipboard contents are too big and have not been sent:"
                      " %s compressed bytes dropped (maximum is %s)", len(wire_data), self.max_clipboard_packet_size)
             no_contents()
             return
     self.send("clipboard-contents", request_id, selection,
                dtype, dformat, wire_encoding, wire_data)
示例#3
0
 def send_cursor(self):
     self.send_cursor_pending = False
     self.cursor_data = X11Keyboard.get_cursor_image()
     if self.cursor_data:
         pixels = self.cursor_data[7]
         log("send_cursor() cursor=%s", self.cursor_data[:7]+["%s bytes" % len(pixels)]+self.cursor_data[8:])
         if self.default_cursor_data and str(pixels)==str(self.default_cursor_data[7]):
             log("send_cursor(): default cursor - clearing it")
             self.cursor_data = None
         elif pixels is not None:
             #convert bytearray to string:
             pixels = str(pixels)
             if len(pixels)<64:
                 self.cursor_data[7] = pixels
             else:
                 self.cursor_data[7] = zlib_compress("cursor", pixels)
     else:
         log("send_cursor() failed to get cursor image")
     for ss in self._server_sources.values():
         ss.send_cursor(self.cursor_data)
     return False