Skip to content

Commit

Permalink
Avoid producing NaN/Inf values in event locations
Browse files Browse the repository at this point in the history
  • Loading branch information
serenity4 committed Nov 13, 2024
1 parent 52e89fa commit 0fe6aee
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0fe6aee

Please sign in to comment.