Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get and set large picture #25

Open
ZHLONG-CN opened this issue Jan 21, 2025 · 0 comments
Open

Cannot get and set large picture #25

ZHLONG-CN opened this issue Jan 21, 2025 · 0 comments

Comments

@ZHLONG-CN
Copy link

ZHLONG-CN commented Jan 21, 2025

Try to get a 1.3MB picture from clipboard.
Execute the code, I got

>>> import klembord
... klembord.init()
... clipboard = klembord.get(('image/png',))
... print(len(clipboard['image/png'] or ''))  # clipboard['image/png'] is None
0

When get a 3KB picture is ok.

>>> import klembord
... klembord.init()
... clipboard = klembord.get(('image/png',))
... print(len(clipboard['image/png'] or ''))
3136

Try to set 1.3MB picture to clipboard raise an exception.

>>> klembord.set({'image/png': png, 'TEXT': 'abcd'.encode()})
Exception in thread klembord XSetter server:
Traceback (most recent call last):
  File "/usr/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File ".../site-packages/klembord/xclipboard.py", line 221, in serve
    client_prop = process_request(
                  ^^^^^^^^^^^^^^^^
  File ".../site-packages/klembord/xclipboard.py", line 301, in process_request
    client.change_property(
  File ".../site-packages/Xlib/xobject/drawable.py", line 430, in change_property
    request.ChangeProperty(display = self.display,
  File ".../site-packages/Xlib/protocol/rq.py", line 1347, in __init__
    self._binary = self._request.to_binary(*args, **keys)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/Xlib/protocol/rq.py", line 1069, in to_binary
    static_part = struct.pack(self.static_codes, *pack_items)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: 'H' format requires 0 <= number <= 65535

Try to set 3KB picture to clipboard is ok but need time.sleep:

>>> klembord.set({'image/png': png_, 'TEXT': 'abcd'.encode()})
... time.sleep(1)
... clipboard = klembord.get(('image/png',))
... print(len(clipboard['image/png'] or ''))
3136

Without time.sleep, the result turns out abnormal and kinda randomly, I even can't reproduce.

>>> klembord.set({'image/png': png_, 'TEXT': 'abcd'.encode()})
... clipboard = klembord.get(('image/png',))
... print(len(clipboard['image/png'] or ''))
13861
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant