diff --git a/glfw/wl_client_side_decorations.c b/glfw/wl_client_side_decorations.c index a0d234c0a..1aef40cd0 100644 --- a/glfw/wl_client_side_decorations.c +++ b/glfw/wl_client_side_decorations.c @@ -115,6 +115,16 @@ alloc_buffer_pair(_GLFWWaylandBufferPair *pair, struct wl_shm_pool *pool, uint8_ } #define st decs.shadow_tile + +void +initialize_csd_metrics(_GLFWwindow *window) { + decs.metrics.width = 12; + decs.metrics.top = 36; + decs.metrics.visible_titlebar_height = window->wl.decorations.metrics.top - window->wl.decorations.metrics.width; + decs.metrics.horizontal = 2 * window->wl.decorations.metrics.width; + decs.metrics.vertical = window->wl.decorations.metrics.width + window->wl.decorations.metrics.top; +} + static size_t create_shadow_tile(_GLFWwindow *window) { const size_t margin = decs.bottom.buffer.height; diff --git a/glfw/wl_client_side_decorations.h b/glfw/wl_client_side_decorations.h index 4689b45f0..8ea3d105f 100644 --- a/glfw/wl_client_side_decorations.h +++ b/glfw/wl_client_side_decorations.h @@ -8,6 +8,7 @@ #include "internal.h" +void initialize_csd_metrics(_GLFWwindow *window); void free_all_csd_resources(_GLFWwindow *window); void free_csd_surfaces(_GLFWwindow *window); void change_csd_title(_GLFWwindow *window); diff --git a/glfw/wl_window.c b/glfw/wl_window.c index e7d662090..f31c85df2 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -712,11 +712,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { - window->wl.decorations.metrics.width = 12; - window->wl.decorations.metrics.top = 36; - window->wl.decorations.metrics.visible_titlebar_height = window->wl.decorations.metrics.top - window->wl.decorations.metrics.width; - window->wl.decorations.metrics.horizontal = 2 * window->wl.decorations.metrics.width; - window->wl.decorations.metrics.vertical = window->wl.decorations.metrics.width + window->wl.decorations.metrics.top; + initialize_csd_metrics(window); window->wl.transparent = fbconfig->transparent; strncpy(window->wl.appId, wndconfig->wl.appId, sizeof(window->wl.appId)); @@ -826,7 +822,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) // ensure they do not happen. window->wl.title = utf_8_strndup(title, 2048); if (window->wl.xdg.toplevel) xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title); - if (window->wl.decorations.top.surface) change_csd_title(window); + change_csd_title(window); } void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED,