Skip to content

frontend: docks keep the sizes the user gave them (Refs #5230) - #5411

Merged
vpacher merged 2 commits into
masterfrom
fix/5230-dock-adapter
Nov 21, 2026
Merged

vpacher merged 2 commits into
masterfrom
fix/5230-dock-adapter

Conversation

@vpacher

@vpacher vpacher commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Refs #5230 (step 3 of the plan in #5230 (comment)). Builds on the model in #5362 (merged).

Problem

DockProportions decides from Qt state alone: it compares saveState() blobs and restores old ones. A dock change in a small window (P2), after a drag and a shrink (P4), Reset Docks in a small window (P5) and a moved floating dock (P6) were lost at the next window change or quit, and a dock floated under a tiling window manager saved the row as squeezed into the half tile (P7).

Change

  • frontend/utility/DockLayout, the adapter between QMainWindow and rust/obs-dock-layout (frontend: obs-dock-layout, the dock layout model (Refs #5230) #5362), through its C header frontend/utility/obs-dock-layout.h. Unity group frontend.dock-layout, feature-dock-layout.cmake, linked through rust/obs-frontend.
    • It takes one snapshot per event-loop turn after a window resize or show, a dock show, hide, move or resize, or a dock added later, and gives it to the model with its cause: a window change, a separator drag, or a restore. It applies the model's resizes with resizeDocks().
    • While the left button is down on the window (a separator drag), it takes no snapshot; the release gives the drag's snapshot.
    • It decides nothing before the first Start() (OBSBasic sets its default layout up first), and nothing while the window is hidden; a restore is looked at once the window shows (R9).
    • Floating docks: nothing (their geometry is the user's).
  • OBSBasic
    • Start: restoreState(DockState), then Start(DockSizes, DockState).
    • Quit (saveAll): DockState = StateToSave() (the live layout, or the restored one while it has no known sizes and the user changed nothing), and BasicWindow/DockSizes = the sizes record for that blob.
    • Reset Docks: after its own resizeDocks(), Start(nullptr, saveState()): a layout without known sizes.
    • Twitch, Restream, YouTube: the adapter hears of a service layout only when restoreState() accepted it. Before, an empty or invalid service layout became the baseline.
  • DockProportions removed (frontend/utility/dock-proportions.hpp).
  • The model fix this adapter needed went into frontend: obs-dock-layout, the dock layout model (Refs #5230) #5362 before it merged: a dock at its minimum across its area's depth is a window clamp only when the preview is at its minimum too. With real Qt, a side column left at its minimum never got a depth, so every start counted as "no sizes" and the record was ignored.
  • Without the frontend's Rust (OBS_FRONTEND_RUST, the C rollback build) the adapter is upstream OBS: live saveState(), no DockSizes.

Tests

test_dock_state_restart (25 cases, both window-manager profiles) and test_dock_proportions (9 cases) now drive the adapter with the real model and persist DockState with DockSizes through config_save_safe as OBSBasic does. Both link the frontend's Rust owner interface (OBS::fallback-warning-test-frontend) and fail without OBS_FRONTEND_RUST.

  • New cases: P2 e5_move_a_dock_small, P4 e6_drag_shrink_move, P5 e7_reset_docks_small, P6 e8_move_a_floating_dock, P7 p7_float_a_dock_sizes (sizes, and the layout both profiles save must match).
  • Changed: separator_click_does_not_save_a_clamped_layout compared saved blob bytes; the saved blob is now live and the sizes are in DockSizes, so it compares the layout after a restart. The proportions cases size docks with a real separator drag (several moves, events processed between them), because only a drag is the user's change now.
  • Registration: test_dock_proportions now requires HAVE_QT_WIDGETS_TEST_OWNER/HAVE_QT_WIDGETS_TESTLIB_OWNER like test_dock_state_restart, so the Qt replay in canonical_remux_queue_runs_unchanged (Qt and cmocka only, no frontend Rust) no longer builds it; canonical_dock_proportions_is_registered and qt_widgets_expected.json pin the new records. ci/test_dock_state_writers.py accepts the sizes argument.
  • Not changed: qt_widgets_runtime.rs (libobs-integration, needs DISPLAY) still expects 3 cases of test_dock_state_restart and gives no frontend Rust owner. It was already stale before this PR (20 cases since test: dock layout cases under a floating and a tiling window manager (Refs #5230) #5359) and no CI lane runs it.

RED 093a1ec7c (stub adapter with upstream behavior, OBSBasic unchanged): test_dock_proportions fails 8 of 9 (the shares come back even, the column narrow); test_dock_state_restart fails 24 of 25: the first two on their asserts (the saved blob is the clamp; 315 is not within the range [498, 502]), the rest crash after cmocka's longjmp leaves the Qt windows of a failed case behind (a fixture weakness that only shows when a case fails). GREEN e688cdc67: the Qt Frontend Linux lane passes on build-rust (ci/linux_qt_frontend.py, Qt 6.11.1 with QtTest), 30 Qt tests; test_dock_state_restart 25/25, test_dock_proportions 9/9; ./lint passes; the touched registration tests pass.

Other platforms, the same two harnesses built standalone against the real model: macOS 27.2.1 (Cocoa, Qt 6.11.1) 25/25 and 9/9; Windows 11 (Qt 6.10.1, MSVC, the windows platform in a console session, QT_SCALE_FACTOR=0.75 for the VM's 1280x800 display) 25/25 and 9/9. e8_move_a_floating_dock moves the dock to 120,140, because Qt keeps a floating dock on screen when it restores one.

Tier 2 and Tier 3: not applicable (frontend; no C original for the adapter). Test cost: test_dock_state_restart about 12 s, test_dock_proportions about 4 s (Xvfb/offscreen), no own threads.

Real app

The local Qt-lane build (X11) on build-rust, Xvfb with i3 (a tiling window manager), driven with xdotool:

Step Result
First start, quit DockState with 5 docks visible, DockSizes=v1;…;aL=280;aB=216;dcontrolsDock=210;dmixerDock=593;dscenesDock=448;dsourcesDock=448;dtransitionsDock=185
Restart log Dock layout: restored 342 bytes, with its sizes; column 280 px, bottom row in the saved shares
Float Scenes, quit, restart (#5230 report of 11-20) Scenes floating and visible, the other docks visible, record kept
i3 tiles OBS's windows, float Scenes: main window 960 px (P7) row keeps its shares in the half tile; record unchanged (dmixerDock=593…)
Drag the column edge from 280 to 377 px, quit aL=377; the row lengths unchanged

macOS app (Apple silicon, the user's own profile), by hand:

Step Result
First start, quit log restored 342 bytes, no sizes for it yet; quit writes DockSizes (aL=378;aB=247;…)
Restart log with its sizes; the sizes come back
Drag the column and a bottom-row edge, quit aL=593, dmixerDock=576, dtransitionsDock=479
Float Scenes, quit, restart twice (#5230 report of 11-20) Scenes floating and visible, the other docks visible, the sizes kept

The macOS quit bug found on the way (a floating main dock could cancel Cmd+Q) is #5406, fixed in #5410.

Not checked yet: Wayland (Hyprland), the Windows app. Refs, not Fixes, until a Hyprland user confirms.

docs/features.md: the dock entry is rewritten as one line for #2225, #3740 and #5230.

🤖 Generated with Claude Code

The Qt dock tests (test_dock_state_restart, test_dock_proportions) now
drive frontend/utility/DockLayout, the adapter between QMainWindow and
rust/obs-dock-layout, and persist DockState with DockSizes as OBSBasic
does. New cases: P2 (move a dock in a small window), P4 (drag, shrink,
move), P5 (Reset Docks small), P6 (move a floating dock), P7 (float under
a tiling window manager, sizes). The adapter is a stub with upstream
behavior; OBSBasic still uses DockProportions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vpacher vpacher changed the title feat: frontend docks keep the sizes the user gave them, GREEN (Refs #5230) frontend: docks keep the sizes the user gave them (Refs #5230) Nov 21, 2026
…5230)

DockLayout feeds each window change to rust/obs-dock-layout and applies
its resizes with resizeDocks(); separator drags and placement changes are
the user's. OBSBasic restores DockState with its BasicWindow/DockSizes,
saves both at quit, starts a reset layout without sizes, and tells the
adapter about a service layout only when restoreState() accepted it.
DockProportions is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vpacher
vpacher force-pushed the fix/5230-dock-adapter branch from ba26fe0 to e688cdc Compare November 21, 2026 13:09
@vpacher
vpacher marked this pull request as ready for review November 21, 2026 13:20
@vpacher
vpacher requested a review from zackees as a code owner November 21, 2026 13:20
@vpacher
vpacher enabled auto-merge November 21, 2026 13:20
@vpacher
vpacher added this pull request to the merge queue Nov 21, 2026
Merged via the queue into master with commit 3081e28 Nov 21, 2026
46 checks passed
@vpacher
vpacher deleted the fix/5230-dock-adapter branch November 21, 2026 13:50
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