Change window handle storage to template instead of void* (nw) (#1725)

* Change window handle storage to template instead of void* (nw)
This commit is contained in:
Brad Hughes 2016-11-17 00:32:26 -05:00 committed by GitHub
parent f31d9ea30a
commit 98f22fc6de
28 changed files with 154 additions and 151 deletions

View File

@ -243,7 +243,7 @@ void debugger_windows::show_all()
void debugger_windows::hide_all()
{
SetForegroundWindow(osd_common_t::s_window_list.front()->platform_window<HWND>());
SetForegroundWindow(std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window());
for (auto &info : m_window_list)
info->hide();
}

View File

@ -36,7 +36,7 @@ debugwin_info::debugwin_info(debugger_windows_interface &debugger, bool is_main_
register_window_class();
m_wnd = win_create_window_ex_utf8(DEBUG_WINDOW_STYLE_EX, "MAMEDebugWindow", title, DEBUG_WINDOW_STYLE,
0, 0, 100, 100, osd_common_t::s_window_list.front()->platform_window<HWND>(), create_standard_menubar(), GetModuleHandleUni(), this);
0, 0, 100, 100, std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window(), create_standard_menubar(), GetModuleHandleUni(), this);
if (m_wnd == nullptr)
return;

View File

@ -121,7 +121,7 @@ public:
}
// set the cooperative level
result = devinfo->dinput.device->SetCooperativeLevel(osd_common_t::s_window_list.front()->platform_window<HWND>(), cooperative_level);
result = devinfo->dinput.device->SetCooperativeLevel(std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window(), cooperative_level);
if (result != DI_OK)
goto error;

View File

@ -529,7 +529,7 @@ public:
registration.usUsagePage = usagepage();
registration.usUsage = usage();
registration.dwFlags = m_global_inputs_enabled ? 0x00000100 : 0;
registration.hwndTarget = osd_common_t::s_window_list.front()->platform_window<HWND>();
registration.hwndTarget = std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window();
// register the device
(*register_rawinput_devices)(&registration, 1, sizeof(registration));

View File

@ -43,7 +43,7 @@ static std::shared_ptr<sdl_window_info> window_from_id(Uint32 windowID)
auto& windows = osd_common_t::s_window_list;
auto window = std::find_if(windows.begin(), windows.end(), [sdl_window](std::shared_ptr<osd_window> w)
{
return w->platform_window<SDL_Window*>() == sdl_window;
return std::static_pointer_cast<sdl_window_info>(w)->platform_window() == sdl_window;
});
if (window == windows.end())

View File

@ -217,7 +217,7 @@ private:
Platform::Agile<CoreWindow> m_coreWindow;
internal:
UwpKeyboardDevice(CoreWindow ^coreWindow, running_machine& machine, char *name, const char *id, input_module &module)
UwpKeyboardDevice(Platform::Agile<CoreWindow> coreWindow, running_machine& machine, char *name, const char *id, input_module &module)
: UwpInputDevice(machine, name, id, DEVICE_CLASS_KEYBOARD, module),
keyboard({{0}}),
m_coreWindow(coreWindow)
@ -292,16 +292,14 @@ internal:
void input_init(running_machine &machine) override
{
auto first_window = std::static_pointer_cast<uwp_window_info>(osd_common_t::s_window_list.front());
CoreWindow ^coreWindow = first_window->uwp_window();
uwp_input_device *devinfo;
auto coreWindow = first_window->platform_window();
// allocate the UWP implementation of the device object
UwpKeyboardDevice ^refdevice = ref new UwpKeyboardDevice(coreWindow, machine, "UWP Keyboard 1", "UWP Keyboard 1", *this->NativeModule);
// Allocate the wrapper and add it to the list
auto created_devinfo = std::make_unique<uwp_input_device>(refdevice);
devinfo = NativeModule->devicelist()->add_device<uwp_input_device>(machine, std::move(created_devinfo));
uwp_input_device *devinfo = NativeModule->devicelist()->add_device<uwp_input_device>(machine, std::move(created_devinfo));
// Give the UWP implementation a handle to the input_device
refdevice->InputDevice = devinfo->device();

View File

@ -157,7 +157,7 @@ public:
mouse.lY = (cursor_info.ptScreenPos.y - win32_mouse.last_point.y) * INPUT_RELATIVE_PER_PIXEL;
RECT window_pos = {0};
GetWindowRect(osd_common_t::s_window_list.front()->platform_window<HWND>(), &window_pos);
GetWindowRect(std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window(), &window_pos);
// We reset the cursor position to the middle of the window each frame
win32_mouse.last_point.x = window_pos.left + (window_pos.right - window_pos.left) / 2;
@ -291,8 +291,9 @@ public:
RECT client_rect;
// get the position relative to the window
GetClientRect(osd_common_t::s_window_list.front()->platform_window<HWND>(), &client_rect);
ScreenToClient(osd_common_t::s_window_list.front()->platform_window<HWND>(), &mousepos);
HWND hwnd = std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window();
GetClientRect(hwnd, &client_rect);
ScreenToClient(hwnd, &mousepos);
// convert to absolute coordinates
xpos = normalize_absolute_axis(mousepos.x, client_rect.left, client_rect.right);
@ -352,10 +353,11 @@ private:
POINT mousepos;
// get the position relative to the window
GetClientRect(osd_common_t::s_window_list.front()->platform_window<HWND>(), &client_rect);
HWND hwnd = std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window();
GetClientRect(hwnd, &client_rect);
mousepos.x = args.xpos;
mousepos.y = args.ypos;
ScreenToClient(osd_common_t::s_window_list.front()->platform_window<HWND>(), &mousepos);
ScreenToClient(hwnd, &mousepos);
// convert to absolute coordinates
mouse.lX = normalize_absolute_axis(mousepos.x, client_rect.left, client_rect.right);

View File

@ -113,7 +113,7 @@ public:
return nullptr;
#if defined(OSD_WINDOWS)
auto nearest = monitor_from_handle(reinterpret_cast<std::uintptr_t>(MonitorFromWindow(window.platform_window<HWND>(), MONITOR_DEFAULTTONEAREST)));
auto nearest = monitor_from_handle(reinterpret_cast<std::uintptr_t>(MonitorFromWindow(static_cast<const win_window_info &>(window).platform_window(), MONITOR_DEFAULTTONEAREST)));
assert(nearest != nullptr);
return nearest;
#elif defined(OSD_UWP)

View File

@ -15,6 +15,7 @@
#include "modules/osdwindow.h"
#include "monitor_common.h"
#include "window.h"
inline osd_rect SDL_Rect_to_osd_rect(const SDL_Rect &r)
{
@ -95,7 +96,7 @@ public:
if (!m_initialized)
return nullptr;
std::uint64_t display = SDL_GetWindowDisplayIndex(window.platform_window<SDL_Window*>());
std::uint64_t display = SDL_GetWindowDisplayIndex(static_cast<const sdl_window_info &>(window).platform_window());
return monitor_from_handle(display);
}

View File

@ -83,7 +83,7 @@ public:
if (!m_initialized)
return nullptr;
auto nearest = monitor_from_handle(reinterpret_cast<std::uintptr_t>(MonitorFromWindow(window.platform_window<HWND>(), MONITOR_DEFAULTTONEAREST)));
auto nearest = monitor_from_handle(reinterpret_cast<std::uintptr_t>(MonitorFromWindow(static_cast<const win_window_info &>(window).platform_window(), MONITOR_DEFAULTTONEAREST)));
assert(nearest != nullptr);
return nearest;
}

View File

@ -78,7 +78,6 @@ public:
m_win_config(config),
m_index(0),
m_prescale(1),
m_platform_window(nullptr),
m_renderer(nullptr),
m_main(nullptr)
{}
@ -114,15 +113,6 @@ public:
virtual osd_monitor_info *monitor() const = 0;
template <class TWindow>
TWindow platform_window() const { return static_cast<TWindow>(m_platform_window); }
void set_platform_window(void *window)
{
assert(window == nullptr || m_platform_window == nullptr);
m_platform_window = window;
}
std::shared_ptr<osd_window> main_window() const { return m_main; }
void set_main_window(std::shared_ptr<osd_window> main) { m_main = main; }
@ -152,11 +142,32 @@ public:
protected:
int m_prescale;
private:
void *m_platform_window;
std::unique_ptr<osd_renderer> m_renderer;
std::shared_ptr<osd_window> m_main;
};
template <class TWindowHandle>
class osd_window_t : public osd_window
{
private:
TWindowHandle m_platform_window;
public:
osd_window_t(const osd_window_config &config)
: osd_window(config),
m_platform_window(nullptr)
{
}
TWindowHandle platform_window() const { return m_platform_window; }
void set_platform_window(TWindowHandle window)
{
assert(window == nullptr || m_platform_window == nullptr);
m_platform_window = window;
}
};
class osd_renderer
{
public:

View File

@ -437,9 +437,9 @@ int renderer_sdl2::create()
auto win = assert_window();
if (video_config.waitvsync)
m_sdl_renderer = SDL_CreateRenderer(win->platform_window<SDL_Window*>(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
m_sdl_renderer = SDL_CreateRenderer(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
else
m_sdl_renderer = SDL_CreateRenderer(win->platform_window<SDL_Window*>(), -1, SDL_RENDERER_ACCELERATED);
m_sdl_renderer = SDL_CreateRenderer(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window(), -1, SDL_RENDERER_ACCELERATED);
if (!m_sdl_renderer)
{

View File

@ -198,9 +198,9 @@ inline void winrtSetWindow(::IUnknown* _window)
bgfx::setPlatformData(pd);
}
IInspectable* AsInspectable(Platform::Object^ o)
IInspectable* AsInspectable(Platform::Agile<Windows::UI::Core::CoreWindow> win)
{
return reinterpret_cast<IInspectable*>(o);
return reinterpret_cast<IInspectable*>(win.Get());
}
#endif
@ -226,11 +226,12 @@ int renderer_bgfx::create()
bgfx::setPlatformData(blank_pd);
}
#ifdef OSD_WINDOWS
winSetHwnd(win->platform_window<HWND>());
winSetHwnd(std::static_pointer_cast<win_window_info>(win)->platform_window());
#elif defined(OSD_UWP)
winrtSetWindow(win->platform_window<IInspectable*>());
winrtSetWindow(AsInspectable(std::static_pointer_cast<uwp_window_info>(win)->platform_window()));
#else
sdlSetWindow(win->platform_window<SDL_Window*>());
sdlSetWindow(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window());
#endif
std::string backend(m_options.bgfx_backend());
if (backend == "auto")
@ -277,11 +278,11 @@ int renderer_bgfx::create()
if (win->m_index != 0)
{
#ifdef OSD_WINDOWS
m_framebuffer = m_targets->create_backbuffer(win->platform_window<HWND>(), m_width[win->m_index], m_height[win->m_index]);
m_framebuffer = m_targets->create_backbuffer(std::static_pointer_cast<win_window_info>(win)->platform_window(), m_width[win->m_index], m_height[win->m_index]);
#elif defined(OSD_UWP)
m_framebuffer = m_targets->create_backbuffer(win->platform_window<IInspectable*>(), m_width[win->m_index], m_height[win->m_index]);
m_framebuffer = m_targets->create_backbuffer(AsInspectable(std::static_pointer_cast<uwp_window_info>(win)->platform_window()), m_width[win->m_index], m_height[win->m_index]);
#else
m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(win->platform_window<SDL_Window*>()), m_width[win->m_index], m_height[win->m_index]);
m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window()), m_width[win->m_index], m_height[win->m_index]);
#endif
bgfx::touch(win->m_index);
}
@ -918,11 +919,11 @@ bool renderer_bgfx::update_dimensions()
delete m_framebuffer;
#ifdef OSD_WINDOWS
m_framebuffer = m_targets->create_backbuffer(win->platform_window<HWND>(), width, height);
m_framebuffer = m_targets->create_backbuffer(std::static_pointer_cast<win_window_info>(win)->platform_window(), width, height);
#elif defined(OSD_UWP)
m_framebuffer = m_targets->create_backbuffer(win->platform_window<IInspectable*>(), width, height);
m_framebuffer = m_targets->create_backbuffer(AsInspectable(std::static_pointer_cast<uwp_window_info>(win)->platform_window()), width, height);
#else
m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(win->platform_window<SDL_Window*>()), width, height);
m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window()), width, height);
#endif
bgfx::setViewFrameBuffer(s_current_view, m_framebuffer->target());

View File

@ -179,7 +179,7 @@ render_primitive_list *renderer_d3d9::get_primitives()
if (win == nullptr)
return nullptr;
GetClientRectExceptMenu(win->platform_window<HWND>(), &client, win->fullscreen());
GetClientRectExceptMenu(std::static_pointer_cast<win_window_info>(win)->platform_window(), &client, win->fullscreen());
if (rect_width(&client) > 0 && rect_height(&client) > 0)
{
win->target()->set_bounds(rect_width(&client), rect_height(&client), win->pixel_aspect());
@ -526,7 +526,7 @@ int renderer_d3d9::initialize()
// create the device immediately for the full screen case (defer for window mode in update_window_size())
auto win = assert_window();
if (win->fullscreen() && device_create(win->main_window()->platform_window<HWND>()))
if (win->fullscreen() && device_create(std::static_pointer_cast<win_window_info>(win->main_window())->platform_window()))
{
return false;
}
@ -747,7 +747,7 @@ void renderer_d3d9::update_presentation_parameters()
m_presentation.BackBufferCount = video_config.triplebuf ? 2 : 1;
m_presentation.MultiSampleType = D3DMULTISAMPLE_NONE;
m_presentation.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_presentation.hDeviceWindow = win->platform_window<HWND>();
m_presentation.hDeviceWindow = std::static_pointer_cast<win_window_info>(win)->platform_window();
m_presentation.Windowed = !win->fullscreen() || win->win_has_menu();
m_presentation.EnableAutoDepthStencil = FALSE;
m_presentation.AutoDepthStencilFormat = D3DFMT_D16;
@ -1214,7 +1214,7 @@ int renderer_d3d9::config_adapter_mode()
RECT client;
// bounds are from the window client rect
GetClientRectExceptMenu(win->platform_window<HWND>(), &client, win->fullscreen());
GetClientRectExceptMenu(std::static_pointer_cast<win_window_info>(win)->platform_window(), &client, win->fullscreen());
m_width = client.right - client.left;
m_height = client.bottom - client.top;
@ -1384,7 +1384,7 @@ bool renderer_d3d9::update_window_size()
// get the current window bounds
RECT client;
GetClientRectExceptMenu(win->platform_window<HWND>(), &client, win->fullscreen());
GetClientRectExceptMenu(std::static_pointer_cast<win_window_info>(win)->platform_window(), &client, win->fullscreen());
// if we have a device and matching width/height, nothing to do
if (m_device != nullptr && rect_width(&client) == m_width && rect_height(&client) == m_height)
@ -1402,7 +1402,7 @@ bool renderer_d3d9::update_window_size()
// set the new bounds and create the device again
m_width = rect_width(&client);
m_height = rect_height(&client);
if (device_create(win->main_window()->platform_window<HWND>()))
if (device_create(std::static_pointer_cast<win_window_info>(win->main_window())->platform_window()))
return false;
// reset the resize state to normal, and indicate we made a change

View File

@ -50,7 +50,7 @@ render_primitive_list *renderer_gdi::get_primitives()
return nullptr;
RECT client;
GetClientRect(win->platform_window<HWND>(), &client);
GetClientRect(std::static_pointer_cast<win_window_info>(win)->platform_window(), &client);
win->target()->set_bounds(rect_width(&client), rect_height(&client), win->pixel_aspect());
return &win->target()->get_primitives();
}
@ -69,7 +69,7 @@ int renderer_gdi::draw(const int update)
// get the target bounds
RECT bounds;
GetClientRect(win->platform_window<HWND>(), &bounds);
GetClientRect(std::static_pointer_cast<win_window_info>(win)->platform_window(), &bounds);
// compute width/height/pitch of target
int width = rect_width(&bounds);

View File

@ -27,9 +27,9 @@ render_primitive_list *renderer_none::get_primitives()
RECT client;
#if defined(OSD_WINDOWS)
GetClientRect(win->platform_window<HWND>(), &client);
GetClientRect(std::static_pointer_cast<win_window_info>(win)->platform_window(), &client);
#elif defined(OSD_UWP)
auto bounds = std::static_pointer_cast<uwp_window_info>(win)->uwp_window()->Bounds;
auto bounds = std::static_pointer_cast<uwp_window_info>(win)->platform_window()->Bounds;
client.left = bounds.Left;
client.right = bounds.Right;
client.top = bounds.Top;

View File

@ -557,9 +557,9 @@ int renderer_ogl::create()
// create renderer
#if defined(OSD_WINDOWS)
m_gl_context = global_alloc(win_gl_context(win->platform_window<HWND>()));
m_gl_context = global_alloc(win_gl_context(std::static_pointer_cast<win_window_info>(win)->platform_window()));
#else
m_gl_context = global_alloc(sdl_gl_context(win->platform_window<SDL_Window*>()));
m_gl_context = global_alloc(sdl_gl_context(std::static_pointer_cast<sdl_window_info>(win)->platform_window()));
#endif
if (m_gl_context->LastErrorMsg() != nullptr)
{

View File

@ -196,16 +196,16 @@ int renderer_sdl1::create()
if (video_config.waitvsync)
m_sdl_renderer = SDL_CreateRenderer(win->platform_window<SDL_Window*>(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
m_sdl_renderer = SDL_CreateRenderer(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
else
m_sdl_renderer = SDL_CreateRenderer(win->platform_window<SDL_Window*>(), -1, SDL_RENDERER_ACCELERATED);
m_sdl_renderer = SDL_CreateRenderer(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window(), -1, SDL_RENDERER_ACCELERATED);
if (!m_sdl_renderer)
{
if (video_config.waitvsync)
m_sdl_renderer = SDL_CreateRenderer(win->platform_window<SDL_Window*>(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_SOFTWARE);
m_sdl_renderer = SDL_CreateRenderer(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_SOFTWARE);
else
m_sdl_renderer = SDL_CreateRenderer(win->platform_window<SDL_Window*>(), -1, SDL_RENDERER_SOFTWARE);
m_sdl_renderer = SDL_CreateRenderer(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window(), -1, SDL_RENDERER_SOFTWARE);
}
if (!m_sdl_renderer)

View File

@ -407,10 +407,10 @@ HRESULT sound_direct_sound::dsound_init()
#ifdef SDLMAME_WIN32
SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version);
SDL_GetWindowWMInfo(osd_common_t::s_window_list.front()->platform_window<SDL_Window*>(), &wminfo);
SDL_GetWindowWMInfo(std::dynamic_pointer_cast<sdl_window_info>(osd_common_t::s_window_list.front())->platform_window(), &wminfo);
HWND const window = wminfo.info.win.window;
#else // SDLMAME_WIN32
HWND const window = osd_common_t::s_window_list.front()->platform_window<HWND>();
HWND const window = std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window();
#endif // SDLMAME_WIN32
result = m_dsound->SetCooperativeLevel(window, DSSCL_PRIORITY);
}

View File

@ -217,7 +217,7 @@ void sdl_window_info::capture_pointer()
{
if (!m_mouse_captured)
{
SDL_SetWindowGrab(platform_window<SDL_Window*>(), SDL_TRUE);
SDL_SetWindowGrab(platform_window(), SDL_TRUE);
SDL_SetRelativeMouseMode(SDL_TRUE);
m_mouse_captured = true;
}
@ -227,7 +227,7 @@ void sdl_window_info::release_pointer()
{
if (m_mouse_captured)
{
SDL_SetWindowGrab(platform_window<SDL_Window*>(), SDL_FALSE);
SDL_SetWindowGrab(platform_window(), SDL_FALSE);
SDL_SetRelativeMouseMode(SDL_FALSE);
m_mouse_captured = false;
}
@ -262,7 +262,7 @@ void sdl_window_info::resize(int32_t width, int32_t height)
if (width != cd.width() || height != cd.height())
{
SDL_SetWindowSize(platform_window<SDL_Window*>(), width, height);
SDL_SetWindowSize(platform_window(), width, height);
renderer().notify_changed();
}
}
@ -306,11 +306,11 @@ void sdl_window_info::toggle_full_screen()
#endif
if (fullscreen() && (video_config.switchres || is_osx))
{
SDL_SetWindowFullscreen(platform_window<SDL_Window*>(), 0); // Try to set mode
SDL_SetWindowDisplayMode(platform_window<SDL_Window*>(), &m_original_mode->mode); // Try to set mode
SDL_SetWindowFullscreen(platform_window<SDL_Window*>(), SDL_WINDOW_FULLSCREEN); // Try to set mode
SDL_SetWindowFullscreen(platform_window(), 0); // Try to set mode
SDL_SetWindowDisplayMode(platform_window(), &m_original_mode->mode); // Try to set mode
SDL_SetWindowFullscreen(platform_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode
}
SDL_DestroyWindow(platform_window<SDL_Window*>());
SDL_DestroyWindow(platform_window());
downcast<sdl_osd_interface &>(machine().osd()).release_keys();
@ -451,12 +451,12 @@ void sdl_window_info::complete_destroy()
if (fullscreen() && video_config.switchres)
{
SDL_SetWindowFullscreen(platform_window<SDL_Window*>(), 0); // Try to set mode
SDL_SetWindowDisplayMode(platform_window<SDL_Window*>(), &m_original_mode->mode); // Try to set mode
SDL_SetWindowFullscreen(platform_window<SDL_Window*>(), SDL_WINDOW_FULLSCREEN); // Try to set mode
SDL_SetWindowFullscreen(platform_window(), 0); // Try to set mode
SDL_SetWindowDisplayMode(platform_window(), &m_original_mode->mode); // Try to set mode
SDL_SetWindowFullscreen(platform_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode
}
SDL_DestroyWindow(platform_window<SDL_Window*>());
SDL_DestroyWindow(platform_window());
// release all keys ...
downcast<sdl_osd_interface &>(machine().osd()).release_keys();
}
@ -770,20 +770,20 @@ int sdl_window_info::complete_create()
{
SDL_DisplayMode mode;
//SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode);
SDL_GetWindowDisplayMode(platform_window<SDL_Window*>(), &mode);
SDL_GetWindowDisplayMode(platform_window(), &mode);
m_original_mode->mode = mode;
mode.w = temp.width();
mode.h = temp.height();
if (m_win_config.refresh)
mode.refresh_rate = m_win_config.refresh;
SDL_SetWindowDisplayMode(platform_window<SDL_Window*>(), &mode); // Try to set mode
SDL_SetWindowDisplayMode(platform_window(), &mode); // Try to set mode
#ifndef SDLMAME_WIN32
/* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
* is in place after the mode switch - which will most likely be the case
* This is a hack to work around a deficiency in SDL2
*/
SDL_WarpMouseInWindow(platform_window<SDL_Window*>(), 1, 1);
SDL_WarpMouseInWindow(platform_window(), 1, 1);
#endif
}
else
@ -793,14 +793,14 @@ int sdl_window_info::complete_create()
// show window
SDL_ShowWindow(platform_window<SDL_Window*>());
SDL_ShowWindow(platform_window());
//SDL_SetWindowFullscreen(window->sdl_window(), 0);
//SDL_SetWindowFullscreen(window->sdl_window(), window->fullscreen());
SDL_RaiseWindow(platform_window<SDL_Window*>());
SDL_RaiseWindow(platform_window());
#ifdef SDLMAME_WIN32
if (fullscreen())
SDL_SetWindowGrab(platform_window<SDL_Window*>(), SDL_TRUE);
SDL_SetWindowGrab(platform_window(), SDL_TRUE);
#endif
// set main window
@ -1075,7 +1075,7 @@ osd_dim sdl_window_info::get_min_bounds(int constrain)
osd_dim sdl_window_info::get_size()
{
int w=0; int h=0;
SDL_GetWindowSize(platform_window<SDL_Window*>(), &w, &h);
SDL_GetWindowSize(platform_window(), &w, &h);
return osd_dim(w,h);
}
@ -1130,7 +1130,7 @@ sdl_window_info::sdl_window_info(
int index,
std::shared_ptr<osd_monitor_info> a_monitor,
const osd_window_config *config)
: osd_window(*config)
: osd_window_t(*config)
, m_next(nullptr)
, m_startmaximized(0)
// Following three are used by input code to defer resizes

View File

@ -35,7 +35,7 @@ typedef uintptr_t HashT;
#define OSDWORK_CALLBACK(name) void *name(void *param, ATTR_UNUSED int threadid)
class sdl_window_info : public osd_window
class sdl_window_info : public osd_window_t<SDL_Window*>
{
public:
sdl_window_info(running_machine &a_machine, int index, std::shared_ptr<osd_monitor_info> a_monitor,

View File

@ -71,7 +71,7 @@ bool windows_osd_interface::video_init()
if (video_config.mode != VIDEO_MODE_NONE)
{
auto win = std::static_pointer_cast<uwp_window_info>(osd_common_t::s_window_list.front());
win->uwp_window()->Activate();
win->platform_window()->Activate();
}
return true;

View File

@ -247,7 +247,7 @@ uwp_window_info::uwp_window_info(
running_machine &machine,
int index,
std::shared_ptr<osd_monitor_info> monitor,
const osd_window_config *config) : osd_window(*config),
const osd_window_config *config) : osd_window_t(*config),
m_next(nullptr),
m_init_state(0),
m_startmaximized(0),
@ -279,24 +279,24 @@ CoreCursor^ uwp_window_info::s_cursor = nullptr;
void uwp_window_info::capture_pointer()
{
uwp_window()->SetPointerCapture();
platform_window()->SetPointerCapture();
}
void uwp_window_info::release_pointer()
{
uwp_window()->ReleasePointerCapture();
platform_window()->ReleasePointerCapture();
}
void uwp_window_info::hide_pointer()
{
auto window = uwp_window();
auto window = platform_window();
uwp_window_info::s_cursor = window->PointerCursor;
window->PointerCursor = nullptr;
}
void uwp_window_info::show_pointer()
{
auto window = uwp_window();
auto window = platform_window();
window->PointerCursor = uwp_window_info::s_cursor;
}
@ -501,7 +501,7 @@ void uwp_window_info::update()
}
// if we're visible and running and not in the middle of a resize, draw
if (platform_window<HWND>() != nullptr && m_target != nullptr && has_renderer())
if (platform_window() != nullptr && m_target != nullptr && has_renderer())
{
bool got_lock = true;
auto clock = std::chrono::high_resolution_clock();
@ -545,7 +545,7 @@ void uwp_window_info::draw_video_contents(int update)
std::lock_guard<std::mutex> lock(m_render_lock);
// if we're iconic, don't bother
if (platform_window<HWND>() != nullptr)
if (platform_window() != nullptr)
{
// if no bitmap, just fill
if (m_primlist == nullptr)
@ -687,9 +687,8 @@ int uwp_window_info::complete_create()
// get the monitor bounds
osd_rect monitorbounds = m_monitor->position_size();
IInspectable* raw_window = reinterpret_cast<IInspectable*>(Windows::UI::Core::CoreWindow::GetForCurrentThread());
raw_window->AddRef(); // TODO: Should probably figure out a way to auto-release
set_platform_window(raw_window);
auto coreWindow = Platform::Agile<CoreWindow>(CoreWindow::GetForCurrentThread());
set_platform_window(coreWindow);
// skip the positioning stuff for -video none */
if (video_config.mode == VIDEO_MODE_NONE)

View File

@ -15,6 +15,7 @@
#include <windowsx.h>
#include <mmsystem.h>
#include <inspectable.h>
#include <agile.h>
#undef min
#undef max
@ -46,7 +47,7 @@
// TYPE DEFINITIONS
//============================================================
class uwp_window_info : public osd_window
class uwp_window_info : public osd_window_t<Platform::Agile<Windows::UI::Core::CoreWindow>>
{
public:
uwp_window_info(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config *config);
@ -60,7 +61,7 @@ public:
virtual osd_dim get_size() override
{
auto bounds = uwp_window()->Bounds;
auto bounds = platform_window()->Bounds;
return osd_dim(bounds.Width, bounds.Height);
}
@ -74,12 +75,6 @@ public:
void show_pointer() override;
void hide_pointer() override;
Windows::UI::Core::CoreWindow^ uwp_window()
{
auto inspectable = platform_window<IInspectable*>();
return reinterpret_cast<Windows::UI::Core::CoreWindow^>(inspectable);
}
virtual osd_monitor_info *monitor() const override { return m_monitor.get(); }
void destroy() override;
@ -88,10 +83,6 @@ public:
static void create(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config *config);
// static callbacks
static LRESULT CALLBACK video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
// member variables
uwp_window_info * m_next;

View File

@ -65,7 +65,7 @@ bool windows_osd_interface::video_init()
}
if (video_config.mode != VIDEO_MODE_NONE)
SetForegroundWindow(osd_common_t::s_window_list.front()->platform_window<HWND>());
SetForegroundWindow(std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window());
return true;
}

View File

@ -304,7 +304,7 @@ win_window_info::win_window_info(
running_machine &machine,
int index,
std::shared_ptr<osd_monitor_info> monitor,
const osd_window_config *config) : osd_window(*config),
const osd_window_config *config) : osd_window_t(*config),
m_next(nullptr),
m_init_state(0),
m_startmaximized(0),
@ -337,9 +337,9 @@ POINT win_window_info::s_saved_cursor_pos = { -1, -1 };
void win_window_info::capture_pointer()
{
RECT bounds;
GetClientRect(platform_window<HWND>(), &bounds);
ClientToScreen(platform_window<HWND>(), &reinterpret_cast<POINT *>(&bounds)[0]);
ClientToScreen(platform_window<HWND>(), &reinterpret_cast<POINT *>(&bounds)[1]);
GetClientRect(platform_window(), &bounds);
ClientToScreen(platform_window(), &reinterpret_cast<POINT *>(&bounds)[0]);
ClientToScreen(platform_window(), &reinterpret_cast<POINT *>(&bounds)[1]);
ClipCursor(&bounds);
}
@ -423,7 +423,7 @@ void winwindow_process_events_periodic(running_machine &machine)
static bool is_mame_window(HWND hwnd)
{
for (auto window : osd_common_t::s_window_list)
if (window->platform_window<HWND>() == hwnd)
if (std::static_pointer_cast<win_window_info>(window)->platform_window() == hwnd)
return true;
return false;
@ -649,10 +649,10 @@ void winwindow_toggle_full_screen(void)
// iterate over windows and toggle their fullscreen state
for (auto window : osd_common_t::s_window_list)
SendMessage(window->platform_window<HWND>(), WM_USER_SET_FULLSCREEN, !video_config.windowed, 0);
SendMessage(std::static_pointer_cast<win_window_info>(window)->platform_window(), WM_USER_SET_FULLSCREEN, !video_config.windowed, 0);
// Set the first window as foreground
SetForegroundWindow(osd_common_t::s_window_list.front()->platform_window<HWND>());
SetForegroundWindow(std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window());
}
@ -668,7 +668,7 @@ BOOL winwindow_has_focus(void)
// see if one of the video windows has focus
for (auto window : osd_common_t::s_window_list)
if (focuswnd == window->platform_window<HWND>())
if (focuswnd == std::static_pointer_cast<win_window_info>(window)->platform_window())
return TRUE;
return FALSE;
@ -823,8 +823,8 @@ void win_window_info::destroy()
osd_common_t::s_window_list.remove(shared_from_this());
// destroy the window
if (platform_window<HWND>() != nullptr)
DestroyWindow(platform_window<HWND>());
if (platform_window() != nullptr)
DestroyWindow(platform_window());
// free the render target
machine().render().target_free(m_target);
@ -858,14 +858,14 @@ void win_window_info::update()
if (!fullscreen())
{
if (m_isminimized)
SendMessage(platform_window<HWND>(), WM_USER_SET_MINSIZE, 0, 0);
SendMessage(platform_window(), WM_USER_SET_MINSIZE, 0, 0);
if (m_ismaximized)
SendMessage(platform_window<HWND>(), WM_USER_SET_MAXSIZE, 0, 0);
SendMessage(platform_window(), WM_USER_SET_MAXSIZE, 0, 0);
}
}
// if we're visible and running and not in the middle of a resize, draw
if (platform_window<HWND>() != nullptr && m_target != nullptr && has_renderer())
if (platform_window() != nullptr && m_target != nullptr && has_renderer())
{
bool got_lock = true;
@ -889,7 +889,7 @@ void win_window_info::update()
// post a redraw request with the primitive list as a parameter
last_update_time = timeGetTime();
SendMessage(platform_window<HWND>(), WM_USER_REDRAW, 0, (LPARAM)primlist);
SendMessage(platform_window(), WM_USER_REDRAW, 0, (LPARAM)primlist);
}
}
}
@ -1094,7 +1094,7 @@ int win_window_info::complete_create()
// adjust the window position to the initial width/height
tempwidth = (m_win_config.width != 0) ? m_win_config.width : 640;
tempheight = (m_win_config.height != 0) ? m_win_config.height : 480;
SetWindowPos(platform_window<HWND>(), nullptr, monitorbounds.left() + 20, monitorbounds.top() + 20,
SetWindowPos(platform_window(), nullptr, monitorbounds.left() + 20, monitorbounds.top() + 20,
monitorbounds.left() + tempwidth + wnd_extra_width(),
monitorbounds.top() + tempheight + wnd_extra_height(),
SWP_NOZORDER);
@ -1113,14 +1113,14 @@ int win_window_info::complete_create()
if (renderer().create())
return 1;
ShowWindow(platform_window<HWND>(), SW_SHOW);
ShowWindow(platform_window(), SW_SHOW);
}
// clear the window
dc = GetDC(platform_window<HWND>());
GetClientRect(platform_window<HWND>(), &client);
dc = GetDC(platform_window());
GetClientRect(platform_window(), &client);
FillRect(dc, &client, (HBRUSH)GetStockObject(BLACK_BRUSH));
ReleaseDC(platform_window<HWND>(), dc);
ReleaseDC(platform_window(), dc);
return 0;
}
@ -1153,7 +1153,7 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
HDC hdc = BeginPaint(wnd, &pstruct);
window->draw_video_contents(hdc, TRUE);
if (window->win_has_menu())
DrawMenuBar(window->platform_window<HWND>());
DrawMenuBar(window->platform_window());
EndPaint(wnd, &pstruct);
break;
}
@ -1378,13 +1378,13 @@ void win_window_info::draw_video_contents(HDC dc, int update)
std::lock_guard<std::mutex> lock(m_render_lock);
// if we're iconic, don't bother
if (platform_window<HWND>() != nullptr && !IsIconic(platform_window<HWND>()))
if (platform_window() != nullptr && !IsIconic(platform_window()))
{
// if no bitmap, just fill
if (m_primlist == nullptr)
{
RECT fill;
GetClientRect(platform_window<HWND>(), &fill);
GetClientRect(platform_window(), &fill);
FillRect(dc, &fill, (HBRUSH)GetStockObject(BLACK_BRUSH));
}
@ -1633,7 +1633,7 @@ void win_window_info::update_minmax_state()
// compare the maximum bounds versus the current bounds
osd_dim minbounds = get_min_bounds(video_config.keepaspect);
osd_dim maxbounds = get_max_bounds(video_config.keepaspect);
GetWindowRect(platform_window<HWND>(), &bounds);
GetWindowRect(platform_window(), &bounds);
// if either the width or height matches, we were maximized
m_isminimized = (rect_width(&bounds) == minbounds.width()) ||
@ -1663,12 +1663,12 @@ void win_window_info::minimize_window()
// get the window rect
RECT bounds;
GetWindowRect(platform_window<HWND>(), &bounds);
GetWindowRect(platform_window(), &bounds);
osd_rect newrect(bounds.left, bounds.top, newsize );
SetWindowPos(platform_window<HWND>(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER);
SetWindowPos(platform_window(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER);
}
@ -1690,7 +1690,7 @@ void win_window_info::maximize_window()
work.top() + (work.height() - newsize.height()) / 2,
newsize);
SetWindowPos(platform_window<HWND>(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER);
SetWindowPos(platform_window(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER);
}
@ -1707,7 +1707,7 @@ void win_window_info::adjust_window_position_after_major_change()
assert(GetCurrentThreadId() == window_threadid);
// get the current size
GetWindowRect(platform_window<HWND>(), &oldrect);
GetWindowRect(platform_window(), &oldrect);
osd_rect newrect = RECT_to_osd_rect(oldrect);
// adjust the window size so the client area is what we want
@ -1728,7 +1728,7 @@ void win_window_info::adjust_window_position_after_major_change()
// adjust the position if different
if (oldrect.left != newrect.left() || oldrect.top != newrect.top() ||
oldrect.right != newrect.right() || oldrect.bottom != newrect.bottom())
SetWindowPos(platform_window<HWND>(), fullscreen() ? HWND_TOPMOST : HWND_TOP,
SetWindowPos(platform_window(), fullscreen() ? HWND_TOPMOST : HWND_TOP,
newrect.left(), newrect.top(),
newrect.width(), newrect.height(), 0);
@ -1763,24 +1763,24 @@ void win_window_info::set_fullscreen(int fullscreen)
renderer_reset();
// hide ourself
ShowWindow(platform_window<HWND>(), SW_HIDE);
ShowWindow(platform_window(), SW_HIDE);
// configure the window if non-fullscreen
if (!fullscreen)
{
// adjust the style
SetWindowLong(platform_window<HWND>(), GWL_STYLE, WINDOW_STYLE);
SetWindowLong(platform_window<HWND>(), GWL_EXSTYLE, WINDOW_STYLE_EX);
SetWindowPos(platform_window<HWND>(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
SetWindowLong(platform_window(), GWL_STYLE, WINDOW_STYLE);
SetWindowLong(platform_window(), GWL_EXSTYLE, WINDOW_STYLE_EX);
SetWindowPos(platform_window(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
// force to the bottom, then back on top
SetWindowPos(platform_window<HWND>(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos(platform_window<HWND>(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos(platform_window(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos(platform_window(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
// if we have previous non-fullscreen bounds, use those
if (m_non_fullscreen_bounds.right != m_non_fullscreen_bounds.left)
{
SetWindowPos(platform_window<HWND>(), HWND_TOP, m_non_fullscreen_bounds.left, m_non_fullscreen_bounds.top,
SetWindowPos(platform_window(), HWND_TOP, m_non_fullscreen_bounds.left, m_non_fullscreen_bounds.top,
rect_width(&m_non_fullscreen_bounds), rect_height(&m_non_fullscreen_bounds),
SWP_NOZORDER);
}
@ -1788,7 +1788,7 @@ void win_window_info::set_fullscreen(int fullscreen)
// otherwise, set a small size and maximize from there
else
{
SetWindowPos(platform_window<HWND>(), HWND_TOP, 0, 0, MIN_WINDOW_DIM, MIN_WINDOW_DIM, SWP_NOZORDER);
SetWindowPos(platform_window(), HWND_TOP, 0, 0, MIN_WINDOW_DIM, MIN_WINDOW_DIM, SWP_NOZORDER);
maximize_window();
}
}
@ -1797,15 +1797,15 @@ void win_window_info::set_fullscreen(int fullscreen)
else
{
// save the bounds
GetWindowRect(platform_window<HWND>(), &m_non_fullscreen_bounds);
GetWindowRect(platform_window(), &m_non_fullscreen_bounds);
// adjust the style
SetWindowLong(platform_window<HWND>(), GWL_STYLE, FULLSCREEN_STYLE);
SetWindowLong(platform_window<HWND>(), GWL_EXSTYLE, FULLSCREEN_STYLE_EX);
SetWindowPos(platform_window<HWND>(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
SetWindowLong(platform_window(), GWL_STYLE, FULLSCREEN_STYLE);
SetWindowLong(platform_window(), GWL_EXSTYLE, FULLSCREEN_STYLE_EX);
SetWindowPos(platform_window(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
// set topmost
SetWindowPos(platform_window<HWND>(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos(platform_window(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
// adjust the window to compensate for the change
@ -1815,7 +1815,7 @@ void win_window_info::set_fullscreen(int fullscreen)
if (!this->fullscreen() || m_fullscreen_safe)
{
if (video_config.mode != VIDEO_MODE_NONE)
ShowWindow(platform_window<HWND>(), SW_SHOW);
ShowWindow(platform_window(), SW_SHOW);
set_renderer(osd_renderer::make_for_type(video_config.mode, shared_from_this()));
if (renderer().create())

View File

@ -43,7 +43,7 @@
// TYPE DEFINITIONS
//============================================================
class win_window_info : public osd_window
class win_window_info : public osd_window_t<HWND>
{
public:
win_window_info(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config *config);
@ -58,7 +58,7 @@ public:
virtual bool win_has_menu() override
{
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
return GetMenu(platform_window<HWND>()) ? true : false;
return GetMenu(platform_window()) ? true : false;
#else
return false;
#endif
@ -68,7 +68,7 @@ public:
{
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
RECT client;
GetClientRect(platform_window<HWND>(), &client);
GetClientRect(platform_window(), &client);
return osd_dim(client.right - client.left, client.bottom - client.top);
#else
throw ref new Platform::NotImplementedException();

View File

@ -80,7 +80,7 @@ public:
winwindow_toggle_full_screen();
vsnprintf(buffer, ARRAY_LENGTH(buffer), msg, args);
win_message_box_utf8(!osd_common_t::s_window_list.empty() ? osd_common_t::s_window_list.front()->platform_window<HWND>() : nullptr, buffer, emulator_info::get_appname(), MB_OK);
win_message_box_utf8(!osd_common_t::s_window_list.empty() ? std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window() : nullptr, buffer, emulator_info::get_appname(), MB_OK);
}
else
chain_output(channel, msg, args);
@ -410,7 +410,7 @@ void MameMainApp::Run()
// To satisfy the latter things, pass in the module path name
char exe_path[MAX_PATH];
GetModuleFileNameA(nullptr, exe_path, MAX_PATH);
char* args[2] = { exe_path, (char*)"-verbose" };
char* args[3] = { exe_path, (char*)"-verbose", (char*)"-mouse" };
DWORD result = emulator_info::start_frontend(*m_options.get(), *m_osd.get(), ARRAY_LENGTH(args), args);
osd_output::pop(&winerror);