Wayland GNOME: Fix a crash when using multiple monitors with different scales and starting on or moving to the monitor with lower scale

Fucking GNOME and its fucking lack of support for SSD. How much of my
life I have wasted on these nincompoops.

Fixes #7894
This commit is contained in:
Kovid Goyal 2024-09-26 00:49:04 +05:30
parent 216b6e2e8c
commit f48bcb1a17
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 6 deletions

View file

@ -74,6 +74,11 @@ consumption to do the same tasks.
Detailed list of changes
-------------------------------------
0.36.4 [future]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Wayland GNOME: Fix a crash when using multiple monitors with different scales and starting on or moving to the monitor with lower scale (:iss:`7894`)
0.36.3 [2024-09-25]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -468,10 +468,8 @@ render_shadows(_GLFWwindow *window) {
static bool
create_shm_buffers(_GLFWwindow* window) {
const double scale = _glfwWaylandWindowScale(window);
decs.mapping.size = 0;
#define bp(which, width, height) decs.mapping.size += init_buffer_pair(&decs.which.buffer, width, height, scale);
#define bp(which, width, height) decs.mapping.size += init_buffer_pair(&decs.which.buffer, width, height, decs.for_window_state.fscale);
bp(titlebar, window->wl.width, decs.metrics.visible_titlebar_height);
bp(shadow_top, window->wl.width, decs.metrics.width);
bp(shadow_bottom, window->wl.width, decs.metrics.width);
@ -504,7 +502,7 @@ create_shm_buffers(_GLFWwindow* window) {
wl_shm_pool_destroy(pool);
render_title_bar(window, true);
render_shadows(window);
debug("Created decoration buffers at scale: %f\n", scale);
debug("Created decoration buffers at scale: %f\n", decs.for_window_state.fscale);
return true;
}
@ -577,10 +575,11 @@ ensure_csd_resources(_GLFWwindow *window) {
if (!window_is_csd_capable(window)) return false;
const bool is_focused = window->id == _glfw.focusedWindowId;
const bool focus_changed = is_focused != decs.for_window_state.focused;
const double current_scale = _glfwWaylandWindowScale(window);
const bool size_changed = (
decs.for_window_state.width != window->wl.width ||
decs.for_window_state.height != window->wl.height ||
decs.for_window_state.fscale != _glfwWaylandWindowScale(window) ||
decs.for_window_state.fscale != current_scale ||
!decs.mapping.data
);
const bool state_changed = decs.for_window_state.toplevel_states != window->wl.current.toplevel_states;
@ -589,6 +588,7 @@ ensure_csd_resources(_GLFWwindow *window) {
decs.for_window_state.width, decs.for_window_state.height, window->wl.width, window->wl.height, needs_update,
size_changed, state_changed, decs.buffer_destroyed);
if (!needs_update) return false;
decs.for_window_state.fscale = current_scale; // used in create_shm_buffers
if (size_changed || decs.buffer_destroyed) {
free_csd_buffers(window);
if (!create_shm_buffers(window)) return false;
@ -618,7 +618,6 @@ ensure_csd_resources(_GLFWwindow *window) {
decs.for_window_state.width = window->wl.width;
decs.for_window_state.height = window->wl.height;
decs.for_window_state.fscale = _glfwWaylandWindowScale(window);
decs.for_window_state.focused = is_focused;
decs.for_window_state.toplevel_states = window->wl.current.toplevel_states;
return true;