From 4ae1bca67deef6cc5ec37d43a830aff65afc4d72 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 8 Nov 2024 13:36:20 -0500 Subject: [PATCH] UI/AppKit: Handle window resize events during live resizing 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). --- Ladybird/AppKit/UI/InspectorController.mm | 4 +--- Ladybird/AppKit/UI/LadybirdWebView.mm | 3 +++ Ladybird/AppKit/UI/TabController.mm | 7 +------ Ladybird/AppKit/UI/TaskManagerController.mm | 4 +--- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Ladybird/AppKit/UI/InspectorController.mm b/Ladybird/AppKit/UI/InspectorController.mm index 87c0ab98c45..7937bf37354 100644 --- a/Ladybird/AppKit/UI/InspectorController.mm +++ b/Ladybird/AppKit/UI/InspectorController.mm @@ -55,9 +55,7 @@ - (void)windowDidResize:(NSNotification*)notification { - if (![[self window] inLiveResize]) { - [[[self inspector] web_view] handleResize]; - } + [[[self inspector] web_view] handleResize]; } - (void)windowDidChangeBackingProperties:(NSNotification*)notification diff --git a/Ladybird/AppKit/UI/LadybirdWebView.mm b/Ladybird/AppKit/UI/LadybirdWebView.mm index b8bfdf089a2..b98e1e60da2 100644 --- a/Ladybird/AppKit/UI/LadybirdWebView.mm +++ b/Ladybird/AppKit/UI/LadybirdWebView.mm @@ -196,6 +196,9 @@ struct HideCursor { - (void)handleResize { + auto size = Ladybird::ns_size_to_gfx_size([[self window] frame].size); + [self setWindowSize:size]; + [self updateViewportRect]; [self updateStatusLabelPosition]; } diff --git a/Ladybird/AppKit/UI/TabController.mm b/Ladybird/AppKit/UI/TabController.mm index fb04691ebc2..9463988fe26 100644 --- a/Ladybird/AppKit/UI/TabController.mm +++ b/Ladybird/AppKit/UI/TabController.mm @@ -623,12 +623,7 @@ static NSString* const TOOLBAR_TAB_OVERVIEW_IDENTIFIER = @"ToolbarTabOverviewIde 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 diff --git a/Ladybird/AppKit/UI/TaskManagerController.mm b/Ladybird/AppKit/UI/TaskManagerController.mm index 4d8bed0d251..abdf705e130 100644 --- a/Ladybird/AppKit/UI/TaskManagerController.mm +++ b/Ladybird/AppKit/UI/TaskManagerController.mm @@ -54,9 +54,7 @@ - (void)windowDidResize:(NSNotification*)notification { - if (![[self window] inLiveResize]) { - [[[self taskManager] web_view] handleResize]; - } + [[[self taskManager] web_view] handleResize]; } - (void)windowDidChangeBackingProperties:(NSNotification*)notification