CPSplitView: Pair each will-resize notification with a did-resize notification

-_maybePostWillResizeNotification previously set its posted flag outside
suppressed notification groups as well, with the flag cleared only at the
end of a group. -adjustSubviews then unconditionally posted a second
will-resize notification, and -trackDivider: posted one on mouse-down
and another on the first drag movement without a matching did-resize,
resulting in three will-resize notifications and one did-resize
notification during a single drag.

-_maybePostWillResizeNotification now posts on every call outside a
suppressed group and once per suppressed group. -adjustSubviews posts
exclusively through it, and divider dragging relies on the paired
will/did-resize notifications emitted by -setPosition:ofDividerAtIndex:,
matching NSSplitView.
This commit is contained in:
David Richardson committed 2026-11-23 12:26:08 -06:00
1 parent 95c48bac49
commit f5128e3f70
3 files changed
+22 -5

No files matched your search

+8 -3
View File
@@ -164,18 +164,23 @@
_initialOffset = startPosition - point[_originComponent];
// Don't autosave during a resize. We'll wait until it's done.
_shouldAutosave = NO;
[self _postNotificationWillResize];
}
}
else if (type == CPLeftMouseDragged && _currentDivider != CPNotFound)
{
/*
Each -setPosition:ofDividerAtIndex: posts a will-resize and a did-resize notification,
as NSSplitView does for each step of a drag.
2026-11-23: the mouse-down and the first drag event also posted a will-resize
notification, with no did-resize notification to match. One drag posted three
will-resize notifications and one did-resize notification.
*/
if (!_isTracking)
{
// Don't autosave during a resize. We'll wait until it's done.
_shouldAutosave = NO;
[self _postNotificationWillResize];
_isTracking = YES;
}
-1
View File
@@ -118,7 +118,6 @@
- (void)adjustSubviews
{
[self _maybePostWillResizeNotification];
[self _postNotificationWillResize];
// 2 possibilities : we have, or not, enough flexible space to accomodate fixed size subviews
@@ -45,9 +45,22 @@ var ShouldSuppressResizeNotifications = 1,
[self _autosave];
}
/*
Posts the will-resize notification that comes before a resize. Outside a suppressed group,
each call posts, because each call is followed by one did-resize notification. Inside a
suppressed group, only the first call posts, and the end of the group posts the one
did-resize notification.
2026-11-23: the flag that marks the first call was also set outside a suppressed group, and
only the end of a group cleared it. After one resize outside a group, later resizes posted
no will-resize notification, so adjustSubviews posted a second one unconditionally, and
the notifications were not paired.
*/
- (void)_maybePostWillResizeNotification
{
if ((_suppressResizeNotificationsMask & DidPostWillResizeNotification) === 0)
if ((_suppressResizeNotificationsMask & ShouldSuppressResizeNotifications) === 0)
[self _postNotificationWillResize];
else if ((_suppressResizeNotificationsMask & DidPostWillResizeNotification) === 0)
{
[self _postNotificationWillResize];
_suppressResizeNotificationsMask |= DidPostWillResizeNotification;