2024-10-29 15:05:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2024-11-09 17:50:33 +00:00
|
|
|
#import <Interface/LadybirdWebView.h>
|
|
|
|
#import <Interface/LadybirdWebViewWindow.h>
|
2024-10-29 15:05:25 +00:00
|
|
|
|
|
|
|
#if !__has_feature(objc_arc)
|
|
|
|
# error "This project requires ARC"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
@interface LadybirdWebViewWindow ()
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation LadybirdWebViewWindow
|
|
|
|
|
|
|
|
- (instancetype)initWithWebView:(LadybirdWebView*)web_view
|
|
|
|
windowRect:(NSRect)window_rect
|
|
|
|
{
|
|
|
|
static constexpr auto style_mask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
|
|
|
|
|
|
|
|
self = [super initWithContentRect:window_rect
|
|
|
|
styleMask:style_mask
|
|
|
|
backing:NSBackingStoreBuffered
|
|
|
|
defer:NO];
|
|
|
|
|
|
|
|
if (self) {
|
|
|
|
self.web_view = web_view;
|
2024-11-07 17:26:42 +00:00
|
|
|
|
2024-10-29 15:05:25 +00:00
|
|
|
if (self.web_view == nil)
|
|
|
|
self.web_view = [[LadybirdWebView alloc] init:nil];
|
|
|
|
|
2024-11-07 17:26:42 +00:00
|
|
|
[self.web_view setClipsToBounds:YES];
|
2024-10-29 15:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - NSWindow
|
|
|
|
|
|
|
|
- (void)setIsVisible:(BOOL)flag
|
|
|
|
{
|
|
|
|
[self.web_view handleVisibility:flag];
|
|
|
|
[super setIsVisible:flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setIsMiniaturized:(BOOL)flag
|
|
|
|
{
|
|
|
|
[self.web_view handleVisibility:!flag];
|
|
|
|
[super setIsMiniaturized:flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|