Skip to content

Commit

Permalink
UI/AppKit: Handle window resize events during live resizing
Browse files Browse the repository at this point in the history
This lets us redraw the WebView while live resize events are ongoing. By
doing so, we can also update the window rect from within the WebView,
rather than requiring a separate method invocation (which the Inspector
and Task Manager windows were missing).
  • Loading branch information
trflynn89 committed Nov 8, 2024
1 parent 3bbe1b0 commit 4ae1bca
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
4 changes: 1 addition & 3 deletions Ladybird/AppKit/UI/InspectorController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ - (void)windowWillClose:(NSNotification*)notification

- (void)windowDidResize:(NSNotification*)notification
{
if (![[self window] inLiveResize]) {
[[[self inspector] web_view] handleResize];
}
[[[self inspector] web_view] handleResize];
}

- (void)windowDidChangeBackingProperties:(NSNotification*)notification
Expand Down
3 changes: 3 additions & 0 deletions Ladybird/AppKit/UI/LadybirdWebView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ - (void)setWindowSize:(Gfx::IntSize)size

- (void)handleResize
{
auto size = Ladybird::ns_size_to_gfx_size([[self window] frame].size);
[self setWindowSize:size];

[self updateViewportRect];
[self updateStatusLabelPosition];
}
Expand Down
7 changes: 1 addition & 6 deletions Ladybird/AppKit/UI/TabController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,7 @@ - (void)windowDidResize:(NSNotification*)notification
self.location_toolbar_item_width = [[[self.location_toolbar_item view] widthAnchor] constraintEqualToConstant:width];
self.location_toolbar_item_width.active = YES;

if (![[self window] inLiveResize]) {
[[[self tab] web_view] handleResize];
}

auto size = Ladybird::ns_size_to_gfx_size([[self tab] frame].size);
[[[self tab] web_view] setWindowSize:size];
[[[self tab] web_view] handleResize];
}

- (void)windowDidChangeBackingProperties:(NSNotification*)notification
Expand Down
4 changes: 1 addition & 3 deletions Ladybird/AppKit/UI/TaskManagerController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ - (void)windowWillClose:(NSNotification*)notification

- (void)windowDidResize:(NSNotification*)notification
{
if (![[self window] inLiveResize]) {
[[[self taskManager] web_view] handleResize];
}
[[[self taskManager] web_view] handleResize];
}

- (void)windowDidChangeBackingProperties:(NSNotification*)notification
Expand Down

0 comments on commit 4ae1bca

Please sign in to comment.