Skip to content

frontend: restore the dock layout again when the window grows after the start (#3740) - #4841

Merged
vpacher merged 9 commits into
masterfrom
fix/3740-tiling-dock-layout
Nov 13, 2026
Merged

vpacher merged 9 commits into
masterfrom
fix/3740-tiling-dock-layout

Conversation

@vpacher

@vpacher vpacher commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Refs #3740. CI does not build test_dock_state_restart yet (the Linux Qt asset has no QtTest, #4837), so the evidence below is from a local run. Merged before the reporter's retest so it does not go stale; a fix for anything the retest finds follows in a new PR.

Problem

OBSBasic shows the main window and then restores the dock layout into it. A tiling window manager (Hyprland, the reporter's setup) resizes the shown window to its tile right after. The layout is restored into the start size, Qt squeezes it to fit, and when the window grows, Qt shares the new space out on its own. Quit saves that evened-out layout, so every start loses the user's dock sizes again. DockProportions also recorded the squeezed shares as the user's and put them back on later resizes. Plain Qt (upstream OBS) loses the layout the same way in this sequence.

Change

frontend/utility/dock-proportions.hpp: SetRestoredState arms a re-apply. Until the user changes a dock, each change of the window size restores the saved layout again at the new size and drops the shares seen so far, and a save writes the restored layout. After the first user change, the helper works as before (#2225, #3796).

What counts as a user change: after each restore has settled, the helper keeps a snapshot of saveState(). A different state at the same window size ends the re-apply: a separator drag, and also a dock hidden through its menu action, moved, floated, a tab switched or a dock added (by the user or a plugin). A dock shown or hidden alone in its area triggers that check too. The first version ended the re-apply only on a separator drag, so a hidden dock came back at the next window resize, and a quit from a smaller window (after leaving full screen, for example) saved the layout Qt had squeezed into it: no dock was at its minimum, so the clamp rule of #2225 did not apply. Both were found by the reporter's tests on Hyprland.

docs/features.md: one sentence in the existing dock entry.

Tests

RED 401b87b54: layout_survives_window_manager_resize_after_restore in test_dock_state_restart saves a layout at 1600x900 (docks 500, 200, 400, 200, 276 px wide, 246 px high), restores it into a shown 1000x600 window and grows the window to 1600x900, then restarts. On master it fails: after the resize all five docks are 315 x 369 px, and the restart restores that.

GREEN 967877ec0: after the resize and after the restart the docks are 500, 200, 400, 200, 276 x 246 px.

6a70d77e9: layout_survives_several_window_manager_resizes (1000x600, then 800x900, then 1600x900: the reporter's start from a terminal).

RED 53e545859 and 23fb35cf6, after the reporter's second test round:

  • layout_survives_a_session_at_a_smaller_size: restore at 1600x900, shrink to 1450x800 (out of full screen into a tile), save, restart at 1600x900. Before the fix, the restart showed dock 0 at 387 px instead of 500 px.
  • hidden_dock_stays_hidden_after_a_window_resize: hide a dock through its toggleViewAction(), resize the window. Before the fix, the dock came back (visible=1).

GREEN e809ba48e: both pass; the restart shows 500, 200, 400, 200, 276 px, and the hidden dock stays hidden after the resize and after the restart.

Guard ebc02f236: moved_and_floated_docks_stay_after_a_window_resize (one dock floated, one moved to the left area, then a window resize and a restart).

Local run, Linux, Xvfb, ci/linux_qt_frontend.py against Qt 6.11.1 built with the obs-studio-libs recipe plus -DFEATURE_testlib=ON (obs-rust/obs-studio-libs#32): all 30 Qt-linked tests pass, including the 8 cases of test_dock_state_restart and the 9 of test_dock_proportions (#2225). The existing case changed_layout_after_clamped_start_survives_restart now gets the original 500/200/400 px layout back when the window grows after a clamped start (before: 315/315/316 px); it passes either way.

Test cost: test_dock_state_restart takes 1.48 s with its 8 cases (was 0.62 s with 4; Xvfb on CT115-class hardware); no threads of its own.

Not tested here: Hyprland or another Wayland compositor; the tests resize the window the way a tiling window manager does. The reporter tests the branch on Hyprland; the second round found the two cases above, and the reporter mentioned other unwanted resets that this change may not cover.

🤖 Generated with Claude Code

vpacher and others added 3 commits November 13, 2026 09:04
…he start (#3740)

OBSBasic restores the dock layout into the shown window. A tiling window
manager (Hyprland) resizes that window to its tile right after: Qt
squeezes the layout into the start size, shares the new space out on
its own when the window grows, and that evened-out layout is what quit
saves. DockProportions also recorded the squeezed shares as the user's.

Until the user changes a dock (a separator drag that changes the
layout), each window resize now restores the layout again at the new
size and drops the shares seen so far.

GREEN for layout_survives_window_manager_resize_after_restore: the
docks keep 500/200/400/200/276 px after the resize and after restart
(before: all 315 px). All 30 Qt-linked tests pass against Qt 6.11.1
with QtTest (#4837), including test_dock_proportions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reporter starts OBS from a terminal: the window first shares the
workspace with the terminal, too narrow for the layout, and gets the
whole workspace when the terminal is hidden. Every resize before the
user changes a dock must restore the layout again.

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

alerque commented Nov 13, 2026

Copy link
Copy Markdown

Compiling to test on Hyprland on real hardware now.

vpacher and others added 5 commits November 13, 2026 11:30
… stays hidden (#3740)

The reporter's full-screen start: OBS starts full screen with the
layout, leaves full screen into a smaller tile, nobody touches a dock,
and quits. The next start must show the start layout, not the one Qt
squeezed into the smaller window. And a dock hidden through its menu
action must stay hidden across a window resize and a restart: the
restore on a window resize must not bring it back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
At 1100x700 some docks reach their minimum and the clamp rule of #2225
keeps the start layout. The reporter's tile is only a little smaller:
the docks get squeezed, none reaches its minimum, and the squeezed
layout is saved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DockProportions restored the start layout on every window resize until
the user dragged a separator, but a dock the user hid, moved or floated
came back at the next window resize, and a save from a smaller window
wrote the layout Qt squeezed into it (no dock at its minimum, so the
clamp rule of #2225 did not apply).

Now a snapshot of saveState() is kept after each restore has settled.
A different state at the same window size is a change by the user or a
plugin (a dock hidden, moved, floated, a tab switched, a dock added):
the restores stop and the usual rules apply. Until then a save writes
the start layout. A dock shown or hidden alone in its area triggers the
check too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vpacher
vpacher marked this pull request as ready for review November 13, 2026 15:05
@vpacher
vpacher requested a review from zackees as a code owner November 13, 2026 15:05
@vpacher
vpacher added this pull request to the merge queue Nov 13, 2026
Merged via the queue into master with commit 1d8b65e Nov 13, 2026
42 checks passed
@vpacher
vpacher deleted the fix/3740-tiling-dock-layout branch November 13, 2026 15:31
wesleyhawes pushed a commit to wesleyhawes/obs-studio that referenced this pull request Nov 21, 2026
…t#5230) (obs-rust#5245)

* test: a dock change or Reset Docks with a window resize stays (obs-rust#5230)

On a tiling window manager a dock change and a window resize often come
together: a dock dragged out of the window becomes a new window and the
compositor retiles. Since obs-rust#4841, DockProportions sees a user change only
at the same window size, so the resize puts the start layout back over
the change, and quit saves the start layout. Reset Docks is undone the
same way, and every later start repeats it.

Both cases fail on master and pass with the helper from before obs-rust#4841.

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

* frontend: keep a dock change that comes with a window resize (obs-rust#5230)

obs-rust#4841 restores the start layout on each window resize until the user
changes a dock, and it saw a change only at the same window size. On a
tiling window manager a dock change and a window resize often come
together: the dock moved back, Reset Docks was undone, and quit saved
the start layout again, so every start repeated it.

DockProportions now also keeps where the docks are once a restore has
settled (area, order in the area, floating, hidden, tabs), which a
window resize does not change. A different placement ends the restores,
with or without a resize. Reset Docks also ends them: the reset layout
is the user's.

GREEN for floated_dock_stays_when_the_window_resizes_at_the_same_time
and reset_docks_stays_when_the_window_resizes_at_the_same_time; the
obs-rust#3740 cases still pass.

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

* docs: features entry for dock changes kept with a window resize (obs-rust#5230)

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants