mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
-osd/windows: Minimise full-screen windows on losing focus (#2997).
-osd/modules/osdwindow.cpp: Clean up window title formatting. * Show data type model in window title. * Moved window title formatting to a single place. -tools/chdman.cpp: Removed some unnecessary .c_str() calls.
This commit is contained in:
parent
ef82fd102d
commit
7cfe419ca8
@ -270,13 +270,13 @@ void image_manager::postdevice_init()
|
|||||||
|
|
||||||
bool image_manager::try_change_working_directory(std::string &working_directory, const std::string &subdir)
|
bool image_manager::try_change_working_directory(std::string &working_directory, const std::string &subdir)
|
||||||
{
|
{
|
||||||
const osd::directory::entry *entry;
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
bool done = false;
|
|
||||||
|
|
||||||
auto directory = osd::directory::open(working_directory);
|
auto directory = osd::directory::open(working_directory);
|
||||||
if (directory)
|
if (directory)
|
||||||
{
|
{
|
||||||
|
const osd::directory::entry *entry;
|
||||||
|
bool done = false;
|
||||||
while (!done && (entry = directory->read()) != nullptr)
|
while (!done && (entry = directory->read()) != nullptr)
|
||||||
{
|
{
|
||||||
if (!core_stricmp(subdir.c_str(), entry->name))
|
if (!core_stricmp(subdir.c_str(), entry->name))
|
||||||
|
@ -313,12 +313,6 @@ int mac_window_info::window_init()
|
|||||||
|
|
||||||
set_renderer(osd_renderer::make_for_type(video_config.mode, static_cast<osd_window*>(this)->shared_from_this()));
|
set_renderer(osd_renderer::make_for_type(video_config.mode, static_cast<osd_window*>(this)->shared_from_this()));
|
||||||
|
|
||||||
// make the window title
|
|
||||||
if (video_config.numscreens == 1)
|
|
||||||
sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), machine().system().type.fullname(), machine().system().name);
|
|
||||||
else
|
|
||||||
sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine().system().type.fullname(), machine().system().name, index());
|
|
||||||
|
|
||||||
result = complete_create();
|
result = complete_create();
|
||||||
|
|
||||||
// handle error conditions
|
// handle error conditions
|
||||||
@ -515,7 +509,7 @@ void mac_window_info::update()
|
|||||||
// complete_create
|
// 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);
|
extern void *GetOSWindow(void *wincontroller);
|
||||||
|
|
||||||
int mac_window_info::complete_create()
|
int mac_window_info::complete_create()
|
||||||
@ -552,7 +546,7 @@ int mac_window_info::complete_create()
|
|||||||
// get monitor work area for centering
|
// get monitor work area for centering
|
||||||
osd_rect work = monitor()->usuable_position_size();
|
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.left() + (work.width() - temp.width()) / 2,
|
||||||
work.top() + (work.height() - temp.height()) / 2,
|
work.top() + (work.height() - temp.height()) / 2,
|
||||||
temp.width(), temp.height(), fullscreen());
|
temp.width(), temp.height(), fullscreen());
|
||||||
|
@ -59,7 +59,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// window handle and info
|
// window handle and info
|
||||||
char m_title[256];
|
|
||||||
int m_startmaximized;
|
int m_startmaximized;
|
||||||
|
|
||||||
// dimensions
|
// dimensions
|
||||||
|
@ -109,7 +109,7 @@ void *GetOSWindow(void *wincontroller)
|
|||||||
return [wc getWindow];
|
return [wc getWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CreateMAMEWindow(char *title, int x, int y, int w, int h, bool isFullscreen)
|
void *CreateMAMEWindow(const char *title, int x, int y, int w, int h, bool isFullscreen)
|
||||||
{
|
{
|
||||||
NSRect bounds = NSMakeRect(x, y, w, h);
|
NSRect bounds = NSMakeRect(x, y, w, h);
|
||||||
NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
|
NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
|
||||||
|
@ -22,6 +22,35 @@
|
|||||||
#include "render/drawsdl.h"
|
#include "render/drawsdl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
osd_window::osd_window(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config &config) :
|
||||||
|
#ifdef OSD_WINDOWS
|
||||||
|
m_dc(nullptr), m_resize_state(0),
|
||||||
|
#endif
|
||||||
|
m_target(nullptr),
|
||||||
|
m_primlist(nullptr),
|
||||||
|
m_win_config(config),
|
||||||
|
m_index(index),
|
||||||
|
m_fullscreen(false),
|
||||||
|
m_prescale(1),
|
||||||
|
m_machine(machine),
|
||||||
|
m_monitor(std::move(monitor)),
|
||||||
|
m_renderer(nullptr),
|
||||||
|
m_main(nullptr),
|
||||||
|
m_title(
|
||||||
|
util::string_format(
|
||||||
|
(video_config.numscreens > 1)
|
||||||
|
? "%1$s: %2$s [%3$s] - Screen %4$d (%5$s%6$sP%7$d)"
|
||||||
|
: "%1$s: %2$s [%3$s] (%5$s%6$sP%7$d)",
|
||||||
|
emulator_info::get_appname(),
|
||||||
|
machine.system().type.fullname(),
|
||||||
|
machine.system().name,
|
||||||
|
index,
|
||||||
|
(sizeof(int) == sizeof(void *)) ? "I" : "",
|
||||||
|
(sizeof(long) == sizeof(void *)) ? "L" : (sizeof(long long) == sizeof(void *)) ? "LL" : "",
|
||||||
|
sizeof(void *) * 8))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
float osd_window::pixel_aspect() const
|
float osd_window::pixel_aspect() const
|
||||||
{
|
{
|
||||||
return monitor()->pixel_aspect();
|
return monitor()->pixel_aspect();
|
||||||
|
@ -65,28 +65,14 @@ class osd_monitor_info;
|
|||||||
class osd_window : public std::enable_shared_from_this<osd_window>
|
class osd_window : public std::enable_shared_from_this<osd_window>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
osd_window(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config &config)
|
osd_window(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config &config);
|
||||||
:
|
|
||||||
#ifdef OSD_WINDOWS
|
|
||||||
m_dc(nullptr), m_resize_state(0),
|
|
||||||
#endif
|
|
||||||
m_target(nullptr),
|
|
||||||
m_primlist(nullptr),
|
|
||||||
m_win_config(config),
|
|
||||||
m_index(index),
|
|
||||||
m_fullscreen(false),
|
|
||||||
m_prescale(1),
|
|
||||||
m_machine(machine),
|
|
||||||
m_monitor(std::move(monitor)),
|
|
||||||
m_renderer(nullptr),
|
|
||||||
m_main(nullptr)
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual ~osd_window() { }
|
virtual ~osd_window() { }
|
||||||
|
|
||||||
render_target *target() const { return m_target; }
|
render_target *target() const { return m_target; }
|
||||||
int fullscreen() const { return m_fullscreen; }
|
int fullscreen() const { return m_fullscreen; }
|
||||||
running_machine &machine() const { return m_machine; }
|
running_machine &machine() const { return m_machine; }
|
||||||
|
const std::string &title() const { return m_title; }
|
||||||
|
|
||||||
bool has_renderer() const { return m_renderer != nullptr; }
|
bool has_renderer() const { return m_renderer != nullptr; }
|
||||||
osd_renderer &renderer() const { return *m_renderer; }
|
osd_renderer &renderer() const { return *m_renderer; }
|
||||||
@ -168,6 +154,7 @@ private:
|
|||||||
std::shared_ptr<osd_monitor_info> m_monitor;
|
std::shared_ptr<osd_monitor_info> m_monitor;
|
||||||
std::unique_ptr<osd_renderer> m_renderer;
|
std::unique_ptr<osd_renderer> m_renderer;
|
||||||
std::shared_ptr<osd_window> m_main;
|
std::shared_ptr<osd_window> m_main;
|
||||||
|
const std::string m_title;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class TWindowHandle>
|
template <class TWindowHandle>
|
||||||
|
@ -411,12 +411,6 @@ int sdl_window_info::window_init()
|
|||||||
|
|
||||||
set_renderer(osd_renderer::make_for_type(video_config.mode, static_cast<osd_window*>(this)->shared_from_this()));
|
set_renderer(osd_renderer::make_for_type(video_config.mode, static_cast<osd_window*>(this)->shared_from_this()));
|
||||||
|
|
||||||
// make the window title
|
|
||||||
if (video_config.numscreens == 1)
|
|
||||||
sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), machine().system().type.fullname(), machine().system().name);
|
|
||||||
else
|
|
||||||
sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine().system().type.fullname(), machine().system().name, index());
|
|
||||||
|
|
||||||
int result = complete_create();
|
int result = complete_create();
|
||||||
|
|
||||||
// handle error conditions
|
// handle error conditions
|
||||||
@ -691,7 +685,7 @@ int sdl_window_info::complete_create()
|
|||||||
osd_rect work = monitor()->usuable_position_size();
|
osd_rect work = monitor()->usuable_position_size();
|
||||||
|
|
||||||
// create the SDL window
|
// create the SDL window
|
||||||
auto sdlwindow = SDL_CreateWindow(m_title,
|
auto sdlwindow = SDL_CreateWindow(title().c_str(),
|
||||||
work.left() + (work.width() - temp.width()) / 2,
|
work.left() + (work.width() - temp.width()) / 2,
|
||||||
work.top() + (work.height() - temp.height()) / 2,
|
work.top() + (work.height() - temp.height()) / 2,
|
||||||
temp.width(), temp.height(), m_extra_flags);
|
temp.width(), temp.height(), m_extra_flags);
|
||||||
|
@ -64,7 +64,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// window handle and info
|
// window handle and info
|
||||||
char m_title[256];
|
|
||||||
int m_startmaximized;
|
int m_startmaximized;
|
||||||
|
|
||||||
// dimensions
|
// dimensions
|
||||||
|
@ -258,7 +258,6 @@ uwp_window_info::uwp_window_info(
|
|||||||
m_lastclickx(0),
|
m_lastclickx(0),
|
||||||
m_lastclicky(0)
|
m_lastclicky(0)
|
||||||
{
|
{
|
||||||
memset(m_title,0,sizeof(m_title));
|
|
||||||
m_non_fullscreen_bounds.left = 0;
|
m_non_fullscreen_bounds.left = 0;
|
||||||
m_non_fullscreen_bounds.top = 0;
|
m_non_fullscreen_bounds.top = 0;
|
||||||
m_non_fullscreen_bounds.right = 0;
|
m_non_fullscreen_bounds.right = 0;
|
||||||
@ -393,12 +392,6 @@ void uwp_window_info::create(running_machine &machine, int index, std::shared_pt
|
|||||||
window->m_targetlayerconfig = window->target()->layer_config();
|
window->m_targetlayerconfig = window->target()->layer_config();
|
||||||
window->m_targetvismask = window->target()->visibility_mask();
|
window->m_targetvismask = window->target()->visibility_mask();
|
||||||
|
|
||||||
// make the window title
|
|
||||||
if (video_config.numscreens == 1)
|
|
||||||
sprintf(window->m_title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().type.fullname(), machine.system().name);
|
|
||||||
else
|
|
||||||
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
|
// set the initial maximized state
|
||||||
window->m_startmaximized = downcast<windows_options &>(machine.options()).maximize();
|
window->m_startmaximized = downcast<windows_options &>(machine.options()).maximize();
|
||||||
|
|
||||||
|
@ -78,7 +78,6 @@ public:
|
|||||||
volatile int m_init_state;
|
volatile int m_init_state;
|
||||||
|
|
||||||
// window handle and info
|
// window handle and info
|
||||||
char m_title[256];
|
|
||||||
RECT m_non_fullscreen_bounds;
|
RECT m_non_fullscreen_bounds;
|
||||||
int m_startmaximized;
|
int m_startmaximized;
|
||||||
int m_isminimized;
|
int m_isminimized;
|
||||||
|
@ -314,7 +314,6 @@ win_window_info::win_window_info(
|
|||||||
, m_lastclicky(0)
|
, m_lastclicky(0)
|
||||||
, m_attached_mode(false)
|
, m_attached_mode(false)
|
||||||
{
|
{
|
||||||
memset(m_title,0,sizeof(m_title));
|
|
||||||
m_non_fullscreen_bounds.left = 0;
|
m_non_fullscreen_bounds.left = 0;
|
||||||
m_non_fullscreen_bounds.top = 0;
|
m_non_fullscreen_bounds.top = 0;
|
||||||
m_non_fullscreen_bounds.right = 0;
|
m_non_fullscreen_bounds.right = 0;
|
||||||
@ -779,12 +778,6 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
|
|||||||
window->m_targetlayerconfig = window->target()->layer_config();
|
window->m_targetlayerconfig = window->target()->layer_config();
|
||||||
window->m_targetvismask = window->target()->visibility_mask();
|
window->m_targetvismask = window->target()->visibility_mask();
|
||||||
|
|
||||||
// make the window title
|
|
||||||
if (video_config.numscreens == 1)
|
|
||||||
sprintf(window->m_title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().type.fullname(), machine.system().name);
|
|
||||||
else
|
|
||||||
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
|
// set the initial maximized state
|
||||||
window->m_startmaximized = downcast<windows_options &>(machine.options()).maximize();
|
window->m_startmaximized = downcast<windows_options &>(machine.options()).maximize();
|
||||||
|
|
||||||
@ -1046,7 +1039,7 @@ int win_window_info::complete_create()
|
|||||||
hwnd = win_create_window_ex_utf8(
|
hwnd = win_create_window_ex_utf8(
|
||||||
fullscreen() ? FULLSCREEN_STYLE_EX : WINDOW_STYLE_EX,
|
fullscreen() ? FULLSCREEN_STYLE_EX : WINDOW_STYLE_EX,
|
||||||
"MAME",
|
"MAME",
|
||||||
m_title,
|
title().c_str(),
|
||||||
fullscreen() ? FULLSCREEN_STYLE : WINDOW_STYLE,
|
fullscreen() ? FULLSCREEN_STYLE : WINDOW_STYLE,
|
||||||
monitorbounds.left() + 20, monitorbounds.top() + 20,
|
monitorbounds.left() + 20, monitorbounds.top() + 20,
|
||||||
monitorbounds.left() + 100, monitorbounds.top() + 100,
|
monitorbounds.left() + 100, monitorbounds.top() + 100,
|
||||||
@ -1279,6 +1272,22 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
|
|||||||
}
|
}
|
||||||
return DefWindowProc(wnd, message, wparam, lparam);
|
return DefWindowProc(wnd, message, wparam, lparam);
|
||||||
|
|
||||||
|
case WM_ACTIVATE:
|
||||||
|
if (window->has_renderer() && window->fullscreen())
|
||||||
|
{
|
||||||
|
if ((wparam == WA_ACTIVE) || (wparam == WA_CLICKACTIVE))
|
||||||
|
{
|
||||||
|
for (const auto &w : osd_common_t::s_window_list)
|
||||||
|
ShowWindow(std::static_pointer_cast<win_window_info>(w)->platform_window(), SW_RESTORE);
|
||||||
|
}
|
||||||
|
else if ((wparam == WA_INACTIVE) && !is_mame_window(HWND(lparam)))
|
||||||
|
{
|
||||||
|
for (const auto &w : osd_common_t::s_window_list)
|
||||||
|
ShowWindow(std::static_pointer_cast<win_window_info>(w)->platform_window(), SW_MINIMIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DefWindowProc(wnd, message, wparam, lparam);
|
||||||
|
|
||||||
// close: cause MAME to exit
|
// close: cause MAME to exit
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
window->machine().schedule_exit();
|
window->machine().schedule_exit();
|
||||||
|
@ -100,7 +100,6 @@ public:
|
|||||||
volatile int m_init_state;
|
volatile int m_init_state;
|
||||||
|
|
||||||
// window handle and info
|
// window handle and info
|
||||||
char m_title[256];
|
|
||||||
RECT m_non_fullscreen_bounds;
|
RECT m_non_fullscreen_bounds;
|
||||||
int m_startmaximized;
|
int m_startmaximized;
|
||||||
int m_isminimized;
|
int m_isminimized;
|
||||||
|
@ -1318,14 +1318,15 @@ void output_track_metadata(int mode, util::core_file &file, int tracknum, const
|
|||||||
size = 2352;
|
size = 2352;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bool needquote = filename.find(' ') != std::string::npos;
|
const bool needquote = filename.find(' ') != std::string::npos;
|
||||||
file.printf("%d %d %d %d %s%s%s %d\n", tracknum+1, frameoffs, mode, size, needquote?"\"":"", filename.c_str(), needquote?"\"":"", discoffs);
|
const char *const quotestr = needquote ? "\"" : "";
|
||||||
|
file.printf("%d %d %d %d %s%s%s %d\n", tracknum+1, frameoffs, mode, size, quotestr, filename, quotestr, discoffs);
|
||||||
}
|
}
|
||||||
else if (mode == MODE_CUEBIN)
|
else if (mode == MODE_CUEBIN)
|
||||||
{
|
{
|
||||||
// first track specifies the file
|
// first track specifies the file
|
||||||
if (tracknum == 0)
|
if (tracknum == 0)
|
||||||
file.printf("FILE \"%s\" BINARY\n", filename.c_str());
|
file.printf("FILE \"%s\" BINARY\n", filename);
|
||||||
|
|
||||||
// determine submode
|
// determine submode
|
||||||
std::string tempstr;
|
std::string tempstr;
|
||||||
@ -1404,9 +1405,9 @@ void output_track_metadata(int mode, util::core_file &file, int tracknum, const
|
|||||||
|
|
||||||
// all tracks but the first one have a file offset
|
// all tracks but the first one have a file offset
|
||||||
if (tracknum > 0)
|
if (tracknum > 0)
|
||||||
file.printf("DATAFILE \"%s\" #%d %s // length in bytes: %d\n", filename.c_str(), uint32_t(discoffs), msf_string_from_frames(info.frames), info.frames * (info.datasize + info.subsize));
|
file.printf("DATAFILE \"%s\" #%d %s // length in bytes: %d\n", filename, uint32_t(discoffs), msf_string_from_frames(info.frames), info.frames * (info.datasize + info.subsize));
|
||||||
else
|
else
|
||||||
file.printf("DATAFILE \"%s\" %s // length in bytes: %d\n", filename.c_str(), msf_string_from_frames(info.frames), info.frames * (info.datasize + info.subsize));
|
file.printf("DATAFILE \"%s\" %s // length in bytes: %d\n", filename, msf_string_from_frames(info.frames), info.frames * (info.datasize + info.subsize));
|
||||||
|
|
||||||
// tracks with pregaps get a START marker too
|
// tracks with pregaps get a START marker too
|
||||||
if (info.pregap > 0)
|
if (info.pregap > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user