From 4cf96da22c09651c1da2b27ee61028d558e7af49 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 12 Mar 2021 01:15:08 +1100 Subject: -A few incremental UI code improvements: * Simplified message when toggling UI controls. * Show actual configured UI toggle key, not misleading hard-coded text. * Push window activated/deactivated events to UI manager. * Simplified SDL window event handling code - events are pretty precise. -Miscellaneous code cleanup. --- src/emu/uiinput.cpp | 42 +++++++++++++++++++++------ src/emu/uiinput.h | 29 ++++++++++--------- src/frontend/mame/ui/inputmap.cpp | 2 +- src/frontend/mame/ui/selmenu.cpp | 2 ++ src/frontend/mame/ui/ui.cpp | 24 ++++------------ src/mame/drivers/firebeat.cpp | 47 +++++++++++++------------------ src/mame/drivers/r2dx_v33.cpp | 8 +++--- src/mame/video/avgdvg.cpp | 13 ++------- src/osd/modules/input/input_sdlcommon.cpp | 36 +++++++++-------------- src/osd/modules/input/input_sdlcommon.h | 2 -- src/osd/sdl/window.cpp | 19 ++++++------- src/osd/windows/window.cpp | 33 ++++++++++++++-------- 12 files changed, 126 insertions(+), 131 deletions(-) diff --git a/src/emu/uiinput.cpp b/src/emu/uiinput.cpp index 497ce3e7030..d1398591687 100644 --- a/src/emu/uiinput.cpp +++ b/src/emu/uiinput.cpp @@ -294,12 +294,38 @@ g_profiler.stop(); return pressed; } +/*------------------------------------------------- + push_window_focus_event - pushes a focus + event to the specified render_target +-------------------------------------------------*/ + +void ui_input_manager::push_window_focus_event(render_target *target) +{ + ui_event event = { ui_event::type::NONE }; + event.event_type = ui_event::type::WINDOW_FOCUS; + event.target = target; + push_event(event); +} + +/*------------------------------------------------- + push_window_defocus_event - pushes a defocus + event to the specified render_target +-------------------------------------------------*/ + +void ui_input_manager::push_window_defocus_event(render_target *target) +{ + ui_event event = { ui_event::type::NONE }; + event.event_type = ui_event::type::WINDOW_DEFOCUS; + event.target = target; + push_event(event); +} + /*------------------------------------------------- push_mouse_move_event - pushes a mouse move event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_move_event(render_target* target, s32 x, s32 y) +void ui_input_manager::push_mouse_move_event(render_target *target, s32 x, s32 y) { ui_event event = { ui_event::type::NONE }; event.event_type = ui_event::type::MOUSE_MOVE; @@ -314,7 +340,7 @@ void ui_input_manager::push_mouse_move_event(render_target* target, s32 x, s32 y mouse leave event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_leave_event(render_target* target) +void ui_input_manager::push_mouse_leave_event(render_target *target) { ui_event event = { ui_event::type::NONE }; event.event_type = ui_event::type::MOUSE_LEAVE; @@ -327,7 +353,7 @@ void ui_input_manager::push_mouse_leave_event(render_target* target) down event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_down_event(render_target* target, s32 x, s32 y) +void ui_input_manager::push_mouse_down_event(render_target *target, s32 x, s32 y) { ui_event event = { ui_event::type::NONE }; event.event_type = ui_event::type::MOUSE_DOWN; @@ -342,7 +368,7 @@ void ui_input_manager::push_mouse_down_event(render_target* target, s32 x, s32 y down event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_up_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::type::NONE }; event.event_type = ui_event::type::MOUSE_UP; @@ -357,7 +383,7 @@ push_mouse_down_event - pushes a mouse down event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_rdown_event(render_target* target, s32 x, s32 y) +void ui_input_manager::push_mouse_rdown_event(render_target *target, s32 x, s32 y) { ui_event event = { ui_event::type::NONE }; event.event_type = ui_event::type::MOUSE_RDOWN; @@ -372,7 +398,7 @@ push_mouse_down_event - pushes a mouse down event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_rup_event(render_target* target, s32 x, s32 y) +void ui_input_manager::push_mouse_rup_event(render_target *target, s32 x, s32 y) { ui_event event = { ui_event::type::NONE }; event.event_type = ui_event::type::MOUSE_RUP; @@ -387,7 +413,7 @@ void ui_input_manager::push_mouse_rup_event(render_target* target, s32 x, s32 y) a mouse double-click event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_double_click_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::type::NONE }; event.event_type = ui_event::type::MOUSE_DOUBLE_CLICK; @@ -401,7 +427,7 @@ void ui_input_manager::push_mouse_double_click_event(render_target* target, s32 push_char_event - pushes a char event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_char_event(render_target* target, char32_t ch) +void ui_input_manager::push_char_event(render_target *target, char32_t ch) { ui_event event = { ui_event::type::NONE }; event.event_type = ui_event::type::IME_CHAR; diff --git a/src/emu/uiinput.h b/src/emu/uiinput.h index 17747fc9f98..29b18d06d30 100644 --- a/src/emu/uiinput.h +++ b/src/emu/uiinput.h @@ -14,12 +14,6 @@ #pragma once -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -#define EVENT_QUEUE_SIZE 128 - /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ @@ -29,6 +23,8 @@ struct ui_event enum class type { NONE, + WINDOW_FOCUS, + WINDOW_DEFOCUS, MOUSE_MOVE, MOUSE_LEAVE, MOUSE_DOWN, @@ -90,20 +86,25 @@ public: 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); - void push_mouse_up_event(render_target* target, s32 x, s32 y); - void push_mouse_rdown_event(render_target* target, s32 x, s32 y); - void push_mouse_rup_event(render_target* target, s32 x, s32 y); - void push_mouse_double_click_event(render_target* target, s32 x, s32 y); - void push_char_event(render_target* target, char32_t ch); + void push_window_focus_event(render_target *target); + void push_window_defocus_event(render_target *target); + 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); + void push_mouse_up_event(render_target *target, s32 x, s32 y); + void push_mouse_rdown_event(render_target *target, s32 x, s32 y); + void push_mouse_rup_event(render_target *target, s32 x, s32 y); + void push_mouse_double_click_event(render_target *target, s32 x, s32 y); + void push_char_event(render_target *target, char32_t ch); void push_mouse_wheel_event(render_target *target, s32 x, s32 y, short delta, int ucNumLines); void mark_all_as_pressed(); private: + // constants + constexpr static unsigned EVENT_QUEUE_SIZE = 128; + // internal state running_machine & m_machine; // reference to our machine diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index 72e93216943..a4638e76536 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -38,7 +38,7 @@ void menu_input_groups::populate(float &customtop, float &custombottom) item_append(_("User Interface"), 0, (void *)uintptr_t(IPG_UI + 1)); for (int player = 0; player < MAX_PLAYERS; player++) { - auto s = string_format("Player %d Controls", player + 1); + auto s = string_format(_("Player %1$d Controls"), player + 1); item_append(s, 0, (void *)uintptr_t(IPG_PLAYER1 + player + 1)); } item_append(_("Other Controls"), 0, (void *)uintptr_t(IPG_OTHER + 1)); diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp index f24016ae31f..236a33225bc 100644 --- a/src/frontend/mame/ui/selmenu.cpp +++ b/src/frontend/mame/ui/selmenu.cpp @@ -1851,6 +1851,8 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev) stop = true; break; case ui_event::type::NONE: + case ui_event::type::WINDOW_FOCUS: + case ui_event::type::WINDOW_DEFOCUS: case ui_event::type::MOUSE_MOVE: case ui_event::type::MOUSE_LEAVE: case ui_event::type::MOUSE_UP: diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index f5e04284cd7..b41c0703ec0 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -1215,26 +1215,11 @@ uint32_t mame_ui_manager::handler_ingame(render_container &container) machine().set_ui_active(!machine().ui_active()); // display a popup indicating the new status + std::string const name = machine().input().seq_name(machine().ioport().type_seq(IPT_UI_TOGGLE_UI)); if (machine().ui_active()) - { - popup_time(2, "%s\n%s\n%s\n%s\n%s\n%s\n", - _("Keyboard Emulation Status"), - "-------------------------", - _("Mode: PARTIAL Emulation"), - _("UI: Enabled"), - "-------------------------", - _("**Use ScrLock to toggle**")); - } + popup_time(2, _("UI controls enabled\nUse %1$s to toggle"), name); else - { - popup_time(2, "%s\n%s\n%s\n%s\n%s\n%s\n", - _("Keyboard Emulation Status"), - "-------------------------", - _("Mode: FULL Emulation"), - _("UI: Disabled"), - "-------------------------", - _("**Use ScrLock to toggle**")); - } + popup_time(2, _("UI controls disabled\nUse %1$s to toggle"), name); } } @@ -1255,7 +1240,8 @@ uint32_t mame_ui_manager::handler_ingame(render_container &container) if (machine().ui_input().pressed(IPT_UI_TIMECODE)) machine().video().save_input_timecode(); - if (ui_disabled) return ui_disabled; + if (ui_disabled) + return ui_disabled; if (machine().ui_input().pressed(IPT_UI_CANCEL)) { diff --git a/src/mame/drivers/firebeat.cpp b/src/mame/drivers/firebeat.cpp index 9f163b46aa1..26ac10aa36e 100644 --- a/src/mame/drivers/firebeat.cpp +++ b/src/mame/drivers/firebeat.cpp @@ -222,9 +222,8 @@ void firebeat_extend_spectrum_analyzer_device::device_reset() { for (int ch = 0; ch < TOTAL_CHANNELS; ch++) { - for (int i = 0; i < TOTAL_BUFFERS; i++) { + for (int i = 0; i < TOTAL_BUFFERS; i++) std::fill(std::begin(m_audio_buf[i][ch]), std::end(m_audio_buf[i][ch]), 0); - } std::fill(std::begin(m_fft_buf[ch]), std::end(m_fft_buf[ch]), 0); std::fill(std::begin(m_bars[ch]), std::end(m_bars[ch]), 0); @@ -260,38 +259,35 @@ void firebeat_extend_spectrum_analyzer_device::sound_stream_update(sound_stream auto srate = stream.sample_rate(); auto order = WDL_fft_permute_tab(FFT_LENGTH / 2); - for (int ch = 0; ch < TOTAL_CHANNELS; ch++) { + for (int ch = 0; ch < TOTAL_CHANNELS; ch++) + { double notch_max[TOTAL_BARS] = { -1, -1, -1, -1, -1, -1 }; int cur_notch = 0; for (int i = 0; i <= FFT_LENGTH / 2; i++) { const double freq = (double)i / FFT_LENGTH * srate; - if (freq < NOTCHES[cur_notch]) { + if (freq < NOTCHES[cur_notch]) continue; - } - if (freq > NOTCHES[cur_notch+1]) { + if (freq > NOTCHES[cur_notch+1]) cur_notch++; - } - if (cur_notch >= LAST_NOTCH) { - // Don't need to calculate anything above this frequency + if (cur_notch >= LAST_NOTCH) // Don't need to calculate anything above this frequency break; - } - WDL_FFT_COMPLEX* bin = (WDL_FFT_COMPLEX*)m_fft_buf[ch] + order[i]; + WDL_FFT_COMPLEX *bin = (WDL_FFT_COMPLEX*)m_fft_buf[ch] + order[i]; const double re = bin->re; const double im = bin->im; const double mag = sqrt(re*re + im*im); - if (notch_max[cur_notch] == -1 && freq >= NOTCHES[cur_notch] && freq < NOTCHES[cur_notch+1]) { + if (notch_max[cur_notch] == -1 && freq >= NOTCHES[cur_notch] && freq < NOTCHES[cur_notch+1]) notch_max[cur_notch] = mag; - } } - for (int i = 0; i < TOTAL_BARS; i++) { + for (int i = 0; i < TOTAL_BARS; i++) + { double val = log10(notch_max[i] * 4096) * 20; val = std::max(0, val); m_bars[ch][i] = uint32_t(std::min(val, 255.0f)); @@ -312,12 +308,12 @@ void firebeat_extend_spectrum_analyzer_device::apply_fft(uint32_t buf_index) *buf_r++ = *audio_r++; } - for (int ch = 0; ch < TOTAL_CHANNELS; ch++) { - WDL_real_fft((WDL_FFT_REAL*)m_fft_buf[ch], FFT_LENGTH, 0); + for (int ch = 0; ch < TOTAL_CHANNELS; ch++) + { + WDL_real_fft((WDL_FFT_REAL *)m_fft_buf[ch], FFT_LENGTH, 0); - for (int i = 0; i < FFT_LENGTH; i++) { + for (int i = 0; i < FFT_LENGTH; i++) m_fft_buf[ch][i] /= (WDL_FFT_REAL)FFT_LENGTH; - } } } @@ -352,11 +348,7 @@ uint8_t firebeat_extend_spectrum_analyzer_device::read(offs_t offset) auto val = (ch < TOTAL_CHANNELS && notch >= 0 && notch < TOTAL_BARS) ? m_bars[ch][notch] : 0; - if (is_upper) { - return (val >> 8) & 0xff; - } - - return val & 0xff; + return (is_upper ? (val >> 8) : val) & 0xff; } DEFINE_DEVICE_TYPE(KONAMI_FIREBEAT_EXTEND_SPECTRUM_ANALYZER, firebeat_extend_spectrum_analyzer_device, "firebeat_spectrum_analyzer", "Firebeat Spectrum Analyzer") @@ -1004,7 +996,8 @@ void firebeat_state::extend_board_irq_w(offs_t offset, uint8_t data) m_extend_board_irq_active &= ~(data & 0xff); m_extend_board_irq_enable = data & 0xff; - if (BIT(m_extend_board_irq_enable, 2) != is_fdd_irq_enabled) { + if (BIT(m_extend_board_irq_enable, 2) != is_fdd_irq_enabled) + { // Clearing the FDD IRQ here helps fix some issues with the FDD getting stuck m_maincpu->set_input_line(INPUT_LINE_IRQ1, CLEAR_LINE); } @@ -1277,10 +1270,10 @@ void firebeat_spu_state::rf5c400_map(address_map& map) In another part of the program (0x363c for a21jca03.bin) is the following code for determining when to start and stop the DMA: start_dma(); - while (get_dma_timer() < dma_max_timer) { - if (irq6_called_flag) { + while (get_dma_timer() < dma_max_timer) + { + if (irq6_called_flag) break; - } } end_dma(); diff --git a/src/mame/drivers/r2dx_v33.cpp b/src/mame/drivers/r2dx_v33.cpp index c82673ab54c..69ab307b2c0 100644 --- a/src/mame/drivers/r2dx_v33.cpp +++ b/src/mame/drivers/r2dx_v33.cpp @@ -628,18 +628,18 @@ static INPUT_PORTS_START( nzerotea ) PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:!1,!2") + PORT_DIPSETTING( 0x0100, DEF_STR( Easy ) ) PORT_DIPSETTING( 0x0300, DEF_STR( Normal ) ) PORT_DIPSETTING( 0x0200, DEF_STR( Hard ) ) - PORT_DIPSETTING( 0x0100, DEF_STR( Easy ) ) PORT_DIPSETTING( 0x0000, DEF_STR( Very_Hard ) ) PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:!3,!4") + PORT_DIPSETTING( 0x0000, "1" ) PORT_DIPSETTING( 0x0c00, "2" ) - PORT_DIPSETTING( 0x0800, "4" ) PORT_DIPSETTING( 0x0400, "3" ) - PORT_DIPSETTING( 0x0000, "1" ) + PORT_DIPSETTING( 0x0800, "4" ) PORT_DIPNAME( 0x3000, 0x3000, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW2:!5,!6") - PORT_DIPSETTING( 0x3000, "2000000" ) PORT_DIPSETTING( 0x2000, "1000000" ) + PORT_DIPSETTING( 0x3000, "2000000" ) PORT_DIPSETTING( 0x1000, "3000000" ) PORT_DIPSETTING( 0x0000, "No Extend" ) PORT_DIPNAME( 0x4000, 0x4000, "Demo Sound" ) PORT_DIPLOCATION("SW2:!7") diff --git a/src/mame/video/avgdvg.cpp b/src/mame/video/avgdvg.cpp index 91193e027d4..188bf61c4de 100644 --- a/src/mame/video/avgdvg.cpp +++ b/src/mame/video/avgdvg.cpp @@ -130,18 +130,11 @@ void avgdvg_device_base::vg_flush() cy0 = m_vectbuf[i].y; cx1 = m_vectbuf[i].arg1; cy1 = m_vectbuf[i].arg2; + using std::swap; if (cx0 > cx1) - { - const int t = cx1; - cx1 = cx0; - cx0 = t; - } + swap(cx0, cx1); if (cy0 > cy1) - { - const int t = cy1; - cy1 = cy0; - cy0 = t; - } + swap(cy0, cy1); } } diff --git a/src/osd/modules/input/input_sdlcommon.cpp b/src/osd/modules/input/input_sdlcommon.cpp index 1f2606fd973..17186c24eb9 100644 --- a/src/osd/modules/input/input_sdlcommon.cpp +++ b/src/osd/modules/input/input_sdlcommon.cpp @@ -86,23 +86,9 @@ void sdl_event_manager::process_window_event(running_machine &machine, SDL_Event switch (sdlevent.window.event) { - case SDL_WINDOWEVENT_SHOWN: - m_has_focus = true; - break; - - case SDL_WINDOWEVENT_CLOSE: - machine.schedule_exit(); - break; - - case SDL_WINDOWEVENT_LEAVE: - machine.ui_input().push_mouse_leave_event(window->target()); - m_mouse_over_window = 0; - break; - case SDL_WINDOWEVENT_MOVED: window->notify_changed(); m_focus_window = window; - m_has_focus = true; break; case SDL_WINDOWEVENT_RESIZED: @@ -116,24 +102,28 @@ void sdl_event_manager::process_window_event(running_machine &machine, SDL_Event //printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event)); window->resize(sdlevent.window.data1, sdlevent.window.data2); } - m_focus_window = window; - m_has_focus = true; break; case SDL_WINDOWEVENT_ENTER: m_mouse_over_window = 1; - [[fallthrough]]; + break; + + case SDL_WINDOWEVENT_LEAVE: + machine.ui_input().push_mouse_leave_event(window->target()); + m_mouse_over_window = 0; + break; + case SDL_WINDOWEVENT_FOCUS_GAINED: - case SDL_WINDOWEVENT_EXPOSED: - case SDL_WINDOWEVENT_MAXIMIZED: - case SDL_WINDOWEVENT_RESTORED: m_focus_window = window; - m_has_focus = true; + machine.ui_input().push_window_focus_event(window->target()); break; - case SDL_WINDOWEVENT_MINIMIZED: case SDL_WINDOWEVENT_FOCUS_LOST: - m_has_focus = false; + machine.ui_input().push_window_defocus_event(window->target()); + break; + + case SDL_WINDOWEVENT_CLOSE: + machine.schedule_exit(); break; } } diff --git a/src/osd/modules/input/input_sdlcommon.h b/src/osd/modules/input/input_sdlcommon.h index ee13ce307dd..030a8ca4bd7 100644 --- a/src/osd/modules/input/input_sdlcommon.h +++ b/src/osd/modules/input/input_sdlcommon.h @@ -117,12 +117,10 @@ class sdl_event_manager : public event_manager_t { private: bool m_mouse_over_window; - bool m_has_focus; std::shared_ptr m_focus_window; sdl_event_manager() : m_mouse_over_window(true), - m_has_focus(true), m_focus_window(nullptr) { } diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp index 3216589de6e..d751472ebd7 100644 --- a/src/osd/sdl/window.cpp +++ b/src/osd/sdl/window.cpp @@ -193,7 +193,7 @@ void sdl_osd_interface::window_exit() window->destroy(); } - switch(video_config.mode) + switch (video_config.mode) { case VIDEO_MODE_SDL2ACCEL: renderer_sdl1::exit(); @@ -528,11 +528,7 @@ osd_dim sdl_window_info::pick_best_mode() void sdl_window_info::update() { - osd_ticks_t event_wait_ticks; - // adjust the cursor state - //sdlwindow_update_cursor_state(machine, window); - update_cursor_state(); // if we're visible and running and not in the middle of a resize, draw @@ -558,6 +554,7 @@ void sdl_window_info::update() } } + osd_ticks_t event_wait_ticks; if (video_config.waitvsync && video_config.syncrefresh) event_wait_ticks = osd_ticks_per_second(); // block at most a second else @@ -585,20 +582,20 @@ void sdl_window_info::update() m_primlist = &primlist; - // if no bitmap, just fill if (m_primlist == nullptr) { + // if no bitmap, just fill } - // otherwise, render with our drawing system else { - if( video_config.perftest ) + // otherwise, render with our drawing system + if (video_config.perftest) measure_fps(update); else renderer().draw(update); } - /* all done, ready for next */ + // all done, ready for next m_rendered_event.set(); } } @@ -768,8 +765,8 @@ int sdl_window_info::complete_create() return 1; // Make sure we have a consistent state - SDL_ShowCursor(0); - SDL_ShowCursor(1); + SDL_ShowCursor(SDL_DISABLE); + SDL_ShowCursor(SDL_ENABLE); return 0; } diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index 75090e0548f..cc9ff4484ba 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -921,9 +921,10 @@ void winwindow_ui_pause(running_machine &machine, int pause) assert(GetCurrentThreadId() == main_threadid); - // if we're pausing, increment the pause counter if (pause) { + // if we're pausing, increment the pause counter + // if we're the first to pause, we have to actually initiate it if (ui_temp_pause++ == 0) { @@ -935,10 +936,10 @@ void winwindow_ui_pause(running_machine &machine, int pause) SetEvent(ui_pause_event); } } - - // if we're resuming, decrement the pause counter else { + // if we're resuming, decrement the pause counter + // if we're the last to resume, unpause MAME if (--ui_temp_pause == 0) { @@ -1273,18 +1274,26 @@ 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 (window->has_renderer()) { - if ((wparam == WA_ACTIVE) || (wparam == WA_CLICKACTIVE)) - { - for (const auto &w : osd_common_t::s_window_list) - ShowWindow(std::static_pointer_cast(w)->platform_window(), SW_RESTORE); - } - else if ((wparam == WA_INACTIVE) && !is_mame_window(HWND(lparam))) + if (window->fullscreen()) { - for (const auto &w : osd_common_t::s_window_list) - ShowWindow(std::static_pointer_cast(w)->platform_window(), SW_MINIMIZE); + if ((wparam == WA_ACTIVE) || (wparam == WA_CLICKACTIVE)) + { + for (const auto &w : osd_common_t::s_window_list) + ShowWindow(std::static_pointer_cast(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(w)->platform_window(), SW_MINIMIZE); + } } + + if ((wparam == WA_ACTIVE) || (wparam == WA_CLICKACTIVE)) + window->machine().ui_input().push_window_focus_event(window->target()); + else if (wparam == WA_INACTIVE) + window->machine().ui_input().push_window_defocus_event(window->target()); } return DefWindowProc(wnd, message, wparam, lparam); -- cgit v1.2.3