diff options
Diffstat (limited to 'src/osd/windows/window.cpp')
-rw-r--r-- | src/osd/windows/window.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index c3376b2fb0c..d331ec3f4d8 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -15,6 +15,7 @@ #include <process.h> #include <atomic> +#include <cstring> #include <chrono> #include <list> #include <memory> @@ -1663,7 +1664,7 @@ void win_window_info::minimize_window() RECT bounds; GetWindowRect(platform_window(), &bounds); - osd_rect newrect(bounds.left, bounds.top, newsize ); + osd_rect newrect(bounds.left, bounds.top, newsize); SetWindowPos(platform_window(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER); @@ -1715,17 +1716,35 @@ void win_window_info::adjust_window_position_after_major_change() if (video_config.keepaspect) newrect = constrain_to_aspect_ratio(newrect, WMSZ_BOTTOMRIGHT); } - - // in full screen, make sure it covers the primary display else { + // in full screen, make sure it covers the primary display std::shared_ptr<osd_monitor_info> monitor = monitor_from_rect(nullptr); newrect = monitor->position_size(); } + // restrict the window to one monitor and avoid toolbars if possible + HMONITOR const nearest_monitor = MonitorFromWindow(platform_window(), MONITOR_DEFAULTTONEAREST); + if (NULL != nearest_monitor) + { + MONITORINFO info; + std::memset(&info, 0, sizeof(info)); + info.cbSize = sizeof(info); + if (GetMonitorInfo(nearest_monitor, &info)) + { + if (newrect.right() > info.rcWork.right) + newrect = newrect.move_by(info.rcWork.right - newrect.right(), 0); + if (newrect.bottom() > info.rcWork.bottom) + newrect = newrect.move_by(0, info.rcWork.bottom - newrect.bottom()); + if (newrect.left() < info.rcWork.left) + newrect = newrect.move_by(info.rcWork.left - newrect.left(), 0); + if (newrect.top() < info.rcWork.top) + newrect = newrect.move_by(0, info.rcWork.top - newrect.top()); + } + } + // adjust the position if different - if (oldrect.left != newrect.left() || oldrect.top != newrect.top() || - oldrect.right != newrect.right() || oldrect.bottom != newrect.bottom()) + if (RECT_to_osd_rect(oldrect) != newrect) SetWindowPos(platform_window(), fullscreen() ? HWND_TOPMOST : HWND_TOP, newrect.left(), newrect.top(), newrect.width(), newrect.height(), 0); |