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() {