diff --git a/UI/AppKit/Application/ApplicationDelegate.mm b/UI/AppKit/Application/ApplicationDelegate.mm index 3260bd0b34a..b8deadca7c6 100644 --- a/UI/AppKit/Application/ApplicationDelegate.mm +++ b/UI/AppKit/Application/ApplicationDelegate.mm @@ -15,22 +15,13 @@ #import #import -#if defined(LADYBIRD_USE_SWIFT) -// FIXME: Report this codegen error to Apple -# define StyleMask NSWindowStyleMask -# import -# undef StyleMask -#else -# import -#endif - #import #if !__has_feature(objc_arc) # error "This project requires ARC" #endif -@interface ApplicationDelegate () +@interface ApplicationDelegate () { Web::CSS::PreferredColorScheme m_preferred_color_scheme; Web::CSS::PreferredContrast m_preferred_contrast; @@ -45,8 +36,6 @@ @property (nonatomic, strong) InfoBar* info_bar; -@property (nonatomic, strong) TaskManagerController* task_manager_controller; - @property (nonatomic, strong) NSMenuItem* toggle_devtools_menu_item; - (NSMenuItem*)createApplicationMenu; @@ -152,12 +141,6 @@ - (void)removeTab:(TabController*)controller { [self.managed_tabs removeObject:controller]; - - if ([self.managed_tabs count] == 0u) { - if (self.task_manager_controller != nil) { - [self.task_manager_controller.window close]; - } - } } - (Web::CSS::PreferredColorScheme)preferredColorScheme @@ -299,13 +282,9 @@ - (void)openTaskManager:(id)sender { - if (self.task_manager_controller != nil) { - [self.task_manager_controller.window makeKeyAndOrderFront:sender]; - return; - } - - self.task_manager_controller = [[TaskManagerController alloc] initWithDelegate:self]; - [self.task_manager_controller showWindow:nil]; + [self createNewTab:URL::URL::about("processes"_string) + fromTab:self.active_tab + activateTab:Web::HTML::ActivateTab::Yes]; } - (void)openLocation:(id)sender @@ -864,11 +843,4 @@ return YES; } -#pragma mark - TaskManagerDelegate - -- (void)onTaskManagerClosed -{ - self.task_manager_controller = nil; -} - @end diff --git a/UI/AppKit/CMakeLists.txt b/UI/AppKit/CMakeLists.txt index b3d07cc40b1..1705e2f5fbb 100644 --- a/UI/AppKit/CMakeLists.txt +++ b/UI/AppKit/CMakeLists.txt @@ -21,25 +21,6 @@ target_compile_options(ladybird_impl PUBLIC ) target_compile_features(ladybird_impl PUBLIC cxx_std_23) -if (ENABLE_SWIFT) - target_sources(ladybird_impl PRIVATE - Interface/TaskManager.swift - Interface/TaskManagerController.swift - ) - target_compile_definitions(ladybird_impl PUBLIC LADYBIRD_USE_SWIFT) - set_target_properties(ladybird_impl PROPERTIES Swift_MODULE_NAME "SwiftLadybird") - - get_target_property(LADYBIRD_NATIVE_DIRS ladybird_impl INCLUDE_DIRECTORIES) - _swift_generate_cxx_header(ladybird_impl "Ladybird-Swift.h" - SEARCH_PATHS ${LADYBIRD_NATIVE_DIRS} - ) -else() - target_sources(ladybird_impl PRIVATE - Interface/TaskManager.mm - Interface/TaskManagerController.mm - ) -endif() - add_executable(ladybird MACOSX_BUNDLE main.mm ) diff --git a/UI/AppKit/Interface/TaskManager.h b/UI/AppKit/Interface/TaskManager.h deleted file mode 100644 index 1a7d0a0a273..00000000000 --- a/UI/AppKit/Interface/TaskManager.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2024, Tim Flynn - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#import -#import - -@class LadybirdWebView; - -@interface TaskManager : LadybirdWebViewWindow - -- (instancetype)init; - -@end diff --git a/UI/AppKit/Interface/TaskManager.mm b/UI/AppKit/Interface/TaskManager.mm deleted file mode 100644 index 9fd55645005..00000000000 --- a/UI/AppKit/Interface/TaskManager.mm +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2024, Tim Flynn - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include -#include -#include - -#import -#import - -#if !__has_feature(objc_arc) -# error "This project requires ARC" -#endif - -static constexpr CGFloat const WINDOW_WIDTH = 600; -static constexpr CGFloat const WINDOW_HEIGHT = 400; - -@interface TaskManager () -{ - RefPtr m_update_timer; -} - -@end - -@implementation TaskManager - -- (instancetype)init -{ - auto tab_rect = [[NSApp keyWindow] frame]; - auto position_x = tab_rect.origin.x + (tab_rect.size.width - WINDOW_WIDTH) / 2; - auto position_y = tab_rect.origin.y + (tab_rect.size.height - WINDOW_HEIGHT) / 2; - auto window_rect = NSMakeRect(position_x, position_y, WINDOW_WIDTH, WINDOW_HEIGHT); - - if (self = [super initWithWebView:nil windowRect:window_rect]) { - __weak TaskManager* weak_self = self; - - m_update_timer = Core::Timer::create_repeating(1000, [weak_self] { - TaskManager* strong_self = weak_self; - if (strong_self == nil) { - return; - } - - [strong_self updateStatistics]; - }); - - [self setContentView:self.web_view]; - [self setTitle:@"Task Manager"]; - [self setIsVisible:YES]; - - [self updateStatistics]; - m_update_timer->start(); - } - - return self; -} - -- (void)updateStatistics -{ - WebView::Application::the().update_process_statistics(); - [self.web_view loadHTML:WebView::Application::the().generate_process_statistics_html()]; -} - -@end diff --git a/UI/AppKit/Interface/TaskManager.swift b/UI/AppKit/Interface/TaskManager.swift deleted file mode 100644 index 92118fd513e..00000000000 --- a/UI/AppKit/Interface/TaskManager.swift +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2024, Tim Flynn - * Copyright (c) 2024, Andrew Kaster - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -import Foundation -import Ladybird.WebView -import Ladybird.WebViewApplication -import Ladybird.WebViewWindow -import SwiftUI - -public class TaskManager: LadybirdWebViewWindow { - - private let WINDOW_WIDTH: CGFloat = 600 - private let WINDOW_HEIGHT: CGFloat = 400 - - private var timer: Timer? - - init() { - let tab_rect = NSApplication.shared.keyWindow!.frame - let position_x = tab_rect.origin.x + (tab_rect.size.width - WINDOW_WIDTH) / 2 - let position_y = tab_rect.origin.y + (tab_rect.size.height - WINDOW_HEIGHT) / 2 - let window_rect = NSMakeRect(position_x, position_y, WINDOW_WIDTH, WINDOW_HEIGHT) - - super.init(webView: nil, windowRect: window_rect) - - self.timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] timer in - if let strong_self = self { - strong_self.updateStatistics() - } - } - - self.contentView = self.web_view - self.title = "Task Manager" - self.setIsVisible(true) - - self.updateStatistics() - } - - func updateStatistics() { - WebView.Application.the().update_process_statistics() - self.web_view.loadHTML(WebView.Application.the().generate_process_statistics_html().__bytes_as_string_viewUnsafe()) - } -} diff --git a/UI/AppKit/Interface/TaskManagerController.h b/UI/AppKit/Interface/TaskManagerController.h deleted file mode 100644 index 9875f21f8d0..00000000000 --- a/UI/AppKit/Interface/TaskManagerController.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2024, Tim Flynn - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#import - -@protocol TaskManagerDelegate - -- (void)onTaskManagerClosed; - -@end - -@interface TaskManagerController : NSWindowController - -- (instancetype)initWithDelegate:(id)delegate; - -@end diff --git a/UI/AppKit/Interface/TaskManagerController.mm b/UI/AppKit/Interface/TaskManagerController.mm deleted file mode 100644 index 0763a333a1b..00000000000 --- a/UI/AppKit/Interface/TaskManagerController.mm +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2024, Tim Flynn - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#import -#import -#import - -#if !__has_feature(objc_arc) -# error "This project requires ARC" -#endif - -@interface TaskManagerController () - -@property (nonatomic, weak) id delegate; - -@end - -@implementation TaskManagerController - -- (instancetype)initWithDelegate:(id)delegate -{ - if (self = [super init]) { - self.delegate = delegate; - } - - return self; -} - -#pragma mark - Private methods - -- (TaskManager*)taskManager -{ - return (TaskManager*)[self window]; -} - -#pragma mark - NSWindowController - -- (IBAction)showWindow:(id)sender -{ - self.window = [[TaskManager alloc] init]; - [self.window setDelegate:self]; - [self.window makeKeyAndOrderFront:sender]; -} - -#pragma mark - NSWindowDelegate - -- (void)windowWillClose:(NSNotification*)notification -{ - [self.delegate onTaskManagerClosed]; -} - -- (void)windowDidResize:(NSNotification*)notification -{ - [[[self taskManager] web_view] handleResize]; -} - -- (void)windowDidChangeBackingProperties:(NSNotification*)notification -{ - [[[self taskManager] web_view] handleDevicePixelRatioChange]; -} - -@end diff --git a/UI/AppKit/Interface/TaskManagerController.swift b/UI/AppKit/Interface/TaskManagerController.swift deleted file mode 100644 index 67ac5149175..00000000000 --- a/UI/AppKit/Interface/TaskManagerController.swift +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2024, Tim Flynn - * Copyright (c) 2024, Andrew Kaster - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -import Foundation -import SwiftUI - -@objc -public protocol TaskManagerDelegate where Self: NSObject { - func onTaskManagerClosed() -} - -public class TaskManagerController: NSWindowController, NSWindowDelegate { - - private weak var delegate: TaskManagerDelegate? - - @objc - public convenience init(delegate: TaskManagerDelegate) { - self.init() - self.delegate = delegate - } - - @IBAction public override func showWindow(_ sender: Any?) { - self.window = TaskManager.init() - self.window!.delegate = self - self.window!.makeKeyAndOrderFront(sender) - } - - public func windowWillClose(_ sender: Notification) { - self.delegate?.onTaskManagerClosed() - } - - public func windowDidResize(_ sender: Notification) { - guard self.window != nil else { return } - if !self.window!.inLiveResize { - self.taskManager().web_view.handleResize() - } - } - - public func windowDidChangeBackingProperties(_ sender: Notification) { - self.taskManager().web_view.handleDevicePixelRatioChange() - } - - private func taskManager() -> TaskManager { - return self.window as! TaskManager - } -}