From b4b43190ce623f1a75c94f7100c2d5b0b7bbb4f8 Mon Sep 17 00:00:00 2001 From: TheCherno Date: Sat, 10 Nov 2018 10:45:30 +1100 Subject: [PATCH 01/21] Added premake file. --- premake5.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 premake5.lua diff --git a/premake5.lua b/premake5.lua new file mode 100644 index 000000000..13e7dba7e --- /dev/null +++ b/premake5.lua @@ -0,0 +1,45 @@ +project "GLFW" + kind "StaticLib" + language "C" + + targetdir ("bin/" .. outputdir .. "/%{prj.name}") + objdir ("bin-int/" .. outputdir .. "/%{prj.name}") + + files + { + "include/GLFW/glfw3.h", + "include/GLFW/glfw3native.h", + "src/glfw_config.h", + "src/context.c", + "src/init.c", + "src/input.c", + "src/monitor.c", + "src/vulkan.c", + "src/window.c" + } + + filter "system:windows" + buildoptions { "-std=c11", "-lgdi32" } + systemversion "10.0.17134.0" + staticruntime "On" + + files + { + "src/win32_init.c", + "src/win32_joystick.c", + "src/win32_monitor.c", + "src/win32_time.c", + "src/win32_thread.c", + "src/win32_window.c", + "src/wgl_context.c", + "src/egl_context.c", + "src/osmesa_context.c" + } + + defines + { + "_GLFW_WIN32", + "_CRT_SECURE_NO_WARNINGS" + } + filter { "system:windows", "configurations:Release" } + buildoptions "/MT" From c951daa4d7f4e8be84c60527fd9e62a82c9ed220 Mon Sep 17 00:00:00 2001 From: Marian Bielcik Date: Wed, 2 Jan 2019 08:14:27 +0100 Subject: [PATCH 02/21] Add support for Linux --- premake5.lua | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/premake5.lua b/premake5.lua index 13e7dba7e..f1335326b 100644 --- a/premake5.lua +++ b/premake5.lua @@ -2,11 +2,11 @@ project "GLFW" kind "StaticLib" language "C" - targetdir ("bin/" .. outputdir .. "/%{prj.name}") + targetdir ("bin/" .. outputdir .. "/%{prj.name}") objdir ("bin-int/" .. outputdir .. "/%{prj.name}") - files - { + files + { "include/GLFW/glfw3.h", "include/GLFW/glfw3native.h", "src/glfw_config.h", @@ -17,10 +17,36 @@ project "GLFW" "src/vulkan.c", "src/window.c" } + + filter "system:linux" + + pic "On" + + systemversion "latest" + staticruntime "On" + + files + { + "src/x11_init.c", + "src/x11_monitor.c", + "src/x11_window.c", + "src/xkb_unicode.c", + "src/posix_time.c", + "src/posix_thread.c", + "src/glx_context.c", + "src/egl_context.c", + "src/osmesa_context.c", + "src/linux_joystick.c" + } + + defines + { + "_GLFW_X11" + } - filter "system:windows" + filter "system:windows" buildoptions { "-std=c11", "-lgdi32" } - systemversion "10.0.17134.0" + systemversion "latest" staticruntime "On" files @@ -36,10 +62,10 @@ project "GLFW" "src/osmesa_context.c" } - defines - { + defines + { "_GLFW_WIN32", "_CRT_SECURE_NO_WARNINGS" - } + } filter { "system:windows", "configurations:Release" } buildoptions "/MT" From f822529f26be5700dd2773adf2f90f98a710db3b Mon Sep 17 00:00:00 2001 From: Marian Bielcik Date: Wed, 10 Apr 2019 20:52:18 +0200 Subject: [PATCH 03/21] Added bin and bin-int to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f6103c222..2a1c12ee9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ Release MinSizeRel RelWithDebInfo *.xcodeproj +bin +bin-int # CMake files Makefile From 8f16ea039262ae4d4e4f0760e1a89eb5bd3ea1c7 Mon Sep 17 00:00:00 2001 From: lovely_santa Date: Wed, 3 Jul 2019 11:32:20 +0200 Subject: [PATCH 04/21] Converted spaces to tabs as requested in #1 --- premake5.lua | 128 +++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/premake5.lua b/premake5.lua index f1335326b..e296af314 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,71 +1,71 @@ project "GLFW" - kind "StaticLib" - language "C" - - targetdir ("bin/" .. outputdir .. "/%{prj.name}") - objdir ("bin-int/" .. outputdir .. "/%{prj.name}") + kind "StaticLib" + language "C" - files - { - "include/GLFW/glfw3.h", - "include/GLFW/glfw3native.h", - "src/glfw_config.h", - "src/context.c", - "src/init.c", - "src/input.c", - "src/monitor.c", - "src/vulkan.c", - "src/window.c" - } + targetdir ("bin/" .. outputdir .. "/%{prj.name}") + objdir ("bin-int/" .. outputdir .. "/%{prj.name}") - filter "system:linux" + files + { + "include/GLFW/glfw3.h", + "include/GLFW/glfw3native.h", + "src/glfw_config.h", + "src/context.c", + "src/init.c", + "src/input.c", + "src/monitor.c", + "src/vulkan.c", + "src/window.c" + } + filter "system:linux" + pic "On" - pic "On" + systemversion "latest" + staticruntime "On" - systemversion "latest" - staticruntime "On" - - files - { - "src/x11_init.c", - "src/x11_monitor.c", - "src/x11_window.c", - "src/xkb_unicode.c", - "src/posix_time.c", - "src/posix_thread.c", - "src/glx_context.c", - "src/egl_context.c", - "src/osmesa_context.c", - "src/linux_joystick.c" - } + files + { + "src/x11_init.c", + "src/x11_monitor.c", + "src/x11_window.c", + "src/xkb_unicode.c", + "src/posix_time.c", + "src/posix_thread.c", + "src/glx_context.c", + "src/egl_context.c", + "src/osmesa_context.c", + "src/linux_joystick.c" + } - defines - { - "_GLFW_X11" - } - - filter "system:windows" - buildoptions { "-std=c11", "-lgdi32" } - systemversion "latest" - staticruntime "On" - - files - { - "src/win32_init.c", - "src/win32_joystick.c", - "src/win32_monitor.c", - "src/win32_time.c", - "src/win32_thread.c", - "src/win32_window.c", - "src/wgl_context.c", - "src/egl_context.c", - "src/osmesa_context.c" - } + defines + { + "_GLFW_X11" + } - defines - { - "_GLFW_WIN32", - "_CRT_SECURE_NO_WARNINGS" - } - filter { "system:windows", "configurations:Release" } - buildoptions "/MT" + filter "system:windows" + buildoptions { "-std=c11", "-lgdi32" } + + systemversion "latest" + staticruntime "On" + + files + { + "src/win32_init.c", + "src/win32_joystick.c", + "src/win32_monitor.c", + "src/win32_time.c", + "src/win32_thread.c", + "src/win32_window.c", + "src/wgl_context.c", + "src/egl_context.c", + "src/osmesa_context.c" + } + + defines + { + "_GLFW_WIN32", + "_CRT_SECURE_NO_WARNINGS" + } + + filter { "system:windows", "configurations:Release" } + buildoptions "/MT" From 05f2147de2a2053c27ab8d71740c91cd8e7ed36b Mon Sep 17 00:00:00 2001 From: lovely_santa Date: Wed, 3 Jul 2019 11:34:28 +0200 Subject: [PATCH 05/21] Added symbols and optimization --- premake5.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/premake5.lua b/premake5.lua index e296af314..cb72ce4a1 100644 --- a/premake5.lua +++ b/premake5.lua @@ -67,5 +67,10 @@ project "GLFW" "_CRT_SECURE_NO_WARNINGS" } - filter { "system:windows", "configurations:Release" } - buildoptions "/MT" + filter "configurations:Debug" + runtime "Debug" + symbols "on" + + filter "configurations:Release" + runtime "Release" + optimize "on" From 5bc798607dbc14ecacd0a2437123e98a54d3130b Mon Sep 17 00:00:00 2001 From: TheCherno Date: Mon, 26 Aug 2019 10:11:15 +1000 Subject: [PATCH 06/21] Removed unused build options. --- premake5.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/premake5.lua b/premake5.lua index cb72ce4a1..f3272ac20 100644 --- a/premake5.lua +++ b/premake5.lua @@ -43,8 +43,6 @@ project "GLFW" } filter "system:windows" - buildoptions { "-std=c11", "-lgdi32" } - systemversion "latest" staticruntime "On" From 1a3b9eacfc729503d54d127ff4afe394947e4d61 Mon Sep 17 00:00:00 2001 From: TheCherno Date: Thu, 15 Apr 2021 14:43:43 +1000 Subject: [PATCH 07/21] staticruntime off --- premake5.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/premake5.lua b/premake5.lua index f3272ac20..c1a9a1348 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,6 +1,7 @@ project "GLFW" kind "StaticLib" language "C" + staticruntime "off" targetdir ("bin/" .. outputdir .. "/%{prj.name}") objdir ("bin-int/" .. outputdir .. "/%{prj.name}") @@ -21,8 +22,7 @@ project "GLFW" pic "On" systemversion "latest" - staticruntime "On" - + files { "src/x11_init.c", @@ -44,7 +44,6 @@ project "GLFW" filter "system:windows" systemversion "latest" - staticruntime "On" files { From 6d3052e388dcd96c13f2b4b945a0551027176b4a Mon Sep 17 00:00:00 2001 From: Jaytheway Date: Tue, 28 Sep 2021 11:35:27 +0300 Subject: [PATCH 08/21] Added window creation hint to disable native OS title-bar - Disabling title-bar only implemented for win32 window. --- include/GLFW/glfw3.h | 59 ++++++++++++++++++++++ premake5.lua | 5 ++ src/cocoa_window.m | 7 +++ src/internal.h | 5 ++ src/null_window.c | 4 ++ src/win32_window.c | 115 +++++++++++++++++++++++++++++++++++++++++++ src/window.c | 34 +++++++++++++ src/wl_window.c | 7 +++ src/x11_window.c | 7 +++ 9 files changed, 243 insertions(+) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e5b9b6c64..bdc2bebe5 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -842,6 +842,12 @@ extern "C" { * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib). */ #define GLFW_FOCUS_ON_SHOW 0x0002000C + /*! @brief Window has titlebar window hint and attribute + * + * Window has titlebar [window hint](@ref GLFW_TITLEBAR_hint) and + * [window attribute](@ref GLFW_TITLEBAR_attrib). + */ +#define GLFW_TITLEBAR 0x0002000D /*! @brief Framebuffer bit depth hint. * @@ -1291,8 +1297,30 @@ typedef void (* GLFWerrorfun)(int,const char*); * * @ingroup window */ + typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int); +/*! @brief The function pointer type for window titlebar hittest callbacks. + * + * This is the function pointer type for window titelebar hittest callbacks. + * A window titlebar hittest callback function has the following signature: + * @code + * void callback_name(GLFWwindow* window, int xpos, int ypos, int* hit) + * @endcode + * + * @param[in] window The window that was moved. + * @param[in] xpos The x-coordinate of mouse, in screen coordinates. + * @param[in] ypos The y-coordinate of mouse, in screen coordinates. + * @param[out] hit 'true' or '1' if mouse hovering titlebar. + * + * @sa @ref window_pos + * @sa @ref glfwSetTitlebarHitTestCallback + * + * @ingroup window + */ +typedef void (*GLFWtitlebarhittestfun)(GLFWwindow*, int, int, int*); + + /*! @brief The function pointer type for window size callbacks. * * This is the function pointer type for window size callbacks. A window size @@ -3688,6 +3716,37 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); */ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback); +/*! @brief Sets the titlebar hittest callback for the specified window. + * + * This function sets the titlebar hittest callback of the specified window, + * which is called when the mouse hoveres the window to ask client if it's + * hovering over custom titlebar area which needs to be handles as a native + * titlebar. The callback is provided with the x and y coordinates of the mouse + * cursor in screen coordinates. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int xpos, int ypos, int* hit) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWtitlebarhittestfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_pos + * + * @ingroup window + */ +GLFWAPI GLFWtitlebarhittestfun glfwSetTitlebarHitTestCallback(GLFWwindow* window, GLFWtitlebarhittestfun callback); + /*! @brief Sets the size callback for the specified window. * * This function sets the size callback of the specified window, which is diff --git a/premake5.lua b/premake5.lua index c1a9a1348..65452ab43 100644 --- a/premake5.lua +++ b/premake5.lua @@ -64,6 +64,11 @@ project "GLFW" "_CRT_SECURE_NO_WARNINGS" } + links + { + "Dwmapi.lib" + } + filter "configurations:Debug" runtime "Debug" symbols "on" diff --git a/src/cocoa_window.m b/src/cocoa_window.m index c50bf21a8..69adbc847 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1337,6 +1337,13 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) } // autoreleasepool } +void _glfwPlatformSetWindowTitlebar(_GLFWwindow* window, GLFWbool enabled) +{ + // TODO + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Window attribute setting not implemented yet"); +} + void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) { @autoreleasepool { diff --git a/src/internal.h b/src/internal.h index 6d7587c8c..ba456b9a1 100644 --- a/src/internal.h +++ b/src/internal.h @@ -260,6 +260,7 @@ struct _GLFWwndconfig GLFWbool resizable; GLFWbool visible; GLFWbool decorated; + GLFWbool titlebar; GLFWbool focused; GLFWbool autoIconify; GLFWbool floating; @@ -373,6 +374,7 @@ struct _GLFWwindow // Window settings and state GLFWbool resizable; GLFWbool decorated; + GLFWbool titlebar; GLFWbool autoIconify; GLFWbool floating; GLFWbool focusOnShow; @@ -400,6 +402,7 @@ struct _GLFWwindow struct { GLFWwindowposfun pos; + GLFWtitlebarhittestfun tbhittest; GLFWwindowsizefun size; GLFWwindowclosefun close; GLFWwindowrefreshfun refresh; @@ -673,6 +676,7 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window); float _glfwPlatformGetWindowOpacity(_GLFWwindow* window); void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled); void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled); +void _glfwPlatformSetWindowTitlebar(_GLFWwindow* window, GLFWbool enabled); void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled); void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity); @@ -708,6 +712,7 @@ void _glfwPlatformUnlockMutex(_GLFWmutex* mutex); void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused); void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos); void _glfwInputWindowSize(_GLFWwindow* window, int width, int height); +void _glfwInputTitleBarHitTest(_GLFWwindow* window, int posX, int posY, int* hit); void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height); void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale); diff --git a/src/null_window.c b/src/null_window.c index 936400d39..7129c9f9e 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -185,6 +185,10 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) { } +void _glfwPlatformSetWindowTitlebar(_GLFWwindow* window, GLFWbool enabled) +{ +} + void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) { } diff --git a/src/win32_window.c b/src/win32_window.c index 0ae0998a3..fb4d1a25a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -35,6 +35,7 @@ #include #include #include +#include // Returns the window style for the specified window // @@ -508,6 +509,8 @@ static void releaseMonitor(_GLFWwindow* window) static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + static RECT border_thickness; + _GLFWwindow* window = GetPropW(hWnd, L"GLFW"); if (!window) { @@ -545,6 +548,48 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, break; } + + case WM_CREATE: + { + if (_glfw.hints.window.titlebar) + break; + + //find border thickness + SetRectEmpty(&border_thickness); + if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_THICKFRAME) + { + AdjustWindowRectEx(&border_thickness, GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION, FALSE, NULL); + border_thickness.left *= -1; + border_thickness.top *= -1; + } + else// if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_BORDER) + { + SetRect(&border_thickness, 4, 4, 4, 4); + } + + MARGINS margins = { 0 }; + DwmExtendFrameIntoClientArea(hWnd, &margins); + SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + + break; + } + + case WM_ACTIVATE: + { + if (_glfw.hints.window.titlebar) + break; + + // Extend the frame into the client area. + MARGINS margins = { 0 }; + auto hr = DwmExtendFrameIntoClientArea(hWnd, &margins); + + if (!SUCCEEDED(hr)) + { + // Handle the error. + } + + break; + } } return DefWindowProcW(hWnd, uMsg, wParam, lParam); @@ -951,6 +996,16 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, break; } + case WM_NCCALCSIZE: + { + if (window->titlebar) + break; + + if (lParam) + return 0; + + break; + } case WM_SIZE: { const GLFWbool iconified = wParam == SIZE_MINIMIZED; @@ -1182,6 +1237,61 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, DragFinish(drop); return 0; } + + case WM_ACTIVATE: + { + if (window->titlebar) + break; + + // Extend the frame into the client area. + MARGINS margins = { 0 }; + auto hr = DwmExtendFrameIntoClientArea(hWnd, &margins); + + if (!SUCCEEDED(hr)) + { + // Handle the error. + } + + break; + } + case WM_NCHITTEST: + { + if (window->titlebar) + break; + + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + ScreenToClient(hWnd, &pt); + RECT rc; + GetClientRect(hWnd, &rc); + + int titlebarHittest = 0; + _glfwInputTitleBarHitTest(window, pt.x, pt.y, &titlebarHittest); + + if (titlebarHittest) + { + return HTCAPTION; + } + else + { + enum { left = 1, top = 2, right = 4, bottom = 8 }; + int hit = 0; + if (pt.x < border_thickness.left) hit |= left; + if (pt.x > rc.right - border_thickness.right) hit |= right; + if (pt.y < border_thickness.top) hit |= top; + if (pt.y > rc.bottom - border_thickness.bottom) hit |= bottom; + + if (hit & top && hit & left) return HTTOPLEFT; + if (hit & top && hit & right) return HTTOPRIGHT; + if (hit & bottom && hit & left) return HTBOTTOMLEFT; + if (hit & bottom && hit & right) return HTBOTTOMRIGHT; + if (hit & left) return HTLEFT; + if (hit & top) return HTTOP; + if (hit & right) return HTRIGHT; + if (hit & bottom) return HTBOTTOM; + + return HTCLIENT; + } + } } return DefWindowProcW(hWnd, uMsg, wParam, lParam); @@ -1828,6 +1938,11 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) updateWindowStyles(window); } +void _glfwPlatformSetWindowTitlebar(_GLFWwindow* window, GLFWbool enabled) +{ + updateWindowStyles(window); +} + void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) { const HWND after = enabled ? HWND_TOPMOST : HWND_NOTOPMOST; diff --git a/src/window.c b/src/window.c index bb5ba9567..74b9a6ea1 100644 --- a/src/window.c +++ b/src/window.c @@ -86,6 +86,14 @@ void _glfwInputWindowSize(_GLFWwindow* window, int width, int height) window->callbacks.size((GLFWwindow*) window, width, height); } +// Notifies shared code that mouse hittest needs to be resolved +// +void _glfwInputTitleBarHitTest(_GLFWwindow* window, int posX, int posY, int* hit) +{ + if (window->callbacks.tbhittest) + window->callbacks.tbhittest((GLFWwindow*)window, posX, posY, hit); +} + // Notifies shared code that a window has been iconified or restored // void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified) @@ -200,6 +208,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->monitor = (_GLFWmonitor*) monitor; window->resizable = wndconfig.resizable; window->decorated = wndconfig.decorated; + window->titlebar = wndconfig.titlebar; window->autoIconify = wndconfig.autoIconify; window->floating = wndconfig.floating; window->focusOnShow = wndconfig.focusOnShow; @@ -262,6 +271,7 @@ void glfwDefaultWindowHints(void) _glfw.hints.window.resizable = GLFW_TRUE; _glfw.hints.window.visible = GLFW_TRUE; _glfw.hints.window.decorated = GLFW_TRUE; + _glfw.hints.window.titlebar = GLFW_TRUE; _glfw.hints.window.focused = GLFW_TRUE; _glfw.hints.window.autoIconify = GLFW_TRUE; _glfw.hints.window.centerCursor = GLFW_TRUE; @@ -345,6 +355,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_DECORATED: _glfw.hints.window.decorated = value ? GLFW_TRUE : GLFW_FALSE; return; + case GLFW_TITLEBAR: + _glfw.hints.window.titlebar = value ? GLFW_TRUE : GLFW_FALSE; + return; case GLFW_FOCUSED: _glfw.hints.window.focused = value ? GLFW_TRUE : GLFW_FALSE; return; @@ -828,6 +841,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) return window->resizable; case GLFW_DECORATED: return window->decorated; + case GLFW_TITLEBAR: + return window->titlebar; case GLFW_FLOATING: return window->floating; case GLFW_AUTO_ICONIFY: @@ -889,6 +904,15 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) if (!window->monitor) _glfwPlatformSetWindowDecorated(window, value); } + else if (attrib == GLFW_TITLEBAR) + { + if (window->titlebar == value) + return; + + window->titlebar = value; + if (!window->monitor) + _glfwPlatformSetWindowTitlebar(window, value); + } else if (attrib == GLFW_FLOATING) { if (window->floating == value) @@ -981,6 +1005,16 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle, return cbfun; } +GLFWAPI GLFWtitlebarhittestfun glfwSetTitlebarHitTestCallback(GLFWwindow* handle, GLFWtitlebarhittestfun tbhtfun) +{ + _GLFWwindow* window = (_GLFWwindow*)handle; + assert(window != NULL); + + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFW_SWAP_POINTERS(window->callbacks.tbhittest, tbhtfun); + return tbhtfun; +} + GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle, GLFWwindowsizefun cbfun) { diff --git a/src/wl_window.c b/src/wl_window.c index c8dde30ad..1d2012a63 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1111,6 +1111,13 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) } } +void _glfwPlatformSetWindowTitlebar(_GLFWwindow* window, GLFWbool enabled) +{ + // TODO + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Window attribute setting not implemented yet"); +} + void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) { // TODO diff --git a/src/x11_window.c b/src/x11_window.c index d6e6bf379..5838ddf93 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2658,6 +2658,13 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) sizeof(hints) / sizeof(long)); } +void _glfwPlatformSetWindowTitlebar(_GLFWwindow* window, GLFWbool enabled) +{ + // TODO + _glfwInputError(GLFW_PLATFORM_ERROR, + "X11: Window attribute setting not implemented yet"); +} + void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) { if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_ABOVE) From aa91434c64bddf85cab16027b9af126f87cde028 Mon Sep 17 00:00:00 2001 From: TheCherno Date: Tue, 22 Feb 2022 12:53:35 +1100 Subject: [PATCH 09/21] Added missing files to premake - Also added a missing function to null platform --- premake5.lua | 11 ++++++++++- src/null_init.c | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/premake5.lua b/premake5.lua index 65452ab43..8f7c5a07c 100644 --- a/premake5.lua +++ b/premake5.lua @@ -15,9 +15,17 @@ project "GLFW" "src/init.c", "src/input.c", "src/monitor.c", + + "src/null_init.c", + "src/null_joystick.c", + "src/null_monitor.c", + "src/null_window.c", + + "src/platform.c", "src/vulkan.c", - "src/window.c" + "src/window.c", } + filter "system:linux" pic "On" @@ -49,6 +57,7 @@ project "GLFW" { "src/win32_init.c", "src/win32_joystick.c", + "src/win32_module.c", "src/win32_monitor.c", "src/win32_time.c", "src/win32_thread.c", diff --git a/src/null_init.c b/src/null_init.c index de4b28f35..3ffb01698 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -106,6 +106,7 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform) _glfwWaitEventsNull, _glfwWaitEventsTimeoutNull, _glfwPostEmptyEventNull, + _glfwSetWindowTitlebarNull, _glfwGetEGLPlatformNull, _glfwGetEGLNativeDisplayNull, _glfwGetEGLNativeWindowNull, From cb65f3d485b2c801181d53bd044859ae5489a68f Mon Sep 17 00:00:00 2001 From: TheCherno Date: Tue, 22 Feb 2022 14:18:51 +1100 Subject: [PATCH 10/21] Fixed titlebar refactor --- src/internal.h | 1 - src/win32_window.c | 6 +++--- src/window.c | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/internal.h b/src/internal.h index ec5c65aea..142dc0ee5 100644 --- a/src/internal.h +++ b/src/internal.h @@ -527,7 +527,6 @@ struct _GLFWwindow // Window settings and state GLFWbool resizable; GLFWbool decorated; - GLFWbool titlebar; GLFWbool autoIconify; GLFWbool floating; GLFWbool focusOnShow; diff --git a/src/win32_window.c b/src/win32_window.c index bbe81a316..f0b7bcfdf 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1015,7 +1015,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_NCCALCSIZE: { - if (window->titlebar) + if (_glfw.hints.window.titlebar) break; if (lParam) @@ -1268,7 +1268,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_ACTIVATE: { - if (window->titlebar) + if (_glfw.hints.window.titlebar) break; // Extend the frame into the client area. @@ -1284,7 +1284,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, } case WM_NCHITTEST: { - if (window->titlebar) + if (_glfw.hints.window.titlebar) break; POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; diff --git a/src/window.c b/src/window.c index c41caa100..72a6b25e6 100644 --- a/src/window.c +++ b/src/window.c @@ -852,7 +852,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) case GLFW_DECORATED: return window->decorated; case GLFW_TITLEBAR: - return window->titlebar; + return _glfw.hints.window.titlebar; case GLFW_FLOATING: return window->floating; case GLFW_AUTO_ICONIFY: @@ -913,10 +913,10 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) if (!window->monitor) _glfw.platform.setWindowDecorated(window, value); case GLFW_TITLEBAR: - if (window->titlebar == value) + if (_glfw.hints.window.titlebar == value) return; - window->titlebar = value; + _glfw.hints.window.titlebar = value; if (!window->monitor) _glfw.platform.setWindowTitleBar(window, value); return; From d516e6680183bed7096c8fb58c31365deb2cc9b7 Mon Sep 17 00:00:00 2001 From: TheCherno Date: Thu, 31 Mar 2022 09:56:44 +1100 Subject: [PATCH 11/21] Added Dist config to premake script --- premake5.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/premake5.lua b/premake5.lua index 8f7c5a07c..ed7ce228e 100644 --- a/premake5.lua +++ b/premake5.lua @@ -85,3 +85,8 @@ project "GLFW" filter "configurations:Release" runtime "Release" optimize "on" + + filter "configurations:Dist" + runtime "Release" + optimize "on" + symbols "off" \ No newline at end of file From a9d784817245d0b0a5f4ab781944342425876fbf Mon Sep 17 00:00:00 2001 From: Th3T3chn0G1t Date: Tue, 28 Jun 2022 12:31:56 +0100 Subject: [PATCH 12/21] Fixed macOS and Linux builds to work with Hazel patches --- premake5.lua | 23 +++++++++++++++++++++++ src/cocoa_init.m | 6 +++++- src/x11_init.c | 4 ++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/premake5.lua b/premake5.lua index ed7ce228e..d6bb8da29 100644 --- a/premake5.lua +++ b/premake5.lua @@ -39,6 +39,7 @@ project "GLFW" "src/xkb_unicode.c", "src/posix_time.c", "src/posix_thread.c", + "src/posix_module.c", "src/glx_context.c", "src/egl_context.c", "src/osmesa_context.c", @@ -50,6 +51,28 @@ project "GLFW" "_GLFW_X11" } + filter "system:macosx" + pic "On" + + files + { + "src/cocoa_init.m", + "src/cocoa_monitor.m", + "src/cocoa_window.m", + "src/cocoa_joystick.m", + "src/cocoa_time.c", + "src/nsgl_context.m", + "src/posix_thread.c", + "src/posix_module.c", + "src/osmesa_context.c", + "src/egl_context.c" + } + + defines + { + "_GLFW_COCOA" + } + filter "system:windows" systemversion "latest" diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 48bc2c294..5c0c4e82d 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -543,13 +543,17 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform) _glfwGetWindowOpacityCocoa, _glfwSetWindowResizableCocoa, _glfwSetWindowDecoratedCocoa, - _glfwSetWindowFloatingCocoa, + _glfwSetWindowFloatingNull, _glfwSetWindowOpacityCocoa, _glfwSetWindowMousePassthroughCocoa, _glfwPollEventsCocoa, _glfwWaitEventsCocoa, _glfwWaitEventsTimeoutCocoa, _glfwPostEmptyEventCocoa, + + // Hazel + _glfwSetWindowTitlebarNull, + _glfwGetEGLPlatformCocoa, _glfwGetEGLNativeDisplayCocoa, _glfwGetEGLNativeWindowCocoa, diff --git a/src/x11_init.c b/src/x11_init.c index acfa79338..a4e72a281 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1204,6 +1204,10 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform) _glfwWaitEventsX11, _glfwWaitEventsTimeoutX11, _glfwPostEmptyEventX11, + + // Hazel + _glfwSetWindowTitlebarNull, + _glfwGetEGLPlatformX11, _glfwGetEGLNativeDisplayX11, _glfwGetEGLNativeWindowX11, From 359bcc31d07640963eea97c448ab82acf80f0185 Mon Sep 17 00:00:00 2001 From: Mohit Sethi Date: Fri, 25 Nov 2022 21:32:36 +0530 Subject: [PATCH 13/21] Fix imgui window resizing and dragging issue while undocking. --- src/win32_window.c | 94 ++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 57 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index f0b7bcfdf..3313a139d 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -490,7 +490,9 @@ static void releaseMonitor(_GLFWwindow* window) static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static RECT border_thickness; + static RECT border_thickness = { 0, 0, 0, 0 }; + if (!_glfw.hints.window.titlebar) + SetRect(&border_thickness, 8, 8, 8, 8); _GLFWwindow* window = GetPropW(hWnd, L"GLFW"); if (!window) @@ -548,22 +550,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (_glfw.hints.window.titlebar) break; - //find border thickness - SetRectEmpty(&border_thickness); - if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_THICKFRAME) - { - AdjustWindowRectEx(&border_thickness, GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION, FALSE, NULL); - border_thickness.left *= -1; - border_thickness.top *= -1; - } - else// if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_BORDER) - { - SetRect(&border_thickness, 4, 4, 4, 4); - } - MARGINS margins = { 0 }; DwmExtendFrameIntoClientArea(hWnd, &margins); - SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); break; } @@ -573,14 +561,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (_glfw.hints.window.titlebar) break; - // Extend the frame into the client area. MARGINS margins = { 0 }; - auto hr = DwmExtendFrameIntoClientArea(hWnd, &margins); - - if (!SUCCEEDED(hr)) - { - // Handle the error. - } + DwmExtendFrameIntoClientArea(hWnd, &margins); break; } @@ -1273,13 +1255,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // Extend the frame into the client area. MARGINS margins = { 0 }; - auto hr = DwmExtendFrameIntoClientArea(hWnd, &margins); - - if (!SUCCEEDED(hr)) - { - // Handle the error. - } - + DwmExtendFrameIntoClientArea(hWnd, &margins); + break; } case WM_NCHITTEST: @@ -1287,38 +1264,41 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (_glfw.hints.window.titlebar) break; - POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - ScreenToClient(hWnd, &pt); - RECT rc; - GetClientRect(hWnd, &rc); + if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_THICKFRAME) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + ScreenToClient(hWnd, &pt); + RECT rc; + GetClientRect(hWnd, &rc); - int titlebarHittest = 0; - _glfwInputTitleBarHitTest(window, pt.x, pt.y, &titlebarHittest); + int titlebarHittest = 0; + _glfwInputTitleBarHitTest(window, pt.x, pt.y, &titlebarHittest); - if (titlebarHittest) - { - return HTCAPTION; - } - else - { - enum { left = 1, top = 2, right = 4, bottom = 8 }; - int hit = 0; - if (pt.x < border_thickness.left) hit |= left; - if (pt.x > rc.right - border_thickness.right) hit |= right; - if (pt.y < border_thickness.top) hit |= top; - if (pt.y > rc.bottom - border_thickness.bottom) hit |= bottom; + if (titlebarHittest) + { + return HTCAPTION; + } + else + { + enum { left = 1, top = 2, right = 4, bottom = 8 }; + int hit = 0; + if (pt.x < border_thickness.left) hit |= left; + if (pt.x > rc.right - border_thickness.right) hit |= right; + if (pt.y < border_thickness.top) hit |= top; + if (pt.y > rc.bottom - border_thickness.bottom) hit |= bottom; - if (hit & top && hit & left) return HTTOPLEFT; - if (hit & top && hit & right) return HTTOPRIGHT; - if (hit & bottom && hit & left) return HTBOTTOMLEFT; - if (hit & bottom && hit & right) return HTBOTTOMRIGHT; - if (hit & left) return HTLEFT; - if (hit & top) return HTTOP; - if (hit & right) return HTRIGHT; - if (hit & bottom) return HTBOTTOM; + if (hit & top && hit & left) return HTTOPLEFT; + if (hit & top && hit & right) return HTTOPRIGHT; + if (hit & bottom && hit & left) return HTBOTTOMLEFT; + if (hit & bottom && hit & right) return HTBOTTOMRIGHT; + if (hit & left) return HTLEFT; + if (hit & top) return HTTOP; + if (hit & right) return HTRIGHT; + if (hit & bottom) return HTBOTTOM; - return HTCLIENT; - } + return HTCLIENT; + } + } } } From 32af0691085ead064256925e60a68412c546f224 Mon Sep 17 00:00:00 2001 From: Mohit Sethi Date: Fri, 2 Dec 2022 20:34:26 +0530 Subject: [PATCH 14/21] Added Dist configuration + optimize for speed --- premake5.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/premake5.lua b/premake5.lua index ed7ce228e..62dd8001e 100644 --- a/premake5.lua +++ b/premake5.lua @@ -84,9 +84,9 @@ project "GLFW" filter "configurations:Release" runtime "Release" - optimize "on" + optimize "speed" - filter "configurations:Dist" + filter "configurations:Dist" runtime "Release" - optimize "on" - symbols "off" \ No newline at end of file + optimize "speed" + symbols "off" From db92674a9e0ee38344a6dcea71552a6be1f40d37 Mon Sep 17 00:00:00 2001 From: Mohit Sethi Date: Tue, 13 Dec 2022 14:57:46 +0530 Subject: [PATCH 15/21] Fix window clipping when maximized --- src/win32_window.c | 110 ++++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 37 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index 3313a139d..a2913d371 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -491,8 +491,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static RECT border_thickness = { 0, 0, 0, 0 }; - if (!_glfw.hints.window.titlebar) - SetRect(&border_thickness, 8, 8, 8, 8); + BOOL hasThickFrame = GetWindowLongPtr(hWnd, GWL_STYLE) & WS_THICKFRAME; _GLFWwindow* window = GetPropW(hWnd, L"GLFW"); if (!window) @@ -550,8 +549,21 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (_glfw.hints.window.titlebar) break; - MARGINS margins = { 0 }; - DwmExtendFrameIntoClientArea(hWnd, &margins); + if (hasThickFrame) + { + RECT size_rect; + GetWindowRect(hWnd, &size_rect); + + // Inform the application of the frame change to force redrawing with the new + // client area that is extended into the title bar + SetWindowPos( + hWnd, NULL, + size_rect.left, size_rect.top, + size_rect.right - size_rect.left, size_rect.bottom - size_rect.top, + SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE + ); + break; + } break; } @@ -561,9 +573,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (_glfw.hints.window.titlebar) break; - MARGINS margins = { 0 }; - DwmExtendFrameIntoClientArea(hWnd, &margins); - + RECT title_bar_rect = {0}; + InvalidateRect(hWnd, &title_bar_rect, FALSE); break; } } @@ -995,16 +1006,28 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, break; } - case WM_NCCALCSIZE: - { - if (_glfw.hints.window.titlebar) - break; + case WM_NCCALCSIZE: + { + if (_glfw.hints.window.titlebar || !hasThickFrame || !wParam) + break; - if (lParam) - return 0; + UINT dpi = GetDpiForWindow(hWnd); + + int frame_x = GetSystemMetricsForDpi(SM_CXFRAME, dpi); + int frame_y = GetSystemMetricsForDpi(SM_CYFRAME, dpi); + int padding = GetSystemMetricsForDpi(92, dpi); + + NCCALCSIZE_PARAMS* params = (NCCALCSIZE_PARAMS*)lParam; + RECT* requested_client_rect = params->rgrc; + + requested_client_rect->right -= frame_x + padding; + requested_client_rect->left += frame_x + padding; + requested_client_rect->bottom -= frame_y + padding; + requested_client_rect->top += frame_y + (window->win32.maximized ? 1.0f : -1.0f) * padding; + + return 0; + } - break; - } case WM_SIZE: { const int width = LOWORD(lParam); @@ -1045,6 +1068,18 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, window->win32.iconified = iconified; window->win32.maximized = maximized; + + RECT size_rect; + GetWindowRect(hWnd, &size_rect); + + // Inform the application of the frame change to force redrawing with the new + // client area that is extended into the title bar + SetWindowPos( + hWnd, NULL, + size_rect.left, size_rect.top, + size_rect.right - size_rect.left, size_rect.bottom - size_rect.top, + SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE + ); return 0; } @@ -1253,10 +1288,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (_glfw.hints.window.titlebar) break; - // Extend the frame into the client area. - MARGINS margins = { 0 }; - DwmExtendFrameIntoClientArea(hWnd, &margins); - + RECT title_bar_rect = { 0 }; + InvalidateRect(hWnd, &title_bar_rect, FALSE); break; } case WM_NCHITTEST: @@ -1264,28 +1297,26 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (_glfw.hints.window.titlebar) break; - if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_THICKFRAME) + if (hasThickFrame) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; ScreenToClient(hWnd, &pt); - RECT rc; - GetClientRect(hWnd, &rc); - - int titlebarHittest = 0; - _glfwInputTitleBarHitTest(window, pt.x, pt.y, &titlebarHittest); - - if (titlebarHittest) - { - return HTCAPTION; - } - else + + if (!window->win32.maximized) { + RECT rc; + GetClientRect(hWnd, &rc); + + UINT dpi = GetDpiForWindow(hWnd); + int frame_y = GetSystemMetricsForDpi(SM_CYFRAME, dpi); + int padding = GetSystemMetricsForDpi(92, dpi); + enum { left = 1, top = 2, right = 4, bottom = 8 }; int hit = 0; - if (pt.x < border_thickness.left) hit |= left; - if (pt.x > rc.right - border_thickness.right) hit |= right; - if (pt.y < border_thickness.top) hit |= top; - if (pt.y > rc.bottom - border_thickness.bottom) hit |= bottom; + if (pt.x < border_thickness.left) hit |= left; + if (pt.x > rc.right - border_thickness.right) hit |= right; + if (pt.y < border_thickness.top || pt.y < frame_y + padding) hit |= top; + if (pt.y > rc.bottom - border_thickness.bottom) hit |= bottom; if (hit & top && hit & left) return HTTOPLEFT; if (hit & top && hit & right) return HTTOPRIGHT; @@ -1295,9 +1326,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (hit & top) return HTTOP; if (hit & right) return HTRIGHT; if (hit & bottom) return HTBOTTOM; - - return HTCLIENT; } + + int titlebarHittest = 0; + _glfwInputTitleBarHitTest(window, pt.x, pt.y, &titlebarHittest); + if (titlebarHittest) + return HTCAPTION; + + return HTCLIENT; } } } From 8a96738c07a45fc1bad99d5babfdf8bd1ce195ee Mon Sep 17 00:00:00 2001 From: Mohit Sethi Date: Fri, 23 Dec 2022 17:42:38 +0530 Subject: [PATCH 16/21] Disable _CRT_SECURE_NO_WARNINGS --- premake5.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/premake5.lua b/premake5.lua index 62dd8001e..62e29bd3a 100644 --- a/premake5.lua +++ b/premake5.lua @@ -70,7 +70,6 @@ project "GLFW" defines { "_GLFW_WIN32", - "_CRT_SECURE_NO_WARNINGS" } links From a36f9a6a29cc373f86decfb5dd06b7f81eda061f Mon Sep 17 00:00:00 2001 From: Mohit Sethi Date: Sun, 25 Dec 2022 01:08:49 +0530 Subject: [PATCH 17/21] Turn off warnings --- premake5.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/premake5.lua b/premake5.lua index 62e29bd3a..e47049691 100644 --- a/premake5.lua +++ b/premake5.lua @@ -2,6 +2,7 @@ project "GLFW" kind "StaticLib" language "C" staticruntime "off" + warnings "off" targetdir ("bin/" .. outputdir .. "/%{prj.name}") objdir ("bin-int/" .. outputdir .. "/%{prj.name}") From 07df3a26af0fdd1f13455a0c3de62bab1f12e157 Mon Sep 17 00:00:00 2001 From: Mohit Sethi Date: Sun, 25 Dec 2022 03:52:42 +0530 Subject: [PATCH 18/21] Remove dwmapi linking, compile posix_module.c as well for Linux --- premake5.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/premake5.lua b/premake5.lua index e47049691..7376fdd62 100644 --- a/premake5.lua +++ b/premake5.lua @@ -38,6 +38,7 @@ project "GLFW" "src/x11_monitor.c", "src/x11_window.c", "src/xkb_unicode.c", + "src/posix_module.c", "src/posix_time.c", "src/posix_thread.c", "src/glx_context.c", @@ -73,11 +74,6 @@ project "GLFW" "_GLFW_WIN32", } - links - { - "Dwmapi.lib" - } - filter "configurations:Debug" runtime "Debug" symbols "on" From f664c210a2c79474874df4329127e28689a5a8ca Mon Sep 17 00:00:00 2001 From: Mohit Sethi Date: Sat, 1 Apr 2023 04:39:03 +0530 Subject: [PATCH 19/21] Fix errors with GetSystemMetricsForDpi --- src/win32_window.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index a2913d371..3a57c307c 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1011,19 +1011,16 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (_glfw.hints.window.titlebar || !hasThickFrame || !wParam) break; - UINT dpi = GetDpiForWindow(hWnd); - - int frame_x = GetSystemMetricsForDpi(SM_CXFRAME, dpi); - int frame_y = GetSystemMetricsForDpi(SM_CYFRAME, dpi); - int padding = GetSystemMetricsForDpi(92, dpi); + const int frame_x = 2.0f * GetSystemMetrics(SM_CXFRAME); + const int frame_y = 2.0f * GetSystemMetrics(SM_CYFRAME); NCCALCSIZE_PARAMS* params = (NCCALCSIZE_PARAMS*)lParam; RECT* requested_client_rect = params->rgrc; - requested_client_rect->right -= frame_x + padding; - requested_client_rect->left += frame_x + padding; - requested_client_rect->bottom -= frame_y + padding; - requested_client_rect->top += frame_y + (window->win32.maximized ? 1.0f : -1.0f) * padding; + requested_client_rect->right -= frame_x; + requested_client_rect->left += frame_x; + requested_client_rect->bottom -= frame_y; + requested_client_rect->top += window->win32.maximized ? frame_y : 0.0f; return 0; } @@ -1307,15 +1304,13 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, RECT rc; GetClientRect(hWnd, &rc); - UINT dpi = GetDpiForWindow(hWnd); - int frame_y = GetSystemMetricsForDpi(SM_CYFRAME, dpi); - int padding = GetSystemMetricsForDpi(92, dpi); + int frame_y = 2.0f * GetSystemMetrics(SM_CYFRAME); enum { left = 1, top = 2, right = 4, bottom = 8 }; int hit = 0; if (pt.x < border_thickness.left) hit |= left; if (pt.x > rc.right - border_thickness.right) hit |= right; - if (pt.y < border_thickness.top || pt.y < frame_y + padding) hit |= top; + if (pt.y < border_thickness.top || pt.y < frame_y) hit |= top; if (pt.y > rc.bottom - border_thickness.bottom) hit |= bottom; if (hit & top && hit & left) return HTTOPLEFT; From 62fad91c8b5d46131e234600607d3bb6d881cf34 Mon Sep 17 00:00:00 2001 From: Peter Nilsson Date: Thu, 20 Apr 2023 19:53:22 +0200 Subject: [PATCH 20/21] Removed linking from premake5.lua - I will note that linking should be done by the target application (e.g Hazelnut) --- premake5.lua | 5 ----- src/win32_window.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/premake5.lua b/premake5.lua index d6bb8da29..4714ddf4a 100644 --- a/premake5.lua +++ b/premake5.lua @@ -96,11 +96,6 @@ project "GLFW" "_CRT_SECURE_NO_WARNINGS" } - links - { - "Dwmapi.lib" - } - filter "configurations:Debug" runtime "Debug" symbols "on" diff --git a/src/win32_window.c b/src/win32_window.c index f0b7bcfdf..8f5b57860 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -552,7 +552,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, SetRectEmpty(&border_thickness); if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_THICKFRAME) { - AdjustWindowRectEx(&border_thickness, GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION, FALSE, NULL); + AdjustWindowRectEx(&border_thickness, GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION, FALSE, 0); border_thickness.left *= -1; border_thickness.top *= -1; } From 026a148d7dd78d597de380c4e77ca0869f0ceaab Mon Sep 17 00:00:00 2001 From: TheCherno Date: Fri, 15 Sep 2023 09:19:23 +1000 Subject: [PATCH 21/21] Added Debug-AS config to build script --- premake5.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/premake5.lua b/premake5.lua index d7a70410b..b0e66cb2e 100644 --- a/premake5.lua +++ b/premake5.lua @@ -102,6 +102,12 @@ project "GLFW" runtime "Debug" symbols "on" + filter { "system:windows", "configurations:Debug-AS" } + runtime "Debug" + symbols "on" + sanitize { "Address" } + flags { "NoRuntimeChecks", "NoIncrementalLink" } + filter "configurations:Release" runtime "Release" optimize "speed"