Repository navigation
Fix resize events never reaching the event handler - #211
xRookieFight wants to merge 2 commits into
Conversation
medvednikov
left a comment
There was a problem hiding this comment.
Reviewed the callback signatures, resize dimensions, and event dispatch at 7876b5c. The resize dimensions agree with GG's logical window units. Focused V probes comparing the old callback with the new wrapper confirmed two regressions in mouse handling that the wrapper now activates; both are noted inline. The probes use the actual handler bodies with minimal editor-state stubs, rather than a native window. CI was excluded from this review.
| bg_color: ved.cfg.bgcolor | ||
| frame_fn: frame | ||
| on_event: ved.on_event | ||
| event_fn: ved_event |
There was a problem hiding this comment.
[P2] Use logical mouse coordinates in the newly enabled handler
With disable_mouse: false, this callback now reaches the mouse hit testing, but GG has already divided e.mouse_x and e.mouse_y by its display scale before invoking event_fn. The handler still doubles split boundaries and divides cursor coordinates by two. For example, with two 600-pixel splits and 20-pixel lines, a logical click at (700, 210) remains in the first split and selects row index 4 instead of row index 9 in the second split. A focused callback probe confirms that the old registration never reached this mouse path, while the new wrapper does. Please update the hit testing to use GG's logical coordinates when enabling this callback.
| // Using on_event with the wrong signature made `e` point at the Ved struct. | ||
| fn ved_event(e &gg.Event, data voidptr) { | ||
| mut ved := unsafe { &Ved(data) } | ||
| ved.on_event(e) |
There was a problem hiding this comment.
[P2] Keep mouse focus within the current workspace
With disable_mouse: false, switch to any workspace after the first and click its editor. The newly enabled mouse handler assigns ved.cur_split = i, where i is local to the visible workspace, but update_view() uses it to index the global views array. With two splits in workspace index 1, a click changes cur_split from 2 to 0: subsequent keystrokes edit a file in workspace 0 while workspace 1 remains displayed. The callback probe reproduces this transition only with the new wrapper. Please include the current workspace's split offset and apply cursor updates to the newly focused view, rather than the view pointer captured before update_view().
on_eventwas passed as theon_eventcallback, which gg calls with(data, e). The handler took onlye, so resize events never matched. Switched toevent_fnthrough a small wrapper, and the window size is now synced intowin_widthandwin_heighton resize. Tested on X11 by resizing the window, the event now arrives.