From 326cd19708ab8b089938f0142978caf917635f4b Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 18 May 2017 17:28:33 -0400 Subject: [PATCH 1/3] idek --- linux_4ed.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/linux_4ed.cpp b/linux_4ed.cpp index 7d25f910..e4e84058 100644 --- a/linux_4ed.cpp +++ b/linux_4ed.cpp @@ -2308,18 +2308,18 @@ size_change(i32 x, i32 y){ return(r); } -internal b32 -LinuxX11WindowInit(int argc, char** argv, int* WinWidth, int* WinHeight) -{ #define BASE_W 800 #define BASE_H 600 - + +internal b32 +LinuxX11WindowInit(int argc, char** argv, int* window_width, int* window_height){ if (linuxvars.settings.set_window_size){ - *WinWidth = linuxvars.settings.window_w; - *WinHeight = linuxvars.settings.window_h; + *window_width = linuxvars.settings.window_w; + *window_height = linuxvars.settings.window_h; } else { - *WinWidth = BASE_W * size_change(linuxvars.dpi_x, linuxvars.dpi_y); - *WinHeight = BASE_H * size_change(linuxvars.dpi_x, linuxvars.dpi_y); + i32 schange = size_change(linuxvars.dpi_x, linuxvars.dpi_y); + *window_width = BASE_W * schange; + *window_height = BASE_H * schange; } if (!GLXCanUseFBConfig(linuxvars.XDisplay)){ @@ -2339,7 +2339,8 @@ LinuxX11WindowInit(int argc, char** argv, int* WinWidth, int* WinHeight) swa.bit_gravity = NorthWestGravity; swa.colormap = XCreateColormap(linuxvars.XDisplay, RootWindow(linuxvars.XDisplay, Config.BestInfo.screen), Config.BestInfo.visual, AllocNone); - linuxvars.XWindow = XCreateWindow(linuxvars.XDisplay, RootWindow(linuxvars.XDisplay, Config.BestInfo.screen), 0, 0, *WinWidth, *WinHeight, 0, Config.BestInfo.depth, InputOutput, Config.BestInfo.visual, CWBackingStore|CWBitGravity|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa); + u32 CWflags = CWBackingStore|CWBitGravity|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask; + linuxvars.XWindow = XCreateWindow(linuxvars.XDisplay, RootWindow(linuxvars.XDisplay, Config.BestInfo.screen), 0, 0, *window_width, *window_height, 0, Config.BestInfo.depth, InputOutput, Config.BestInfo.visual, CWflags, &swa); if (!linuxvars.XWindow){ LinuxFatalErrorMsg("XCreateWindow failed. Make sure your display is set up correctly."); @@ -2427,8 +2428,8 @@ LinuxX11WindowInit(int argc, char** argv, int* WinWidth, int* WinHeight) XWindowAttributes WinAttribs; if (XGetWindowAttributes(linuxvars.XDisplay, linuxvars.XWindow, &WinAttribs)) { - *WinWidth = WinAttribs.width; - *WinHeight = WinAttribs.height; + *window_width = WinAttribs.width; + *window_height = WinAttribs.height; } Atom wm_protos[] = { @@ -2978,8 +2979,8 @@ main(int argc, char **argv){ } #endif - int WinWidth, WinHeight; - if (!LinuxX11WindowInit(argc, argv, &WinWidth, &WinHeight)){ + int window_width, window_height; + if (!LinuxX11WindowInit(argc, argv, &window_width, &window_height)){ return 1; } @@ -3060,7 +3061,7 @@ main(int argc, char **argv){ linuxvars.app.init(&linuxvars.system, &linuxvars.target, &memory_vars, linuxvars.clipboard_contents, current_directory, linuxvars.custom_api); - LinuxResizeTarget(WinWidth, WinHeight); + LinuxResizeTarget(window_width, window_height); // // Main loop From 8dd40675744297b939ad840be1443290c65d000d Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 22 May 2017 16:30:53 -0400 Subject: [PATCH 2/3] fixed linux thread_memory --- linux_4ed.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux_4ed.cpp b/linux_4ed.cpp index e4e84058..a14fd0a2 100644 --- a/linux_4ed.cpp +++ b/linux_4ed.cpp @@ -2911,7 +2911,7 @@ main(int argc, char **argv){ thread->group_id = BACKGROUND_THREADS; Thread_Memory *memory = linuxvars.thread_memory + i; - *memory = thread_memory_zero(); + *memory = null_thread_memory; memory->id = thread->id; thread->queue = &linuxvars.queues[BACKGROUND_THREADS]; From 8a3020d72deb214dcbd2d03b96dc439cd86cc1d0 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 23 May 2017 11:37:58 -0400 Subject: [PATCH 3/3] linux window size crash bug fixed --- linux_4ed.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/linux_4ed.cpp b/linux_4ed.cpp index a14fd0a2..93ef4526 100644 --- a/linux_4ed.cpp +++ b/linux_4ed.cpp @@ -2299,13 +2299,12 @@ LinuxGetXSettingsDPI(Display* dpy, int screen) // X11 window init // -internal i32 +internal f32 size_change(i32 x, i32 y){ f32 xs = x/96.f; f32 ys = y/96.f; f32 s = Min(xs, ys); - i32 r = floor32(s); - return(r); + return(s); } #define BASE_W 800 @@ -2317,10 +2316,12 @@ LinuxX11WindowInit(int argc, char** argv, int* window_width, int* window_height) *window_width = linuxvars.settings.window_w; *window_height = linuxvars.settings.window_h; } else { - i32 schange = size_change(linuxvars.dpi_x, linuxvars.dpi_y); - *window_width = BASE_W * schange; - *window_height = BASE_H * schange; + f32 schange = size_change(linuxvars.dpi_x, linuxvars.dpi_y); + *window_width = ceil32(BASE_W * schange); + *window_height = ceil32(BASE_H * schange); } + *window_width = Max(*window_width, 1); + *window_height = Max(*window_height, 1); if (!GLXCanUseFBConfig(linuxvars.XDisplay)){ LinuxFatalErrorMsg("Your XServer's GLX version is too old. GLX 1.3+ is required.");