Merge pull request #4 from Jack-Punter/win32_clipboard_fix

Remove win32 clipboard flag which ocasionally results in mis-paste from the system clipboard
This commit is contained in:
Jack Punter 2024-01-24 21:17:15 +00:00 committed by GitHub
commit 8ae8433e09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 29 deletions

View File

@ -172,7 +172,6 @@ struct Win32_Vars{
String_Const_u8 binary_path; String_Const_u8 binary_path;
b8 clip_catch_all; b8 clip_catch_all;
b8 next_clipboard_is_self;
DWORD clipboard_sequence; DWORD clipboard_sequence;
Plat_Handle clip_wakeup_timer; Plat_Handle clip_wakeup_timer;
@ -446,7 +445,6 @@ win32_post_clipboard(Arena *scratch, char *text, i32 len){
dest[len] = 0; dest[len] = 0;
GlobalUnlock(memory_handle); GlobalUnlock(memory_handle);
SetClipboardData(CF_TEXT, memory_handle); SetClipboardData(CF_TEXT, memory_handle);
win32vars.next_clipboard_is_self = true;
} }
CloseClipboard(); CloseClipboard();
} }
@ -458,15 +456,11 @@ system_get_clipboard_sig(){
DWORD new_number = GetClipboardSequenceNumber(); DWORD new_number = GetClipboardSequenceNumber();
if (new_number != win32vars.clipboard_sequence){ if (new_number != win32vars.clipboard_sequence){
win32vars.clipboard_sequence = new_number; win32vars.clipboard_sequence = new_number;
if (win32vars.next_clipboard_is_self){
win32vars.next_clipboard_is_self = false; for (i32 R = 0; R < 8; ++R){
} result = win32_read_clipboard_contents(win32vars.tctx, arena);
else{ if (result.str == 0){
for (i32 R = 0; R < 8; ++R){ break;
result = win32_read_clipboard_contents(win32vars.tctx, arena);
if (result.str == 0){
break;
}
} }
} }
} }
@ -1952,24 +1946,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
} }
win32vars.clip_wakeup_timer = system_wake_up_timer_create(); win32vars.clip_wakeup_timer = system_wake_up_timer_create();
win32vars.clipboard_sequence = 0; win32vars.clipboard_sequence = 0;
win32vars.next_clipboard_is_self = 0;
#if 0
if (win32vars.clipboard_sequence == 0){
Scratch_Block scratch(win32vars.tctx);
win32_post_clipboard(scratch, "", 0);
win32vars.clipboard_sequence = GetClipboardSequenceNumber();
win32vars.next_clipboard_is_self = 0;
if (win32vars.clipboard_sequence == 0){
log_os(" failure\n");
}
else{
log_os(" got first sequence number\n");
}
}
else{
log_os(" no initial sequence number\n");
}
#endif
log_os("Setting up keyboard layout...\n"); log_os("Setting up keyboard layout...\n");
win32vars.kl_universal = LoadKeyboardLayoutW(L"00000409", 0); win32vars.kl_universal = LoadKeyboardLayoutW(L"00000409", 0);