# HG changeset patch # User Sam Lantinga # Date 1278920966 25200 # Node ID 8e91c39472102f528b4a9a12eebd90418a4a1df5 # Parent 15d2c6f40c4880dce79a5dd235228800b737eb06 Made it possible to switch the text format in one place diff -r 15d2c6f40c48 -r 8e91c3947210 src/video/x11/SDL_x11clipboard.c --- a/src/video/x11/SDL_x11clipboard.c Mon Jul 12 00:36:55 2010 -0700 +++ b/src/video/x11/SDL_x11clipboard.c Mon Jul 12 00:49:26 2010 -0700 @@ -27,6 +27,13 @@ #include "SDL_x11video.h" +/* If you don't support UTF-8, you might use XA_STRING here */ +#if 1 +#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False) +#else +#define TEXT_FORMAT XA_STRING +#endif + /* Get any application owned window handle for clipboard association */ static Window GetWindow(_THIS) @@ -58,8 +65,8 @@ return -1; } - /* If you don't support UTF-8, you might use XA_STRING here */ - format = XInternAtom(display, "UTF8_STRING", False); + /* Save the selection on the root window */ + format = TEXT_FORMAT; XChangeProperty(display, DefaultRootWindow(display), XA_CUT_BUFFER0, format, 8, PropModeReplace, (const unsigned char *)text, SDL_strlen(text)); @@ -88,12 +95,9 @@ text = NULL; - /* Get the SDL window that will own the selection */ + /* Get the window that holds the selection */ window = GetWindow(_this); - - /* If you don't support UTF-8, you might use XA_STRING here */ - format = XInternAtom(display, "UTF8_STRING", False); - + format = TEXT_FORMAT; owner = XGetSelectionOwner(display, XA_PRIMARY); if ((owner == None) || (owner == window)) { owner = DefaultRootWindow(display);