Fix GNOME breaking when setting window geometry

The current version of GNOME has a regression that causes the compositor
to send incorrect geometry with the next configure event if the CSD
buffers are created after a call to set_window_geometry.

So call set_window_geometry last. And shake head sadly.
This commit is contained in:
Kovid Goyal
2021-04-07 22:14:09 +05:30
parent 82a5733ec5
commit 4e6d5d3f1e
4 changed files with 24 additions and 24 deletions

View File

@@ -13,6 +13,7 @@
#include <string.h>
#include <stdlib.h>
#define debug(...) if (_glfw.hints.init.debugRendering) fprintf(stderr, __VA_ARGS__);
#define decs window->wl.decorations
#define ARGB(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
@@ -273,6 +274,7 @@ create_shm_buffers(_GLFWwindow* window) {
create_shadow_tile(window);
render_title_bar(window, true);
render_edges(window);
debug("Created decoration buffers at scale: %u vertical_height: %zu horizontal_width: %zu\n", scale, vertical_height, horizontal_width);
return true;
}
@@ -375,12 +377,6 @@ free_all_csd_resources(_GLFWwindow *window) {
decs.shadow_tile.data = NULL;
}
void
resize_csd(_GLFWwindow *window) {
if (!window->decorated || window->wl.decorations.serverSide) return;
ensure_csd_resources(window);
}
void
change_csd_title(_GLFWwindow *window) {
if (!window->decorated || window->wl.decorations.serverSide) return;
@@ -400,10 +396,10 @@ set_csd_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height) {
*height = window->wl.user_requested_content_size.height;
if (has_csd) *height += decs.metrics.visible_titlebar_height;
}
struct { int32_t x, y, width, height; } geometry = {.x = 0, .y = 0, .width = *width, .height = *height};
decs.geometry.x = 0; decs.geometry.y = 0;
decs.geometry.width = *width; decs.geometry.height = *height;
if (has_csd) {
geometry.y = -decs.metrics.visible_titlebar_height;
decs.geometry.y = -decs.metrics.visible_titlebar_height;
*height -= decs.metrics.visible_titlebar_height;
}
xdg_surface_set_window_geometry(window->wl.xdg.surface, geometry.x, geometry.y, geometry.width, geometry.height);
}