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:
parent
82a5733ec5
commit
4e6d5d3f1e
14
glfw/wl_client_side_decorations.c
vendored
14
glfw/wl_client_side_decorations.c
vendored
@ -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);
|
||||
}
|
||||
|
||||
1
glfw/wl_client_side_decorations.h
vendored
1
glfw/wl_client_side_decorations.h
vendored
@ -10,7 +10,6 @@
|
||||
|
||||
void free_all_csd_resources(_GLFWwindow *window);
|
||||
void free_csd_surfaces(_GLFWwindow *window);
|
||||
void resize_csd(_GLFWwindow *window);
|
||||
void change_csd_title(_GLFWwindow *window);
|
||||
bool ensure_csd_resources(_GLFWwindow *window);
|
||||
void set_csd_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height);
|
||||
|
||||
4
glfw/wl_platform.h
vendored
4
glfw/wl_platform.h
vendored
@ -186,6 +186,10 @@ typedef struct _GLFWwindowWayland
|
||||
unsigned int width, top, horizontal, vertical, visible_titlebar_height;
|
||||
} metrics;
|
||||
|
||||
struct {
|
||||
int32_t x, y, width, height;
|
||||
} geometry;
|
||||
|
||||
struct {
|
||||
uint32_t *data;
|
||||
size_t for_decoration_size, stride, segments, corner_size;
|
||||
|
||||
29
glfw/wl_window.c
vendored
29
glfw/wl_window.c
vendored
@ -42,7 +42,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#define debug(...) if (_glfw.hints.init.debugRendering) printf(__VA_ARGS__);
|
||||
#define debug(...) if (_glfw.hints.init.debugRendering) fprintf(stderr, __VA_ARGS__);
|
||||
|
||||
static struct wl_buffer* createShmBuffer(const GLFWimage* image, bool is_opaque, bool init_data)
|
||||
{
|
||||
@ -213,18 +213,15 @@ static void setOpaqueRegion(_GLFWwindow* window)
|
||||
}
|
||||
|
||||
|
||||
static void resizeFramebuffer(_GLFWwindow* window)
|
||||
{
|
||||
static void
|
||||
resizeFramebuffer(_GLFWwindow* window) {
|
||||
int scale = window->wl.scale;
|
||||
int scaledWidth = window->wl.width * scale;
|
||||
int scaledHeight = window->wl.height * scale;
|
||||
debug("Resizing framebuffer to: %dx%d at scale: %d\n", window->wl.width, window->wl.height, scale);
|
||||
wl_egl_window_resize(window->wl.native, scaledWidth, scaledHeight, 0, 0);
|
||||
if (!window->wl.transparent)
|
||||
setOpaqueRegion(window);
|
||||
if (!window->wl.transparent) setOpaqueRegion(window);
|
||||
_glfwInputFramebufferSize(window, scaledWidth, scaledHeight);
|
||||
|
||||
if (window->wl.decorations.mapping.data) resize_csd(window);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -265,8 +262,7 @@ static void xdgDecorationHandleConfigure(void* data,
|
||||
_GLFWwindow* window = data;
|
||||
|
||||
window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
|
||||
if (!window->wl.decorations.serverSide) ensure_csd_resources(window);
|
||||
ensure_csd_resources(window);
|
||||
}
|
||||
|
||||
static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = {
|
||||
@ -293,6 +289,7 @@ static void surfaceHandleEnter(void *data,
|
||||
if (checkScaleChange(window)) {
|
||||
resizeFramebuffer(window);
|
||||
_glfwInputWindowContentScale(window, window->wl.scale, window->wl.scale);
|
||||
ensure_csd_resources(window);
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,6 +314,7 @@ static void surfaceHandleLeave(void *data,
|
||||
if (checkScaleChange(window)) {
|
||||
resizeFramebuffer(window);
|
||||
_glfwInputWindowContentScale(window, window->wl.scale, window->wl.scale);
|
||||
ensure_csd_resources(window);
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,8 +383,7 @@ static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on)
|
||||
if (!window->wl.decorations.serverSide) free_csd_surfaces(window);
|
||||
} else {
|
||||
xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
|
||||
if (!_glfw.wl.decorationManager)
|
||||
ensure_csd_resources(window);
|
||||
ensure_csd_resources(window);
|
||||
}
|
||||
}
|
||||
setIdleInhibitor(window, on);
|
||||
@ -450,11 +447,15 @@ static void xdgToplevelHandleConfigure(void* data,
|
||||
bool live_resize_done = !(new_states & TOPLEVEL_STATE_RESIZING) && (window->wl.toplevel_states & TOPLEVEL_STATE_RESIZING);
|
||||
window->wl.toplevel_states = new_states;
|
||||
set_csd_window_geometry(window, &width, &height);
|
||||
wl_surface_commit(window->wl.surface);
|
||||
dispatchChangesAfterConfigure(window, width, height);
|
||||
debug("final window content size: %dx%d\n", window->wl.width, window->wl.height);
|
||||
_glfwInputWindowFocus(window, window->wl.toplevel_states & TOPLEVEL_STATE_ACTIVATED);
|
||||
ensure_csd_resources(window);
|
||||
#define geometry window->wl.decorations.geometry
|
||||
debug("Setting window geometry: x=%d y=%d %dx%d\n", 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
|
||||
wl_surface_commit(window->wl.surface);
|
||||
if (live_resize_done) _glfwInputLiveResize(window, false);
|
||||
}
|
||||
|
||||
@ -872,8 +873,8 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
set_csd_window_geometry(window, &width, &height);
|
||||
window->wl.width = width; window->wl.height = height;
|
||||
resizeFramebuffer(window);
|
||||
wl_surface_commit(window->wl.surface);
|
||||
ensure_csd_resources(window);
|
||||
wl_surface_commit(window->wl.surface);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user