mac clipboard wrapper
parent
67ab069e5b
commit
fd141031b9
|
@ -89,11 +89,13 @@ inline i32 div_ceil(i32 n, i32 d){
|
||||||
}
|
}
|
||||||
|
|
||||||
inline i32 l_round_up_i32(i32 x, i32 b){
|
inline i32 l_round_up_i32(i32 x, i32 b){
|
||||||
return( ((x)+(b)-1) - (((x)+(b)-1)%(b)) );
|
i32 t = x + b - 1;
|
||||||
|
return(t - (t%b));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u32 l_round_up_u32(u32 x, u32 b){
|
inline u32 l_round_up_u32(u32 x, u32 b){
|
||||||
return( ((x)+(b)-1) - (((x)+(b)-1)%(b)) );
|
i32 t = x + b - 1;
|
||||||
|
return(t - (t%b));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u32 round_up_pot_u32(u32 x){
|
inline u32 round_up_pot_u32(u32 x){
|
||||||
|
|
|
@ -36,6 +36,9 @@ typedef struct OSX_Vars{
|
||||||
void *clipboard_data;
|
void *clipboard_data;
|
||||||
umem clipboard_size, clipboard_max;
|
umem clipboard_size, clipboard_max;
|
||||||
b32 just_posted_to_clipboard;
|
b32 just_posted_to_clipboard;
|
||||||
|
|
||||||
|
char *clipboard_space;
|
||||||
|
umem clipboard_space_max;
|
||||||
} OSX_Vars;
|
} OSX_Vars;
|
||||||
|
|
||||||
// In C++ layer.
|
// In C++ layer.
|
||||||
|
|
|
@ -1465,20 +1465,17 @@ LinuxHandleX11Events(void)
|
||||||
response.time = request.time;
|
response.time = request.time;
|
||||||
response.property = None;
|
response.property = None;
|
||||||
|
|
||||||
if (
|
if (linuxvars.clipboard_outgoing.size &&
|
||||||
linuxvars.clipboard_outgoing.size &&
|
|
||||||
request.selection == linuxvars.atom_CLIPBOARD &&
|
request.selection == linuxvars.atom_CLIPBOARD &&
|
||||||
request.property != None &&
|
request.property != None &&
|
||||||
request.display &&
|
request.display &&
|
||||||
request.requestor
|
request.requestor){
|
||||||
){
|
|
||||||
Atom atoms[] = {
|
Atom atoms[] = {
|
||||||
XA_STRING,
|
XA_STRING,
|
||||||
linuxvars.atom_UTF8_STRING
|
linuxvars.atom_UTF8_STRING
|
||||||
};
|
};
|
||||||
|
|
||||||
if (request.target == linuxvars.atom_TARGETS){
|
if (request.target == linuxvars.atom_TARGETS){
|
||||||
|
|
||||||
XChangeProperty(
|
XChangeProperty(
|
||||||
request.display,
|
request.display,
|
||||||
request.requestor,
|
request.requestor,
|
||||||
|
@ -1487,8 +1484,7 @@ LinuxHandleX11Events(void)
|
||||||
32,
|
32,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
(u8*)atoms,
|
(u8*)atoms,
|
||||||
ArrayCount(atoms)
|
ArrayCount(atoms));
|
||||||
);
|
|
||||||
|
|
||||||
response.property = request.property;
|
response.property = request.property;
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,32 @@ OSX_Vars osx;
|
||||||
#include "4ed_font_data.h"
|
#include "4ed_font_data.h"
|
||||||
#include "4ed_system_shared.cpp"
|
#include "4ed_system_shared.cpp"
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clipboard
|
||||||
|
//
|
||||||
|
|
||||||
|
internal
|
||||||
|
Sys_Post_Clipboard_Sig(system_post_clipboard){
|
||||||
|
char *string = str.str;
|
||||||
|
if (!terminate_with_null(&str)){
|
||||||
|
if (osx.clipboard_space_max <= str.size + 1){
|
||||||
|
if (osx.clipboard_space != 0){
|
||||||
|
system_memory_free(osx.clipboard_space, osx.clipboard_space_max);
|
||||||
|
}
|
||||||
|
osx.clipboard_space_max = l_round_up_u32(str.size*2 + 1, KB(4096));
|
||||||
|
osx.clipboard_space = (char*)system_memory_allocate(osx.clipboard_space_max);
|
||||||
|
}
|
||||||
|
memcpy(osx.clipboard_space, str.str, str.size);
|
||||||
|
osx.clipboard_space[str.size] = 0;
|
||||||
|
string = osx.clipboard_space;
|
||||||
|
}
|
||||||
|
osx_post_to_clipboard(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
#include "4ed_link_system_functions.cpp"
|
#include "4ed_link_system_functions.cpp"
|
||||||
#include "4ed_shared_init_logic.cpp"
|
#include "4ed_shared_init_logic.cpp"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue