use SDL2 clipboard (not with Win32)
This commit is contained in:
parent
0843bd6a3c
commit
8ec57abf88
@ -407,8 +407,22 @@ bye:
|
|||||||
if (unicode)
|
if (unicode)
|
||||||
*unicode = NULL;
|
*unicode = NULL;
|
||||||
return haiku_get_clipboard();
|
return haiku_get_clipboard();
|
||||||
#elif defined(USE_X11) || defined(__macosx__)
|
#elif defined(USE_X11) || defined(__macosx__) || defined(USE_SDL2)
|
||||||
#if defined(USE_X11)
|
if (unicode)
|
||||||
|
*unicode = NULL;
|
||||||
|
#if defined(USE_SDL2)
|
||||||
|
if (!SDL_HasClipboardText())
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char * utf8_str = SDL_GetClipboardText();
|
||||||
|
if (utf8_str != NULL)
|
||||||
|
{
|
||||||
|
#elif defined(USE_X11)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
Atom selection = XInternAtom(X11_display, "CLIPBOARD", False);
|
Atom selection = XInternAtom(X11_display, "CLIPBOARD", False);
|
||||||
Window selection_owner = XGetSelectionOwner(X11_display, selection);
|
Window selection_owner = XGetSelectionOwner(X11_display, selection);
|
||||||
|
|
||||||
@ -417,14 +431,13 @@ bye:
|
|||||||
selection = XInternAtom(X11_display, "PRIMARY", False);
|
selection = XInternAtom(X11_display, "PRIMARY", False);
|
||||||
selection_owner = XGetSelectionOwner(X11_display, selection);
|
selection_owner = XGetSelectionOwner(X11_display, selection);
|
||||||
}
|
}
|
||||||
if (unicode)
|
if (selection_owner == None)
|
||||||
*unicode = NULL;
|
return NULL;
|
||||||
if (selection_owner != None)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
XConvertSelection(X11_display, selection, XInternAtom(X11_display, "UTF8_STRING", False),
|
XConvertSelection(X11_display, selection, XInternAtom(X11_display, "UTF8_STRING", False),
|
||||||
XInternAtom(X11_display, "GFX2_CLIP", False), /* Property */
|
XInternAtom(X11_display, "GFX2_CLIP", False), /* Property */
|
||||||
X11_window, CurrentTime);
|
X11_window, CurrentTime);
|
||||||
|
// wait for the event to be received
|
||||||
for(i = 0; X11_clipboard == NULL && i < 10; i++)
|
for(i = 0; X11_clipboard == NULL && i < 10; i++)
|
||||||
{
|
{
|
||||||
Get_input(20);
|
Get_input(20);
|
||||||
@ -485,6 +498,8 @@ bye:
|
|||||||
*output = '\0';
|
*output = '\0';
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
free(utf8_str);
|
free(utf8_str);
|
||||||
|
#elif defined(USE_SDL2)
|
||||||
|
SDL_free(utf8_str);
|
||||||
#endif
|
#endif
|
||||||
return ansi_str;
|
return ansi_str;
|
||||||
}
|
}
|
||||||
@ -500,6 +515,12 @@ bye:
|
|||||||
// return the uf8_string, that's better than nothing
|
// return the uf8_string, that's better than nothing
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
return utf8_str;
|
return utf8_str;
|
||||||
|
#elif defined(USE_SDL2)
|
||||||
|
{
|
||||||
|
char * return_str = strdup(utf8_str);
|
||||||
|
SDL_free(utf8_str);
|
||||||
|
return return_str;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
return strdup(utf8_str);
|
return strdup(utf8_str);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user