diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 9900dab23..ecfdda066 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1903,6 +1903,11 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) window->ns.object = nil; } +bool _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig *value) { + (void)window; (void)value; + return false; +} + void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) { if (!title) return; diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 4b4542c9f..54556b943 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -2873,6 +2873,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, G GLFWAPI bool glfwToggleFullscreen(GLFWwindow *window, unsigned int flags); GLFWAPI bool glfwIsFullscreen(GLFWwindow *window, unsigned int flags); GLFWAPI bool glfwAreSwapsAllowed(const GLFWwindow* window); +GLFWAPI bool glfwSetLayerShellConfig(GLFWwindow* handle, const GLFWLayerShellConfig *value); /*! @brief Destroys the specified window and its context. * diff --git a/glfw/internal.h b/glfw/internal.h index de0d83ecf..267cc6eeb 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -714,6 +714,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window); void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title); void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count, const GLFWimage* images); +bool _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig *value); void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos); void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos); void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height); diff --git a/glfw/window.c b/glfw/window.c index f25e46836..c4cb91ab0 100644 --- a/glfw/window.c +++ b/glfw/window.c @@ -551,6 +551,14 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value) window->shouldClose = value; } +GLFWAPI bool glfwSetLayerShellConfig(GLFWwindow* handle, const GLFWLayerShellConfig *value) { + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + + _GLFW_REQUIRE_INIT_OR_RETURN(false); + return _glfwPlatformSetLayerShellConfig(window, value); +} + GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title) { _GLFWwindow* window = (_GLFWwindow*) handle; diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 67299c649..1c601d353 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -1707,6 +1707,12 @@ void _glfwPlatformHideWindow(_GLFWwindow* window) wl_surface_commit(window->wl.surface); } +bool _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig *value) { + if (!is_layer_shell(window)) return false; + window->wl.layer_shell.config = *value; + return true; +} + static void request_attention(GLFWwindow *window, const char *token, void *data UNUSED) { if (window && token && token[0] && _glfw.wl.xdg_activation_v1) xdg_activation_v1_activate(_glfw.wl.xdg_activation_v1, token, ((_GLFWwindow*)window)->wl.surface); diff --git a/glfw/x11_window.c b/glfw/x11_window.c index abc9200f1..a00b4c115 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -1963,6 +1963,11 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) XFlush(_glfw.x11.display); } +bool _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig *value) { + (void)window; (void)value; + return false; +} + void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) { #if defined(X_HAVE_UTF8_STRING) diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index 077dd7db1..6d2ec4ee0 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -1704,7 +1704,8 @@ def get_clipboard_mime(ct: int, mime: Optional[str], callback: Callable[[bytes], def run_with_activation_token(func: Callable[[str], None]) -> bool: ... def make_x11_window_a_dock_window(x11_window_id: int, strut: Tuple[int, int, int, int, int, int, int, int, int, int, int, int]) -> None: ... def toggle_os_window_visibility(os_window_id: int) -> bool: ... -def layer_shell_config_for_os_window(os_window_id: int) -> LayerShellConfig: ... +def layer_shell_config_for_os_window(os_window_id: int) -> dict[str, Any] | None: ... +def set_layer_shell_config(os_window_id: int, cfg: LayerShellConfig) -> bool: ... def wrapped_kitten_names() -> List[str]: ... def expand_ansi_c_escapes(test: str) -> str: ... def update_tab_bar_edge_colors(os_window_id: int) -> bool: ... diff --git a/kitty/glfw-wrapper.c b/kitty/glfw-wrapper.c index e4f7226dc..a99621d11 100644 --- a/kitty/glfw-wrapper.c +++ b/kitty/glfw-wrapper.c @@ -131,6 +131,9 @@ load_glfw(const char* path) { *(void **) (&glfwAreSwapsAllowed_impl) = dlsym(handle, "glfwAreSwapsAllowed"); if (glfwAreSwapsAllowed_impl == NULL) fail("Failed to load glfw function glfwAreSwapsAllowed with error: %s", dlerror()); + *(void **) (&glfwSetLayerShellConfig_impl) = dlsym(handle, "glfwSetLayerShellConfig"); + if (glfwSetLayerShellConfig_impl == NULL) fail("Failed to load glfw function glfwSetLayerShellConfig with error: %s", dlerror()); + *(void **) (&glfwDestroyWindow_impl) = dlsym(handle, "glfwDestroyWindow"); if (glfwDestroyWindow_impl == NULL) fail("Failed to load glfw function glfwDestroyWindow with error: %s", dlerror()); diff --git a/kitty/glfw-wrapper.h b/kitty/glfw-wrapper.h index 68bb9972b..841065fbe 100644 --- a/kitty/glfw-wrapper.h +++ b/kitty/glfw-wrapper.h @@ -1868,6 +1868,10 @@ typedef bool (*glfwAreSwapsAllowed_func)(const GLFWwindow*); GFW_EXTERN glfwAreSwapsAllowed_func glfwAreSwapsAllowed_impl; #define glfwAreSwapsAllowed glfwAreSwapsAllowed_impl +typedef bool (*glfwSetLayerShellConfig_func)(GLFWwindow*, const GLFWLayerShellConfig*); +GFW_EXTERN glfwSetLayerShellConfig_func glfwSetLayerShellConfig_impl; +#define glfwSetLayerShellConfig glfwSetLayerShellConfig_impl + typedef void (*glfwDestroyWindow_func)(GLFWwindow*); GFW_EXTERN glfwDestroyWindow_func glfwDestroyWindow_impl; #define glfwDestroyWindow glfwDestroyWindow_impl diff --git a/kitty/glfw.c b/kitty/glfw.c index d32632142..2ad860948 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -2475,6 +2475,16 @@ layer_shell_config_for_os_window(PyObject *self UNUSED, PyObject *wid) { #endif } +static PyObject* +set_layer_shell_config(PyObject *self UNUSED, PyObject *args) { + unsigned long long wid; PyObject *pylsc; + if (!PyArg_ParseTuple(args, "KO", &wid, &pylsc)) return NULL; + OSWindow *window = os_window_for_id(wid); + if (!window || !window->handle || !window->is_layer_shell) Py_RETURN_FALSE; + GLFWLayerShellConfig lsc = {0}; + if (!layer_shell_config_from_python(pylsc, &lsc)) return NULL; + return Py_NewRef(glfwSetLayerShellConfig(window->handle, &lsc) ? Py_True : Py_False); +} // Boilerplate {{{ @@ -2483,6 +2493,7 @@ static PyMethodDef module_methods[] = { METHODB(is_css_pointer_name_valid, METH_O), METHODB(toggle_os_window_visibility, METH_O), METHODB(layer_shell_config_for_os_window, METH_O), + METHODB(set_layer_shell_config, METH_VARARGS), METHODB(pointer_name_to_css_name, METH_O), {"create_os_window", (PyCFunction)(void (*) (void))(create_os_window), METH_VARARGS | METH_KEYWORDS, NULL}, METHODB(set_default_window_icon, METH_VARARGS),