diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index 43d4cbf6a6c..75c7c94e79f 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -443,7 +443,7 @@ public: bool should_poll_devices(running_machine& machine) override { - return sdl_event_manager::instance().app_has_mouse_focus() && input_enabled(); + return sdl_event_manager::instance().has_focus() && input_enabled(); } virtual void handle_event(SDL_Event &sdlevent) override diff --git a/src/osd/modules/input/input_sdlcommon.cpp b/src/osd/modules/input/input_sdlcommon.cpp index e22606f9fb3..44d7b599313 100644 --- a/src/osd/modules/input/input_sdlcommon.cpp +++ b/src/osd/modules/input/input_sdlcommon.cpp @@ -85,12 +85,13 @@ void sdl_event_manager::process_window_event(running_machine &machine, SDL_Event case SDL_WINDOWEVENT_LEAVE: machine.ui_input().push_mouse_leave_event(window->target()); - m_app_has_mouse_focus = 0; + 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: @@ -105,16 +106,22 @@ void sdl_event_manager::process_window_event(running_machine &machine, SDL_Event window->resize(sdlevent.window.data1, sdlevent.window.data2); } m_focus_window = window; + m_has_focus = true; break; case SDL_WINDOWEVENT_ENTER: - m_app_has_mouse_focus = 1; + m_mouse_over_window = 1; /* fall through */ 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; + break; + + case SDL_WINDOWEVENT_FOCUS_LOST: + m_has_focus = false; break; } } @@ -268,7 +275,7 @@ bool sdl_osd_interface::should_hide_mouse() if (!options().mouse() && !options().lightgun()) return false; - if (!sdl_event_manager::instance().app_has_mouse_focus()) + if (!sdl_event_manager::instance().mouse_over_window()) return false; // otherwise, yes diff --git a/src/osd/modules/input/input_sdlcommon.h b/src/osd/modules/input/input_sdlcommon.h index a4bde246967..833efb271a6 100644 --- a/src/osd/modules/input/input_sdlcommon.h +++ b/src/osd/modules/input/input_sdlcommon.h @@ -76,6 +76,10 @@ protected: } public: + virtual ~event_manager_t() + { + } + void subscribe(int* event_types, int num_event_types, TSubscriber *subscriber) { std::lock_guard scope_lock(m_lock); @@ -109,17 +113,20 @@ class sdl_window_info; class sdl_event_manager : public event_manager_t { private: - bool m_app_has_mouse_focus; + bool m_mouse_over_window; + bool m_has_focus; sdl_window_info * m_focus_window; sdl_event_manager() - : m_app_has_mouse_focus(true), + : m_mouse_over_window(true), + m_has_focus(true), m_focus_window(nullptr) { } public: - bool app_has_mouse_focus() { return m_app_has_mouse_focus; } + bool mouse_over_window() const { return m_mouse_over_window; } + bool has_focus() const { return m_focus_window; } sdl_window_info * focus_window() { return m_focus_window; } static sdl_event_manager& instance() diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index e61008275ec..c4749be03c5 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -149,19 +149,11 @@ public: virtual bool video_init() override; virtual bool window_init() override; -#ifdef USE_OLD_SDL_INPUT - virtual bool input_init() override; - virtual void input_pause() override; - virtual void input_resume() override; -#endif virtual bool output_init() override; //virtual bool midi_init(); virtual void video_exit() override; virtual void window_exit() override; -#ifdef USE_OLD_SDL_INPUT - virtual void input_exit() override; -#endif virtual void output_exit() override; //virtual void midi_exit(); diff --git a/src/osd/sdl/video.cpp b/src/osd/sdl/video.cpp index 3df00d90078..b089988c84a 100644 --- a/src/osd/sdl/video.cpp +++ b/src/osd/sdl/video.cpp @@ -286,12 +286,7 @@ finishit: static void check_osd_inputs(running_machine &machine) { -#ifdef USE_OLD_SDL_INPUT - sdl_window_info *window = sdlinput_get_focus_window(); -#else - // BUG: TODO: Fix focus window support sdl_window_info *window = sdl_window_list; -#endif // check for toggling fullscreen mode if (machine.ui_input().pressed(IPT_OSD_1)) diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp index 1ca6e9605a6..b58167f128c 100644 --- a/src/osd/sdl/window.cpp +++ b/src/osd/sdl/window.cpp @@ -649,13 +649,8 @@ void sdl_window_info::update_cursor_state() // the possibility of losing control if (!(machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)) { - //FIXME: SDL1.3: really broken: the whole SDL code - // will only work correct with relative mouse movements ... -#ifdef USE_OLD_SDL_INPUT - bool should_hide_mouse = sdlinput_should_hide_mouse(); -#else bool should_hide_mouse = downcast(machine().osd()).should_hide_mouse(); -#endif + if (!fullscreen() && !should_hide_mouse) { SDL_ShowCursor(SDL_ENABLE); @@ -780,12 +775,7 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_video_window_destroy_wt ) } SDL_DestroyWindow(window->sdl_window()); // release all keys ... -#ifdef USE_OLD_SDL_INPUT - sdlinput_release_keys(); -#else downcast(window->machine().osd()).release_keys(); -#endif - osd_free(wp); return nullptr; @@ -1203,11 +1193,7 @@ OSDWORK_CALLBACK( sdl_window_info::draw_video_contents_wt ) ASSERT_REDRAW_THREAD(); // Some configurations require events to be polled in the worker thread -#ifdef USE_OLD_SDL_INPUT - sdlinput_process_events_buf(); -#else downcast< sdl_osd_interface& >(window->machine().osd()).process_events_buf(); -#endif // Check whether window has vector screens