Skip to content

Unify GTK (absolute) vs TUI (content-relative) window-rect coordinate conventions #550

Description

@JDonaghy

Summary

Follow-up from #547. GTK and TUI use two different coordinate conventions for the window_rects fed into Engine::calculate_group_window_rects / render::build_screen_layout, and every shared render helper that touches those rects (e.g. the new render::breadcrumb_draw_targets() from #547) has to carry an origin_offset parameter purely to paper over the difference. Unifying the convention would let that parameter — and the offset math at every call site — disappear.

The asymmetry

  • GTK (src/gtk/mod.rs::render_content): editor_bounds = WindowRect::new(x, y, w, editor_area_h) where (x, y) comes from layout.main_content_bounds (i.e. absolute screen/pixel coordinates). Window rects, and everything derived from them (e.g. BreadcrumbBar::bounds), are already in final screen space.
  • TUI (src/tui_main/render_impl.rs::build_screen_for_tui): content_bounds = WindowRect::new(0.0, 0.0, content_cols, content_rows) — always origin (0, 0), i.e. content-area-relative. Every draw call site (tab bars, breadcrumbs, dividers, windows) has to manually add editor_area.x / editor_area.y to translate back into terminal screen space.

This is presumably historical (TUI's content_bounds predates the shared render::build_screen_layout path), not a deliberate design choice — nothing in either backend's rendering model requires window rects to be in one convention over the other.

Proposed direction

Make TUI's window_rects (and therefore every WindowRect/bounds field derived from them — BreadcrumbBar::bounds, tab bar bounds, divider positions, etc.) absolute in terminal-screen space from the start, matching GTK. Candidates:

Why this wasn't done in #547

This touches window-rect computation and every click/hit-test path in both backends — a much bigger, more architecturally invasive change than a bugfix PR should carry. It's exactly the kind of cross-cutting normalization the Platform-Neutral milestone (#7) exists for, but needs its own dedicated pass with full regression coverage on both backends' mouse/click paths, not a drive-by.

Acceptance criteria

  • TUI's window rects (and everything derived from them) are absolute screen-space coordinates, matching GTK's convention.
  • origin_offset-style parameters (e.g. on render::breadcrumb_draw_targets()) can be dropped/hardcoded to (0.0, 0.0) for both backends.
  • All existing TUI click/hit-test tests (tui_main::mouse and friends) continue to pass, plus new coverage for the specific offset removal if any test previously encoded the old relative convention.

Parent context: Platform-Neutral milestone (#7), surfaced while working #547.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    coordTracked by coord-tui pipelineenhancementNew feature or requeststatus:readyRefined and ready to enter the work pipelineuiUI/rendering

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions