diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index f8b0ae00..b87dd461 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3312,6 +3312,8 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); */ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images); +GLFWAPI void glfwSetWindowTitlebarColor(GLFWwindow* window, int r, int g, int b, int a); + /*! @brief Retrieves the position of the content area of the specified window. * * This function retrieves the position, in screen coordinates, of the diff --git a/src/cocoa_init.m b/src/cocoa_init.m index b3831df1..96fa6e98 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -527,6 +527,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform) _glfwCreateWindowCocoa, _glfwDestroyWindowCocoa, _glfwSetWindowTitleCocoa, + _glfwSetWindowTitlebarColorCocoa, _glfwSetWindowIconCocoa, _glfwGetWindowPosCocoa, _glfwSetWindowPosCocoa, diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 9f7d191d..75a5f309 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -217,6 +217,7 @@ void _glfwTerminateCocoa(void); GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); void _glfwDestroyWindowCocoa(_GLFWwindow* window); void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title); +void _glfwSetWindowTitlebarColorCocoa(_GLFWwindow* window, int r, int g, int b, int a); void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos); void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos); diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 1d2644d7..92677f28 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1027,6 +1027,20 @@ void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title) [window->ns.object setMiniwindowTitle:string]; } // autoreleasepool } +void _glfwSetWindowTitlebarColorCocoa(_GLFWwindow* window, int r, int g, int b, int a) +{ + @autoreleasepool { + CGFloat red = r/ 255; + CGFloat green =g / 255; + CGFloat blue = b / 255; + CGFloat alpha = a / 255; + + NSColor *color = [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:alpha]; + + [window->ns.object setTitlebarAppearsTransparent:YES]; // gives it "flat" look + [window->ns.object setBackgroundColor:color]; + } // autoreleasepool +} void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images) diff --git a/src/internal.h b/src/internal.h index fe0369aa..d22ece75 100644 --- a/src/internal.h +++ b/src/internal.h @@ -708,6 +708,7 @@ struct _GLFWplatform GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*); void (*destroyWindow)(_GLFWwindow*); void (*setWindowTitle)(_GLFWwindow*,const char*); + void (*setWindowTitlebarColor)(_GLFWwindow*,int, int, int, int); void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*); void (*getWindowPos)(_GLFWwindow*,int*,int*); void (*setWindowPos)(_GLFWwindow*,int,int); diff --git a/src/null_platform.h b/src/null_platform.h index fb9374b4..a8e73804 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -212,6 +212,7 @@ void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); void _glfwDestroyWindowNull(_GLFWwindow* window); void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title); +void _glfwSetWindowTitlebarColorNull(_GLFWwindow* window, int r, int g, int b, int a); void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos); diff --git a/src/null_window.c b/src/null_window.c index e0bbb3b6..646452da 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -181,6 +181,9 @@ void _glfwDestroyWindowNull(_GLFWwindow* window) void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title) { +} +void _glfwSetWindowTitlebarColorNull(_GLFWwindow* window, int r, int g, int b, int a) { + } void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images) diff --git a/src/win32_init.c b/src/win32_init.c index ef2615f1..cdb91c9e 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -637,6 +637,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform) _glfwCreateWindowWin32, _glfwDestroyWindowWin32, _glfwSetWindowTitleWin32, + _glfwSetWindowTitlebarColorWin32, _glfwSetWindowIconWin32, _glfwGetWindowPosWin32, _glfwSetWindowPosWin32, diff --git a/src/win32_platform.h b/src/win32_platform.h index 82b34bb9..056d6b1e 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -542,6 +542,7 @@ void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* ys GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); void _glfwDestroyWindowWin32(_GLFWwindow* window); void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title); +void _glfwSetWindowTitlebarColorWin32(_GLFWwindow* window, int r, int g, int b, int a); void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos); void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos); diff --git a/src/win32_window.c b/src/win32_window.c index a4a18171..a23b1419 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1538,7 +1538,9 @@ void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title) SetWindowTextW(window->win32.handle, wideTitle); _glfw_free(wideTitle); } - +void _glfwSetWindowTitlebarColorWin32(GLFWwindow* window, int r, int g, int b, int a) { + +} void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images) { HICON bigIcon = NULL, smallIcon = NULL; diff --git a/src/window.c b/src/window.c index 1c8519ff..7aae3d1b 100644 --- a/src/window.c +++ b/src/window.c @@ -524,7 +524,13 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title) _GLFW_REQUIRE_INIT(); _glfw.platform.setWindowTitle(window, title); } - +GLFWAPI void glfwSetWindowTitlebarColor(GLFWwindow* handle, int r, int g, int b, int a) { + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + assert(window != NULL); + _GLFW_REQUIRE_INIT(); + _glfw.platform.setWindowTitlebarColor(handle, r,g,b,a); +} GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle, int count, const GLFWimage* images) { diff --git a/src/wl_init.c b/src/wl_init.c index 0ec65900..1f69f34a 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -447,6 +447,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform) _glfwCreateWindowWayland, _glfwDestroyWindowWayland, _glfwSetWindowTitleWayland, + _glfwSetWindowTitlebarColorWayland, _glfwSetWindowIconWayland, _glfwGetWindowPosWayland, _glfwSetWindowPosWayland, diff --git a/src/wl_platform.h b/src/wl_platform.h index d00e28fe..aaacc902 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -24,6 +24,7 @@ // //======================================================================== +#include "internal.h" #include #include #include @@ -612,6 +613,7 @@ void _glfwTerminateWayland(void); GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); void _glfwDestroyWindowWayland(_GLFWwindow* window); void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title); +void _glfwSetWindowTitlebarColorWayland(_GLFWwindow* window, int r, int g, int b, int a); void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos); void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos); diff --git a/src/wl_window.c b/src/wl_window.c index 7c509896..277a7f0a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2111,6 +2111,9 @@ void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title) else if (window->wl.xdg.toplevel) xdg_toplevel_set_title(window->wl.xdg.toplevel, title); } +void _glfwSetWindowTitlebarColorWayland(_GLFWwindow* window, int r, int g, int b, int a) { + +} void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images) diff --git a/src/x11_init.c b/src/x11_init.c index a0100f2f..6b745c5f 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1208,6 +1208,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform) _glfwCreateWindowX11, _glfwDestroyWindowX11, _glfwSetWindowTitleX11, + _glfwSetWindowTitlebarColorX11, _glfwSetWindowIconX11, _glfwGetWindowPosX11, _glfwSetWindowPosX11, diff --git a/src/x11_platform.h b/src/x11_platform.h index cdea3957..06c17e59 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -25,6 +25,7 @@ // //======================================================================== +#include "internal.h" #include #include #include @@ -904,6 +905,7 @@ void _glfwTerminateX11(void); GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); void _glfwDestroyWindowX11(_GLFWwindow* window); void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title); +void _glfwSetWindowTitlebarColorX11(_GLFWwindow* window, int r, int g, int b, int a); void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos); void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos); diff --git a/src/x11_window.c b/src/x11_window.c index 7da9b965..4b3eaee6 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2101,6 +2101,9 @@ void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title) XFlush(_glfw.x11.display); } +void _glfwSetWindowTitlebarColorX11(_GLFWwindow* window, int r, int g, int b, int a) { + +} void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images) {