From 1d9819174d8aab6bd40a26a883bea2495100e403 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Wed, 23 Apr 2025 19:19:46 +0800 Subject: [PATCH] ENH:reshow taskbar when soft is maximized and taskbar is hide jira:github 6659 code is from OrcaSlicer,thanks for OrcaSlicer and Noisyfox commit 68997f260fda7994ae0f9772fdb66489e18e305c Author: Noisyfox Date: Wed Jan 22 10:03:53 2025 +0800 Fix auto-hide taskbar overlapping issue when maximized (#8118) Change-Id: I7aa3208cae76f3c91ca0555f1adf60a71942d432 --- src/slic3r/GUI/MainFrame.cpp | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index fa8f69411..c4d92d0aa 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -65,6 +65,7 @@ #ifdef _WIN32 #include #include +#include #endif // _WIN32 #include @@ -704,6 +705,54 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_ } #ifdef __WIN32__ +// Orca: Fix maximized window overlaps taskbar when taskbar auto hide is enabled (#8085) +// Adopted from https://gist.github.com/MortenChristiansen/6463580 +static void AdjustWorkingAreaForAutoHide(const HWND hWnd, MINMAXINFO *mmi) +{ + const auto taskbarHwnd = FindWindowA("Shell_TrayWnd", nullptr); + if (!taskbarHwnd) { return; } + const auto monitorContainingApplication = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL); + const auto monitorWithTaskbarOnIt = MonitorFromWindow(taskbarHwnd, MONITOR_DEFAULTTONULL); + if (monitorContainingApplication != monitorWithTaskbarOnIt) { return; } + APPBARDATA abd; + abd.cbSize = sizeof(APPBARDATA); + abd.hWnd = taskbarHwnd; + + // Find if task bar has auto-hide enabled + const auto uState = (UINT) SHAppBarMessage(ABM_GETSTATE, &abd); + if ((uState & ABS_AUTOHIDE) != ABS_AUTOHIDE) { return; } + + RECT borderThickness; + SetRectEmpty(&borderThickness); + AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION, FALSE, 0); + + // Determine taskbar position + SHAppBarMessage(ABM_GETTASKBARPOS, &abd); + const auto &rc = abd.rc; + if (rc.top == rc.left && rc.bottom > rc.right) { + // Left + const auto offset = borderThickness.left + 2; + mmi->ptMaxPosition.x += offset; + mmi->ptMaxTrackSize.x -= offset; + mmi->ptMaxSize.x -= offset; + } else if (rc.top == rc.left && rc.bottom < rc.right) { + // Top + const auto offset = borderThickness.top + 2; + mmi->ptMaxPosition.y += offset; + mmi->ptMaxTrackSize.y -= offset; + mmi->ptMaxSize.y -= offset; + } else if (rc.top > rc.left) { + // Bottom + const auto offset = borderThickness.bottom + 2; + mmi->ptMaxSize.y -= offset; + mmi->ptMaxTrackSize.y -= offset; + } else { + // Right + const auto offset = borderThickness.right + 2; + mmi->ptMaxSize.x -= offset; + mmi->ptMaxTrackSize.x -= offset; + } +} WXLRESULT MainFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { @@ -748,6 +797,15 @@ WXLRESULT MainFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam } } break; + case WM_GETMINMAXINFO: { + if (lParam) { + HWND hWnd = GetHandle(); + auto mmi = (MINMAXINFO *) lParam; + HandleGetMinMaxInfo(mmi); + AdjustWorkingAreaForAutoHide(hWnd, mmi); + return 0; + } + } } return wxFrame::MSWWindowProc(nMsg, wParam, lParam); }