summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-01-21 23:33:53 +1100
committer Vas Crabb <vas@vastheman.com>2021-01-21 23:33:53 +1100
commit7cfe419ca809eb8572f5a0c1e85e8170342c028e (patch)
treec64b2e2230ff7b23fe9122bf74096ddef3420c00
parentef82fd102d548e70aa73e3ba189a6e2d5464b405 (diff)
-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.
-rw-r--r--src/emu/image.cpp4
-rw-r--r--src/osd/mac/window.cpp10
-rw-r--r--src/osd/mac/window.h1
-rw-r--r--src/osd/mac/windowcontroller.mm2
-rw-r--r--src/osd/modules/osdwindow.cpp29
-rw-r--r--src/osd/modules/osdwindow.h19
-rw-r--r--src/osd/sdl/window.cpp8
-rw-r--r--src/osd/sdl/window.h1
-rw-r--r--src/osd/uwp/window.cpp7
-rw-r--r--src/osd/uwp/window.h1
-rw-r--r--src/osd/windows/window.cpp25
-rw-r--r--src/osd/windows/window.h1
-rw-r--r--src/tools/chdman.cpp11
13 files changed, 61 insertions, 58 deletions
diff --git a/src/emu/image.cpp b/src/emu/image.cpp
index 4b9302fa9d3..23cd76c91cd 100644
--- a/src/emu/image.cpp
+++ b/src/emu/image.cpp
@@ -270,13 +270,13 @@ void image_manager::postdevice_init()
bool image_manager::try_change_working_directory(std::string &working_directory, const std::string &subdir)
{
- const osd::directory::entry *entry;
bool success = false;
- bool done = false;
auto directory = osd::directory::open(working_directory);
if (directory)
{
+ const osd::directory::entry *entry;
+ bool done = false;
while (!done && (entry = directory->read()) != nullptr)
{
if (!core_stricmp(subdir.c_str(), entry->name))
diff --git a/src/osd/mac/window.cpp b/src/osd/mac/window.cpp
index cff0f5a8b79..9d570f1595f 100644
--- a/src/osd/mac/window.cpp
+++ b/src/osd/mac/window.cpp
@@ -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()));
- // 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();
// handle error conditions
@@ -515,7 +509,7 @@ void mac_window_info::update()
// 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()
@@ -552,7 +546,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());
diff --git a/src/osd/mac/window.h b/src/osd/mac/window.h
index 8fed34e5f99..9ae9d1171f5 100644
--- a/src/osd/mac/window.h
+++ b/src/osd/mac/window.h
@@ -59,7 +59,6 @@ public:
private:
// window handle and info
- char m_title[256];
int m_startmaximized;
// dimensions
diff --git a/src/osd/mac/windowcontroller.mm b/src/osd/mac/windowcontroller.mm
index dd49d559b0b..3a4b046d662 100644
--- a/src/osd/mac/windowcontroller.mm
+++ b/src/osd/mac/windowcontroller.mm
@@ -109,7 +109,7 @@ void *GetOSWindow(void *wincontroller)
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);
NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
diff --git a/src/osd/modules/osdwindow.cpp b/src/osd/modules/osdwindow.cpp
index f93e54e691f..ee01a971ceb 100644
--- a/src/osd/modules/osdwindow.cpp
+++ b/src/osd/modules/osdwindow.cpp
@@ -22,6 +22,35 @@
#include "render/drawsdl.h"
#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
{
return monitor()->pixel_aspect();
diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h
index 49ef2f8fad9..4b74d504a1c 100644
--- a/src/osd/modules/osdwindow.h
+++ b/src/osd/modules/osdwindow.h
@@ -65,28 +65,14 @@ class osd_monitor_info;
class osd_window : public std::enable_shared_from_this<osd_window>
{
public:
- 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)
- {}
+ osd_window(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config &config);
virtual ~osd_window() { }
render_target *target() const { return m_target; }
int fullscreen() const { return m_fullscreen; }
running_machine &machine() const { return m_machine; }
+ const std::string &title() const { return m_title; }
bool has_renderer() const { return m_renderer != nullptr; }
osd_renderer &renderer() const { return *m_renderer; }
@@ -168,6 +154,7 @@ private:
std::shared_ptr<osd_monitor_info> m_monitor;
std::unique_ptr<osd_renderer> m_renderer;
std::shared_ptr<osd_window> m_main;
+ const std::string m_title;
};
template <class TWindowHandle>
diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp
index 99c2f00e57f..3216589de6e 100644
--- a/src/osd/sdl/window.cpp
+++ b/src/osd/sdl/window.cpp
@@ -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()));
- // 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();
// handle error conditions
@@ -691,7 +685,7 @@ int sdl_window_info::complete_create()
osd_rect work = monitor()->usuable_position_size();
// 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.top() + (work.height() - temp.height()) / 2,
temp.width(), temp.height(), m_extra_flags);
diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h
index 4e39dcf63d0..f5d5715b2f4 100644
--- a/src/osd/sdl/window.h
+++ b/src/osd/sdl/window.h
@@ -64,7 +64,6 @@ public:
private:
// window handle and info
- char m_title[256];
int m_startmaximized;
// dimensions
diff --git a/src/osd/uwp/window.cpp b/src/osd/uwp/window.cpp
index 94cf4558558..ae89ac7cac8 100644
--- a/src/osd/uwp/window.cpp
+++ b/src/osd/uwp/window.cpp
@@ -258,7 +258,6 @@ uwp_window_info::uwp_window_info(
m_lastclickx(0),
m_lastclicky(0)
{
- memset(m_title,0,sizeof(m_title));
m_non_fullscreen_bounds.left = 0;
m_non_fullscreen_bounds.top = 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_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
window->m_startmaximized = downcast<windows_options &>(machine.options()).maximize();
diff --git a/src/osd/uwp/window.h b/src/osd/uwp/window.h
index 65a5e8b8bad..e581ec71246 100644
--- a/src/osd/uwp/window.h
+++ b/src/osd/uwp/window.h
@@ -78,7 +78,6 @@ public:
volatile int m_init_state;
// window handle and info
- char m_title[256];
RECT m_non_fullscreen_bounds;
int m_startmaximized;
int m_isminimized;
diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp
index 8a431d33f5f..75090e0548f 100644
--- a/src/osd/windows/window.cpp
+++ b/src/osd/windows/window.cpp
@@ -314,7 +314,6 @@ win_window_info::win_window_info(
, m_lastclicky(0)
, m_attached_mode(false)
{
- memset(m_title,0,sizeof(m_title));
m_non_fullscreen_bounds.left = 0;
m_non_fullscreen_bounds.top = 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_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
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(
fullscreen() ? FULLSCREEN_STYLE_EX : WINDOW_STYLE_EX,
"MAME",
- m_title,
+ title().c_str(),
fullscreen() ? FULLSCREEN_STYLE : WINDOW_STYLE,
monitorbounds.left() + 20, monitorbounds.top() + 20,
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);
+ 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
case WM_CLOSE:
window->machine().schedule_exit();
diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h
index 3a02ae87277..71bd519ab3a 100644
--- a/src/osd/windows/window.h
+++ b/src/osd/windows/window.h
@@ -100,7 +100,6 @@ public:
volatile int m_init_state;
// window handle and info
- char m_title[256];
RECT m_non_fullscreen_bounds;
int m_startmaximized;
int m_isminimized;
diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp
index c4cf8302aa3..6ea7648522c 100644
--- a/src/tools/chdman.cpp
+++ b/src/tools/chdman.cpp
@@ -1318,14 +1318,15 @@ void output_track_metadata(int mode, util::core_file &file, int tracknum, const
size = 2352;
break;
}
- 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 bool needquote = filename.find(' ') != std::string::npos;
+ 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)
{
// first track specifies the file
if (tracknum == 0)
- file.printf("FILE \"%s\" BINARY\n", filename.c_str());
+ file.printf("FILE \"%s\" BINARY\n", filename);
// determine submode
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
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
- 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
if (info.pregap > 0)