Fixed windows clipboard problem
parent
cc9a282d55
commit
f5c5add46d
|
@ -199,10 +199,9 @@ sysshared_partition_double(Partition *part){
|
||||||
|
|
||||||
internal void*
|
internal void*
|
||||||
sysshared_push_block(Partition *part, i32 size){
|
sysshared_push_block(Partition *part, i32 size){
|
||||||
void *result = 0;
|
void *result = push_block(part, size);
|
||||||
result = push_block(part, size);
|
|
||||||
if (!result){
|
if (!result){
|
||||||
sysshared_partition_grow(part, size+part->max);
|
sysshared_partition_grow(part, size + part->max);
|
||||||
result = push_block(part, size);
|
result = push_block(part, size);
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
|
|
@ -143,6 +143,9 @@ struct Win32_Vars{
|
||||||
b32 next_clipboard_is_self;
|
b32 next_clipboard_is_self;
|
||||||
DWORD clipboard_sequence;
|
DWORD clipboard_sequence;
|
||||||
|
|
||||||
|
Partition clip_post_part;
|
||||||
|
i32 clip_post_len;
|
||||||
|
|
||||||
HWND window_handle;
|
HWND window_handle;
|
||||||
i32 dpi_x, dpi_y;
|
i32 dpi_x, dpi_y;
|
||||||
|
|
||||||
|
@ -279,21 +282,23 @@ Sys_Send_Exit_Signal_Sig(system_send_exit_signal){
|
||||||
|
|
||||||
#include "4ed_coroutine_functions.cpp"
|
#include "4ed_coroutine_functions.cpp"
|
||||||
|
|
||||||
|
#include "4ed_font_data.h"
|
||||||
|
#include "4ed_system_shared.cpp"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clipboard
|
// Clipboard
|
||||||
//
|
//
|
||||||
|
|
||||||
internal
|
internal void
|
||||||
Sys_Post_Clipboard_Sig(system_post_clipboard){
|
win32_post_clipboard(char *text, i32 len){
|
||||||
if (OpenClipboard(win32vars.window_handle)){
|
if (OpenClipboard(win32vars.window_handle)){
|
||||||
if (!EmptyClipboard()){
|
if (!EmptyClipboard()){
|
||||||
win32_output_error_string(false);
|
win32_output_error_string(false);
|
||||||
}
|
}
|
||||||
HANDLE memory_handle = GlobalAlloc(GMEM_MOVEABLE, str.size + 1);
|
HANDLE memory_handle = GlobalAlloc(GMEM_MOVEABLE, len + 1);
|
||||||
if (memory_handle){
|
if (memory_handle){
|
||||||
char *dest = (char*)GlobalLock(memory_handle);
|
char *dest = (char*)GlobalLock(memory_handle);
|
||||||
copy_fast_unsafe_cs(dest, str);
|
memmove(dest, text, len + 1);
|
||||||
dest[str.size] = 0;
|
|
||||||
GlobalUnlock(memory_handle);
|
GlobalUnlock(memory_handle);
|
||||||
SetClipboardData(CF_TEXT, memory_handle);
|
SetClipboardData(CF_TEXT, memory_handle);
|
||||||
win32vars.next_clipboard_is_self = true;
|
win32vars.next_clipboard_is_self = true;
|
||||||
|
@ -302,6 +307,15 @@ Sys_Post_Clipboard_Sig(system_post_clipboard){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal
|
||||||
|
Sys_Post_Clipboard_Sig(system_post_clipboard){
|
||||||
|
Partition *part = &win32vars.clip_post_part;
|
||||||
|
win32vars.clip_post_len = str.size;
|
||||||
|
u8 *post = (u8*)sysshared_push_block(part, str.size + 1);
|
||||||
|
memmove(post, str.str, str.size);
|
||||||
|
post[str.size] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
win32_read_clipboard_contents(){
|
win32_read_clipboard_contents(){
|
||||||
b32 result = false;
|
b32 result = false;
|
||||||
|
@ -490,8 +504,6 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
|
||||||
return(close_me);
|
return(close_me);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "4ed_font_data.h"
|
|
||||||
#include "4ed_system_shared.cpp"
|
|
||||||
#include "opengl/4ed_opengl_render.cpp"
|
#include "opengl/4ed_opengl_render.cpp"
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1114,7 +1126,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
||||||
|
|
||||||
win32vars.clipboard_sequence = GetClipboardSequenceNumber();
|
win32vars.clipboard_sequence = GetClipboardSequenceNumber();
|
||||||
if (win32vars.clipboard_sequence == 0){
|
if (win32vars.clipboard_sequence == 0){
|
||||||
system_post_clipboard(make_lit_string(""));
|
win32_post_clipboard("", 0);
|
||||||
|
|
||||||
win32vars.clipboard_sequence = GetClipboardSequenceNumber();
|
win32vars.clipboard_sequence = GetClipboardSequenceNumber();
|
||||||
win32vars.next_clipboard_is_self = 0;
|
win32vars.next_clipboard_is_self = 0;
|
||||||
|
@ -1349,6 +1361,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
||||||
}
|
}
|
||||||
input.clipboard = win32vars.clipboard_contents;
|
input.clipboard = win32vars.clipboard_contents;
|
||||||
|
|
||||||
|
win32vars.clip_post_len = 0;
|
||||||
|
|
||||||
// NOTE(allen): Initialize result So the Core Doesn't Have to Fill Things it Doesn't Care About
|
// NOTE(allen): Initialize result So the Core Doesn't Have to Fill Things it Doesn't Care About
|
||||||
Application_Step_Result result = {0};
|
Application_Step_Result result = {0};
|
||||||
result.mouse_cursor_type = APP_MOUSE_CURSOR_DEFAULT;
|
result.mouse_cursor_type = APP_MOUSE_CURSOR_DEFAULT;
|
||||||
|
@ -1375,6 +1389,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
||||||
keep_running = false;
|
keep_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(allen): Post New Clipboard Content
|
||||||
|
if (win32vars.clip_post_len > 0){
|
||||||
|
win32_post_clipboard((char*)win32vars.clip_post_part.base, win32vars.clip_post_len);
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE(allen): Switch to New Cursor
|
// NOTE(allen): Switch to New Cursor
|
||||||
Win32SetCursorFromUpdate(result.mouse_cursor_type);
|
Win32SetCursorFromUpdate(result.mouse_cursor_type);
|
||||||
if (win32vars.cursor_show != win32vars.prev_cursor_show){
|
if (win32vars.cursor_show != win32vars.prev_cursor_show){
|
||||||
|
|
Loading…
Reference in New Issue