We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1599 - On X11, SDL2 should use CLIPBOARD as well as PRIMARY for copy/paste
Summary: On X11, SDL2 should use CLIPBOARD as well as PRIMARY for copy/paste
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: main (show other bugs)
Version: HG 2.0
Hardware: x86 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-12 13:22 UTC by David White
Modified: 2012-09-14 01:17 UTC (History)
1 user (show)

See Also:


Attachments
Patch to fix SDL_(Set|Get)ClipboardText on Linux (2.58 KB, patch)
2012-09-12 13:22 UTC, David White
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David White 2012-09-12 13:22:52 UTC
Created attachment 948 [details]
Patch to fix SDL_(Set|Get)ClipboardText on Linux

Background: X has two main 'buffers' for copy/paste:

PRIMARY -- normally used for implicit selection of text, with middle-click to paste
CLIPBOARD -- works with an explicit copy/paste like on other platforms.

Currently SDL2 only provides access to PRIMARY. Since CLIPBOARD is much closer to functionality of other platforms, SDL should provide access to that instead.

The attached patch makes it so that SDL_SetClipboardText() sets both PRIMARY and CLIPBOARD and SDL_GetClipboardText() reads from CLIPBOARD instead of primary.

This will make it so that a program implemented on Windows using the clipboard functions will behave naturally on Linux. The existing implementation makes it so a program implemented on Windows behaves strangely on Linux.
Comment 1 Petr Pisar 2012-09-13 00:49:27 UTC
Just a formal remarks:

(1)
--- a/src/video/x11/SDL_x11clipboard.c	Mon Sep 10 20:25:55 2012 -0700
+++ b/src/video/x11/SDL_x11clipboard.c	Wed Sep 12 13:10:44 2012 -0700
@@ -49,29 +49,37 @@ GetWindow(_THIS)
 }
 
 int
 X11_SetClipboardText(_THIS, const char *text)
 {
     Display *display = ((SDL_VideoData *) _this->driverdata)->display;
     Atom format;
     Window window;
+	Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0);
+
+	fprintf(stderr, "SET CLIPBOARD TEXT(%s)\n", text);

I guess the fprintf() should go away.

(2)
The indentation of your patch does not follow current code.
Comment 2 Sam Lantinga 2012-09-14 01:17:15 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/6f52dc57f05e