51 lines
1.4 KiB
Objective-C
51 lines
1.4 KiB
Objective-C
#import <Cocoa/Cocoa.h>
|
|
#import <Carbon/Carbon.h>
|
|
|
|
#import "MenulessWindow.h"
|
|
#include "Helpers.h"
|
|
|
|
/* TODO: Either change name or move some of the configuration out of the
|
|
* init, decide whether this is a generic menuless window or not. */
|
|
@implementation MenulessWindow
|
|
|
|
- (instancetype)initWithContentViewController:(NSViewController *)contentViewController {
|
|
self = [super initWithContentRect:NSMakeRect(0, 0, 100, 100)
|
|
styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable
|
|
backing:NSBackingStoreBuffered
|
|
defer:false];
|
|
if(self) {
|
|
[super setContentViewController:contentViewController];
|
|
[self setTitle:@""];
|
|
[self setTitlebarAppearsTransparent:YES];
|
|
[self setCollectionBehavior:NSWindowCollectionBehaviorManaged];
|
|
[self setReleasedWhenClosed:NO];
|
|
[self setHidesOnDeactivate:NO];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (BOOL)performKeyEquivalent:(NSEvent *)event {
|
|
NSEventModifierFlags modifiers = [event modifierFlags];
|
|
unsigned short key = [event keyCode];
|
|
|
|
if([event type] == NSEventTypeKeyDown) {
|
|
if(modsContains(NSEventModifierFlagCommand, modifiers) &&
|
|
key == kVK_ANSI_W)
|
|
{
|
|
[self performClose:nil];
|
|
return YES;
|
|
}
|
|
}
|
|
|
|
return NO;
|
|
}
|
|
|
|
/* - (instancetype)init { */
|
|
/* self = [super init]; */
|
|
/* if(self) { */
|
|
/* } */
|
|
/* return self; */
|
|
/* } */
|
|
|
|
@end
|