Skip to content

frontend: obs-dock-layout, the dock layout model (Refs #5230) - #5362

Merged
vpacher merged 5 commits into
masterfrom
fix/5230-dock-layout-model
Nov 21, 2026
Merged

vpacher merged 5 commits into
masterfrom
fix/5230-dock-layout-model

Conversation

@vpacher

@vpacher vpacher commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Refs #5230 (step 2 of the plan in #5230 (comment))

Problem

DockProportions decides from Qt state alone: it compares saveState() blobs and restores old ones. That is the cause of P2, P4, P5, P6 and P7, and its rules cannot be tested without a display. The rewrite needs a layout model that decides the same way under every window manager and runs on all six CI targets (W1, W5).

Change

New crate rust/obs-dock-layout. No Qt, no platform code, #![deny(unsafe_code)] outside src/ffi/. Not used by the frontend yet: the Qt adapter, its header and the removal of DockProportions come in step 3.

  • Input: a snapshot of the window and its docks after each change (size, preview room, and per dock its object name, area, floating, shown, rect, minimum size, tab group), with a cause: change, separator drag or restored.
  • Wanted sizes: the depth of each dock area in pixels and the length of each dock in its row, applied as shares of the row (D1). Only a separator drag changes them (D3, R7). In a clamped row, the dragged docks share the row's wanted total in their new ratio, so the untouched docks keep their shares.
  • Window changes only apply them: resizeDocks calls for each row and area where they fit, an area only into the room the preview has. A difference of 1 px is left alone.
  • Placement changes are kept, also when the window changes in the same turn (P7). Hide, show and float keep a dock's length; a move to another area or tab group learns it again from the screen, in the row's scale.
  • No known sizes (first start after the upgrade, a layout written by upstream OBS, Reset Docks, a service layout): the adapter restores that layout again at each window change, until it shows unclamped or the user changes something. Until then, quit saves that layout. This is the one exception to "never restore an old layout again" (decided 2026-11-20).
  • Record: BasicWindow/DockSizes = v1;<hash of the DockState blob>;aB=200;dscenes=597;... (D6). A record for another blob (upstream OBS wrote DockState in between), another version or a malformed entry is no record.
  • C ABI in src/ffi/, re-exported by rust/obs-frontend (obs_dock_layout_*). Every number from the caller is clamped to ±2^20 px, so nothing can overflow or panic across the ABI.

Tests

Tier 1, 37 cases in obs-tests-gpu (the frontend's Rust category, rust/obs-dock-layout/tests/dock_layout/):

  • record format and hash check (E25);
  • window changes: E2, E3, D1 (area keeps pixels), R9 (hidden window), fixed point (the model's own output gives no resize), a size change that is not a drag;
  • drags: full window, clamped row (D3), to the minimum (R7), area edge;
  • placement: hide and show round trip, P7, E14, a tab click, a move to another area;
  • restores with no known sizes: UI forgetting dock sizes on every restart #3740, P2, P5, P6, E25, a record that misses a dock, a separator click that resizes nothing;
  • W2: one session (drag, another window, float) under a floating and a tiling profile saves the same record;
  • the C ABI, null arguments, and extreme numbers.
  • a side column at its minimum: learned when the preview has room, a clamp when the preview is at its minimum too.

RED 90ad959c7: every case fails, the methods and the record codec are todo!() (the C ABI test aborts the binary, as a panic cannot unwind out of extern "C"). GREEN 3aa790481: 35/35, and all 280 tests of obs-tests-gpu pass on build-rust (Linux x86_64); ./lint passes there.

Added 2026-11-21 after the real-Qt check of step 3 (d6d012116 RED, a4ac02a58 GREEN): a dock at its minimum across its area's depth is a window clamp only when the central widget is at its minimum too. With real Qt, a side column the user left at its minimum never got a depth, so every start counted as "no sizes" and the record was ignored. 37/37 on build-rust; RED fails a_side_column_at_its_minimum_with_room_is_learned.

What these tests do not show yet. The snapshots are a hand-written model of Qt. Only the full-size row (597/595/396 px) comes from test_dock_state_restart. These Qt behaviors are assumptions, checked against real Qt in step 3: proportional scaling on a window change, what a restore into a smaller window shows, and where the space of a hidden dock goes.

Open for step 3, pinned by tests:

  • A dock that first appears during the restores ends them. The model cannot tell a plugin's load-time dock from a browser dock the user added. The adapter must send the restored snapshot after the load-time docks exist.
  • After a user change in a clamped window, the first unclamped row is learned as Qt shows it.

Tier 2 and Tier 3: not applicable (new code, no C original; upstream OBS has no such logic). Real-app check: step 3, when the adapter uses the model.

Test cost: the 35 cases take 0.00 s together, no own threads, no allocation that grows with input.

No features.md line: nothing user-visible until step 3.

Rebase on #5383

3ead375f2: the lockfile fixtures of hybrid_archive_reads_the_repository_lockfile (#5383) used obs-dock-layout as a package name that no lockfile has. This PR adds that crate, so the merge-queue run (44900012182) found the dependency and failed in Fast Gate and the macOS and Windows Rust Tests. The fixtures now use obs-unrelated-fixture and unrelated-fixture-dep; the 6 archive_freshness tests pass on macOS.

🤖 Generated with Claude Code

@vpacher
vpacher requested a review from zackees as a code owner November 20, 2026 13:12
@vpacher vpacher changed the title feat: obs-dock-layout model, GREEN (Refs #5230) frontend: obs-dock-layout, the dock layout model (Refs #5230) Nov 20, 2026
@vpacher
vpacher marked this pull request as draft November 20, 2026 13:12
@obs-rust-project-manager obs-rust-project-manager Bot moved this to In progress in obs-rust Multiview Nov 20, 2026
@vpacher
vpacher marked this pull request as ready for review November 20, 2026 14:32
@vpacher
vpacher added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In progress to Ready to merge in obs-rust Multiview Nov 20, 2026
@vpacher
vpacher added this pull request to the merge queue Nov 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 21, 2026
@vpacher
vpacher added this pull request to the merge queue Nov 21, 2026
vpacher and others added 5 commits November 21, 2026 13:07
Step 2 of the dock layout plan on #5230: a new crate with the layout
model of the main window, no Qt and no platform code, so its decisions
run on every CI target (W1, W5). Not used by the frontend yet; the
adapter and its header come in step 3.

The model keeps the sizes the user wants: the depth of each dock area in
pixels and the length of each dock in its row, applied as shares of the
row (D1). Only a separator drag changes them (D3, R7); a window change
only puts them back where they fit. The record is the additive
BasicWindow/DockSizes value with the hash of the DockState blob (D6).

Tier 1 tests in obs-tests-gpu (the frontend's Rust category): record
format, window changes (E2, E3, D1, R9), drags (D3 in a clamped row,
R7), placement (hide/show, P7, E14, tabs), the restores of a layout
with no known sizes (#3740, P2, P5, P6, E25), the C ABI, and one
session under a floating and a tiling window manager that must save
the same record (W2). Every test fails here: the model's methods and
the record codec are todo!().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The model behind the stubs:

- A row is the shown, docked docks of one area that share the area's
  edge; an area whose docks share one depth has a depth.
- Window changes learn sizes not known yet (rescaled to the row's known
  sizes, never from a clamped row) and return the resizeDocks calls
  that give each row its shares and each area its pixels, as far as the
  preview has room. 1 px differences are left alone.
- A separator drag records the docks and areas it resized; a press and
  release that resized nothing is no change. In a clamped
  row the dragged docks share the row's wanted total in their new ratio,
  so the untouched docks keep their shares (D3).
- A dock moved to another area or tab group loses its length; hiding,
  showing and floating keep it.
- Every number from the caller is clamped to +-2^20 px (and a record
  size above that is no record), so no sum or product can overflow and
  nothing panics across the C ABI.
- A layout restored with no known sizes is restored again at each window
  change until it shows unclamped or the user changes something (the
  decision of 2026-11-20 on #5230); quit then saves that blob.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eview has room, RED (Refs #5230)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…view has room, GREEN (Refs #5230)

A dock at its minimum across its area's depth is a window clamp only when
the central widget is at its minimum too. Real Qt (test_dock_state_restart
on the adapter) showed a column the user left at its minimum: its depth was
never learned, so every start had no complete sizes and ignored the record.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…5230)

hybrid_archive_reads_the_repository_lockfile (#5383) used obs-dock-layout as
a package that the repository lockfile does not have. This PR adds that crate,
so in the merge queue the dependency resolved and the archive was stale for
"it changes the packages" instead of "cannot be read" (Fast Gate, macOS and
Windows Rust Tests, run 44900012182). The fixtures now use
obs-unrelated-fixture and unrelated-fixture-dep.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vpacher
vpacher removed this pull request from the merge queue due to a manual request Nov 21, 2026
@vpacher
vpacher force-pushed the fix/5230-dock-layout-model branch from a4ac02a to 3ead375 Compare November 21, 2026 12:11
@vpacher
vpacher enabled auto-merge November 21, 2026 12:12
@vpacher
vpacher added this pull request to the merge queue Nov 21, 2026
Merged via the queue into master with commit 1645460 Nov 21, 2026
45 checks passed
@vpacher
vpacher deleted the fix/5230-dock-layout-model branch November 21, 2026 12:58
amsterdamboomer pushed a commit to amsterdamboomer/obs-studio that referenced this pull request Nov 21, 2026
…ust's packages (Refs obs-rust#5323) (obs-rust#5383)

* test(build): a newer Cargo.lock that keeps libobs-rust's packages is not stale, RED (Refs obs-rust#5323)

A kept Tier 2 tree fails with 'newer input Cargo.lock' when a PR adds a
crate that libobs-rust does not use (merge-group run 44754423221, obs-rust#5362):
Cargo correctly keeps the archive, and the lockfile is newer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(build): stamp libobs-rust's lockfile closure beside the archive, GREEN (Refs obs-rust#5323)

Cargo's depfile lists only path dependencies, so the archive's registry
packages come from the lockfile: the closure of libobs-rust through the
lock's dependency lists. When the archive is newer than Cargo.lock, the
check saves that closure and the archive's mtime in
liblibobs_rust.lock-closure. A newer Cargo.lock is fresh only when its
closure equals the stamp for an unchanged archive. No stamp, a stamp for
another archive build, or a lockfile that cannot be read stay stale.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Ready to merge to Done in obs-rust Multiview Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant