From 1704648ed01dff308de895aa5d4ac7aa46631de6 Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Mon, 29 May 2023 05:37:03 +0200 Subject: [PATCH] mangoapp: get resolution from gamescope [skip ci] --- src/app/main.cpp | 6 +++++- src/app/mangoapp_proto.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 3922ee65..08653949 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -44,6 +44,7 @@ static bool mangoapp_paused = false; std::mutex mangoapp_m; std::condition_variable mangoapp_cv; static uint8_t raw_msg[1024] = {0}; +static uint32_t screenWidth, screenHeight; static unsigned int get_prop(const char* propName){ Display *x11_display = glfwGetX11Display(); @@ -193,6 +194,8 @@ static void msg_read_thread(){ new_frame = true; } mangoapp_cv.notify_one(); + screenWidth = mangoapp_v1->outputWidth; + screenHeight = mangoapp_v1->outputHeight; } } else { printf("Unsupported mangoapp struct version: %i\n", hdr->version); @@ -242,7 +245,8 @@ static bool render(GLFWwindow* window) { position_layer(sw_stats, params, window_size); render_imgui(sw_stats, params, window_size, true); overlay_end_frame(); - glfwSetWindowSize(window, 1280, 800); + if (screenWidth && screenHeight) + glfwSetWindowSize(window, screenWidth, screenHeight); ImGui::EndFrame(); return last_window_size.x != window_size.x || last_window_size.y != window_size.y; } diff --git a/src/app/mangoapp_proto.h b/src/app/mangoapp_proto.h index eebdabab..8bc9c905 100644 --- a/src/app/mangoapp_proto.h +++ b/src/app/mangoapp_proto.h @@ -15,6 +15,8 @@ struct mangoapp_msg_v1 { // For debugging uint64_t app_frametime_ns; uint64_t latency_ns; + uint32_t outputWidth; + uint32_t outputHeight; // WARNING: Always ADD fields, never remove or repurpose fields } __attribute__((packed));