diff --git a/docs/changelog.rst b/docs/changelog.rst index 301e6560b..b1ceebc63 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -54,6 +54,8 @@ Detailed list of changes - Wayland: Support preferred integer scales +- Wayland KDE: Support :opt:`background_blur` + - A new option :opt:`terminfo_type` to allow passing the terminfo database embedded into the :envvar:`TERMINFO` env var directly instead of via a file - Mouse reporting: Fix drag release event outside the window not being reported in legacy mouse reporting modes (:iss:`7244`) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index f525113e1..64137dd9c 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -38,8 +38,6 @@ #define debug(...) if (_glfw.hints.init.debugRendering) fprintf(stderr, __VA_ARGS__); -GLFWAPI int glfwCocoaSetBackgroundBlur(GLFWwindow *w, int radius); - static const char* polymorphic_string_as_utf8(id string) { if (string == nil) return "(nil)"; @@ -1868,7 +1866,7 @@ static bool createNativeWindow(_GLFWwindow* window, _glfwPlatformGetWindowSize(window, &window->ns.width, &window->ns.height); _glfwPlatformGetFramebufferSize(window, &window->ns.fbWidth, &window->ns.fbHeight); - if (wndconfig->ns.blur_radius > 0) glfwCocoaSetBackgroundBlur((GLFWwindow*)window, wndconfig->ns.blur_radius); + if (wndconfig->blur_radius > 0) _glfwPlatformSetWindowBlur(window, wndconfig->blur_radius); return true; } @@ -2986,6 +2984,18 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, #endif } +int +_glfwPlatformSetWindowBlur(_GLFWwindow *window, int radius) { + int orig = window->ns.blur_radius; + if (radius > -1 && radius != window->ns.blur_radius) { + extern OSStatus CGSSetWindowBackgroundBlurRadius(void* connection, NSInteger windowNumber, int radius); + extern void* CGSDefaultConnectionForThread(void); + CGSSetWindowBackgroundBlurRadius(CGSDefaultConnectionForThread(), [window->ns.object windowNumber], radius); + window->ns.blur_radius = radius; + } + return orig; +} + ////////////////////////////////////////////////////////////////////////// ////// GLFW native API ////// @@ -3025,18 +3035,6 @@ GLFWAPI void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun requestRenderFrame((_GLFWwindow*)w, callback); } -GLFWAPI int glfwCocoaSetBackgroundBlur(GLFWwindow *w, int radius) { - _GLFWwindow* window = (_GLFWwindow*)w; - int orig = window->ns.blur_radius; - if (radius > -1 && radius != window->ns.blur_radius) { - extern OSStatus CGSSetWindowBackgroundBlurRadius(void* connection, NSInteger windowNumber, int radius); - extern void* CGSDefaultConnectionForThread(void); - CGSSetWindowBackgroundBlurRadius(CGSDefaultConnectionForThread(), [window->ns.object windowNumber], radius); - window->ns.blur_radius = radius; - } - return orig; -} - GLFWAPI GLFWcocoarenderframefun glfwCocoaSetWindowResizeCallback(GLFWwindow *w, GLFWcocoarenderframefun cb) { _GLFWwindow* window = (_GLFWwindow*)w; GLFWcocoarenderframefun current = window->ns.resizeCallback; @@ -3078,7 +3076,7 @@ GLFWAPI void glfwCocoaSetWindowChrome(GLFWwindow *w, unsigned int color, bool us } [window->ns.object setBackgroundColor:background]; [window->ns.object setAppearance:appearance]; - glfwCocoaSetBackgroundBlur(w, background_blur); + _glfwPlatformSetWindowBlur(w, background_blur); bool has_shadow = false; const char *decorations_desc = "full"; window->ns.titlebar_hidden = false; diff --git a/glfw/glfw.py b/glfw/glfw.py index 1d60fbfa7..3fca901ea 100755 --- a/glfw/glfw.py +++ b/glfw/glfw.py @@ -204,9 +204,14 @@ def build_wayland_protocols( ) -> None: items = [] for protocol in env.wayland_protocols: - src = os.path.join(env.wayland_packagedir, protocol) - if not os.path.exists(src): - raise SystemExit(f'The wayland-protocols package on your system is missing the {protocol} protocol definition file') + if '/' in protocol: + src = os.path.join(env.wayland_packagedir, protocol) + if not os.path.exists(src): + raise SystemExit(f'The wayland-protocols package on your system is missing the {protocol} protocol definition file') + else: + src = os.path.join(os.path.dirname(os.path.abspath(__file__)), protocol) + if not os.path.exists(src): + raise SystemExit(f'The local Wayland protocol {protocol} is missing from kitty sources') for ext in 'hc': dest = wayland_protocol_file_name(src, ext) dest = os.path.join(dest_dir, dest) @@ -297,8 +302,6 @@ def generate_wrappers(glfw_header: str) -> None: uint32_t glfwGetCocoaKeyEquivalent(uint32_t glfw_key, int glfw_mods, int* cocoa_mods) void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun callback) GLFWcocoarenderframefun glfwCocoaSetWindowResizeCallback(GLFWwindow *w, GLFWcocoarenderframefun callback) - int glfwCocoaSetBackgroundBlur(GLFWwindow *w, int blur_radius) - bool glfwSetX11WindowBlurred(GLFWwindow *w, bool enable_blur) void* glfwGetX11Display(void) unsigned long glfwGetX11Window(GLFWwindow* window) void glfwSetPrimarySelectionString(GLFWwindow* window, const char* string) diff --git a/glfw/glfw3.h b/glfw/glfw3.h index a2167e243..e35d1330b 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -1034,10 +1034,10 @@ typedef enum { SRGB_COLORSPACE = 1, DISPLAY_P3_COLORSPACE = 2, } GlfwCocoaColorSpaces; -/*! @brief macOS specific - * [window hint](@ref GLFW_COCOA_BLUR_RADIUS_hint). +/*! @brief Blur Radius. On macOS the actual radius is used. On Linux it is treated as a bool. + * [window hint](@ref GLFW_BLUR_RADIUS). */ -#define GLFW_COCOA_BLUR_RADIUS 0x00023005 +#define GLFW_BLUR_RADIUS 0x0002305 /*! @brief X11 specific * [window hint](@ref GLFW_X11_CLASS_NAME_hint). @@ -1047,7 +1047,6 @@ typedef enum { * [window hint](@ref GLFW_X11_CLASS_NAME_hint). */ #define GLFW_X11_INSTANCE_NAME 0x00024002 -#define GLFW_X11_BLUR 0x00024003 #define GLFW_WAYLAND_APP_ID 0x00025001 /*! @} */ @@ -3800,6 +3799,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); * @ingroup window */ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value); +GLFWAPI int glfwSetWindowBlur(GLFWwindow* window, int value); /*! @brief Sets the user pointer of the specified window. * diff --git a/glfw/internal.h b/glfw/internal.h index d3c2832ba..9465d6319 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -310,16 +310,15 @@ struct _GLFWwndconfig bool focusOnShow; bool mousePassthrough; bool scaleToMonitor; + int blur_radius; struct { bool retina; int color_space; - int blur_radius; char frameName[256]; } ns; struct { char className[256]; char instanceName[256]; - int enable_blur; } x11; struct { char appId[256]; @@ -865,6 +864,7 @@ void _glfwPlatformStopMainLoop(void); unsigned long long _glfwPlatformAddTimer(monotonic_t interval, bool repeats, GLFWuserdatafun callback, void *callback_data, GLFWuserdatafun free_callback); void _glfwPlatformUpdateTimer(unsigned long long timer_id, monotonic_t interval, bool enabled); void _glfwPlatformRemoveTimer(unsigned long long timer_id); +int _glfwPlatformSetWindowBlur(_GLFWwindow* handle, int value); char* _glfw_strdup(const char* source); diff --git a/glfw/kwin-blur-v1.xml b/glfw/kwin-blur-v1.xml new file mode 100644 index 000000000..477bd72af --- /dev/null +++ b/glfw/kwin-blur-v1.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/glfw/source-info.json b/glfw/source-info.json index 90f4d393a..1f4907b04 100644 --- a/glfw/source-info.json +++ b/glfw/source-info.json @@ -80,7 +80,9 @@ "staging/xdg-activation/xdg-activation-v1.xml", "unstable/tablet/tablet-unstable-v2.xml", "staging/cursor-shape/cursor-shape-v1.xml", - "staging/fractional-scale/fractional-scale-v1.xml" + "staging/fractional-scale/fractional-scale-v1.xml", + + "kwin-blur-v1.xml" ], "sources": [ "wl_init.c", diff --git a/glfw/window.c b/glfw/window.c index 0e55b0577..23ea9cfa0 100644 --- a/glfw/window.c +++ b/glfw/window.c @@ -34,7 +34,6 @@ #include #include #include -#include ////////////////////////////////////////////////////////////////////////// @@ -315,6 +314,7 @@ void glfwDefaultWindowHints(void) _glfw.hints.window.autoIconify = true; _glfw.hints.window.centerCursor = true; _glfw.hints.window.focusOnShow = true; + _glfw.hints.window.blur_radius = 0; // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil, // double buffered @@ -334,9 +334,6 @@ void glfwDefaultWindowHints(void) _glfw.hints.window.ns.retina = true; // use the default colorspace assigned by the system _glfw.hints.window.ns.color_space = 0; - // no blur - _glfw.hints.window.ns.blur_radius = 0; - _glfw.hints.window.x11.enable_blur = 0; } GLFWAPI void glfwWindowHint(int hint, int value) @@ -420,11 +417,8 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_COCOA_COLOR_SPACE: _glfw.hints.window.ns.color_space = value; return; - case GLFW_COCOA_BLUR_RADIUS: - _glfw.hints.window.ns.blur_radius = value; - return; - case GLFW_X11_BLUR: - _glfw.hints.window.x11.enable_blur = value; + case GLFW_BLUR_RADIUS: + _glfw.hints.window.blur_radius = value; return; case GLFW_COCOA_GRAPHICS_SWITCHING: _glfw.hints.context.nsgl.offline = value ? true : false; @@ -1018,6 +1012,16 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib); } +GLFWAPI int glfwSetWindowBlur(GLFWwindow* handle, int value) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + + _GLFW_REQUIRE_INIT_OR_RETURN(0); + return _glfwPlatformSetWindowBlur(window, value); +} + + GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; diff --git a/glfw/wl_init.c b/glfw/wl_init.c index a3d640149..9a153e4c2 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -735,6 +735,9 @@ static void registryHandleGlobal(void* data UNUSED, else if (is(wp_viewporter)) { _glfw.wl.wp_viewporter = wl_registry_bind(registry, name, &wp_viewporter_interface, 1); } + else if (is(org_kde_kwin_blur_manager)) { + _glfw.wl.org_kde_kwin_blur_manager = wl_registry_bind(registry, name, &org_kde_kwin_blur_manager_interface, 1); + } #undef is } @@ -975,6 +978,8 @@ void _glfwPlatformTerminate(void) wp_viewporter_destroy(_glfw.wl.wp_viewporter); if (_glfw.wl.wp_fractional_scale_manager_v1) wp_fractional_scale_manager_v1_destroy(_glfw.wl.wp_fractional_scale_manager_v1); + if (_glfw.wl.org_kde_kwin_blur_manager) + org_kde_kwin_blur_manager_destroy(_glfw.wl.org_kde_kwin_blur_manager); if (_glfw.wl.registry) wl_registry_destroy(_glfw.wl.registry); diff --git a/glfw/wl_platform.h b/glfw/wl_platform.h index 0d2f11126..8e648d8cd 100644 --- a/glfw/wl_platform.h +++ b/glfw/wl_platform.h @@ -62,6 +62,7 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR #include "wayland-cursor-shape-v1-client-protocol.h" #include "wayland-fractional-scale-v1-client-protocol.h" #include "wayland-viewporter-client-protocol.h" +#include "wayland-kwin-blur-v1-client-protocol.h" #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) #define _glfw_dlclose(handle) dlclose(handle) @@ -165,6 +166,8 @@ typedef struct _GLFWwindowWayland } xdg; struct wp_fractional_scale_v1 *wp_fractional_scale_v1; struct wp_viewport *wp_viewport; + struct org_kde_kwin_blur *org_kde_kwin_blur; + bool has_blur; _GLFWcursor* currentCursor; double cursorPosX, cursorPosY, allCursorPosX, allCursorPosY; @@ -295,6 +298,7 @@ typedef struct _GLFWlibraryWayland struct wp_cursor_shape_device_v1* wp_cursor_shape_device_v1; struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1; struct wp_viewporter *wp_viewporter; + struct org_kde_kwin_blur_manager *org_kde_kwin_blur_manager; int compositorVersion; int seatVersion; diff --git a/glfw/wl_window.c b/glfw/wl_window.c index e02296152..380b88a3f 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -307,18 +307,22 @@ commit_window_surface_if_safe(_GLFWwindow *window) { } } -// Makes the surface considered as XRGB instead of ARGB. -static void setOpaqueRegion(_GLFWwindow* window, bool commit_surface) -{ - struct wl_region* region; - - region = wl_compositor_create_region(_glfw.wl.compositor); - if (!region) - return; +static void +update_regions(_GLFWwindow* window) { + if (window->wl.transparent && !window->wl.org_kde_kwin_blur) return; + struct wl_region* region = wl_compositor_create_region(_glfw.wl.compositor); + if (!region) return; wl_region_add(region, 0, 0, window->wl.width, window->wl.height); - wl_surface_set_opaque_region(window->wl.surface, region); - if (commit_surface) commit_window_surface_if_safe(window); + // Makes the surface considered as XRGB instead of ARGB. + if (!window->wl.transparent) wl_surface_set_opaque_region(window->wl.surface, region); + + // Set blur region + if (window->wl.org_kde_kwin_blur) { + org_kde_kwin_blur_set_region(window->wl.org_kde_kwin_blur, window->wl.has_blur ? region: NULL); + org_kde_kwin_blur_commit(window->wl.org_kde_kwin_blur); + } + wl_region_destroy(region); } @@ -344,7 +348,7 @@ resizeFramebuffer(_GLFWwindow* window) { debug("Resizing framebuffer to: %dx%d window size: %dx%d at scale: %.2f\n", scaled_width, scaled_height, window->wl.width, window->wl.height, scale); wl_egl_window_resize(window->wl.native, scaled_width, scaled_height, 0, 0); - if (!window->wl.transparent) setOpaqueRegion(window, false); + update_regions(window); window->wl.waiting_for_swap_to_commit = true; _glfwInputFramebufferSize(window, scaled_width, scaled_height); } @@ -543,6 +547,7 @@ static bool createSurface(_GLFWwindow* window, window->wl.wp_viewport = wp_viewporter_get_viewport(_glfw.wl.wp_viewporter, window->wl.surface); wp_fractional_scale_v1_add_listener(window->wl.wp_fractional_scale_v1, &fractional_scale_listener, window); } + if (_glfw.wl.org_kde_kwin_blur_manager && wndconfig->blur_radius > 0) _glfwPlatformSetWindowBlur(window, wndconfig->blur_radius); window->wl.integer_scale.deduced = scale; if (_glfw.wl.has_preferred_buffer_scale) { scale = 1; window->wl.integer_scale.preferred = 1; } @@ -558,8 +563,7 @@ static bool createSurface(_GLFWwindow* window, window->wl.user_requested_content_size.height = wndconfig->height; - if (!window->wl.transparent) - setOpaqueRegion(window, false); + update_regions(window); wl_surface_set_buffer_scale(window->wl.surface, scale); return true; @@ -1065,6 +1069,8 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) wp_fractional_scale_v1_destroy(window->wl.wp_fractional_scale_v1); if (window->wl.wp_viewport) wp_viewport_destroy(window->wl.wp_viewport); + if (window->wl.org_kde_kwin_blur) + org_kde_kwin_blur_release(window->wl.org_kde_kwin_blur); if (window->context.destroy) window->context.destroy(window); @@ -2331,6 +2337,20 @@ _glfwPlatformChangeCursorTheme(void) { } +int +_glfwPlatformSetWindowBlur(_GLFWwindow *window, int blur_radius) { + if (!window->wl.transparent) return 0; + bool has_blur = window->wl.has_blur; + bool new_has_blur = blur_radius > 0; + if (new_has_blur != has_blur) { + if (!window->wl.org_kde_kwin_blur) + window->wl.org_kde_kwin_blur = org_kde_kwin_blur_manager_create(_glfw.wl.org_kde_kwin_blur_manager, window->wl.surface); + window->wl.has_blur = new_has_blur; + update_regions(window); + } + return has_blur ? 1 : 0; +} + ////////////////////////////////////////////////////////////////////////// ////// GLFW native API ////// ////////////////////////////////////////////////////////////////////////// diff --git a/glfw/x11_window.c b/glfw/x11_window.c index cd958e1bf..90ecd08de 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -63,7 +63,6 @@ // covers GLX functions // static unsigned _glfwDispatchX11Events(void); -GLFWAPI bool glfwSetX11WindowBlurred(GLFWwindow *w, bool enable_blur); static void handleEvents(monotonic_t timeout) { @@ -713,9 +712,7 @@ static bool createNativeWindow(_GLFWwindow* window, _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos); _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height); - if (_glfw.hints.window.x11.enable_blur) { - glfwSetX11WindowBlurred((GLFWwindow*)window, 1); - } + if (_glfw.hints.window.blur_radius > 0) _glfwPlatformSetWindowBlur(window, _glfw.hints.window.blur_radius); return true; } @@ -3216,6 +3213,25 @@ _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) { glfw_xkb_update_ime_state(w, &_glfw.x11.xkb, ev); } +int +_glfwPlatformSetWindowBlur(_GLFWwindow *window, int blur_radius) { + if (_glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION == None) { + _glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION = XInternAtom(_glfw.x11.display, "_KDE_NET_WM_BLUR_BEHIND_REGION", False); + } + if (_glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION != None) { + uint32_t data = 0; + if (blur_radius > 0) { + XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION, + XA_CARDINAL, 32, PropModeReplace, (unsigned char*) &data, 1); + } else { + XDeleteProperty(_glfw.x11.display, window->x11.handle, _glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION); + } + return 1; + } + return 0; +} + + ////////////////////////////////////////////////////////////////////////// ////// GLFW native API ////// ////////////////////////////////////////////////////////////////////////// @@ -3260,25 +3276,6 @@ GLFWAPI void glfwSetX11WindowAsDock(int32_t x11_window_id) { PropModeReplace, (unsigned char*) &type, 1); } -GLFWAPI bool glfwSetX11WindowBlurred(GLFWwindow *w, bool enable_blur) { - _GLFW_REQUIRE_INIT_OR_RETURN(0); - _GLFWwindow *window = (_GLFWwindow*)w; - if (_glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION == None) { - _glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION = XInternAtom(_glfw.x11.display, "_KDE_NET_WM_BLUR_BEHIND_REGION", False); - } - if (_glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION != None) { - uint32_t data = 0; - if (enable_blur) { - XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION, - XA_CARDINAL, 32, PropModeReplace, (unsigned char*) &data, 1); - } else { - XDeleteProperty(_glfw.x11.display, window->x11.handle, _glfw.x11._KDE_NET_WM_BLUR_BEHIND_REGION); - } - return true; - } - return false; -} - GLFWAPI void glfwSetX11WindowStrut(int32_t x11_window_id, uint32_t dimensions[12]) { _GLFW_REQUIRE_INIT(); diff --git a/kitty/glfw-wrapper.c b/kitty/glfw-wrapper.c index f14c24cdc..d5159141d 100644 --- a/kitty/glfw-wrapper.c +++ b/kitty/glfw-wrapper.c @@ -221,6 +221,9 @@ load_glfw(const char* path) { *(void **) (&glfwSetWindowAttrib_impl) = dlsym(handle, "glfwSetWindowAttrib"); if (glfwSetWindowAttrib_impl == NULL) fail("Failed to load glfw function glfwSetWindowAttrib with error: %s", dlerror()); + *(void **) (&glfwSetWindowBlur_impl) = dlsym(handle, "glfwSetWindowBlur"); + if (glfwSetWindowBlur_impl == NULL) fail("Failed to load glfw function glfwSetWindowBlur with error: %s", dlerror()); + *(void **) (&glfwSetWindowUserPointer_impl) = dlsym(handle, "glfwSetWindowUserPointer"); if (glfwSetWindowUserPointer_impl == NULL) fail("Failed to load glfw function glfwSetWindowUserPointer with error: %s", dlerror()); @@ -443,12 +446,6 @@ load_glfw(const char* path) { *(void **) (&glfwCocoaSetWindowResizeCallback_impl) = dlsym(handle, "glfwCocoaSetWindowResizeCallback"); if (glfwCocoaSetWindowResizeCallback_impl == NULL) dlerror(); // clear error indicator - *(void **) (&glfwCocoaSetBackgroundBlur_impl) = dlsym(handle, "glfwCocoaSetBackgroundBlur"); - if (glfwCocoaSetBackgroundBlur_impl == NULL) dlerror(); // clear error indicator - - *(void **) (&glfwSetX11WindowBlurred_impl) = dlsym(handle, "glfwSetX11WindowBlurred"); - if (glfwSetX11WindowBlurred_impl == NULL) dlerror(); // clear error indicator - *(void **) (&glfwGetX11Display_impl) = dlsym(handle, "glfwGetX11Display"); if (glfwGetX11Display_impl == NULL) dlerror(); // clear error indicator diff --git a/kitty/glfw-wrapper.h b/kitty/glfw-wrapper.h index 3e43bf81c..cb44daa7a 100644 --- a/kitty/glfw-wrapper.h +++ b/kitty/glfw-wrapper.h @@ -772,10 +772,10 @@ typedef enum { SRGB_COLORSPACE = 1, DISPLAY_P3_COLORSPACE = 2, } GlfwCocoaColorSpaces; -/*! @brief macOS specific - * [window hint](@ref GLFW_COCOA_BLUR_RADIUS_hint). +/*! @brief Blur Radius. On macOS the actual radius is used. On Linux it is treated as a bool. + * [window hint](@ref GLFW_BLUR_RADIUS). */ -#define GLFW_COCOA_BLUR_RADIUS 0x00023005 +#define GLFW_BLUR_RADIUS 0x0002305 /*! @brief X11 specific * [window hint](@ref GLFW_X11_CLASS_NAME_hint). @@ -785,7 +785,6 @@ typedef enum { * [window hint](@ref GLFW_X11_CLASS_NAME_hint). */ #define GLFW_X11_INSTANCE_NAME 0x00024002 -#define GLFW_X11_BLUR 0x00024003 #define GLFW_WAYLAND_APP_ID 0x00025001 /*! @} */ @@ -1950,6 +1949,10 @@ typedef void (*glfwSetWindowAttrib_func)(GLFWwindow*, int, int); GFW_EXTERN glfwSetWindowAttrib_func glfwSetWindowAttrib_impl; #define glfwSetWindowAttrib glfwSetWindowAttrib_impl +typedef int (*glfwSetWindowBlur_func)(GLFWwindow*, int); +GFW_EXTERN glfwSetWindowBlur_func glfwSetWindowBlur_impl; +#define glfwSetWindowBlur glfwSetWindowBlur_impl + typedef void (*glfwSetWindowUserPointer_func)(GLFWwindow*, void*); GFW_EXTERN glfwSetWindowUserPointer_func glfwSetWindowUserPointer_impl; #define glfwSetWindowUserPointer glfwSetWindowUserPointer_impl @@ -2246,14 +2249,6 @@ typedef GLFWcocoarenderframefun (*glfwCocoaSetWindowResizeCallback_func)(GLFWwin GFW_EXTERN glfwCocoaSetWindowResizeCallback_func glfwCocoaSetWindowResizeCallback_impl; #define glfwCocoaSetWindowResizeCallback glfwCocoaSetWindowResizeCallback_impl -typedef int (*glfwCocoaSetBackgroundBlur_func)(GLFWwindow*, int); -GFW_EXTERN glfwCocoaSetBackgroundBlur_func glfwCocoaSetBackgroundBlur_impl; -#define glfwCocoaSetBackgroundBlur glfwCocoaSetBackgroundBlur_impl - -typedef bool (*glfwSetX11WindowBlurred_func)(GLFWwindow*, bool); -GFW_EXTERN glfwSetX11WindowBlurred_func glfwSetX11WindowBlurred_impl; -#define glfwSetX11WindowBlurred glfwSetX11WindowBlurred_impl - typedef void* (*glfwGetX11Display_func)(void); GFW_EXTERN glfwGetX11Display_func glfwGetX11Display_impl; #define glfwGetX11Display glfwGetX11Display_impl diff --git a/kitty/glfw.c b/kitty/glfw.c index 16bc68837..6927fbbaf 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -1004,10 +1004,9 @@ apply_window_chrome_state(GLFWwindow *w, WindowChromeState new_state, int width, glfwSetWindowAttrib(w, GLFW_DECORATED, !hide_window_decorations); glfwSetWindowSize(w, width, height); } + glfwSetWindowBlur(w, new_state.background_blur); if (global_state.is_wayland) { if (glfwWaylandSetTitlebarColor) glfwWaylandSetTitlebarColor(w, new_state.color, new_state.use_system_color); - } else { - glfwSetX11WindowBlurred(w, new_state.background_blur > 0); } #endif } @@ -1091,15 +1090,10 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) { if (OPT(hide_window_decorations) & 1) glfwWindowHint(GLFW_DECORATED, false); const bool set_blur = OPT(background_blur) > 0 && OPT(background_opacity) < 1.f; + glfwWindowHint(GLFW_BLUR_RADIUS, set_blur ? OPT(background_blur) : 0); #ifdef __APPLE__ glfwWindowHint(GLFW_COCOA_COLOR_SPACE, OPT(macos_colorspace)); - if (set_blur) { - glfwWindowHint(GLFW_COCOA_BLUR_RADIUS, MIN(OPT(background_blur), 128)); - } else { - glfwWindowHint(GLFW_COCOA_BLUR_RADIUS, 0); - } #else - if (!global_state.is_wayland) glfwWindowHint(GLFW_X11_BLUR, set_blur); glfwWindowHintString(GLFW_X11_INSTANCE_NAME, wm_class_name); glfwWindowHintString(GLFW_X11_CLASS_NAME, wm_class_class); glfwWindowHintString(GLFW_WAYLAND_APP_ID, wm_class_class); diff --git a/kitty/options/definition.py b/kitty/options/definition.py index c43f02f47..270af8389 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -1468,7 +1468,7 @@ control the :italic:`blur radius` (amount of blurring). Setting it to too high a value will cause severe performance issues and/or rendering artifacts. Usually, values up to 64 work well. Note that this might cause performance issues, depending on how the platform implements it, so use with care. Currently supported -on macOS and KDE under X11. +on macOS and KDE. ''') opt('background_image', 'none',