mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 08:48:57 +00:00
Ladybird/AppKit: Track the currently active tab
Will be needed to open new tabs from other Ladybird processes from the active tab.
This commit is contained in:
parent
7ad7ec3c0c
commit
bfb356fd6c
Notes:
sideshowbarker
2024-07-16 23:34:49 +09:00
Author: https://github.com/trflynn89
Commit: bfb356fd6c
Pull-request: https://github.com/SerenityOS/serenity/pull/24151
Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 23 additions and 0 deletions
|
@ -37,6 +37,9 @@
|
||||||
fromTab:(nullable Tab*)tab
|
fromTab:(nullable Tab*)tab
|
||||||
activateTab:(Web::HTML::ActivateTab)activate_tab;
|
activateTab:(Web::HTML::ActivateTab)activate_tab;
|
||||||
|
|
||||||
|
- (void)setActiveTab:(nonnull Tab*)tab;
|
||||||
|
- (nullable Tab*)activeTab;
|
||||||
|
|
||||||
- (void)removeTab:(nonnull TabController*)controller;
|
- (void)removeTab:(nonnull TabController*)controller;
|
||||||
|
|
||||||
- (WebView::CookieJar&)cookieJar;
|
- (WebView::CookieJar&)cookieJar;
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, strong) NSMutableArray<TabController*>* managed_tabs;
|
@property (nonatomic, strong) NSMutableArray<TabController*>* managed_tabs;
|
||||||
|
@property (nonatomic, strong) Tab* active_tab;
|
||||||
|
|
||||||
@property (nonatomic, strong) TaskManagerController* task_manager_controller;
|
@property (nonatomic, strong) TaskManagerController* task_manager_controller;
|
||||||
|
|
||||||
|
@ -119,6 +120,16 @@
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setActiveTab:(Tab*)tab
|
||||||
|
{
|
||||||
|
self.active_tab = tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (Tab*)activeTab
|
||||||
|
{
|
||||||
|
return self.active_tab;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)removeTab:(TabController*)controller
|
- (void)removeTab:(TabController*)controller
|
||||||
{
|
{
|
||||||
[self.managed_tabs removeObject:controller];
|
[self.managed_tabs removeObject:controller];
|
||||||
|
|
|
@ -520,10 +520,19 @@ static NSString* const TOOLBAR_TAB_OVERVIEW_IDENTIFIER = @"ToolbarTabOverviewIde
|
||||||
[self.window makeKeyAndOrderFront:sender];
|
[self.window makeKeyAndOrderFront:sender];
|
||||||
|
|
||||||
[self focusLocationToolbarItem];
|
[self focusLocationToolbarItem];
|
||||||
|
|
||||||
|
auto* delegate = (ApplicationDelegate*)[NSApp delegate];
|
||||||
|
[delegate setActiveTab:[self tab]];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - NSWindowDelegate
|
#pragma mark - NSWindowDelegate
|
||||||
|
|
||||||
|
- (void)windowDidBecomeMain:(NSNotification*)notification
|
||||||
|
{
|
||||||
|
auto* delegate = (ApplicationDelegate*)[NSApp delegate];
|
||||||
|
[delegate setActiveTab:[self tab]];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)windowWillClose:(NSNotification*)notification
|
- (void)windowWillClose:(NSNotification*)notification
|
||||||
{
|
{
|
||||||
[[self tab] tabWillClose];
|
[[self tab] tabWillClose];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue