Skip to content

Fix resize events never reaching the event handler - #211

Open
xRookieFight wants to merge 2 commits into
vlang:masterfrom
xRookieFight:fix/resize-events
Open

xRookieFight wants to merge 2 commits into
vlang:masterfrom
xRookieFight:fix/resize-events

Conversation

@xRookieFight

Copy link
Copy Markdown

on_event was passed as the on_event callback, which gg calls with (data, e). The handler took only e, so resize events never matched. Switched to event_fn through a small wrapper, and the window size is now synced into win_width and win_height on resize. Tested on X11 by resizing the window, the event now arrives.

@medvednikov medvednikov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ved.v
bg_color: ved.cfg.bgcolor
frame_fn: frame
on_event: ved.on_event
event_fn: ved_event

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Comment thread events.v
// 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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants