From 3d42732795fcf2432baac89cb89ba142acf12e9e Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 11 Dec 2022 15:52:18 +0100 Subject: [PATCH] Track window maximized state. --- profiler/src/BackendWayland.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/profiler/src/BackendWayland.cpp b/profiler/src/BackendWayland.cpp index b9ae1735..f05e82e4 100644 --- a/profiler/src/BackendWayland.cpp +++ b/profiler/src/BackendWayland.cpp @@ -57,6 +57,7 @@ static std::unordered_map> s_output; static bool s_running = true; static int s_w, s_h; +static bool s_maximized; static uint64_t s_time; static wl_fixed_t s_wheelAxisX, s_wheelAxisY; @@ -285,6 +286,19 @@ constexpr struct xdg_surface_listener xdgSurfaceListener = { static void XdgToplevelConfigure( void*, struct xdg_toplevel* toplevel, int32_t width, int32_t height, struct wl_array* states ) { if( width == 0 || height == 0 ) return; + + bool max = false; + auto data = (uint32_t*)states->data; + for( size_t i = 0; i < states->size / sizeof(uint32_t); i++ ) + { + if( data[i] == XDG_TOPLEVEL_STATE_MAXIMIZED ) + { + max = true; + break; + } + } + s_maximized = max; + if( s_w != width || s_h != height ) { s_w = width; @@ -311,6 +325,7 @@ Backend::Backend( const char* title, std::function redraw, RunQueue* mai s_mainThreadTasks = mainThreadTasks; s_w = m_winPos.w; s_h = m_winPos.h; + s_maximized = m_winPos.maximize; s_dpy = wl_display_connect( nullptr ); if( !s_dpy ) { fprintf( stderr, "Cannot establish wayland display connection!\n" ); exit( 1 ); } @@ -459,8 +474,15 @@ void Backend::Attention() void Backend::NewFrame( int& w, int& h ) { - w = m_winPos.w = s_w; - h = m_winPos.h = s_h; + m_winPos.maximize = s_maximized; + if( !s_maximized ) + { + m_winPos.w = s_w; + m_winPos.h = s_h; + } + + w = s_w; + h = s_h; ImGuiIO& io = ImGui::GetIO(); io.DisplaySize = ImVec2( w, h );