mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 18:42:23 +08:00

* implement MacOS openFile/openFiles events * wip: windows file association * fix macro import * add file icon copy * try copy icon * keep only required part of scripts * update config schema * fix json * set fileAssociation for mac via config * proper iconName handling * add fileAssociation icon generator * fix file association icons bundle * don't break compatibility * remove mimeType as not supported linux for now * add documentation * adjust config schema * restore formatting * try implement single instance lock with params passing * fix focusing * fix focusing * formatting * use channel buffer for second instance events * handle errors * add comment * remove unused option in file association * wip: linux single instance lock * wip: linux single instance * some experiments with making window active * try to use unminimise * remove unused * try present for window * try present for window * fix build * cleanup * cleanup * implement single instance lock on mac os * implement proper show for windows * proper unmimimise * get rid of openFiles mac os. change configuration structure * remove unused channel * remove unused function * add documentation for single instance lock * add PR link * changes after review * update docs * changes after review --------- Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
74 lines
2.1 KiB
Objective-C
74 lines
2.1 KiB
Objective-C
//
|
|
// AppDelegate.m
|
|
// test
|
|
//
|
|
// Created by Lea Anthony on 10/10/21.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
@implementation AppDelegate
|
|
-(BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
|
|
{
|
|
const char* utf8FileName = filename.UTF8String;
|
|
HandleOpenFile((char*)utf8FileName);
|
|
return YES;
|
|
}
|
|
|
|
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
|
|
return NO;
|
|
}
|
|
|
|
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
|
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
if (self.alwaysOnTop) {
|
|
[self.mainWindow setLevel:NSFloatingWindowLevel];
|
|
}
|
|
if ( !self.startHidden ) {
|
|
[self.mainWindow makeKeyAndOrderFront:self];
|
|
}
|
|
}
|
|
|
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
|
[NSApp activateIgnoringOtherApps:YES];
|
|
if ( self.startFullscreen ) {
|
|
NSWindowCollectionBehavior behaviour = [self.mainWindow collectionBehavior];
|
|
behaviour |= NSWindowCollectionBehaviorFullScreenPrimary;
|
|
[self.mainWindow setCollectionBehavior:behaviour];
|
|
[self.mainWindow toggleFullScreen:nil];
|
|
}
|
|
|
|
if ( self.singleInstanceLockEnabled ) {
|
|
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
|
|
selector:@selector(handleSecondInstanceNotification:) name:self.singleInstanceUniqueId object:nil];
|
|
}
|
|
}
|
|
|
|
void SendDataToFirstInstance(char * singleInstanceUniqueId, char * message) {
|
|
[[NSDistributedNotificationCenter defaultCenter]
|
|
postNotificationName:[NSString stringWithUTF8String:singleInstanceUniqueId]
|
|
object:nil
|
|
userInfo:@{@"message": [NSString stringWithUTF8String:message]}
|
|
deliverImmediately:YES];
|
|
}
|
|
|
|
- (void)handleSecondInstanceNotification:(NSNotification *)note;
|
|
{
|
|
if (note.userInfo[@"message"] != nil) {
|
|
NSString *message = note.userInfo[@"message"];
|
|
const char* utf8Message = message.UTF8String;
|
|
HandleSecondInstanceData((char*)utf8Message);
|
|
}
|
|
}
|
|
|
|
- (void)dealloc {
|
|
[super dealloc];
|
|
}
|
|
|
|
@synthesize touchBar;
|
|
|
|
@end
|