Skip to content

Windows: the custom titlebar's caption buttons, window menu and frame behave as native ones do - #172

Merged
Hona merged 1 commit into
devfrom
chrome-fix
Nov 7, 2026
Merged

Hona merged 1 commit into
devfrom
chrome-fix

Conversation

@Hona

@Hona Hona commented Nov 7, 2026

Copy link
Copy Markdown
Member

Follow-up to #134: the custom titlebar's caption buttons, window menu and frame now behave as native ones do on Windows.

  • Alt+Space: opens the window menu (a posted SC_KEYMENU, so its modal loop runs from the message loop) only when no handler takes the key, never types a space into a focused field, and ignores Ctrl+Alt+Space.
  • Caption presses: one CaptionState (Idle | Hovered | Pressed { button, over }) with mouse capture. Dragging off cancels, dragging back resumes, no other button lights up meanwhile, and no release (top edge, outside the window, lost capture) leaves a button stuck.
  • Modals and accessibility: the buttons sit in a frame of Rune's own (rune-frame) that no root border, clip or transform moves, and they stay in the UI Automation tree and invokable while the view holds a modal.
  • Non-resizable windows: no maximize button on any platform. On Windows the button is dimmed and disabled, with no HTMAXBUTTON and no snap layouts. A window with neither box shows only Close.
  • Frame: WM_DPICHANGED resizes once (winit's own move lands on Windows' rect). Maximizing uses the destination monitor (MonitorFromRect) and checks the auto-hide bar with IsWindow. Edge drags draw each size at once. Windows 10 keeps a 1 px top border. WM_ERASEBKGND returns 1.
  • Zoom: new Cx::titlebar_height(h) sizes the band and the caption buttons as the app runs, so they line up with the app's row at every UI zoom.
  • Memos and playground: memos rebuild when Cx::chrome_insets changes. Staged playground stories no longer get the window's insets or caption colour, and the side column clears the buttons.
  • Hot reload: keeps App::titlebar and Cx::caption_color.
  • API: TitlebarAction is back to Drag and DoubleClick; the window menu is a crate-private latch.
  • Cleanups: the macOS dead-code warning is gone, sync_chrome no longer returns a value, and Host::try_create moved to window/create.rs.

Checks: cargo check --workspace --all-targets, cargo check -p rune --lib --target wasm32-unknown-unknown, and --target aarch64-apple-darwin / x86_64-unknown-linux-gnu (lib) all pass, as do the targeted existing tests (titlebar pointer_hit modal window_wake chrome caption alt, 43 passed). Live proof used cargo run -p rune --example custom_titlebar, driven with posted messages and UI Automation.

Before (#134):

After, press Close, drag onto Maximize, back onto Close, release off it, release on the top edge:

After, Alt+Space in the focused field ("ab", no space typed):

After, modal open (the caption buttons stay in UIA, and invoking Maximize works):

After, Cx::titlebar_height at zoom 1.0, 1.25 and 0.8:

After, no WS_MAXIMIZEBOX:

… behave as native ones do

Alt+Space opens the window menu (posted SC_KEYMENU) when no handler takes it and never types a space. Caption presses are one CaptionState (Idle, Hovered, Pressed { button, over }) with mouse capture, so dragging off cancels, dragging back resumes and no release leaves a button stuck. The buttons sit in a frame of Rune's own and stay in reach of UI Automation while the view holds a modal. Non-resizable windows dim maximize with no snap layouts; WM_DPICHANGED resizes once; maximizing fits the destination display; edge drags draw each size at once; Windows 10 keeps its top border. Cx::titlebar_height sizes the band and the caption buttons with the app's zoom, memos rebuild when Cx::chrome_insets changes, the playground and hot reload keep the window's chrome, and TitlebarAction is back to Drag and DoubleClick.
Copilot AI balanced review requested due to automatic review settings November 7, 2026 01:20

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