From c37419beb9edaf3078913cfa069c9b5d9948067c Mon Sep 17 00:00:00 2001 From: daniel-c-harvey Date: Mon, 27 Jul 2026 00:51:33 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20toggle=20panel=20once=20after=20Alt+D=20?= =?UTF-8?q?docker=20hide=20=E2=80=94=20derive=20visibility=20from=20IsWind?= =?UTF-8?q?owVisible,=20not=20stale=20g=5Fpanel.open=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bank_panel.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/bank_panel.cpp b/src/bank_panel.cpp index 2b6d9b7..922f58c 100644 --- a/src/bank_panel.cpp +++ b/src/bank_panel.cpp @@ -2850,15 +2850,29 @@ void bankPanelInit(ReaSamplerSession* session) { g_panel.session = session; } +// Returns true only when the panel window is actually visible to the user right now. +// IsWindowVisible() returns false when the docker is hidden via Alt+D even though the +// HWND and g_panel.open are still live — the live query is the source of truth for +// toggle decisions and the Actions-list checkmark (OnToggleAction in main.cpp). +static bool panelEffectivelyVisible() { + return g_panel.hwnd && IsWindowVisible(g_panel.hwnd); +} + void bankPanelToggle() { - if (g_panel.open) + // Decide from live visibility, not the cached g_panel.open flag. + // Alt+D hides the docker without destroying the window, leaving g_panel.open + // stale (true) while the panel is gone. Using IsWindowVisible avoids the + // double-fire needed to re-show the panel after a docker hide. + if (panelEffectivelyVisible()) closePanel(); else openPanel(); } bool bankPanelIsOpen() { - return g_panel.open; + // Derive from live window state so the Actions-list checkmark stays honest + // even after Alt+D hides the docker without notifying the extension. + return panelEffectivelyVisible(); } std::vector bankPanelSelectedSampleIds() {