mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-17 22:14:53 +02:00
When going from csd->no csd increase window height to compensate for titlebar.
Sway will send the next configure event (for example when focus changes) with titlebar height added, so to avoid a sudden resize at that time, bump the height by the titlebar.
This commit is contained in:
33
glfw/wl_window.c
vendored
33
glfw/wl_window.c
vendored
@@ -254,6 +254,14 @@ dispatchChangesAfterConfigure(_GLFWwindow *window, int32_t width, int32_t height
|
|||||||
_glfwInputWindowDamage(window);
|
_glfwInputWindowDamage(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
inform_compositor_of_window_geometry(_GLFWwindow *window, const char *event) {
|
||||||
|
#define geometry window->wl.decorations.geometry
|
||||||
|
debug("Setting window geometry in %s event: x=%d y=%d %dx%d\n", event, geometry.x, geometry.y, geometry.width, geometry.height);
|
||||||
|
xdg_surface_set_window_geometry(window->wl.xdg.surface, geometry.x, geometry.y, geometry.width, geometry.height);
|
||||||
|
#undef geometry
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdgDecorationHandleConfigure(void* data,
|
xdgDecorationHandleConfigure(void* data,
|
||||||
@@ -263,11 +271,22 @@ xdgDecorationHandleConfigure(void* data,
|
|||||||
_GLFWwindow* window = data;
|
_GLFWwindow* window = data;
|
||||||
|
|
||||||
bool has_server_side_decorations = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
bool has_server_side_decorations = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||||
debug("XDG decoration configure event received: Has server side decorations: %d\n", has_server_side_decorations);
|
debug("XDG decoration configure event received: has_server_side_decorations: %d\n", has_server_side_decorations);
|
||||||
if (has_server_side_decorations == window->wl.decorations.serverSide) return;
|
if (has_server_side_decorations == window->wl.decorations.serverSide) return;
|
||||||
window->wl.decorations.serverSide = has_server_side_decorations;
|
window->wl.decorations.serverSide = has_server_side_decorations;
|
||||||
if (window->wl.decorations.serverSide) free_csd_surfaces(window);
|
int width = window->wl.width, height = window->wl.height;
|
||||||
else ensure_csd_resources(window);
|
if (window->wl.decorations.serverSide) {
|
||||||
|
free_csd_surfaces(window);
|
||||||
|
height += window->wl.decorations.metrics.visible_titlebar_height;
|
||||||
|
} else {
|
||||||
|
ensure_csd_resources(window);
|
||||||
|
}
|
||||||
|
set_csd_window_geometry(window, &width, &height);
|
||||||
|
dispatchChangesAfterConfigure(window, width, height);
|
||||||
|
ensure_csd_resources(window);
|
||||||
|
wl_surface_commit(window->wl.surface);
|
||||||
|
debug("final window content size: %dx%d\n", window->wl.width, window->wl.height);
|
||||||
|
inform_compositor_of_window_geometry(window, "configure-decorations");
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = {
|
static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = {
|
||||||
@@ -401,14 +420,6 @@ _glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) {
|
|||||||
return !already_fullscreen;
|
return !already_fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
inform_compositor_of_window_geometry(_GLFWwindow *window, const char *event) {
|
|
||||||
#define geometry window->wl.decorations.geometry
|
|
||||||
debug("Setting window geometry in %s event: x=%d y=%d %dx%d\n", event, geometry.x, geometry.y, geometry.width, geometry.height);
|
|
||||||
xdg_surface_set_window_geometry(window->wl.xdg.surface, geometry.x, geometry.y, geometry.width, geometry.height);
|
|
||||||
#undef geometry
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdgToplevelHandleConfigure(void* data,
|
xdgToplevelHandleConfigure(void* data,
|
||||||
struct xdg_toplevel* toplevel UNUSED,
|
struct xdg_toplevel* toplevel UNUSED,
|
||||||
|
|||||||
Reference in New Issue
Block a user