From cac12bbc0fe7fd7eea6c6b1be9c36f6a184c4f95 Mon Sep 17 00:00:00 2001 From: Reupen Shah Date: Tue, 28 Jan 2025 21:20:23 +0000 Subject: [PATCH] Fix taskbar entry appearing when using hide command while already hidden This fixes a bug where, when 'Minimise to icon' is enabled, a taskbar entry incorrectly appeared when using the hide command (View/Hide or /hide on the command line) while foobar2000 is already hidden. --- CHANGELOG.md | 7 +++++++ foo_ui_columns/user_interface_impl.cpp | 15 ++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2966f665..228b9fd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,13 @@ ‘Automatic anti-aliasing’ or ‘GDI-compatible, no anti-aliasing’ based on the system ‘Smooth edges of screen fonts’ setting. +### Bug fixes + +- A bug was fixed where foobar2000 incorrectly appeared in the taskbar when + using the View/Hide menu command or the /hide command-line argument while + foobar2000 was minimised to the system tray. + [[#1110](https://github.com/reupen/columns_ui/pull/1110)] + ### Internal changes - `ui_config_callback::ui_fonts_changed()` is now called once instead of diff --git a/foo_ui_columns/user_interface_impl.cpp b/foo_ui_columns/user_interface_impl.cpp index e93218bc..bdd9437e 100644 --- a/foo_ui_columns/user_interface_impl.cpp +++ b/foo_ui_columns/user_interface_impl.cpp @@ -187,20 +187,21 @@ class UserInterfaceImpl : public user_interface_v3 { SetForegroundWindow(main_window.get_wnd()); } } + void hide() override { - if (main_window.get_wnd()) { + if (is_visible()) ShowWindow(main_window.get_wnd(), SW_MINIMIZE); - } } + bool is_visible() override { - bool rv = false; - if (main_window.get_wnd()) { - rv = IsWindowVisible(main_window.get_wnd()) && !IsIconic(main_window.get_wnd()); - } - return rv; + if (main_window.get_wnd()) + return IsWindowVisible(main_window.get_wnd()) && !IsIconic(main_window.get_wnd()); + + return false; } + void override_statusbar_text(const char* p_text) override { status_bar::set_menu_item_description(p_text);