master
Allen Webster 2020-02-19 21:32:07 -08:00
parent f0421c12b5
commit 0422dadbc8
3 changed files with 340 additions and 338 deletions

View File

@ -6,6 +6,7 @@
extern "C" b32 extern "C" b32
get_version(i32 maj, i32 min, i32 patch){ get_version(i32 maj, i32 min, i32 patch){
printf("CUS: %d.%d.%d\n", MAJOR, MINOR, PATCH);
return(maj == MAJOR && min == MINOR && patch == PATCH); return(maj == MAJOR && min == MINOR && patch == PATCH);
} }

View File

@ -21,7 +21,7 @@ arch=-m64
preproc_file=4coder_command_metadata.i preproc_file=4coder_command_metadata.i
meta_macros="-DMETA_PASS" meta_macros="-DMETA_PASS"
g++ -I"$CODE_HOME" $meta_macros $arch $opts $debug -std=c++11 "$SOURCE" -E -o $preproc_file g++ -I"$CODE_HOME" $meta_macros $arch $opts $debug -std=c++11 "$SOURCE" -E -o $preproc_file
g++ -I"$CODE_HOME" $opts $debug -std=gnu++0x "$CODE_HOME/4coder_metadata_generator.cpp" -o "$CODE_HOME/metadata_generator" g++ -I"$CODE_HOME" $opts $debug -std=c++11 "$CODE_HOME/4coder_metadata_generator.cpp" -o "$CODE_HOME/metadata_generator"
"$CODE_HOME/metadata_generator" -R "$CODE_HOME" "$PWD/$preproc_file" "$CODE_HOME/metadata_generator" -R "$CODE_HOME" "$PWD/$preproc_file"
g++ -I"$CODE_HOME" $arch $opts $debug -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC g++ -I"$CODE_HOME" $arch $opts $debug -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC

View File

@ -101,18 +101,18 @@
#include <GL/glext.h> #include <GL/glext.h>
#ifdef INSO_DEBUG #ifdef INSO_DEBUG
#define LINUX_FN_DEBUG(fmt, ...) do { \ #define LINUX_FN_DEBUG(fmt, ...) do { \
fprintf(stderr, "%s: " fmt "\n", __func__, ##__VA_ARGS__);\ fprintf(stderr, "%s: " fmt "\n", __func__, ##__VA_ARGS__);\
} while (0) } while (0)
// I want to see a message // I want to see a message
#undef AssertBreak #undef AssertBreak
#define AssertBreak(m) ({\ #define AssertBreak(m) ({\
fprintf(stderr, "\n** ASSERTION FAILURE: %s:%d: %s\n\n", __FILE__, __LINE__, #m);\ fprintf(stderr, "\n** ASSERTION FAILURE: %s:%d: %s\n\n", __FILE__, __LINE__, #m);\
*((volatile u64*)0) = 0xba771e70ad5;\ *((volatile u64*)0) = 0xba771e70ad5;\
}) })
#else #else
#define LINUX_FN_DEBUG(...) #define LINUX_FN_DEBUG(...)
#endif #endif
//////////////////////////// ////////////////////////////
@ -276,9 +276,9 @@ linux_alloc_object(Linux_Object_Kind kind){
i32 count = 512; i32 count = 512;
Linux_Object* objects = (Linux_Object*)system_memory_allocate( Linux_Object* objects = (Linux_Object*)system_memory_allocate(
sizeof(Linux_Object) * count, sizeof(Linux_Object) * count,
file_name_line_number_lit_u8 file_name_line_number_lit_u8
); );
objects[0].node.prev = &linuxvars.free_linux_objects; objects[0].node.prev = &linuxvars.free_linux_objects;
linuxvars.free_linux_objects.next = &objects[0].node; linuxvars.free_linux_objects.next = &objects[0].node;
@ -512,9 +512,9 @@ linux_get_xsettings_dpi(Display* dpy, int screen){
} }
out: out:
if (prop){ if (prop){
XFree(prop); XFree(prop);
} }
return dpi; return dpi;
} }
@ -584,12 +584,12 @@ linux_find_font(Face_Description* desc) {
} }
FcPattern *pattern = FcPatternBuild( FcPattern *pattern = FcPatternBuild(
0, 0,
FC_POSTSCRIPT_NAME, FcTypeString, name, FC_POSTSCRIPT_NAME, FcTypeString, name,
FC_SIZE, FcTypeDouble, size, FC_SIZE, FcTypeDouble, size,
FC_FONTFORMAT, FcTypeString, "TrueType", FC_FONTFORMAT, FcTypeString, "TrueType",
FC_STYLE, FcTypeString, (FcChar8*)style, FC_STYLE, FcTypeString, (FcChar8*)style,
NULL); NULL);
if(!pattern) { if(!pattern) {
return result; return result;
@ -1175,14 +1175,14 @@ linux_clipboard_send(XSelectionRequestEvent* req) {
if (req->target == linuxvars.atom_TARGETS){ if (req->target == linuxvars.atom_TARGETS){
XChangeProperty( XChangeProperty(
req->display, req->display,
req->requestor, req->requestor,
req->property, req->property,
XA_ATOM, XA_ATOM,
32, 32,
PropModeReplace, PropModeReplace,
(u8*)formats, (u8*)formats,
ArrayCount(formats)); ArrayCount(formats));
rsp.property = req->property; rsp.property = req->property;
@ -1197,21 +1197,21 @@ linux_clipboard_send(XSelectionRequestEvent* req) {
if (i != ArrayCount(formats)){ if (i != ArrayCount(formats)){
XChangeProperty( XChangeProperty(
req->display, req->display,
req->requestor, req->requestor,
req->property, req->property,
req->target, req->target,
8, 8,
PropModeReplace, PropModeReplace,
linuxvars.clipboard_contents.str, linuxvars.clipboard_contents.str,
linuxvars.clipboard_contents.size linuxvars.clipboard_contents.size
); );
rsp.property = req->property; rsp.property = req->property;
} }
} }
done: done:
XSendEvent(req->display, req->requestor, True, 0, (XEvent*)&rsp); XSendEvent(req->display, req->requestor, True, 0, (XEvent*)&rsp);
} }
@ -1219,8 +1219,8 @@ internal void
linux_clipboard_recv(XSelectionEvent* ev) { linux_clipboard_recv(XSelectionEvent* ev) {
if(ev->selection != linuxvars.atom_CLIPBOARD || if(ev->selection != linuxvars.atom_CLIPBOARD ||
ev->target != linuxvars.atom_UTF8_STRING || ev->target != linuxvars.atom_UTF8_STRING ||
ev->property == None) { ev->property == None) {
return; return;
} }
@ -1231,13 +1231,13 @@ linux_clipboard_recv(XSelectionEvent* ev) {
u8 *data; u8 *data;
int result = XGetWindowProperty( int result = XGetWindowProperty(
linuxvars.dpy, linuxvars.dpy,
linuxvars.win, linuxvars.win,
linuxvars.atom_CLIPBOARD, linuxvars.atom_CLIPBOARD,
0L, 0x20000000L, False, 0L, 0x20000000L, False,
linuxvars.atom_UTF8_STRING, linuxvars.atom_UTF8_STRING,
&type, &fmt, &nitems, &type, &fmt, &nitems,
&bytes_left, &data); &bytes_left, &data);
if(result == Success && fmt == 8){ if(result == Success && fmt == 8){
linalloc_clear(linuxvars.clipboard_arena); linalloc_clear(linuxvars.clipboard_arena);
@ -1377,11 +1377,11 @@ linux_handle_x11_events() {
// NOTE(inso): improves selection dragging (especially in notepad-like mode). // NOTE(inso): improves selection dragging (especially in notepad-like mode).
// we will still get mouse events when the pointer leaves the window if it's dragging. // we will still get mouse events when the pointer leaves the window if it's dragging.
XGrabPointer( XGrabPointer(
linuxvars.dpy, linuxvars.dpy,
linuxvars.win, linuxvars.win,
True, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, True, PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, GrabModeAsync, GrabModeAsync,
None, None, CurrentTime); None, None, CurrentTime);
} break; } break;
@ -1456,11 +1456,11 @@ linux_handle_x11_events() {
else if(atom == linuxvars.atom__NET_WM_PING) { else if(atom == linuxvars.atom__NET_WM_PING) {
event.xclient.window = DefaultRootWindow(linuxvars.dpy); event.xclient.window = DefaultRootWindow(linuxvars.dpy);
XSendEvent( XSendEvent(
linuxvars.dpy, linuxvars.dpy,
event.xclient.window, event.xclient.window,
False, False,
SubstructureRedirectMask | SubstructureNotifyMask, SubstructureRedirectMask | SubstructureNotifyMask,
&event); &event);
} }
} break; } break;
@ -1490,12 +1490,12 @@ linux_handle_x11_events() {
XFixesSelectionNotifyEvent* sne = (XFixesSelectionNotifyEvent*)&event; XFixesSelectionNotifyEvent* sne = (XFixesSelectionNotifyEvent*)&event;
if (sne->subtype == XFixesSelectionNotify && sne->owner != linuxvars.win){ if (sne->subtype == XFixesSelectionNotify && sne->owner != linuxvars.win){
XConvertSelection( XConvertSelection(
linuxvars.dpy, linuxvars.dpy,
linuxvars.atom_CLIPBOARD, linuxvars.atom_CLIPBOARD,
linuxvars.atom_UTF8_STRING, linuxvars.atom_UTF8_STRING,
linuxvars.atom_CLIPBOARD, linuxvars.atom_CLIPBOARD,
linuxvars.win, linuxvars.win,
CurrentTime); CurrentTime);
} }
} }
@ -1700,6 +1700,7 @@ main(int argc, char **argv){
system_error_box(custom_not_found_msg); system_error_box(custom_not_found_msg);
} }
custom.get_version = (_Get_Version_Type*)system_get_proc(custom_library, "get_version"); custom.get_version = (_Get_Version_Type*)system_get_proc(custom_library, "get_version");
printf("VER: %d.%d.%d\n", MAJOR, MINOR, PATCH);
if (custom.get_version == 0 || custom.get_version(MAJOR, MINOR, PATCH) == 0){ if (custom.get_version == 0 || custom.get_version(MAJOR, MINOR, PATCH) == 0){
system_error_box(custom_fail_version_msg); system_error_box(custom_fail_version_msg);
} }