Repository navigation
feat(titlebar): App::titlebar is the window's only bar where a Wayland compositor draws no frame - #2244
Conversation
…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.
|
On a real GNOME/Mutter session, double-clicking an empty titlebar band does not toggle maximize/restore. Tested with Rune
My earlier downstream patch fixed this by deferring the drag until pointer motion, as GTK's 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. |
# 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.
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.
…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.
…'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.
On GNOME under Wayland, a window with
App::titlebarhad 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=0is 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]button-layoutnames, 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 fromorg.gnome.desktop.wm.preferences, through the settings portal Rune already follows, so a change shows while the app runs. GNOME's defaultappmenu:closeis 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 withCx::caption_color, sized in window points at everyCx::zoom. Hidden in full screen.Cx::chrome_insets()reports the buttons' room (leadingortrailing) and the band'sheight, as on Windows..window_resize(edge)elements in Rune's frame around the view, so the cursor, the press andxdg_toplevel.resizeare 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..window_drag()regions already doxdg_toplevel.move, toggle maximize on a double click and callshow_window_menuon 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).RUNE_LINUX_FRAME=0keeps winit's frame;=1draws Rune's under any Wayland compositor (for testing under Sway or KDE).What has run
dc5a0f5fc: this branch two merges ofdevbefore its head, with the same lines of this change. The library's Linux-only lines, with the app. Not built on Linux arm64.devdac67eb35merged in): 47 test targets ok, none failed; therunelib 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.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=1and a virtual pointer: one bar in the picture, three round buttons at its end, and each press reached the app and asked the compositor:set_maximized; the window fills the output and the button shows the restore symbolunset_maximized; the first rectangle comes backset_maximized, orunset_maximizedwhen maximized; nomovemove; under labwc it snapped the window to the left halfresizewith that edge, and the resize cursorshow_window_menuset_minimizedset_fullscreen: the row stays, the buttons go; and backA 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
[4, 7, 8, 5]): the free side is free.What is not shown
wm_capabilitiespath. A button the compositor says the window cannot act on is not drawn (Cx::window_actions): neither sway nor labwc sendswm_capabilities, so that is by tests and type-check only.resize. The request was seen; a window growing under the pointer was not.button-layout(close alone on GNOME's default,appmenu:close; no portal answered in the lab, so that is by reading and a test).Not in this change
dbus-sendreads it starts stay.Where it is
window/titlebar/linux.rsButtonLayout::parse, the desktop's layoutwindow/titlebar/caption.rsround_buttons,edges; the Windows buttons share key, label and actionwindow/titlebar.rsCaption::own_frame,Caption::layout,Caption::edgeswindow/chrome.rs,window/host/{create,events}.rsplatform/portal_appearance.rsbutton-layout(Wayland sessions only)runtime/input/focus.rsmacOS 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-layoutparsing 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.