summaryrefslogtreecommitdiffhomepage
path: root/editor/events.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-01 13:21:50 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-01 13:39:24 +0100
commitf885f420acba648d8b9b98ee92fd3a994d93c43d (patch)
treedc7ceecabf8b694fffad13f79a62dfac979f2506 /editor/events.cpp
parentd478c37fc03c7590823f003a3b326e79ae8012f9 (diff)
editor: check window bounds for mouse events
This is to avoid potentially tripping up asserts after `_virtual_scale` is applied.
Diffstat (limited to 'editor/events.cpp')
-rw-r--r--editor/events.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/editor/events.cpp b/editor/events.cpp
index f8c90ed7..08a3e766 100644
--- a/editor/events.cpp
+++ b/editor/events.cpp
@@ -53,6 +53,9 @@ void app::clear_keys()
void app::on_mouse_move(const mouse_move_event& event) noexcept
{
+ if (!(event.position >= Vector2i() && event.position < M->window_size()))
+ return;
+
struct {
accessor(Vector2i, position)
} e = {event.position};
@@ -64,6 +67,9 @@ void app::on_mouse_move(const mouse_move_event& event) noexcept
void app::on_mouse_up_down(const mouse_button_event& event, bool is_down) noexcept
{
+ if (!(event.position >= Vector2i() && event.position < M->window_size()))
+ return;
+
enum class Button_ : std::underlying_type_t<mouse_button> {
Left = mouse_button_left,
Right = mouse_button_right,
@@ -84,6 +90,9 @@ void app::on_mouse_up_down(const mouse_button_event& event, bool is_down) noexce
void app::on_mouse_scroll(const mouse_scroll_event& event) noexcept
{
+ if (!(event.position >= Vector2i() && event.position < M->window_size()))
+ return;
+
struct {
accessor(Vector2, offset)
accessor(Vector2i, position)