From bde70db68f75613631fb40b2545b8ee8755d6319 Mon Sep 17 00:00:00 2001 From: pit-ray Date: Tue, 13 Feb 2024 16:09:03 +0900 Subject: [PATCH] fix hide window --- include/fluent_tray.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/fluent_tray.hpp b/include/fluent_tray.hpp index a4604f2..854427c 100644 --- a/include/fluent_tray.hpp +++ b/include/fluent_tray.hpp @@ -938,7 +938,7 @@ namespace fluent_tray if(GetForegroundWindow() != hwnd_ && visible_) { if(!hide_menu_window()) { - status_ = TrayStatus::FAILED ; + fail() ; return false ; } } @@ -948,7 +948,7 @@ namespace fluent_tray if(menu.is_mouse_over()) { if(!mouse_is_over_[i]) { if(!change_menu_back_color(menu, ash_color_)) { - status_ = TrayStatus::FAILED ; + fail() ; return false ; } } @@ -957,7 +957,7 @@ namespace fluent_tray else { if(mouse_is_over_[i]) { if(!change_menu_back_color(menu, back_color_)) { - status_ = TrayStatus::FAILED ; + fail() ; return false ; } } @@ -1109,8 +1109,13 @@ namespace fluent_tray * @return Returns true on success, false on failure. */ bool hide_menu_window() { - if(!ShowWindow(hwnd_, SW_HIDE)) { - return false ; + if(!visible_) { + return true ; + } + if(GetForegroundWindow() == hwnd_) { + if(!ShowWindow(hwnd_, SW_HIDE)) { + return false ; + } } visible_ = false ;