summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author antonioginer <antonioginer@users.noreply.github.com>2022-01-22 03:25:47 +0000
committer GitHub <noreply@github.com>2022-01-21 22:25:47 -0500
commit5c5828d8264497e013e5a40d1bb0556e1a85eaff (patch)
tree3224f2c781b54270ebfb150bc53f4b1275a59bb8 /src/osd
parent3b6b046d5145810e7c50917578fcba30b27ab96d (diff)
Correctly adjust window size based on the computed visible area for different stretching cases. (#9140)
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/sdl/window.cpp10
-rw-r--r--src/osd/windows/window.cpp20
-rw-r--r--src/osd/windows/window.h1
3 files changed, 30 insertions, 1 deletions
diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp
index 8c60d1131e8..17e10f575dd 100644
--- a/src/osd/sdl/window.cpp
+++ b/src/osd/sdl/window.cpp
@@ -967,6 +967,10 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
// compute the visible area based on the proposed rectangle
target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), viswidth, visheight);
+ // clamp visable area to the proposed rectangle
+ viswidth = std::min(viswidth, propwidth);
+ visheight = std::min(visheight, propheight);
+
// compute the adjustments we need to make
adjwidth = (viswidth + extrawidth) - rect.width();
adjheight = (visheight + extraheight) - rect.height();
@@ -1015,6 +1019,12 @@ osd_dim sdl_window_info::get_min_bounds(int constrain)
// get the minimum target size
target()->compute_minimum_size(minwidth, minheight);
+ // check if visible area is bigger
+ int32_t viswidth, visheight;
+ target()->compute_visible_area(minwidth, minheight, monitor()->aspect(), target()->orientation(), viswidth, visheight);
+ minwidth = std::max(viswidth, minwidth);
+ minheight = std::max(visheight, minheight);
+
// expand to our minimum dimensions
if (minwidth < MIN_WINDOW_DIM)
minwidth = MIN_WINDOW_DIM;
diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp
index 3153ff545cd..6627be003a8 100644
--- a/src/osd/windows/window.cpp
+++ b/src/osd/windows/window.cpp
@@ -305,6 +305,7 @@ win_window_info::win_window_info(
, m_targetorient(0)
, m_targetvismask(0)
, m_targetscalemode(0)
+ , m_targetkeepaspect(machine.options().keep_aspect())
, m_lastclicktime(std::chrono::steady_clock::time_point::min())
, m_lastclickx(0)
, m_lastclicky(0)
@@ -785,13 +786,16 @@ void win_window_info::update()
render_layer_config const targetlayerconfig = target()->layer_config();
u32 const targetvismask = target()->visibility_mask();
int const targetscalemode = target()->scale_mode();
- if (targetview != m_targetview || targetorient != m_targetorient || targetlayerconfig != m_targetlayerconfig || targetvismask != m_targetvismask || targetscalemode != m_targetscalemode)
+ bool const targetkeepaspect = target()->keepaspect();
+ if (targetview != m_targetview || targetorient != m_targetorient || targetlayerconfig != m_targetlayerconfig || targetvismask != m_targetvismask ||
+ targetscalemode != m_targetscalemode || targetkeepaspect != m_targetkeepaspect)
{
m_targetview = targetview;
m_targetorient = targetorient;
m_targetlayerconfig = targetlayerconfig;
m_targetvismask = targetvismask;
m_targetscalemode = targetscalemode;
+ m_targetkeepaspect = targetkeepaspect;
// in window mode, reminimize/maximize
if (!fullscreen())
@@ -1483,6 +1487,10 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
// compute the visible area based on the proposed rectangle
target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), viswidth, visheight);
+ // clamp visable area to the proposed rectangle
+ viswidth = std::min(viswidth, propwidth);
+ visheight = std::min(visheight, propheight);
+
// compute the adjustments we need to make
adjwidth = (viswidth + extrawidth) - rect.width();
adjheight = (visheight + extraheight) - rect.height();
@@ -1531,6 +1539,12 @@ osd_dim win_window_info::get_min_bounds(int constrain)
// get the minimum target size
target()->compute_minimum_size(minwidth, minheight);
+ // check if visible area is bigger
+ int32_t viswidth, visheight;
+ target()->compute_visible_area(minwidth, minheight, monitor()->aspect(), target()->orientation(), viswidth, visheight);
+ minwidth = std::max(viswidth, minwidth);
+ minheight = std::max(visheight, minheight);
+
// expand to our minimum dimensions
if (minwidth < MIN_WINDOW_DIMX)
minwidth = MIN_WINDOW_DIMX;
@@ -1634,6 +1648,10 @@ void win_window_info::update_minmax_state()
(rect_height(&bounds) == minbounds.height());
m_ismaximized = (rect_width(&bounds) == maxbounds.width()) ||
(rect_height(&bounds) == maxbounds.height());
+
+ // We can't be maximized and minimized simultaneously
+ if (m_ismaximized)
+ m_isminimized = FALSE;
}
else
{
diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h
index 9cae7207524..ac7ccf3277d 100644
--- a/src/osd/windows/window.h
+++ b/src/osd/windows/window.h
@@ -108,6 +108,7 @@ public:
render_layer_config m_targetlayerconfig;
u32 m_targetvismask;
int m_targetscalemode;
+ bool m_targetkeepaspect;
// input info
std::chrono::steady_clock::time_point m_lastclicktime;