Skip to content

frontend: docks keep their shares when the window narrows and widens (#2225) - #2258

Merged
zackees merged 2 commits into
masterfrom
fix/2225-dock-proportions
Oct 24, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/2225-dock-proportions

Conversation

@zackees

@zackees zackees commented Oct 24, 2026

Copy link
Copy Markdown
Member

Refs #2225 (the repro in #2225 (comment) from @alerque: change the window width and back, and the docks' relative sizes are lost).

Cause

Qt scales docks in proportion until one reaches its minimum. From then on it pins the clamped docks at their minimum, and on widening it shares the space out equally. Reproduced with plain Qt 6: five bottom docks at 709/221/252/197/197 with a 150 px minimum become 150 each at 774 px, then 315 each at 1600 px.

Fix

frontend/utility/dock-proportions.hpp (header-only, Qt Widgets only), installed by OBSBasic after the default layout:

  • A row whose total size is unchanged but whose docks changed was resized from inside (a dragged separator or a restored layout): its shares are recorded, unless a dock is at its minimum.
  • A row whose total changed was resized with the window: the saved shares come back via resizeDocks once they fit.
  • The check runs once per layout pass (queued), not on each dock's resize.

Tests

  • RED 9b3bee1: test/cmocka/test_dock_proportions.cpp against a no-op stub. 3 of 4 cases fail, e.g. dock 0: 44.9% of the row before, 19.9% after.
  • GREEN: all 4 pass. Before 709 221 252 197 197, narrow 150 ×5, after 709 221 252 197 197. Stepped resize, dragged separator and unclamped resize are covered too.
  • Ran locally against Qt 6 on the offscreen platform; Linux-only in CMake, like the other Qt Test cases.

Not covered: the profile ini save/restore half of the issue (no repro yet), and I have not run the full app with this change. That's why this says Refs, not Fixes. Features ledger line added.

#2225)

Narrowing the main window clamps every dock in a row to its minimum width;
widening it again shares the width out equally, so hand-sized docks come
back all the same width. test_dock_proportions drives a QMainWindow with a
row of five docks on the offscreen platform. Against the stub helper,
dock 0 goes from 44.9% of the row to 19.9%.
…2225)

DockProportions watches the main window's docks. A row of docks whose
total size stays the same was resized from inside (a dragged separator):
its shares are recorded, unless a dock is at its minimum. A row whose total
changed was resized with the window: the saved shares are put back with
resizeDocks once they fit. OBSBasic installs it after the default layout.

test_dock_proportions passes: 709 221 252 197 197 before, 150 each when
narrow, 709 221 252 197 197 after widening (was 315 each).
@zackees
zackees enabled auto-merge October 24, 2026 23:25
@zackees
zackees added this pull request to the merge queue Oct 24, 2026
Merged via the queue into master with commit 067f850 Oct 24, 2026
37 checks passed
@zackees
zackees deleted the fix/2225-dock-proportions branch October 26, 2026 15:43
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