navigation: window buttons, window drag and wheel tab switching on Linux and Windows - #1917
Open
daniarjabagin wants to merge 1 commit into
Open
daniarjabagin wants to merge 1 commit into
daniarjabagin wants to merge 1 commit into
Conversation
…nux and Windows Under window.decorations = "Disabled" the rio-rendered tab strip is the only chrome a Linux or Windows window has, but outside macOS it offered none of a title bar's controls: no window buttons, and no way to move the window by its strip. Three opt-in [navigation] keys close that gap. window-buttons draws minimize / maximize / close at the right end of the strip, with a hover backdrop (red for close, as every desktop that draws its own buttons does). Tab slots and the lone-tab title shrink to make room, so a floating (dragged) tab never covers the buttons. Close follows the CloseRequested contract, so confirm-before-quit still applies. drag-window lets a left press on empty strip area start a window move through drag_window(), the path macOS already used; the cfg gate around it is replaced by the option. Double-click keeps toggling maximize. scroll-tabs switches tabs on wheel travel over the strip. Touchpad pixel deltas accumulate, one tab per 40 logical px. All three default to false. macOS ignores window-buttons (the traffic lights already occupy the strip) and keeps allowing the drag, as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1916
What
Under
window.decorations = "Disabled"the rio-rendered tab strip is the only chrome a Linux or Windows window has, but outside macOS it offered none of a title bar's controls. This adds three opt-in[navigation]keys:All three default to
false. macOS ignoreswindow-buttons(the traffic lights already occupy the strip) and keeps allowing the drag, exactly as before.How
window-buttons(renderer/island.rs)WindowButtonenum and geometry helpers (window_buttons_width,window_button_hit). Buttons are 36 logical px each, anchored to the right edge — the same anchoring the tab close × uses.tab_strip_layoutgains areserved_rightargument; slots and the lone-tab title budget / centring subtract it, so tabs shrink and a floating (dragged) tab never covers the buttons.sugarloaf.line/rounded_rectlike the existing close ×. Hover backdrop comes fromisland_fillsso it adapts to light and dark backgrounds; close hovers red with a white glyph.screen/mod.rs::handle_island_click): the button hit test runs before the tab-slot logic, because the buttons live past the last slot where a press would otherwise start a window drag. The pressed button is stored aspending_window_buttonand consumed inapplication.rs, which owns the router / event loop a close needs. Close follows theCloseRequestedcontract:confirm_quit()whenconfirm-before-quitis set, otherwise remove the route and exit once none remain.update_close_button_hover(both are evaluated so neither update is skipped).drag-window(screen/mod.rs)start_window_dragloses its macOS cfg;on_chrome_presscalls it whennavigation.allows_window_drag()— always on macOS, opt-in elsewhere.drag_window()is winit'sxdg_toplevel.move/_NET_WM_MOVERESIZE/WM_NCLBUTTONDOWN, so no platform code is added.scroll-tabs(application.rs,screen/mod.rs)MouseWheelover the visible strip goes toScreen::scroll_tabs_over_stripbefore terminal scrolling. Line deltas switch per notch; pixel deltas (touchpads) accumulate, one tab perWHEEL_PX_PER_TAB(40 logical px). Switching reuses the sameswitch_to_next/prev+switch_context_visibilitysequence as the palette actions.Config (
rio-backend/src/config/navigation.rs)boolfields with serde defaults;draws_window_buttons()/allows_window_drag()encode the platform rules in one place.Tests
tab_strip_layout_reserves_window_buttons— slots shrink by the reserved width, tab region ends before the buttons, negative reservation is ignored.window_button_hit_maps_thirds_left_to_right— hit test per button, right margin and disabled state.single_title_stays_clear_of_window_buttons— lone-tab title never runs under the buttons; budget shrinks by the reservation.Locally:
cargo fmt -- --check,cargo clippy --all-targets --all-features(no warnings in touched files),cargo test --features wgpu(all green).Tested on
msys2-build-test,windows-latest);drag_window()/set_minimized/set_maximizedare winit's existing Windows paths. Not hand-tested — happy to adjust if someone can try it.window-buttonsis a no-op, drag stays always-on); verified by reading the cfg paths, no hardware to test.Docs
Companion PR to rioterm.com: raphamorim/rioterm.com#3
controls.mp4