Skip to content

Windows: App::titlebar draws the app's own titlebar with Rune caption buttons, snap layouts and the window menu - #134

Merged
Hona merged 1 commit into
devfrom
rune-chrome
Nov 6, 2026
Merged

Hona merged 1 commit into
devfrom
rune-chrome

Conversation

@Hona

@Hona Hona commented Nov 6, 2026

Copy link
Copy Markdown
Member

Windows apps can now draw their own titlebar the way OpenCode's Electron app does. Until now Rune kept the native title bar, so rune-desktop showed two of them.

  • API: App::titlebar(Titlebar::new(height)) and WindowSpec::titlebar. Cx::chrome_insets() returns leading, trailing and height. Cx::caption_color sets the symbol colour, and Tx::toggle_maximized maximizes or restores the window.
  • Windows: the native title bar goes. Resize edges, Aero Snap and the snap layouts flyout (HTMAXBUTTON) stay, as do double-click to maximize, Alt+Space, right-click for the window menu, and the window animations. Rune draws the caption buttons as elements that match Electron's titleBarOverlay: 46 pt wide, hover and press washes, and a red close button. They are UIA buttons named Minimize, Maximize or Restore, and Close.
  • macOS: the window gets full-size content with drag regions, and the traffic lights are centred in the band. Linux keeps its native frame and reports zero insets.
  • Fix: Alt+Space now opens the window menu. winit swallows WM_SYSCHAR, so this frame passes it on.
  • Example: crates/rune/examples/custom_titlebar.rs.

Before (native title bar plus the app's own strip):

After:

Maximized:

Caption states (rest, close pressed, light theme, maximize pressed):

Window menu (Alt+Space):

Live checks (Windows 11, 150% scale): I checked the non-client hit codes for the top, corners, sides, bottom and each caption button. I clicked minimize, maximize, restore and close, and pressed one button then released over another (no action). I double-clicked the band to maximize, invoked Maximize and Restore through UIA, and opened the window menu with Alt+Space and with a right-click on a drag region. Maximized, the client area equals the work area.

Not verified: the session was locked during testing, so I could not drive real-mouse drag, snap or the flyout. A macOS build is also unverified, because the C build scripts don't cross-compile here.

Checks: cargo check --workspace --all-targets and the wasm32 rune check pass with no new warnings.

… buttons, snap layouts and the window menu

Titlebar::new(height) is plain data for every platform. On Windows the native title bar goes (WM_NCCALCSIZE keeps the side and bottom resize borders; WM_NCHITTEST answers the top resize band and HTMINBUTTON/HTMAXBUTTON/HTCLOSE over the caption buttons, so Windows 11 shows its snap layouts flyout), and Rune draws the caption buttons as elements over the view, as Electron's titleBarOverlay paints them. macOS maps it to a full-size content view with drag regions and centred traffic lights. Cx::chrome_insets reports what the controls take, Cx::caption_color themes the symbols and Tx::toggle_maximized maximizes or restores. Alt+Space and a right-click on a drag region open the window menu.
Copilot AI balanced review requested due to automatic review settings November 6, 2026 20:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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