add initial window size tiling workaround

This commit is contained in:
jacekpoz 2024-08-14 00:18:59 +02:00
parent 1461293594
commit ccdd8601d2
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -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;
}