Skip to content
Permalink
Browse files

Make Clipboard_GetText consistent between backends

Previously windows/X11 would reset dst->length to 0 before appending, while other backends would just append. Now all backends just append.
  • Loading branch information...
UnknownShadow200 committed Aug 11, 2019
1 parent 30d807e commit cf1dc90a0697cd77ec1086a9f187447e1c27b20d
Showing with 7 additions and 7 deletions.
  1. +0 −2 src/Audio.c
  2. +7 −5 src/Window.c
@@ -267,8 +267,6 @@ void Audio_Open(AudioHandle* handle, int buffers) {
Mutex_Unlock(&audio_lock);

alDistanceModel(AL_NONE);
err = alGetError();
if (err) { Logger_Abort2(err, "DistanceModel"); }

for (i = 0; i < Array_Elems(Audio_Contexts); i++) {
struct AudioContext* ctx = &Audio_Contexts[i];
@@ -463,7 +463,6 @@ void Window_SetTitle(const String* title) {
void Clipboard_GetText(String* value) {
/* retry up to 50 times */
int i;
value->length = 0;

for (i = 0; i < 50; i++) {
if (!OpenClipboard(win_handle)) {
@@ -496,18 +495,21 @@ void Clipboard_GetText(String* value) {
}

void Clipboard_SetText(const String* value) {
/* retry up to 10 times */
Codepoint* text;
HANDLE hGlobal;
int i;

/* retry up to 10 times */
for (i = 0; i < 10; i++) {
if (!OpenClipboard(win_handle)) {
Thread_Sleep(100);
continue;
}

HANDLE hGlobal = GlobalAlloc(GMEM_MOVEABLE, (value->length + 1) * 2);
hGlobal = GlobalAlloc(GMEM_MOVEABLE, (value->length + 1) * 2);
if (!hGlobal) { CloseClipboard(); return; }

Codepoint* text = (Codepoint*)GlobalLock(hGlobal);
text = (Codepoint*)GlobalLock(hGlobal);
for (i = 0; i < value->length; i++, text++) {
*text = Convert_CP437ToUnicode(value->buffer[i]);
}
@@ -920,7 +922,7 @@ void Clipboard_GetText(String* value) {
for (i = 0; i < 100; i++) {
Window_ProcessEvents();
if (clipboard_paste_text.length) {
String_Copy(value, &clipboard_paste_text);
String_AppendString(value, &clipboard_paste_text);
return;
} else {
Thread_Sleep(10);

0 comments on commit cf1dc90

Please sign in to comment.
You can’t perform that action at this time.