Tk Source Code

View Ticket
Login
Ticket UUID: 73ba07efcd3834adcebed93f2a3d289ebc2369ea
Title: Use correct property type when handling MULTIPLE conversion requests
Type: Patch Version:
Submitter: dpb Created on: 2017-08-22 19:52:58
Subsystem: 53. [selection] Assigned To: fvogel
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2017-11-19 20:53:12
Resolution: Fixed Closed By: fvogel
    Closed on: 2017-11-19 20:53:12
Description:

Per the ICCCM, the type of the property used for selection conversions for target MULTIPLE is ATOM_PAIR. Tk, however, expects it to have type ATOM. This means that Tk will always fail all MULTIPLE conversion requests from ICCCM-compliant requestors.

This can be shown by running this program while using GNOME:

proc get_clip {offset maxChars} { return abcd }

selection handle -selection CLIPBOARD . get_clip selection own -selection CLIPBOARD .

# see https://www.freedesktop.org/wiki/ClipboardManager/ selection get -selection CLIPBOARD_MANAGER -type SAVE_TARGETS exit

Currently, this results in the following error:

Error in startup script: CLIPBOARD_MANAGER selection doesn't exist or form "SAVE_TARGETS" not defined
    while executing
"selection get -selection CLIPBOARD_MANAGER -type SAVE_TARGETS"
    (file "test.tcl" line 7)

The reason is that gnome-settings-daemon (which handles the SAVE_TARGETS request) sends a MULTIPLE request back, and when that fails, the SAVE_TARGETS request fails too. (Also, on my machine this causes GSD to stop answering any further SAVE_TARGETS requests; you can run killall gsd-clipboard to reset it. I don't know what's up with that.)

I'm attaching a patch that makes Tk use the correct property type. With the patch, running the test program produces no output and, after it exits, the string "abcd" remains in the clipboard.

User Comments: fvogel added on 2017-11-19 20:53:12:
Merged to core-8-6-branch and trunk.

Many thanks for your clear report, for providing the patch, and for your help in showing me the bug and in designing the test case.

dpb added on 2017-11-14 20:50:27:

For reference, I've also submitted a patch for gnome-settings-daemon to fix the problem that necessitates restarting it after this test case fails: 790344.


fvogel added on 2017-11-14 07:06:31:
Thanks, I have changed the expected result accordingly.

dpb added on 2017-11-13 21:38:28:

FWIW, I wouldn't include the NULL that you get from the SAVE_TARGETS request into res. The spec doesn't say what value the clipboard manager should return, and it's not a particularly meaningful value in any case.


fvogel added on 2017-11-13 20:47:08:

I have now checked that the (just modified) test select-14.1 correctly:

- gets skipped on Linux Debian 8 with KDE

- passes on Linux Debian 8 with Gnome at the current state of the bugfix branch bug-73ba07efcd

- fails on Linux Debian 8 with Gnome at the current state of the bugfix branch bug-73ba07efcd if the fix [0bea063c] is reverted

So the fix is efficient (consistent with the added testcase), and the test is run or skipped when appropriate.


fvogel added on 2017-11-12 20:26:40:
I have added test select-14.1, constrained by a new testConstraint "cliboardManagerPresent".

This new test is correctly skipped on Windows and macOS.

I still need to check that it is also skipped on Linux/KDE and that it runs successfully on Linux/Gnome.

dpb added on 2017-11-11 22:38:24:

You can check whether a clipboard manager is present by running selection get -selection CLIPBOARD_MANAGER -type TARGETS and checking whether the result contains SAVE_TARGETS.


fvogel added on 2017-11-05 08:18:44:
gnome-settings-daemon was split into into separate helper daemons since 3.23.2, this is from:
https://git.gnome.org/browse/gnome-settings-daemon/tree/NEWS

Since I have 3.14, I guess that gnome-settings-daemon should be the process to use here.

So...:

- fossil update core-8-6-branch

- compile, install

- paste test script in wish --> CLIPBOARD_MANAGER selection doesn't exist or form "SAVE_TARGETS" not defined

- killall gnome-settings-daemon

- fossil update bug-73ba07efcd

- compile install

- paste test script in wish --> no error anymore! It prints NULL

- exit wish

- paste somewhere --> the string 'abcd' is pasted


Conclusion: yes, I have now seen the fix in action.

I will merge soon. I have first to think about using your script as a test case. This looks easy, the problem is how to make this test run only when the required feature of the clipboard manager is available.

fvogel added on 2017-11-05 08:05:04:

$ ls /usr/lib/gnome-settings-daemon
gnome-settings-daemon             gsd-printer             gsd-test-housekeeping  gsd-test-orientation          gsd-test-sound      gsd-test-xsettings
gnome-settings-daemon-localeexec  gsd-test-a11y-keyboard  gsd-test-input-helper  gsd-test-print-notifications  gsd-test-updates    gsd-wacom-led-helper
gsd-backlight-helper              gsd-test-a11y-settings  gsd-test-keyboard      gsd-test-rfkill               gsd-test-wacom      gsd-wacom-oled-helper
gsd-list-wacom                    gsd-test-cursor         gsd-test-media-keys    gsd-test-screensaver-proxy    gsd-test-wacom-osd
gsd-locate-pointer                gsd-test-datetime       gsd-test-mouse         gsd-test-smartcard            gsd-test-xrandr

No gsd-clipboard in qight.


fvogel added on 2017-11-05 07:59:38:

Despite gnome-settings-daemon is installed on my systm (Linux Debian 8 here):

# dpkg -l | grep gnome-settings
ii  gnome-settings-daemon                  3.14.2-3+deb8u1                            amd64        daemon handling the GNOME session settings

it seems that gsd-clipboard does not run:

$ ps -ef | grep gsd
francois  5309     1  0 08:32 ?        00:00:00 /usr/lib/gnome-settings-daemon/gsd-printer
francois  8939  6087  0 08:56 pts/1    00:00:00 grep gsd

Do I have to start it manually? If so, how?


dpb added on 2017-11-05 01:12:51:

Sorry; it appears that I don't get email notifications for this ticket, so I didn't see your replies...

Anyway, the test script will only work properly if run when a clipboard manager implementing the fd.o clipboard manager specification is present, which is not going to be the case on Windows or OS X. I think KDE's clipboard manager (Klipper) doesn't implement that spec, so it's not going to work on KDE either.

However, it should work on GNOME, since GNOME Settings Daemon (specifically, the gsd-clipboard process) does implement the fd.o spec. Can you test again, and before you run the test with my patch applied, 1) check if gsd-clipboard is running, and 2) kill it (it'll start back up automatically) to make sure it's in a good state?


fvogel added on 2017-09-16 14:12:49:
I have checked all this once more and I confirm. The patch does not seem to change anything for me with either KDE or Gnome. The same error message is still present.

ping...?

fvogel added on 2017-09-03 07:22:30:
I have installed gnome in addition to kde on m Linux box, and have started a session using gnome. The patch does not change the behavior for me, even with gnome.

fvogel added on 2017-09-02 19:08:56:
Digging in the code it appears that, on anything else than Linux, only the XA_STRING atom from the CLIPBOARD selection is supported. Running the given example code is meaningless on Windows or OS X.

Now on Linux, the proposed fix does not work with KDE. The same error message is still present. Is this expected? Would this only work with gnome?

fvogel added on 2017-09-02 17:09:51:
And there is the same problem on OS X too.

fvogel added on 2017-09-02 13:43:04:
I see the same error on Windows as well, any hint for finxing that platform too perhaps?

fvogel added on 2017-09-02 13:34:38:

Thank you very much for the report and even more for the patch. I have committed your patch to branch bug-73ba07efcd.

I see the problem using your example script on Debian with KDE too. I will turn this into a test for the non-regression testsuite.


Attachments: