summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/windows/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/windows/window.cpp')
-rw-r--r--src/osd/windows/window.cpp151
1 files changed, 42 insertions, 109 deletions
diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp
index ca62d750f50..e185d006c5e 100644
--- a/src/osd/windows/window.cpp
+++ b/src/osd/windows/window.cpp
@@ -299,24 +299,19 @@ win_window_info::win_window_info(
int index,
std::shared_ptr<osd_monitor_info> monitor,
const osd_window_config *config)
- : osd_window_t(*config)
- , m_next(nullptr)
+ : osd_window_t(machine, index, std::move(monitor), *config)
, m_init_state(0)
, m_startmaximized(0)
, m_isminimized(0)
, m_ismaximized(0)
- , m_monitor(monitor)
- , m_fullscreen(!video_config.windowed)
, m_fullscreen_safe(0)
, m_aspect(0)
- , m_target(nullptr)
, m_targetview(0)
, m_targetorient(0)
, m_targetvismask(0)
, m_lastclicktime(std::chrono::steady_clock::time_point::min())
, m_lastclickx(0)
, m_lastclicky(0)
- , m_machine(machine)
, m_attached_mode(false)
{
memset(m_title,0,sizeof(m_title));
@@ -324,8 +319,9 @@ win_window_info::win_window_info(
m_non_fullscreen_bounds.top = 0;
m_non_fullscreen_bounds.right = 0;
m_non_fullscreen_bounds.bottom = 0;
+
+ m_fullscreen = !video_config.windowed;
m_prescale = video_config.prescale;
- m_index = index;
}
POINT win_window_info::s_saved_cursor_pos = { -1, -1 };
@@ -752,11 +748,11 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
auto window = std::make_shared<win_window_info>(machine, index, monitor, config);
// set main window
- if (window->m_index > 0)
+ if (window->index() > 0)
{
for (const auto &w : osd_common_t::s_window_list)
{
- if (w->m_index == 0)
+ if (w->index() == 0)
{
window->set_main_window(std::static_pointer_cast<osd_window>(w));
break;
@@ -775,23 +771,13 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
if (win->monitor() == monitor.get())
window->m_fullscreen_safe = FALSE;
- // add us to the list
- osd_common_t::s_window_list.push_back(window);
-
- // load the layout
- window->m_target = machine.render().target_alloc();
-
- // set the specific view
- auto &options = downcast<windows_options &>(machine.options());
-
- const char *defview = options.view();
- window->set_starting_view(index, defview, options.view(index));
+ create_target();
// remember the current values in case they change
- window->m_targetview = window->m_target->view();
- window->m_targetorient = window->m_target->orientation();
- window->m_targetlayerconfig = window->m_target->layer_config();
- window->m_targetvismask = window->m_target->visibility_mask();
+ window->m_targetview = window->target()->view();
+ window->m_targetorient = window->target()->orientation();
+ window->m_targetlayerconfig = window->target()->layer_config();
+ window->m_targetvismask = window->target()->visibility_mask();
// make the window title
if (video_config.numscreens == 1)
@@ -800,7 +786,7 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
sprintf(window->m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().type.fullname(), machine.system().name, index);
// set the initial maximized state
- window->m_startmaximized = options.maximize();
+ window->m_startmaximized = downcast<windows_options &>(machine.options()).maximize();
window->m_init_state = window->complete_create() ? -1 : 1;
@@ -809,48 +795,18 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
fatalerror("Unable to complete window creation\n");
}
-std::shared_ptr<osd_monitor_info> win_window_info::monitor_from_rect(const osd_rect* proposed) const
-{
- std::shared_ptr<osd_monitor_info> monitor;
-
- // in window mode, find the nearest
- if (!fullscreen())
- {
- if (proposed != nullptr)
- {
- monitor = m_monitor->module().monitor_from_rect(*proposed);
- }
- else
- monitor = m_monitor->module().monitor_from_window(*this);
- }
- else
- {
- // in full screen, just use the configured monitor
- monitor = m_monitor;
- }
-
- return monitor;
-}
-
//============================================================
// winwindow_video_window_destroy
// (main thread)
//============================================================
-void win_window_info::destroy()
+void win_window_info::complete_destroy()
{
assert(GetCurrentThreadId() == main_threadid);
- // remove us from the list
- osd_common_t::s_window_list.remove(shared_from_this());
-
// destroy the window
if (platform_window() != nullptr)
DestroyWindow(platform_window());
-
- // free the render target
- machine().render().target_free(m_target);
- m_target = nullptr;
}
@@ -865,10 +821,10 @@ void win_window_info::update()
assert(GetCurrentThreadId() == main_threadid);
// see if the target has changed significantly in window mode
- unsigned const targetview = m_target->view();
- int const targetorient = m_target->orientation();
- render_layer_config const targetlayerconfig = m_target->layer_config();
- u32 const targetvismask = m_target->visibility_mask();
+ unsigned const targetview = target()->view();
+ int const targetorient = target()->orientation();
+ render_layer_config const targetlayerconfig = target()->layer_config();
+ u32 const targetvismask = target()->visibility_mask();
if (targetview != m_targetview || targetorient != m_targetorient || targetlayerconfig != m_targetlayerconfig || targetvismask != m_targetvismask)
{
m_targetview = targetview;
@@ -887,7 +843,7 @@ void win_window_info::update()
}
// if we're visible and running and not in the middle of a resize, draw
- if (platform_window() != nullptr && m_target != nullptr && has_renderer())
+ if (platform_window() != nullptr && target() != nullptr && has_renderer())
{
bool got_lock = true;
@@ -962,29 +918,6 @@ static void create_window_class()
//============================================================
-// set_starting_view
-// (main thread)
-//============================================================
-
-void win_window_info::set_starting_view(int index, const char *defview, const char *view)
-{
- int viewindex;
-
- assert(GetCurrentThreadId() == main_threadid);
-
- // choose non-auto over auto
- if (strcmp(view, "auto") == 0 && strcmp(defview, "auto") != 0)
- view = defview;
-
- // query the video system to help us pick a view
- viewindex = target()->configured_view(view, index, video_config.numscreens);
-
- // set the view
- target()->set_view(viewindex);
-}
-
-
-//============================================================
// winwindow_ui_pause
// (main thread)
//============================================================
@@ -1087,7 +1020,7 @@ int win_window_info::complete_create()
assert(GetCurrentThreadId() == window_threadid);
// get the monitor bounds
- osd_rect monitorbounds = m_monitor->position_size();
+ osd_rect monitorbounds = monitor()->position_size();
// create the window menu if needed
if (downcast<windows_options &>(machine().options()).menu())
@@ -1225,17 +1158,17 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
// input events
case WM_MOUSEMOVE:
- window->machine().ui_input().push_mouse_move_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_move_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_MOUSELEAVE:
- window->machine().ui_input().push_mouse_leave_event(window->m_target);
+ window->machine().ui_input().push_mouse_leave_event(window->target());
break;
case WM_LBUTTONDOWN:
{
auto const ticks = std::chrono::steady_clock::now();
- window->machine().ui_input().push_mouse_down_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_down_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
// check for a double-click - avoid overflow by adding times rather than subtracting
if (ticks < (window->m_lastclicktime + std::chrono::milliseconds(GetDoubleClickTime())) &&
@@ -1243,7 +1176,7 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
GET_Y_LPARAM(lparam) >= window->m_lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->m_lastclicky + 4)
{
window->m_lastclicktime = std::chrono::steady_clock::time_point::min();
- window->machine().ui_input().push_mouse_double_click_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_double_click_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
}
else
{
@@ -1255,26 +1188,26 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
break;
case WM_LBUTTONUP:
- window->machine().ui_input().push_mouse_up_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_up_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_RBUTTONDOWN:
- window->machine().ui_input().push_mouse_rdown_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_rdown_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_RBUTTONUP:
- window->machine().ui_input().push_mouse_rup_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_rup_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_CHAR:
- window->machine().ui_input().push_char_event(window->m_target, (char32_t) wparam);
+ window->machine().ui_input().push_char_event(window->target(), (char32_t) wparam);
break;
case WM_MOUSEWHEEL:
{
UINT ucNumLines = 3; // default
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &ucNumLines, 0);
- window->machine().ui_input().push_mouse_wheel_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), GET_WHEEL_DELTA_WPARAM(wparam), ucNumLines);
+ window->machine().ui_input().push_mouse_wheel_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), GET_WHEEL_DELTA_WPARAM(wparam), ucNumLines);
break;
}
@@ -1392,8 +1325,8 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
* be preserved if set. If not, the standard aspect calculation
* should be used.
*/
- window->m_monitor->refresh();
- window->m_monitor->update_resolution(LOWORD(lparam), HIWORD(lparam));
+ window->monitor()->refresh();
+ window->monitor()->update_resolution(LOWORD(lparam), HIWORD(lparam));
break;
// set focus: if we're not the primary window, switch back
@@ -1472,7 +1405,7 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
return rect;
// do not constrain aspect ratio for integer scaled views
- if (m_target->scale_mode() != SCALE_FRACTIONAL)
+ if (target()->scale_mode() != SCALE_FRACTIONAL)
return rect;
// get the pixel aspect ratio for the target monitor
@@ -1488,21 +1421,21 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
{
case WMSZ_BOTTOM:
case WMSZ_TOP:
- m_target->compute_visible_area(10000, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(10000, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
- m_target->compute_visible_area(propwidth, 10000, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, 10000, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
default:
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
}
// get the minimum width/height for the current layout
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// clamp against the maximum (fit on one screen for full screen mode)
if (fullscreen())
@@ -1539,7 +1472,7 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
propheight = std::min(propheight, maxheight);
// compute the visible area based on the proposed rectangle
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), viswidth, visheight);
// compute the adjustments we need to make
adjwidth = (viswidth + extrawidth) - rect.width();
@@ -1587,7 +1520,7 @@ osd_dim win_window_info::get_min_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// get the minimum target size
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// expand to our minimum dimensions
if (minwidth < MIN_WINDOW_DIMX)
@@ -1600,7 +1533,7 @@ osd_dim win_window_info::get_min_bounds(int constrain)
minheight += wnd_extra_height();
// if we want it constrained, figure out which one is larger
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
{
// first constrain with no height limit
osd_rect test1(0,0,minwidth,10000);
@@ -1638,8 +1571,8 @@ osd_dim win_window_info::get_max_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// compute the maximum client area
- //m_monitor->refresh();
- osd_rect maximum = m_monitor->usuable_position_size();
+ //monitor()->refresh();
+ osd_rect maximum = monitor()->usuable_position_size();
// clamp to the window's max
int tempw = maximum.width();
@@ -1660,7 +1593,7 @@ osd_dim win_window_info::get_max_bounds(int constrain)
maximum = maximum.resize(tempw, temph);
// constrain to fit
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
maximum = constrain_to_aspect_ratio(maximum, WMSZ_BOTTOMRIGHT);
return maximum.dim();
@@ -1737,7 +1670,7 @@ void win_window_info::maximize_window()
osd_dim newsize = get_max_bounds(keepaspect());
// center within the work area
- osd_rect work = m_monitor->usuable_position_size();
+ osd_rect work = monitor()->usuable_position_size();
osd_rect newrect = osd_rect(work.left() + (work.width() - newsize.width()) / 2,
work.top() + (work.height() - newsize.height()) / 2,
newsize);
@@ -1803,7 +1736,7 @@ void win_window_info::adjust_window_position_after_major_change()
newrect.width(), newrect.height(), 0);
// take note of physical window size (used for lightgun coordinate calculation)
- if (m_index == 0)
+ if (index() == 0)
osd_printf_verbose("Physical width %d, height %d\n", newrect.width(), newrect.height());
}