mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
Wayland: Also set layer shell surface layer when showing surface
Without this on KDE the layer is reset to background.
This commit is contained in:
parent
8d213bba04
commit
df052edae8
1 changed files with 19 additions and 13 deletions
32
glfw/wl_window.c
vendored
32
glfw/wl_window.c
vendored
|
|
@ -976,8 +976,20 @@ find_output_by_name(const char* name) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static enum zwlr_layer_shell_v1_layer
|
||||
get_layer_shell_layer(const _GLFWwindow *window) {
|
||||
enum zwlr_layer_shell_v1_layer which_layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND; // Default to background
|
||||
switch (window->wl.layer_shell.config.type) {
|
||||
case GLFW_LAYER_SHELL_BACKGROUND: case GLFW_LAYER_SHELL_NONE: break;
|
||||
case GLFW_LAYER_SHELL_PANEL: which_layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM; break;
|
||||
case GLFW_LAYER_SHELL_TOP: which_layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP; break;
|
||||
case GLFW_LAYER_SHELL_OVERLAY: which_layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY; break;
|
||||
}
|
||||
return which_layer;
|
||||
}
|
||||
|
||||
static void
|
||||
layer_set_properties(const _GLFWwindow *window, uint32_t width, uint32_t height) {
|
||||
layer_set_properties(const _GLFWwindow *window, bool during_creation, uint32_t width, uint32_t height) {
|
||||
#define config window->wl.layer_shell.config
|
||||
enum zwlr_layer_surface_v1_anchor which_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||
int exclusive_zone = config.requested_exclusive_zone;
|
||||
|
|
@ -1031,6 +1043,7 @@ layer_set_properties(const _GLFWwindow *window, uint32_t width, uint32_t height)
|
|||
zwlr_layer_surface_v1_set_anchor(surface, which_anchor);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(surface, exclusive_zone);
|
||||
zwlr_layer_surface_v1_set_margin(surface, config.requested_top_margin, config.requested_right_margin, config.requested_bottom_margin, config.requested_left_margin);
|
||||
if (!during_creation) zwlr_layer_surface_v1_set_layer(surface, get_layer_shell_layer(window));
|
||||
zwlr_layer_surface_v1_set_keyboard_interactivity(surface, focus_policy);
|
||||
#undef surface
|
||||
#undef config
|
||||
|
|
@ -1098,7 +1111,7 @@ layer_surface_handle_configure(void* data, struct zwlr_layer_surface_v1* surface
|
|||
window->wl.width = width; window->wl.height = height;
|
||||
resizeFramebuffer(window);
|
||||
_glfwInputWindowDamage(window);
|
||||
layer_set_properties(window, window->wl.width, window->wl.height);
|
||||
layer_set_properties(window, false, window->wl.width, window->wl.height);
|
||||
if (window->wl.wp_viewport) wp_viewport_set_destination(window->wl.wp_viewport, window->wl.width, window->wl.height);
|
||||
}
|
||||
commit_window_surface_if_safe(window);
|
||||
|
|
@ -1127,22 +1140,15 @@ create_layer_shell_surface(_GLFWwindow *window) {
|
|||
}
|
||||
window->decorated = false; // shell windows must not have decorations
|
||||
struct wl_output *wl_output = find_output_by_name(window->wl.layer_shell.config.output_name);
|
||||
enum zwlr_layer_shell_v1_layer which_layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND; // Default to background
|
||||
switch (window->wl.layer_shell.config.type) {
|
||||
case GLFW_LAYER_SHELL_BACKGROUND: break; case GLFW_LAYER_SHELL_NONE: break;
|
||||
case GLFW_LAYER_SHELL_PANEL: which_layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM; break;
|
||||
case GLFW_LAYER_SHELL_TOP: which_layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP; break;
|
||||
case GLFW_LAYER_SHELL_OVERLAY: which_layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY; break;
|
||||
}
|
||||
#define ls window->wl.layer_shell.zwlr_layer_surface_v1
|
||||
ls = zwlr_layer_shell_v1_get_layer_surface(
|
||||
_glfw.wl.zwlr_layer_shell_v1, window->wl.surface, wl_output, which_layer, "kitty");
|
||||
_glfw.wl.zwlr_layer_shell_v1, window->wl.surface, wl_output, get_layer_shell_layer(window), "kitty");
|
||||
if (!ls) {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: layer-surface creation failed");
|
||||
return false;
|
||||
}
|
||||
zwlr_layer_surface_v1_add_listener(ls, &zwlr_layer_surface_v1_listener, window);
|
||||
layer_set_properties(window, window->wl.width, window->wl.height);
|
||||
layer_set_properties(window, true, window->wl.width, window->wl.height);
|
||||
if (window->wl.wp_viewport) wp_viewport_set_destination(window->wl.wp_viewport, window->wl.width, window->wl.height);
|
||||
commit_window_surface(window);
|
||||
wl_display_roundtrip(_glfw.wl.display);
|
||||
|
|
@ -1727,7 +1733,7 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
|
|||
window->wl.visible = true;
|
||||
} else {
|
||||
// workaround for kwin layer shell bug: https://bugs.kde.org/show_bug.cgi?id=503121
|
||||
if (is_layer_shell(window)) layer_set_properties(window, window->wl.width, window->wl.height);
|
||||
if (is_layer_shell(window)) layer_set_properties(window, false, window->wl.width, window->wl.height);
|
||||
window->wl.visible = true;
|
||||
commit_window_surface(window);
|
||||
}
|
||||
|
|
@ -1752,7 +1758,7 @@ _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig
|
|||
if (value) window->wl.layer_shell.config = *value;
|
||||
uint32_t width, height;
|
||||
calculate_layer_size(window, &width, &height);
|
||||
layer_set_properties(window, width, height);
|
||||
layer_set_properties(window, false, width, height);
|
||||
commit_window_surface(window);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue