summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-10-10 03:11:01 +1100
committer Vas Crabb <vas@vastheman.com>2020-10-10 03:11:01 +1100
commitd822e7ec4ad29eeb7724e9249ef97a7220f541e0 (patch)
tree3db9fd33235502b2bef495a342efb949f813de24
parent7ae53fff264c9d4c75a06a2edebd5346590e138b (diff)
Miscellaneous cleanup:
* osd/windows: Use steady clock for timing double-clicks. * emu/uiinput.cpp: Made the event type a scoped enum.
-rw-r--r--src/emu/uiinput.cpp44
-rw-r--r--src/emu/uiinput.h27
-rw-r--r--src/frontend/mame/ui/menu.cpp162
-rw-r--r--src/frontend/mame/ui/selmenu.cpp30
-rw-r--r--src/frontend/mame/ui/ui.cpp2
-rw-r--r--src/osd/modules/debugger/debugimgui.cpp2
-rw-r--r--src/osd/windows/window.cpp287
-rw-r--r--src/osd/windows/window.h34
8 files changed, 294 insertions, 294 deletions
diff --git a/src/emu/uiinput.cpp b/src/emu/uiinput.cpp
index 232440dcba6..a5470505f12 100644
--- a/src/emu/uiinput.cpp
+++ b/src/emu/uiinput.cpp
@@ -109,13 +109,13 @@ bool ui_input_manager::push_event(ui_event evt)
// some pre-processing (this is an icky place to do this stuff!)
switch (evt.event_type)
{
- case ui_event::MOUSE_MOVE:
+ case ui_event::type::MOUSE_MOVE:
m_current_mouse_target = evt.target;
m_current_mouse_x = evt.mouse_x;
m_current_mouse_y = evt.mouse_y;
break;
- case ui_event::MOUSE_LEAVE:
+ case ui_event::type::MOUSE_LEAVE:
if (m_current_mouse_target == evt.target)
{
m_current_mouse_target = nullptr;
@@ -124,11 +124,11 @@ bool ui_input_manager::push_event(ui_event evt)
}
break;
- case ui_event::MOUSE_DOWN:
+ case ui_event::type::MOUSE_DOWN:
m_current_mouse_down = true;
break;
- case ui_event::MOUSE_UP:
+ case ui_event::type::MOUSE_UP:
m_current_mouse_down = false;
break;
@@ -301,8 +301,8 @@ g_profiler.stop();
void ui_input_manager::push_mouse_move_event(render_target* target, s32 x, s32 y)
{
- ui_event event = { ui_event::NONE };
- event.event_type = ui_event::MOUSE_MOVE;
+ ui_event event = { ui_event::type::NONE };
+ event.event_type = ui_event::type::MOUSE_MOVE;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
@@ -316,8 +316,8 @@ void ui_input_manager::push_mouse_move_event(render_target* target, s32 x, s32 y
void ui_input_manager::push_mouse_leave_event(render_target* target)
{
- ui_event event = { ui_event::NONE };
- event.event_type = ui_event::MOUSE_LEAVE;
+ ui_event event = { ui_event::type::NONE };
+ event.event_type = ui_event::type::MOUSE_LEAVE;
event.target = target;
push_event(event);
}
@@ -329,8 +329,8 @@ void ui_input_manager::push_mouse_leave_event(render_target* target)
void ui_input_manager::push_mouse_down_event(render_target* target, s32 x, s32 y)
{
- ui_event event = { ui_event::NONE };
- event.event_type = ui_event::MOUSE_DOWN;
+ ui_event event = { ui_event::type::NONE };
+ event.event_type = ui_event::type::MOUSE_DOWN;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
@@ -344,8 +344,8 @@ void ui_input_manager::push_mouse_down_event(render_target* target, s32 x, s32 y
void ui_input_manager::push_mouse_up_event(render_target* target, s32 x, s32 y)
{
- ui_event event = { ui_event::NONE };
- event.event_type = ui_event::MOUSE_UP;
+ ui_event event = { ui_event::type::NONE };
+ event.event_type = ui_event::type::MOUSE_UP;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
@@ -359,8 +359,8 @@ down event to the specified render_target
void ui_input_manager::push_mouse_rdown_event(render_target* target, s32 x, s32 y)
{
- ui_event event = { ui_event::NONE };
- event.event_type = ui_event::MOUSE_RDOWN;
+ ui_event event = { ui_event::type::NONE };
+ event.event_type = ui_event::type::MOUSE_RDOWN;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
@@ -374,8 +374,8 @@ down event to the specified render_target
void ui_input_manager::push_mouse_rup_event(render_target* target, s32 x, s32 y)
{
- ui_event event = { ui_event::NONE };
- event.event_type = ui_event::MOUSE_RUP;
+ ui_event event = { ui_event::type::NONE };
+ event.event_type = ui_event::type::MOUSE_RUP;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
@@ -389,8 +389,8 @@ void ui_input_manager::push_mouse_rup_event(render_target* target, s32 x, s32 y)
-------------------------------------------------*/
void ui_input_manager::push_mouse_double_click_event(render_target* target, s32 x, s32 y)
{
- ui_event event = { ui_event::NONE };
- event.event_type = ui_event::MOUSE_DOUBLE_CLICK;
+ ui_event event = { ui_event::type::NONE };
+ event.event_type = ui_event::type::MOUSE_DOUBLE_CLICK;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
@@ -403,8 +403,8 @@ void ui_input_manager::push_mouse_double_click_event(render_target* target, s32
-------------------------------------------------*/
void ui_input_manager::push_char_event(render_target* target, char32_t ch)
{
- ui_event event = { ui_event::NONE };
- event.event_type = ui_event::IME_CHAR;
+ ui_event event = { ui_event::type::NONE };
+ event.event_type = ui_event::type::IME_CHAR;
event.target = target;
event.ch = ch;
push_event(event);
@@ -417,8 +417,8 @@ void ui_input_manager::push_char_event(render_target* target, char32_t ch)
void ui_input_manager::push_mouse_wheel_event(render_target *target, s32 x, s32 y, short delta, int ucNumLines)
{
- ui_event event = { ui_event::NONE };
- event.event_type = ui_event::MOUSE_WHEEL;
+ ui_event event = { ui_event::type::NONE };
+ event.event_type = ui_event::type::MOUSE_WHEEL;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
diff --git a/src/emu/uiinput.h b/src/emu/uiinput.h
index 85f4eb7cebd..17747fc9f98 100644
--- a/src/emu/uiinput.h
+++ b/src/emu/uiinput.h
@@ -26,7 +26,7 @@
struct ui_event
{
- enum type
+ enum class type
{
NONE,
MOUSE_MOVE,
@@ -60,37 +60,36 @@ public:
void frame_update();
- /* pushes a single event onto the queue */
+ // pushes a single event onto the queue
bool push_event(ui_event event);
- /* pops an event off of the queue */
+ // pops an event off of the queue
bool pop_event(ui_event *event);
- /* check the next event type without removing it */
- ui_event::type peek_event_type() const { return (m_events_start != m_events_end) ? m_events[m_events_start].event_type : ui_event::NONE; }
+ // check the next event type without removing it
+ ui_event::type peek_event_type() const { return (m_events_start != m_events_end) ? m_events[m_events_start].event_type : ui_event::type::NONE; }
- /* clears all outstanding events */
+ // clears all outstanding events
void reset();
- /* retrieves the current location of the mouse */
+ // retrieves the current location of the mouse
render_target *find_mouse(s32 *x, s32 *y, bool *button) const;
ioport_field *find_mouse_field() const;
- /* return true if a key down for the given user interface sequence is detected */
+ // return true if a key down for the given user interface sequence is detected
bool pressed(int code);
// enable/disable UI key presses
bool presses_enabled() const { return m_presses_enabled; }
void set_presses_enabled(bool enabled) { m_presses_enabled = enabled; }
- /* return true if a key down for the given user interface sequence is detected, or if
- autorepeat at the given speed is triggered */
+ // return true if a key down for the given user interface sequence is detected, or if autorepeat at the given speed is triggered
bool pressed_repeat(int code, int speed);
// getters
running_machine &machine() const { return m_machine; }
-
+ // queueing events
void push_mouse_move_event(render_target* target, s32 x, s32 y);
void push_mouse_leave_event(render_target* target);
void push_mouse_down_event(render_target* target, s32 x, s32 y);
@@ -108,19 +107,19 @@ private:
// internal state
running_machine & m_machine; // reference to our machine
- /* pressed states; retrieved with ui_input_pressed() */
+ // pressed states; retrieved with ui_input_pressed()
bool m_presses_enabled;
osd_ticks_t m_next_repeat[IPT_COUNT];
u8 m_seqpressed[IPT_COUNT];
- /* mouse position/info */
+ // mouse position/info
render_target * m_current_mouse_target;
s32 m_current_mouse_x;
s32 m_current_mouse_y;
bool m_current_mouse_down;
ioport_field * m_current_mouse_field;
- /* popped states; ring buffer of ui_events */
+ // popped states; ring buffer of ui_events
ui_event m_events[EVENT_QUEUE_SIZE];
int m_events_start;
int m_events_end;
diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp
index aa7d90f0ea3..b0a84d3a95c 100644
--- a/src/frontend/mame/ui/menu.cpp
+++ b/src/frontend/mame/ui/menu.cpp
@@ -911,110 +911,110 @@ void menu::handle_events(uint32_t flags, event &ev)
{
switch (local_menu_event.event_type)
{
- // if we are hovering over a valid item, select it with a single click
- case ui_event::MOUSE_DOWN:
- if (custom_mouse_down())
- return;
+ // if we are hovering over a valid item, select it with a single click
+ case ui_event::type::MOUSE_DOWN:
+ if (custom_mouse_down())
+ return;
- if ((flags & PROCESS_ONLYCHAR) == 0)
+ if ((flags & PROCESS_ONLYCHAR) == 0)
+ {
+ if (m_hover >= 0 && m_hover < m_items.size())
+ m_selected = m_hover;
+ else if (m_hover == HOVER_ARROW_UP)
{
- if (m_hover >= 0 && m_hover < m_items.size())
- m_selected = m_hover;
- else if (m_hover == HOVER_ARROW_UP)
+ if ((flags & FLAG_UI_DATS) != 0)
{
- if ((flags & FLAG_UI_DATS) != 0)
- {
- top_line -= m_visible_items - (last_item_visible() ? 1 : 0);
- return;
- }
- m_selected -= m_visible_items;
- if (m_selected < 0)
- m_selected = 0;
top_line -= m_visible_items - (last_item_visible() ? 1 : 0);
+ return;
}
- else if (m_hover == HOVER_ARROW_DOWN)
+ m_selected -= m_visible_items;
+ if (m_selected < 0)
+ m_selected = 0;
+ top_line -= m_visible_items - (last_item_visible() ? 1 : 0);
+ }
+ else if (m_hover == HOVER_ARROW_DOWN)
+ {
+ if ((flags & FLAG_UI_DATS) != 0)
{
- if ((flags & FLAG_UI_DATS) != 0)
- {
- top_line += m_visible_lines - 2;
- return;
- }
- m_selected += m_visible_lines - 2 + is_first_selected();
- if (m_selected > m_items.size() - 1)
- m_selected = m_items.size() - 1;
top_line += m_visible_lines - 2;
+ return;
}
+ m_selected += m_visible_lines - 2 + is_first_selected();
+ if (m_selected > m_items.size() - 1)
+ m_selected = m_items.size() - 1;
+ top_line += m_visible_lines - 2;
}
- break;
+ }
+ break;
- // if we are hovering over a valid item, fake a UI_SELECT with a double-click
- case ui_event::MOUSE_DOUBLE_CLICK:
- if (!(flags & PROCESS_ONLYCHAR) && m_hover >= 0 && m_hover < m_items.size())
+ // if we are hovering over a valid item, fake a UI_SELECT with a double-click
+ case ui_event::type::MOUSE_DOUBLE_CLICK:
+ if (!(flags & PROCESS_ONLYCHAR) && m_hover >= 0 && m_hover < m_items.size())
+ {
+ m_selected = m_hover;
+ ev.iptkey = IPT_UI_SELECT;
+ if (is_last_selected())
{
- m_selected = m_hover;
- ev.iptkey = IPT_UI_SELECT;
- if (is_last_selected())
+ ev.iptkey = IPT_UI_CANCEL;
+ stack_pop();
+ }
+ stop = true;
+ }
+ break;
+
+ // caught scroll event
+ case ui_event::type::MOUSE_WHEEL:
+ if (!(flags & PROCESS_ONLYCHAR))
+ {
+ if (local_menu_event.zdelta > 0)
+ {
+ if ((flags & FLAG_UI_DATS) != 0)
+ {
+ top_line -= local_menu_event.num_lines;
+ return;
+ }
+ if (is_first_selected())
+ select_last_item();
+ else
{
- ev.iptkey = IPT_UI_CANCEL;
- stack_pop();
+ m_selected -= local_menu_event.num_lines;
+ validate_selection(-1);
}
- stop = true;
+ top_line -= (m_selected <= top_line && top_line != 0);
+ if (m_selected <= top_line && m_visible_items != m_visible_lines)
+ top_line -= local_menu_event.num_lines;
}
- break;
-
- // caught scroll event
- case ui_event::MOUSE_WHEEL:
- if (!(flags & PROCESS_ONLYCHAR))
+ else
{
- if (local_menu_event.zdelta > 0)
+ if ((flags & FLAG_UI_DATS))
{
- if ((flags & FLAG_UI_DATS) != 0)
- {
- top_line -= local_menu_event.num_lines;
- return;
- }
- if (is_first_selected())
- select_last_item();
- else
- {
- m_selected -= local_menu_event.num_lines;
- validate_selection(-1);
- }
- top_line -= (m_selected <= top_line && top_line != 0);
- if (m_selected <= top_line && m_visible_items != m_visible_lines)
- top_line -= local_menu_event.num_lines;
+ top_line += local_menu_event.num_lines;
+ return;
}
+ if (is_last_selected())
+ select_first_item();
else
{
- if ((flags & FLAG_UI_DATS))
- {
- top_line += local_menu_event.num_lines;
- return;
- }
- if (is_last_selected())
- select_first_item();
- else
- {
- m_selected += local_menu_event.num_lines;
- validate_selection(1);
- }
- top_line += (m_selected >= top_line + m_visible_items + (top_line != 0));
- if (m_selected >= (top_line + m_visible_items + (top_line != 0)))
- top_line += local_menu_event.num_lines;
+ m_selected += local_menu_event.num_lines;
+ validate_selection(1);
}
+ top_line += (m_selected >= top_line + m_visible_items + (top_line != 0));
+ if (m_selected >= (top_line + m_visible_items + (top_line != 0)))
+ top_line += local_menu_event.num_lines;
}
- break;
+ }
+ break;
- // translate CHAR events into specials
- case ui_event::IME_CHAR:
- ev.iptkey = IPT_SPECIAL;
- ev.unichar = local_menu_event.ch;
- stop = true;
- break;
+ // translate CHAR events into specials
+ case ui_event::type::IME_CHAR:
+ ev.iptkey = IPT_SPECIAL;
+ ev.unichar = local_menu_event.ch;
+ stop = true;
+ break;
- // ignore everything else
- default:
- break;
+ // ignore everything else
+ default:
+ break;
}
}
}
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index 7a652c1b6bf..9a58691b988 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -1661,7 +1661,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
switch (local_menu_event.event_type)
{
// if we are hovering over a valid item, select it with a single click
- case ui_event::MOUSE_DOWN:
+ case ui_event::type::MOUSE_DOWN:
if (m_ui_error)
{
ev.iptkey = IPT_OTHER;
@@ -1761,7 +1761,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
break;
// if we are hovering over a valid item, fake a UI_SELECT with a double-click
- case ui_event::MOUSE_DOUBLE_CLICK:
+ case ui_event::type::MOUSE_DOUBLE_CLICK:
if (hover() >= 0 && hover() < item_count())
{
set_selected_index(hover());
@@ -1777,7 +1777,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
break;
// caught scroll event
- case ui_event::MOUSE_WHEEL:
+ case ui_event::type::MOUSE_WHEEL:
if (hover() >= 0 && hover() < item_count() - skip_main_items - 1)
{
if (local_menu_event.zdelta > 0)
@@ -1807,7 +1807,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
break;
// translate CHAR events into specials
- case ui_event::IME_CHAR:
+ case ui_event::type::IME_CHAR:
if (exclusive_input_pressed(ev.iptkey, IPT_UI_FOCUS_NEXT, 0) || exclusive_input_pressed(ev.iptkey, IPT_UI_FOCUS_PREV, 0))
{
stop = true;
@@ -1824,7 +1824,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
}
break;
- case ui_event::MOUSE_RDOWN:
+ case ui_event::type::MOUSE_RDOWN:
if (hover() >= 0 && hover() < item_count() - skip_main_items - 1)
{
set_selected_index(hover());
@@ -1847,18 +1847,18 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
{
switch (machine().ui_input().peek_event_type())
{
- case ui_event::MOUSE_DOWN:
- case ui_event::MOUSE_RDOWN:
- case ui_event::MOUSE_DOUBLE_CLICK:
- case ui_event::MOUSE_WHEEL:
+ case ui_event::type::MOUSE_DOWN:
+ case ui_event::type::MOUSE_RDOWN:
+ case ui_event::type::MOUSE_DOUBLE_CLICK:
+ case ui_event::type::MOUSE_WHEEL:
stop = true;
break;
- case ui_event::NONE:
- case ui_event::MOUSE_MOVE:
- case ui_event::MOUSE_LEAVE:
- case ui_event::MOUSE_UP:
- case ui_event::MOUSE_RUP:
- case ui_event::IME_CHAR:
+ case ui_event::type::NONE:
+ case ui_event::type::MOUSE_MOVE:
+ case ui_event::type::MOUSE_LEAVE:
+ case ui_event::type::MOUSE_UP:
+ case ui_event::type::MOUSE_RUP:
+ case ui_event::type::IME_CHAR:
break;
}
}
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp
index d65cf9c581b..90efcb04b7c 100644
--- a/src/frontend/mame/ui/ui.cpp
+++ b/src/frontend/mame/ui/ui.cpp
@@ -1004,7 +1004,7 @@ void mame_ui_manager::process_natural_keyboard()
while (machine().ui_input().pop_event(&event))
{
// if this was a UI_EVENT_CHAR event, post it
- if (event.event_type == ui_event::IME_CHAR)
+ if (event.event_type == ui_event::type::IME_CHAR)
machine().ioport().natkeyboard().post_char(event.ch);
}
diff --git a/src/osd/modules/debugger/debugimgui.cpp b/src/osd/modules/debugger/debugimgui.cpp
index da3e58d4bcf..5e1e7f5c080 100644
--- a/src/osd/modules/debugger/debugimgui.cpp
+++ b/src/osd/modules/debugger/debugimgui.cpp
@@ -353,7 +353,7 @@ void debug_imgui::handle_keys()
{
switch (event.event_type)
{
- case ui_event::IME_CHAR:
+ case ui_event::type::IME_CHAR:
m_key_char = event.ch;
if(focus_view != nullptr)
focus_view->view->process_char(m_key_char);
diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp
index 6f8dc3671c9..5a292f78ff6 100644
--- a/src/osd/windows/window.cpp
+++ b/src/osd/windows/window.cpp
@@ -14,11 +14,9 @@
// standard C headers
#include <process.h>
+#include <algorithm>
#include <atomic>
#include <cstring>
-#include <chrono>
-#include <list>
-#include <memory>
// MAME headers
#include "emu.h"
@@ -96,7 +94,7 @@ static DWORD main_threadid;
//============================================================
// event handling
-static std::chrono::system_clock::time_point last_event_check;
+static std::chrono::steady_clock::time_point last_event_check;
static int ui_temp_pause;
static int ui_temp_was_paused;
@@ -295,29 +293,31 @@ void windows_osd_interface::window_exit()
CloseHandle(ui_pause_event);
}
+
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_t(*config),
- m_next(nullptr),
- 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::system_clock::time_point::min()),
- m_lastclickx(0),
- m_lastclicky(0),
- m_machine(machine),
- m_attached_mode(false)
+ running_machine &machine,
+ int index,
+ std::shared_ptr<osd_monitor_info> monitor,
+ const osd_window_config *config)
+ : osd_window_t(*config)
+ , m_next(nullptr)
+ , 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));
m_non_fullscreen_bounds.left = 0;
@@ -350,7 +350,7 @@ void win_window_info::hide_pointer()
{
GetCursorPos(&s_saved_cursor_pos);
- while (ShowCursor(FALSE) >= -1) {};
+ while (ShowCursor(FALSE) >= -1) { }
ShowCursor(TRUE);
}
@@ -402,7 +402,7 @@ void win_window_info::show_pointer()
void winwindow_process_events_periodic(running_machine &machine)
{
- auto currticks = std::chrono::system_clock::now();
+ auto currticks = std::chrono::steady_clock::now();
assert(GetCurrentThreadId() == main_threadid);
@@ -465,7 +465,7 @@ void winwindow_process_events(running_machine &machine, bool ingame, bool nodisp
assert(GetCurrentThreadId() == main_threadid);
// remember the last time we did this
- last_event_check = std::chrono::system_clock::now();
+ last_event_check = std::chrono::steady_clock::now();
do
{
@@ -1185,7 +1185,7 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
auto *window = (win_window_info *)ptr;
// we may get called before SetWindowLongPtr is called
- if (window != nullptr)
+ if (window)
{
assert(GetCurrentThreadId() == window_threadid);
window->update_minmax_state();
@@ -1194,8 +1194,8 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
// handle a few messages
switch (message)
{
- // paint: redraw the last bitmap
- case WM_PAINT:
+ // paint: redraw the last bitmap
+ case WM_PAINT:
{
PAINTSTRUCT pstruct;
HDC hdc = BeginPaint(wnd, &pstruct);
@@ -1203,37 +1203,37 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
if (window->win_has_menu())
DrawMenuBar(window->platform_window());
EndPaint(wnd, &pstruct);
- break;
}
+ break;
- // non-client paint: punt if full screen
- case WM_NCPAINT:
- if (!window->fullscreen() || window->win_has_menu())
- return DefWindowProc(wnd, message, wparam, lparam);
- break;
+ // non-client paint: punt if full screen
+ case WM_NCPAINT:
+ if (!window->fullscreen() || window->win_has_menu())
+ return DefWindowProc(wnd, message, wparam, lparam);
+ break;
- // input: handle the raw input
- case WM_INPUT:
- downcast<windows_osd_interface&>(window->machine().osd()).handle_input_event(INPUT_EVENT_RAWINPUT, &lparam);
- break;
+ // input: handle the raw input
+ case WM_INPUT:
+ downcast<windows_osd_interface&>(window->machine().osd()).handle_input_event(INPUT_EVENT_RAWINPUT, &lparam);
+ break;
- // syskeys - ignore
- case WM_SYSKEYUP:
- case WM_SYSKEYDOWN:
- break;
+ // syskeys - ignore
+ case WM_SYSKEYUP:
+ case WM_SYSKEYDOWN:
+ break;
- // input events
- case WM_MOUSEMOVE:
- window->machine().ui_input().push_mouse_move_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
- break;
+ // input events
+ case WM_MOUSEMOVE:
+ window->machine().ui_input().push_mouse_move_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ break;
- case WM_MOUSELEAVE:
- window->machine().ui_input().push_mouse_leave_event(window->m_target);
- break;
+ case WM_MOUSELEAVE:
+ window->machine().ui_input().push_mouse_leave_event(window->m_target);
+ break;
- case WM_LBUTTONDOWN:
+ case WM_LBUTTONDOWN:
{
- auto ticks = std::chrono::system_clock::now();
+ 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));
// check for a double-click
@@ -1241,7 +1241,7 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
GET_X_LPARAM(lparam) >= window->m_lastclickx - 4 && GET_X_LPARAM(lparam) <= window->m_lastclickx + 4 &&
GET_Y_LPARAM(lparam) >= window->m_lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->m_lastclicky + 4)
{
- window->m_lastclicktime = std::chrono::system_clock::time_point::min();
+ 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));
}
else
@@ -1250,26 +1250,26 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
window->m_lastclickx = GET_X_LPARAM(lparam);
window->m_lastclicky = GET_Y_LPARAM(lparam);
}
- break;
}
+ break;
- case WM_LBUTTONUP:
- window->machine().ui_input().push_mouse_up_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
- break;
+ case WM_LBUTTONUP:
+ window->machine().ui_input().push_mouse_up_event(window->m_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));
- break;
+ case WM_RBUTTONDOWN:
+ window->machine().ui_input().push_mouse_rdown_event(window->m_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));
- break;
+ case WM_RBUTTONUP:
+ window->machine().ui_input().push_mouse_rup_event(window->m_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);
- break;
+ case WM_CHAR:
+ window->machine().ui_input().push_char_event(window->m_target, (char32_t) wparam);
+ break;
- case WM_MOUSEWHEEL:
+ case WM_MOUSEWHEEL:
{
UINT ucNumLines = 3; // default
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &ucNumLines, 0);
@@ -1277,32 +1277,33 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
break;
}
- // pause the system when we start a menu or resize
- case WM_ENTERSIZEMOVE:
- window->m_resize_state = RESIZE_STATE_RESIZING;
- case WM_ENTERMENULOOP:
- winwindow_ui_pause(window->machine(), TRUE);
- break;
-
- // unpause the system when we stop a menu or resize and force a redraw
- case WM_EXITSIZEMOVE:
- window->m_resize_state = RESIZE_STATE_PENDING;
- case WM_EXITMENULOOP:
- winwindow_ui_pause(window->machine(), FALSE);
- InvalidateRect(wnd, nullptr, FALSE);
- break;
-
- // get min/max info: set the minimum window size
- case WM_GETMINMAXINFO:
+ // pause the system when we start a menu or resize
+ case WM_ENTERSIZEMOVE:
+ window->m_resize_state = RESIZE_STATE_RESIZING;
+ case WM_ENTERMENULOOP:
+ winwindow_ui_pause(window->machine(), TRUE);
+ break;
+
+ // unpause the system when we stop a menu or resize and force a redraw
+ case WM_EXITSIZEMOVE:
+ window->m_resize_state = RESIZE_STATE_PENDING;
+ case WM_EXITMENULOOP:
+ winwindow_ui_pause(window->machine(), FALSE);
+ InvalidateRect(wnd, nullptr, FALSE);
+ break;
+
+ // get min/max info: set the minimum window size
+ case WM_GETMINMAXINFO:
{
auto *minmax = (MINMAXINFO *)lparam;
minmax->ptMinTrackSize.x = MIN_WINDOW_DIMX;
minmax->ptMinTrackSize.y = MIN_WINDOW_DIMY;
break;
}
+ break;
- // sizing: constrain to the aspect ratio unless control key is held down
- case WM_SIZING:
+ // sizing: constrain to the aspect ratio unless control key is held down
+ case WM_SIZING:
{
RECT *rect = (RECT *)lparam;
if (video_config.keepaspect && !(GetAsyncKeyState(VK_CONTROL) & 0x8000))
@@ -1314,11 +1315,11 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
rect->right = r.right();
}
InvalidateRect(wnd, nullptr, FALSE);
- break;
}
+ break;
- // syscommands: catch win_start_maximized
- case WM_SYSCOMMAND:
+ // syscommands: catch win_start_maximized
+ case WM_SYSCOMMAND:
{
uint16_t cmd = wparam & 0xfff0;
@@ -1339,22 +1340,22 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
window->maximize_window();
break;
}
- return DefWindowProc(wnd, message, wparam, lparam);
}
+ return DefWindowProc(wnd, message, wparam, lparam);
- // close: cause MAME to exit
- case WM_CLOSE:
- window->machine().schedule_exit();
- break;
+ // close: cause MAME to exit
+ case WM_CLOSE:
+ window->machine().schedule_exit();
+ break;
- // destroy: clean up all attached rendering bits and nullptr out our hwnd
- case WM_DESTROY:
- window->renderer_reset();
- window->set_platform_window(nullptr);
- return DefWindowProc(wnd, message, wparam, lparam);
+ // destroy: clean up all attached rendering bits and nullptr out our hwnd
+ case WM_DESTROY:
+ window->renderer_reset();
+ window->set_platform_window(nullptr);
+ return DefWindowProc(wnd, message, wparam, lparam);
- // self redraw: draw ourself in a non-painty way
- case WM_USER_REDRAW:
+ // self redraw: draw ourself in a non-painty way
+ case WM_USER_REDRAW:
{
HDC hdc = GetDC(wnd);
@@ -1362,46 +1363,46 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
window->draw_video_contents(hdc, false);
ReleaseDC(wnd, hdc);
- break;
}
-
- // fullscreen set
- case WM_USER_SET_FULLSCREEN:
- window->set_fullscreen(wparam);
- break;
-
- // minimum size set
- case WM_USER_SET_MINSIZE:
- window->minimize_window();
- break;
-
- // maximum size set
- case WM_USER_SET_MAXSIZE:
- window->maximize_window();
- break;
-
- // maximum size set
- case WM_DISPLAYCHANGE:
- /* FIXME: The current codebase has an issue with setting aspect
- * ratios correctly after display change. set_aspect should
- * be set_forced_aspect and on a refresh this forced aspect should
- * 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));
- break;
-
- // set focus: if we're not the primary window, switch back
- // commented out ATM because this prevents us from resizing secondary windows
-// case WM_SETFOCUS:
-// if (window != osd_common_t::s_window_list && osd_common_t::s_window_list != nullptr)
-// SetFocus(osd_common_t::s_window_list->m_hwnd);
-// break;
-
- // everything else: defaults
- default:
- return DefWindowProc(wnd, message, wparam, lparam);
+ break;
+
+ // fullscreen set
+ case WM_USER_SET_FULLSCREEN:
+ window->set_fullscreen(wparam);
+ break;
+
+ // minimum size set
+ case WM_USER_SET_MINSIZE:
+ window->minimize_window();
+ break;
+
+ // maximum size set
+ case WM_USER_SET_MAXSIZE:
+ window->maximize_window();
+ break;
+
+ // maximum size set
+ case WM_DISPLAYCHANGE:
+ /* FIXME: The current codebase has an issue with setting aspect
+ * ratios correctly after display change. set_aspect should
+ * be set_forced_aspect and on a refresh this forced aspect should
+ * 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));
+ break;
+
+ // set focus: if we're not the primary window, switch back
+ // commented out ATM because this prevents us from resizing secondary windows
+// case WM_SETFOCUS:
+// if (window != osd_common_t::s_window_list && osd_common_t::s_window_list != nullptr)
+// SetFocus(osd_common_t::s_window_list->m_hwnd);
+// break;
+
+ // everything else: defaults
+ default:
+ return DefWindowProc(wnd, message, wparam, lparam);
}
return 0;
diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h
index 3dccc520a83..22065135efe 100644
--- a/src/osd/windows/window.h
+++ b/src/osd/windows/window.h
@@ -5,27 +5,27 @@
// window.h - Win32 window handling
//
//============================================================
+#ifndef MAME_OSD_WINDOWS_WINDOW_H
+#define MAME_OSD_WINDOWS_WINDOW_H
-#ifndef __WIN_WINDOW__
-#define __WIN_WINDOW__
-
-// standard windows headers
-#include <windows.h>
-#include <windowsx.h>
-#include <mmsystem.h>
-
-#include <chrono>
-#include <mutex>
-#include <memory>
-#include <list>
+#pragma once
#include "render.h"
#include "modules/osdwindow.h"
+#include "modules/lib/osdlib.h"
-//============================================================
-// PARAMETERS
-//============================================================
+#include <chrono>
+#include <list>
+#include <memory>
+#include <mutex>
+#include <utility>
+#include <vector>
+
+// standard windows headers
+#include <windows.h>
+#include <windowsx.h>
+#include <mmsystem.h>
//============================================================
@@ -128,7 +128,7 @@ public:
u32 m_targetvismask;
// input info
- std::chrono::system_clock::time_point m_lastclicktime;
+ std::chrono::steady_clock::time_point m_lastclicktime;
int m_lastclickx;
int m_lastclicky;
@@ -206,4 +206,4 @@ static inline int rect_height(const RECT *rect)
return rect->bottom - rect->top;
}
-#endif
+#endif // MAME_OSD_WINDOWS_WINDOW_H