Skip to content

feat(titlebar): App::titlebar is the window's only bar where a Wayland compositor draws no frame - #2244

Merged
Hona merged 12 commits into
devfrom
linux-client-frame
Nov 25, 2026
Merged

Hona merged 12 commits into
devfrom
linux-client-frame

Conversation

@Hona

@Hona Hona commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

On GNOME under Wayland, a window with App::titlebar had two bars: winit's grey Adwaita bar, and the app's own under it. Now it has one. Tracks #591 (and its duplicate #993).

It has run under four headless compositors, GNOME's own (mutter) among them, and not yet on a real GNOME desktop. Linux-only code here compiles in no workflow of this repository; it is built by a downstream app's CI (anomalyco/opencode-rune#1184). RUNE_LINUX_FRAME=0 is the way back for a user: it keeps the frame a window had before.

What an app gets

flowchart LR
  A[window with App::titlebar] --> B{Wayland?}
  B -- no: X11 --> N[native frame, insets 0]
  B -- yes --> C{compositor offers<br/>zxdg_decoration_manager_v1?}
  C -- yes: KDE, Sway, Hyprland --> N
  C -- no: GNOME, Weston --> R[opens without decorations:<br/>Rune's caption buttons + resize band,<br/>chrome_insets has height and button room]
Loading
  • Caption buttons. The ones the desktop's button-layout names, less those the window can't act on (Cx::window_actions: no maximize on a fixed-size window, no minimize where the compositor has none), as GTK's window controls leave them out. The layout comes from org.gnome.desktop.wm.preferences, through the settings portal Rune already follows, so a change shows while the app runs. GNOME's default appmenu:close is close alone; a layout on the left puts them on the left; all three at the right where no portal answers. Round 24 pt buttons in the band, washed with Cx::caption_color, sized in window points at every Cx::zoom. Hidden in full screen.
  • Cx::chrome_insets() reports the buttons' room (leading or trailing) and the band's height, as on Windows.
  • Resize. A 5 pt band inside the window's edges, 16 pt along each side of a corner for the diagonals. The parts are ordinary .window_resize(edge) elements in Rune's frame around the view, so the cursor, the press and xdg_toplevel.resize are the existing path. None while maximized, full screen or not resizable, and none along a side the compositor tiled (Cx::tiled_edges): the band beside it then runs to that end.
  • Move, maximize, window menu. Nothing new: .window_drag() regions already do xdg_toplevel.move, toggle maximize on a double click and call show_window_menu on a right click (fix(titlebar): defer Linux mouse window drags past 8 pt so Wayland and X11 titlebar double-clicks work #2252, fix(linux): open the window manager's window menu on right-click of bare window_drag regions #2271).
  • A modal in the view leaves the buttons and the resize band in reach, as it leaves the Windows buttons.
  • Switch. RUNE_LINUX_FRAME=0 keeps winit's frame; =1 draws Rune's under any Wayland compositor (for testing under Sway or KDE).
// Nothing to call: an app that already keeps clear of the insets is done.
let insets = cx.chrome_insets();          // height 44, trailing 41 on default GNOME (close alone)
row().h(insets.height).pr(insets.trailing).window_drag()

What has run

  • Compiled and linked on Linux x64 by a downstream app's CI build (chore(deps): NEVER MERGE: Linux proof build of Rune's own window frame (rune#2244 + #1183) opencode-rune#1184) that pins dc5a0f5fc: this branch two merges of dev before its head, with the same lines of this change. The library's Linux-only lines, with the app. Not built on Linux arm64.
  • Tests: on macOS only, run 45673238324 on this branch's head (with dev dac67eb35 merged in): 47 test targets ok, none failed; the rune lib 3,693 passed, 0 failed, 17 ignored. The 11 new tests are plain data and the headless runtime (no Linux-only line): the layout's buttons and their places, the band's edge and cursor at every side and corner, a tiled side, a press on a button, a modal in the view. They have not been compiled or run on Linux or Windows.
  • Run under four headless compositors, on that Linux x64 build. Not a real desktop:
    • weston (no decoration manager, the GNOME-like case; no pointer there): the toolkit frame's five subsurfaces are made and none gets a buffer, and the window geometry is the content's own size. The same app built without this change gives all five a buffer and starts the geometry 35 points above the content.

    • sway and labwc, with RUNE_LINUX_FRAME=1 and a virtual pointer: one bar in the picture, three round buttons at its end, and each press reached the app and asked the compositor:

      Press Request seen
      Maximize set_maximized; the window fills the output and the button shows the restore symbol
      Maximize again unset_maximized; the first rectangle comes back
      Double click on the bar set_maximized, or unset_maximized when maximized; no move
      Held press and motion on the bar move; under labwc it snapped the window to the left half
      An edge or a corner resize with that edge, and the resize cursor
      8 points inside an edge nothing: the press goes to the app (under sway only)
      An edge while maximized no resize cursor, no request (under labwc only)
      The tiled edge of a snapped window no resize cursor, no request; the free edge still resizes
      Right click on the bar show_window_menu
      Minimize set_minimized
      Close the app ends, exit code 0
      F11 set_fullscreen: the row stays, the buttons go; and back

      A window the compositor maximized by itself shows the restore symbol too: the row follows the compositor's state, not its own click.

    • mutter (GNOME Shell 46, headless, software rendering, no session manager), with nothing forced: mutter offers no decoration manager, so the window takes this frame by itself. One row under GNOME's top bar, three round buttons at its end (no settings portal answered there, so the fallback layout), no second bar. The presses above held with their effects: the window moved along the pointer's path, grew 30 points from its right edge, maximized under the top bar and came back, mutter's own window menu opened on a right click, the window minimized, and Close ended the app with exit code 0.

Known, not a fault a hand can reach

  • A press that follows a pointer motion inside the window by about 4 ms does not find the resize band (a caption button pressed the same way acts). Seen under mutter with a scripted pointer that jumped 800 points and pressed 4 ms later; cause not read. With 157 ms between arriving and pressing, the free edge of a window mutter tiled to the left half resized nine times of nine, and mutter names top, bottom and left for that half (states [4, 7, 8, 5]): the free side is free.

What is not shown

  • The states' names. The log these runs read prints a configure's states as a count, so "maximized" and "tiled" are read from the array's size, the window's size and the picture.
  • Only the left tiled edge was pressed, not the top or the bottom of a tiled window.
  • No wm_capabilities path. A button the compositor says the window cannot act on is not drawn (Cx::window_actions): neither sway nor labwc sends wm_capabilities, so that is by tests and type-check only.
  • The effect of resize. The request was seen; a window growing under the pointer was not.
  • Under mutter: "no resize from an edge while maximized" and "no resize from inside the edge" (the scripted presses there came too soon after the pointer's jump to prove anything: those two lines stand under labwc and sway only); the resize cursors (mutter has no cursor-shape protocol, and the cursor surfaces were not read); the top tiled edge.
  • A touch on the resize band under any compositor.
  • Real GNOME: mutter under a real session, and the portal's button-layout (close alone on GNOME's default, appmenu:close; no portal answered in the lab, so that is by reading and a test).
  • Linux arm64: not built.

Not in this change

  • No shadow and square corners on that window: with decorations off, winit's frame draws nothing at all. A follow-up can keep the vendored Adwaita frame's shadow, border and rounded corners without its header bar, which also moves the resize handles outside the window.
  • The symbols are the Windows ones inside round buttons, not libadwaita's icons.
  • winit still makes its (hidden) frame at the first configure, so the two dbus-send reads it starts stay.

Where it is

File What
window/titlebar/linux.rs the compositor check, ButtonLayout::parse, the desktop's layout
window/titlebar/caption.rs round_buttons, edges; the Windows buttons share key, label and action
window/titlebar.rs Caption::own_frame, Caption::layout, Caption::edges
window/chrome.rs, window/host/{create,events}.rs decorations off; caption and insets synced, with the compositor's allowed actions and tiled edges (#2249, #2283, #2293)
platform/portal_appearance.rs reads and follows button-layout (Wayland sessions only)
runtime/input/focus.rs the resize band stays reachable under a modal

macOS and Windows: the caption gains two fields with the old meaning (layout: None, edges: false); nothing else changes.

Credit

The compositor check and the button-layout parsing follow @jamesponwith's patch in #993; @been-there-done-that's patch in #591 and @zce's cut-down in anomalyco/opencode-rune#1146 showed the rest of the shape. This differs from them in drawing the resize band and the buttons as elements of the existing frame (no host event or cursor override), following layout changes live, and leaving X11 alone.

…d compositor draws no frame (#591)

A Wayland compositor without xdg-decoration (GNOME) draws no window frame, so
winit drew its own grey bar above the app's titlebar. A window with
App::titlebar now opens without decorations there, and Rune draws its own frame:

- the caption buttons the desktop's button-layout names (the settings portal's
  org.gnome.desktop.wm.preferences, followed while the app runs), as round
  buttons over the band, at the side the layout names; all three at the right
  where no portal says;
- Cx::chrome_insets reports their room and the band's height;
- a 6 point band inside the window's edges resizes it (16 points along each
  side of a corner), as window_resize elements in Rune's frame around the
  view, so they show the resize cursors and stay in reach under a modal;
- window_drag regions move the window, maximize it on a double click and open
  the compositor's window menu on a right click, as they already could.

X11 and compositors that offer xdg-decoration (KDE, Sway, Hyprland) keep the
native frame. RUNE_LINUX_FRAME=0 keeps winit's frame and =1 draws Rune's under
any Wayland compositor.

The compositor check and the button-layout parsing follow James Ponwith's
patch for #993; zce's cut-down of it showed the Windows row layout an app can
take from the insets.

Co-authored-by: James Ponwith <[email protected]>
Co-authored-by: Lei <[email protected]>
Six took more of what the view draws at the window's edge (a scroll bar's thumb) than the two patches this follows, which were tried on GNOME at five.
@zce

zce commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

On a real GNOME/Mutter session, double-clicking an empty titlebar band does not toggle maximize/restore.

Tested with Rune 36669bcb + anomalyco/opencode-rune#1183, packaged as opencode-rune 0.0.5. Fedora 45 Workstation, GNOME Shell/Mutter 51.1, Wayland, 3840×2160 at 1.5 (logical 2560×1440). A double-click on the empty drag band above the tabs leaves the window where it is; it never reaches the maximize/restore path.

Event::Region in crates/rune/src/runtime/input/titlebar.rs returns TitlebarAction::Drag on the first press, and crates/rune/src/window/surface/win.rs then calls window.drag_window(). On Mutter, xdg_toplevel.move starts the interactive move immediately; its pointer grab swallows the second press, so the pair never sees a second Region and DoubleClick is never requested. The state machine is right, but the first press hands the pointer away too early.

My earlier downstream patch fixed this by deferring the drag until pointer motion, as GTK's GtkWindowHandle does: arm on press, wait in a WaitingForDrag state, request Drag only after the pointer moves past the drag slop, and return to the armed state when it is released without motion. Then the second press arrives and asks for DoubleClick. The patch is at zce/opencode-rune@4576a5aa ("fix(fedora): keep titlebar double-clicks in the app") and it is not in 36669bcb.

Could that wait-for-motion behavior go into #2244? A normal press-and-drag would still start the move, and double-click would work on Mutter.

Hona added 3 commits November 25, 2026 23:07
# Conflicts:
#	crates/rune/src/runtime/input/titlebar_tests.rs
#	crates/rune/src/window/host/events.rs
…uttons and tiled sides

With Cx::window_actions and Cx::tiled_edges on dev, the frame no longer guesses: a button the window can't act on (maximize on a fixed-size window, minimize where the compositor has none) isn't drawn, as GTK's window controls leave it out, and a side the compositor tiled has no resize band; the band beside it runs to that end.
@Hona
Hona marked this pull request as ready for review November 25, 2026 18:23
@Hona
Hona merged commit e16732a into dev Nov 25, 2026
5 of 6 checks passed
@Hona
Hona deleted the linux-client-frame branch November 25, 2026 18:26
Hona added a commit that referenced this pull request Nov 25, 2026
dev holds the Linux own frame (#2244) as one commit now: the six files both sides changed take dev's text with this branch's own changes applied over it; the result against dev is this branch's 32 files and nothing else. Docs: the README, the titlebar docs and the first changelog entry say what the window has now.
Hona added a commit that referenced this pull request Nov 25, 2026
…une and procwatch (#2370)

A feature-set warning sweep across Linux, macOS, Windows, and wasm32 found
eight dead-code warnings under optional and non-default feature sets:

- `crates/rune/src/open_path.rs:203` (`file_uri_from_bytes`, added in #1947):
  used on Unix only under `feature = "dbus"` (FileManager1) and tests; gate
  with `feature = "dbus"` alongside `test`.
- `crates/rune/src/platform/preferences.rs:77` (`DEFAULT_DOUBLE_CLICK_SECS`,
  added in #1923/#2128): used on Linux only under `feature = "dbus"` and tests;
  gate with `all(target_os = "linux", feature = "dbus")` alongside `test`.
- `crates/rune/src/window/titlebar/linux.rs:82` (`Sides::ALL`, added in #2244):
  used only in `linux_tests.rs`; gate with `#[cfg(test)]`.
- `crates/rune/src/frame/live_log.rs:33` (`CAPTURED` / `capture_frames`, added
  in #2309): used only in `window/win32/resize_sync/tests.rs` under
  `frame-profile`; gate with `#[cfg(all(test, target_os = "windows"))]`.
- `crates/procwatch/src/alloc/sites.rs:222,271,413,418` (`report`, `unsampled`,
  `os::modules`, `os::nt_heaps`, added in #744): `alloc-sites` sampling and
  dumper are Windows-only; gate the implementation behind `#[cfg(windows)]`
  with clean `#[cfg(not(windows))]` no-op stubs.
Hona added a commit to anomalyco/opencode-rune that referenced this pull request Nov 25, 2026
…'s own frame (#1183)

On GNOME under Wayland the window had a second bar above OpenCode's own tab row. With Rune's own frame (anomalyco/rune#2244, in the pin since #1257) the window's buttons sit in the titlebar row instead, as on Windows: one 44 pt row at every layout, 1 pt above the panels.

- shell/view/chrome.rs: the caption row is Windows', or Linux' where `Cx::chrome_insets` has a height (a Wayland compositor that draws no frame).
- shell/view/titlebar.rs: the row's leading padding follows the caption row, not the platform.

Under X11 and compositors that draw the frame, Linux is as before. OpenCode Desktop keeps the system's frame on Linux, so it has the two bars there; one row is ours.

Verified on headless mutter; not shown on a real GNOME desktop (CI run 45712819442 on 5d7b4cb, Linux arm64 skipped).

Refs #1146

The row layout is the one zce's proof of concept showed.
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