Skip to content

Commit

Permalink
#812 pass in the maximum size when calling XGetWindowProperty so we c…
Browse files Browse the repository at this point in the history
…an use large sizes with the clipboard requests

git-svn-id: https://xpra.org/svn/Xpra/trunk@22368 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 9, 2019
1 parent 1b96a20 commit a91b971
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/xpra/x11/bindings/window_bindings.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -940,14 +940,11 @@ cdef class _X11WindowBindings(_X11CoreBindings):
self.addXSelectInput(xwindow, FocusChangeMask)


def XGetWindowProperty(self, Window xwindow, property, req_type=0, etype=None):
def XGetWindowProperty(self, Window xwindow, property, req_type=None, etype=None, int buffer_size=64*1024):
# NB: Accepts req_type == 0 for AnyPropertyType
# "64k is enough for anybody"
# (Except, I've found window icons that are strictly larger)
self.context_check()
cdef int buffer_size = 64 * 1024
if etype=="icons":
buffer_size = 4 * 1024 * 1024
cdef Atom xactual_type = <Atom> 0
cdef int actual_format = 0
cdef unsigned long nitems = 0, bytes_after = 0
Expand Down
7 changes: 4 additions & 3 deletions src/xpra/x11/gtk_x11/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ def _clipboard_got_contents(self, request_id, dtype=None, dformat=None, data=Non
proxy.got_contents(target, dtype, dformat, data)


def _do_munge_raw_selection_to_wire(self, target, dtype, dformat, data):
def _munge_raw_selection_to_wire(self, target, dtype, dformat, data):
if dformat==32 and dtype in (b"ATOM", b"ATOM_PAIR"):
return "atoms", xatoms_to_strings(data)
return ClipboardProtocolHelperCore._do_munge_raw_selection_to_wire(self, target, dtype, dformat, data)
return ClipboardProtocolHelperCore._munge_raw_selection_to_wire(self, target, dtype, dformat, data)

def _munge_wire_selection_to_raw(self, encoding, dtype, dformat, data):
if dtype==b"ATOM":
Expand Down Expand Up @@ -526,7 +526,8 @@ def do_property_notify(self, event):
try:
with xsync:
dtype, dformat = X11Window.GetWindowPropertyType(self.xid, event.atom)
data = X11Window.XGetWindowProperty(self.xid, event.atom, dtype)
MAX_DATA_SIZE = 4*1024*1024
data = X11Window.XGetWindowProperty(self.xid, event.atom, dtype, None, MAX_DATA_SIZE)
X11Window.XDeleteProperty(self.xid, event.atom)
except PropertyError:
log("do_property_notify() property '%s' is gone?", event.atom, exc_info=True)
Expand Down
5 changes: 3 additions & 2 deletions src/xpra/x11/gtk_x11/prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import struct

from xpra.x11.prop_conv import prop_encode, prop_decode, unsupported, PROP_TYPES
from xpra.x11.prop_conv import prop_encode, prop_decode, unsupported, PROP_TYPES, PROP_SIZES
from xpra.gtk_common.gobject_compat import import_gtk, import_gdk
from xpra.x11.gtk_x11.gdk_bindings import (
get_pywindow, #@UnresolvedImport
Expand Down Expand Up @@ -139,8 +139,9 @@ def prop_get(target, key, etype, ignore_errors=False, raise_xerrors=False):
scalar_type = etype
atom = PROP_TYPES[scalar_type][1]
try:
buffer_size = PROP_SIZES.get(scalar_type, 64*1024)
with XSyncContext():
data = X11Window.XGetWindowProperty(get_xwindow(target), key, atom, etype)
data = X11Window.XGetWindowProperty(get_xwindow(target), key, atom, etype, buffer_size)
if data is None:
if not ignore_errors:
log("Missing property %s (%s)", key, etype)
Expand Down
4 changes: 4 additions & 0 deletions src/xpra/x11/prop_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ def _from_utf8(_disp, v):
unsupported, NetWMIcons, None),
}

PROP_SIZES = {
"icons" : 4*1024*1024,
}


def prop_encode(disp, etype, value):
if isinstance(etype, (list, tuple)):
Expand Down

0 comments on commit a91b971

Please sign in to comment.