diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-19 20:15:48 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-19 20:15:48 +0100 |
commit | 19daf844f7493ca05ce7b427664f7345a85752b1 (patch) | |
tree | e6825ac2bdfd4b3b8e686302e04327804e604566 /main | |
parent | bee391a85b2e64a0c5dc31e499cfe2869a3a11b1 (diff) |
main: don't set cursor when not needed
Diffstat (limited to 'main')
-rw-r--r-- | main/events.cpp | 5 | ||||
-rw-r--r-- | main/main-impl.cpp | 6 | ||||
-rw-r--r-- | main/main-impl.hpp | 1 |
3 files changed, 9 insertions, 3 deletions
diff --git a/main/events.cpp b/main/events.cpp index 6888132a..1f1c81a2 100644 --- a/main/events.cpp +++ b/main/events.cpp @@ -91,15 +91,16 @@ void main_impl::anyEvent(SDL_Event& event) case SDL_WINDOWEVENT_FOCUS_LOST: return app.on_focus_out(); case SDL_WINDOWEVENT_FOCUS_GAINED: + _mouse_cursor = (uint32_t)-1; return app.on_focus_in(); case SDL_WINDOWEVENT_LEAVE: return app.on_mouse_leave(); case SDL_WINDOWEVENT_ENTER: + _mouse_cursor = (uint32_t)-1; return app.on_mouse_enter(); - default: { + default: return app.on_any_event(make_any_event(event)); } - } } else return app.on_any_event(make_any_event(event)); diff --git a/main/main-impl.cpp b/main/main-impl.cpp index 8cde3e2f..f6a3dff0 100644 --- a/main/main-impl.cpp +++ b/main/main-impl.cpp @@ -48,7 +48,11 @@ Vector2i floormat_main::window_size() const noexcept void main_impl::set_cursor(uint32_t cursor) noexcept { - setCursor(Cursor(cursor)); + if (cursor != _mouse_cursor || _mouse_cursor == (uint32_t)-1) + { + _mouse_cursor = cursor; + setCursor(Cursor(cursor)); + } } uint32_t main_impl::cursor() const noexcept diff --git a/main/main-impl.hpp b/main/main-impl.hpp index e968951e..dae4286e 100644 --- a/main/main-impl.hpp +++ b/main/main-impl.hpp @@ -82,6 +82,7 @@ private: std::vector<clickable> _clickable_scenery; struct world _world{}; Magnum::Timeline timeline; + uint32_t _mouse_cursor = (uint32_t)-1; floor_mesh _floor_mesh; wall_mesh _wall_mesh; anim_mesh _anim_mesh; |