From ccdd8601d2f6a8961ca38bdf8f21f6cd8f6a9a47 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Wed, 14 Aug 2024 00:18:59 +0200 Subject: [PATCH] add initial window size tiling workaround --- src/ptk.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ptk.c b/src/ptk.c index da1d76f..bdb0b39 100644 --- a/src/ptk.c +++ b/src/ptk.c @@ -124,7 +124,17 @@ bool ptk_init(const size_t width, const size_t height, const char *title, const vk_init_vertices(); - if (!vk_init(m_window, width, height, title, application_version)) { + // on tiling desktops (most standalone X11 WMs / Wayland compositors) + // the size of the window won't necessarily be what the user set due to tiling + // so we do this ugly workaround where we fetch the size again + // after creating the window and then initialize vulkan with that size + // + // this fixes an issue where components would get drawn squished + // and their hitboxes wouldn't match up with them visually + int actual_width = 0, actual_height = 0; + glfwGetFramebufferSize(m_window, &actual_width, &actual_height); + + if (!vk_init(m_window, actual_width, actual_height, title, application_version)) { PTK_ERR("failed initializing vulkan"); return false; }