From 0fe6aee5b09e9546a04706d60c2b573cd32214da Mon Sep 17 00:00:00 2001 From: serenity4 Date: Wed, 13 Nov 2024 11:43:36 +0100 Subject: [PATCH] Avoid producing NaN/Inf values in event locations --- src/events.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/events.jl b/src/events.jl index 285c935..7873c0e 100644 --- a/src/events.jl +++ b/src/events.jl @@ -58,7 +58,12 @@ location(event::xcb_configure_notify_event_t) = (event.x, event.y) location(::xcb_client_message_event_t) = (0, 0) location(event, win) = coordinates(location(event), win) -coordinates(xs, win) = Float64.(xs ./ extent(win)) +function coordinates((x, y), win) + width, height = extent(win) + x = ifelse(iszero(width), 0.0, x/width) + y = ifelse(iszero(height), 0.0, y/height) + (x, y) +end function Event(wm::XWindowManager, win::XCBWindow, event::xcb_button_press_event_t, t) data = MouseEvent(event)