summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/mac/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/mac/window.cpp')
-rw-r--r--src/osd/mac/window.cpp204
1 files changed, 46 insertions, 158 deletions
diff --git a/src/osd/mac/window.cpp b/src/osd/mac/window.cpp
index 3993b3502d2..161bc8b677b 100644
--- a/src/osd/mac/window.cpp
+++ b/src/osd/mac/window.cpp
@@ -9,7 +9,7 @@
//============================================================
// standard C headers
-#include <math.h>
+#include <cmath>
#ifndef _MSC_VER
#include <unistd.h>
#endif
@@ -20,14 +20,13 @@
#include "emu.h"
#include "emuopts.h"
#include "render.h"
+#include "screen.h"
#include "ui/uimain.h"
// OSD headers
#include "window.h"
#include "osdmac.h"
-#include "modules/render/drawbgfx.h"
-#include "modules/render/drawogl.h"
#include "modules/monitor/monitor_common.h"
//============================================================
@@ -68,48 +67,22 @@ bool mac_osd_interface::window_init()
{
osd_printf_verbose("Enter macwindow_init\n");
- // initialize the drawers
-
- switch (video_config.mode)
- {
- case VIDEO_MODE_BGFX:
- renderer_bgfx::init(machine());
- break;
- case VIDEO_MODE_OPENGL:
- renderer_ogl::init(machine());
- break;
- }
-
// set up the window list
osd_printf_verbose("Leave macwindow_init\n");
return true;
}
-void mac_osd_interface::update_slider_list()
+void mac_osd_interface::process_events()
{
- for (auto window : osd_common_t::s_window_list)
- {
- // check if any window has dirty sliders
- if (window->renderer().sliders_dirty())
- {
- build_slider_list();
- return;
- }
- }
}
-void mac_osd_interface::build_slider_list()
+bool mac_osd_interface::has_focus() const
{
- m_sliders.clear();
-
- for (auto window : osd_common_t::s_window_list)
- {
- std::vector<ui::menu_item> window_sliders = window->renderer().get_slider_list();
- m_sliders.insert(m_sliders.end(), window_sliders.begin(), window_sliders.end());
- }
+ return true;
}
+
//============================================================
// macwindow_exit
// (main thread)
@@ -122,23 +95,11 @@ void mac_osd_interface::window_exit()
// free all the windows
while (!osd_common_t::s_window_list.empty())
{
- auto window = osd_common_t::s_window_list.front();
-
- // Part of destroy removes the window from the list
+ auto window = std::move(osd_common_t::s_window_list.back());
+ s_window_list.pop_back();
window->destroy();
}
- switch(video_config.mode)
- {
- case VIDEO_MODE_BGFX:
- renderer_bgfx::exit();
- break;
- case VIDEO_MODE_OPENGL:
- renderer_ogl::exit();
- break;
- default:
- break;
- }
osd_printf_verbose("Leave macwindow_exit\n");
}
@@ -217,8 +178,6 @@ void mac_window_info::toggle_full_screen()
m_windowed_dim = get_size();
}
- // reset UI to main menu
- machine().ui().menu_reset();
// kill off the drawers
renderer_reset();
if (fullscreen() && video_config.switchres)
@@ -229,7 +188,7 @@ void mac_window_info::toggle_full_screen()
downcast<mac_osd_interface &>(machine().osd()).release_keys();
- set_renderer(osd_renderer::make_for_type(video_config.mode, shared_from_this()));
+ renderer_create();
// toggle the window mode
set_fullscreen(!fullscreen());
@@ -241,7 +200,7 @@ void mac_window_info::modify_prescale(int dir)
{
int new_prescale = prescale();
- if (dir > 0 && prescale() < 3)
+ if (dir > 0 && prescale() < 8)
new_prescale = prescale() + 1;
if (dir < 0 && prescale() > 1)
new_prescale = prescale() - 1;
@@ -261,8 +220,8 @@ void mac_window_info::modify_prescale(int dir)
notify_changed();
m_prescale = new_prescale;
}
- machine().ui().popup_time(1, "Prescale %d", prescale());
}
+ machine().ui().popup_time(1, "Prescale %d", prescale());
}
//============================================================
@@ -307,25 +266,11 @@ int mac_window_info::window_init()
// set the initial maximized state
// FIXME: Does not belong here
- mac_options &options = downcast<mac_options &>(m_machine.options());
- m_startmaximized = options.maximize();
+ m_startmaximized = downcast<mac_options &>(machine().options()).maximize();
- // add us to the list
- osd_common_t::s_window_list.push_back(std::static_pointer_cast<mac_window_info>(shared_from_this()));
+ create_target();
- set_renderer(osd_renderer::make_for_type(video_config.mode, static_cast<osd_window*>(this)->shared_from_this()));
-
- // load the layout
- m_target = m_machine.render().target_alloc();
-
- // set the specific view
- set_starting_view(m_index, options.view(), options.view(m_index));
-
- // make the window title
- if (video_config.numscreens == 1)
- sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), m_machine.system().type.fullname(), m_machine.system().name);
- else
- sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), m_machine.system().type.fullname(), m_machine.system().name, m_index);
+ renderer_create();
result = complete_create();
@@ -360,18 +305,6 @@ void mac_window_info::complete_destroy()
downcast<mac_osd_interface &>(machine().osd()).release_keys();
}
-void mac_window_info::destroy()
-{
- // remove us from the list
- osd_common_t::s_window_list.remove(std::static_pointer_cast<mac_window_info>(shared_from_this()));
-
- // free the textures etc
- complete_destroy();
-
- // free the render target, after the textures!
- machine().render().target_free(m_target);
-}
-
//============================================================
// pick_best_mode
@@ -386,7 +319,7 @@ osd_dim mac_window_info::pick_best_mode()
osd_dim ret(0,0);
#if 0
// determine the minimum width/height for the selected target
- m_target->compute_minimum_size(minimum_width, minimum_height);
+ target()->compute_minimum_size(minimum_width, minimum_height);
// use those as the target for now
target_width = minimum_width * std::max(1, prescale());
@@ -399,7 +332,7 @@ osd_dim mac_window_info::pick_best_mode()
}
// FIXME: this should be provided by monitor !
- num = SDL_GetNumDisplayModes(m_monitor->oshandle());
+ num = SDL_GetNumDisplayModes(monitor()->oshandle());
if (num == 0)
{
@@ -411,7 +344,7 @@ osd_dim mac_window_info::pick_best_mode()
for (i = 0; i < num; ++i)
{
SDL_DisplayMode mode;
- SDL_GetDisplayMode(m_monitor->oshandle(), i, &mode);
+ SDL_GetDisplayMode(monitor()->oshandle(), i, &mode);
// compute initial score based on difference between target and current
size_score = 1.0f / (1.0f + abs((int32_t)mode.w - target_width) + abs((int32_t)mode.h - target_height));
@@ -462,12 +395,12 @@ void mac_window_info::update()
update_cursor_state();
// if we're visible and running and not in the middle of a resize, draw
- if (m_target != nullptr)
+ if (target() != nullptr)
{
int tempwidth, tempheight;
// see if the games video mode has changed
- m_target->compute_minimum_size(tempwidth, tempheight);
+ target()->compute_minimum_size(tempwidth, tempheight);
if (osd_dim(tempwidth, tempheight) != m_minimum_dim)
{
m_minimum_dim = osd_dim(tempwidth, tempheight);
@@ -499,13 +432,10 @@ void mac_window_info::update()
// and redraw now
- // Some configurations require events to be polled in the worker thread
- downcast< mac_osd_interface& >(machine().osd()).process_events_buf();
-
// Check whether window has vector screens
{
- const screen_device *screen = screen_device_iterator(machine().root_device()).byindex(m_index);
+ const screen_device *screen = screen_device_enumerator(machine().root_device()).byindex(index());
if ((screen != nullptr) && (screen->screen_type() == SCREEN_TYPE_VECTOR))
renderer().set_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN);
else
@@ -535,31 +465,10 @@ void mac_window_info::update()
//============================================================
-// set_starting_view
-// (main thread)
-//============================================================
-
-void mac_window_info::set_starting_view(int index, const char *defview, const char *view)
-{
- int viewindex;
-
- // 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);
-}
-
-
-//============================================================
// complete_create
//============================================================
-extern void *CreateMAMEWindow(char *title, int x, int y, int w, int h, bool isFullscreen);
+extern void *CreateMAMEWindow(const char *title, int x, int y, int w, int h, bool isFullscreen);
extern void *GetOSWindow(void *wincontroller);
int mac_window_info::complete_create()
@@ -582,9 +491,13 @@ int mac_window_info::complete_create()
temp = m_windowed_dim;
}
else if (m_startmaximized)
- temp = get_max_bounds(video_config.keepaspect );
+ {
+ temp = get_max_bounds(keepaspect());
+ }
else
- temp = get_min_bounds(video_config.keepaspect );
+ {
+ temp = get_min_bounds(keepaspect());
+ }
// create the window .....
osd_printf_verbose("Enter mac_window_info::complete_create\n");
@@ -592,7 +505,7 @@ int mac_window_info::complete_create()
// get monitor work area for centering
osd_rect work = monitor()->usuable_position_size();
- auto window = CreateMAMEWindow(m_title,
+ auto window = CreateMAMEWindow(title().c_str(),
work.left() + (work.width() - temp.width()) / 2,
work.top() + (work.height() - temp.height()) / 2,
temp.width(), temp.height(), fullscreen());
@@ -605,24 +518,6 @@ int mac_window_info::complete_create()
set_platform_window(window);
- // set main window
- if (m_index > 0)
- {
- for (auto w : osd_common_t::s_window_list)
- {
- if (w->m_index == 0)
- {
- set_main_window(std::dynamic_pointer_cast<osd_window>(w));
- break;
- }
- }
- }
- else
- {
- // We must be the main window
- set_main_window(shared_from_this());
- }
-
// update monitor resolution after mode change to ensure proper pixel aspect
monitor()->refresh();
if (fullscreen() && video_config.switchres)
@@ -712,14 +607,13 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
int32_t viswidth, visheight;
int32_t adjwidth, adjheight;
float pixel_aspect;
- std::shared_ptr<osd_monitor_info> monitor = m_monitor;
// 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
- pixel_aspect = monitor->pixel_aspect();
+ pixel_aspect = monitor()->pixel_aspect();
// determine the proposed width/height
propwidth = rect.width() - extrawidth;
@@ -731,21 +625,21 @@ osd_rect mac_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 absolute minimum
propwidth = std::max(propwidth, MIN_WINDOW_DIM);
@@ -758,13 +652,13 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
// clamp against the maximum (fit on one screen for full screen mode)
if (m_fullscreen)
{
- maxwidth = monitor->position_size().width() - extrawidth;
- maxheight = monitor->position_size().height() - extraheight;
+ maxwidth = monitor()->position_size().width() - extrawidth;
+ maxheight = monitor()->position_size().height() - extraheight;
}
else
{
- maxwidth = monitor->usuable_position_size().width() - extrawidth;
- maxheight = monitor->usuable_position_size().height() - extraheight;
+ maxwidth = monitor()->usuable_position_size().width() - extrawidth;
+ maxheight = monitor()->usuable_position_size().height() - extraheight;
// further clamp to the maximum width/height in the window
if (m_win_config.width != 0)
@@ -778,7 +672,7 @@ osd_rect mac_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();
@@ -826,7 +720,7 @@ osd_dim mac_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_DIM)
@@ -839,7 +733,7 @@ osd_dim mac_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);
@@ -892,8 +786,8 @@ osd_dim mac_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();
@@ -914,7 +808,7 @@ osd_dim mac_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);
// remove extra window stuff
@@ -929,25 +823,19 @@ osd_dim mac_window_info::get_max_bounds(int constrain)
mac_window_info::mac_window_info(
running_machine &a_machine,
+ render_module &renderprovider,
int index,
std::shared_ptr<osd_monitor_info> a_monitor,
const osd_window_config *config)
- : osd_window_t(*config)
- , m_next(nullptr)
+ : osd_window_t(a_machine, renderprovider, index, a_monitor, *config)
, m_startmaximized(0)
// Following three are used by input code to defer resizes
, m_minimum_dim(0, 0)
, m_windowed_dim(0, 0)
, m_rendered_event(0, 1)
- , m_target(nullptr)
- , m_machine(a_machine)
- , m_monitor(a_monitor)
- , m_fullscreen(0)
, m_mouse_captured(false)
, m_mouse_hidden(false)
{
- m_index = index;
-
//FIXME: these should be per_window in config-> or even better a bit set
m_fullscreen = !video_config.windowed;
m_prescale = video_config.prescale;