chore: format *.m and *.mm files
This commit is contained in:
parent
af6dac9eee
commit
bf4f513d7e
9 changed files with 2042 additions and 2223 deletions
|
|
@ -28,6 +28,8 @@ include_files = [
|
||||||
"*.c",
|
"*.c",
|
||||||
"*.hpp",
|
"*.hpp",
|
||||||
"*.cpp",
|
"*.cpp",
|
||||||
|
"*.m",
|
||||||
|
"*.mm",
|
||||||
]
|
]
|
||||||
|
|
||||||
dirs = ["src"]
|
dirs = ["src"]
|
||||||
|
|
|
||||||
|
|
@ -2,35 +2,36 @@
|
||||||
|
|
||||||
@interface AppDelegate ()
|
@interface AppDelegate ()
|
||||||
|
|
||||||
@property (strong) IBOutlet NSWindow *window;
|
@property(strong) IBOutlet NSWindow *window;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AppDelegate
|
@implementation AppDelegate {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
|
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
|
||||||
#if OSX_DEPLOYMENT_TARGET >= 1014
|
#if OSX_DEPLOYMENT_TARGET >= 1014
|
||||||
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
|
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{
|
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
|
||||||
return YES;
|
shouldPresentNotification:(NSUserNotification *)notification
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OSX_DEPLOYMENT_TARGET >= 1014
|
#if OSX_DEPLOYMENT_TARGET >= 1014
|
||||||
-(void)userNotificationCenter:(UNUserNotificationCenter *)center
|
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
||||||
willPresentNotification:(UNNotification *)notification
|
willPresentNotification:(UNNotification *)notification
|
||||||
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
|
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
|
||||||
UNNotificationPresentationOptions presentationOptions =
|
{
|
||||||
UNNotificationPresentationOptionSound
|
UNNotificationPresentationOptions presentationOptions = UNNotificationPresentationOptionSound |
|
||||||
| UNNotificationPresentationOptionAlert
|
UNNotificationPresentationOptionAlert |
|
||||||
| UNNotificationPresentationOptionBadge;
|
UNNotificationPresentationOptionBadge;
|
||||||
|
|
||||||
completionHandler(presentationOptions);
|
completionHandler(presentationOptions);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,13 @@
|
||||||
|
|
||||||
#import "OSXHelpers.h"
|
#import "OSXHelpers.h"
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <CoreData/CoreData.h>
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import <CoreData/CoreData.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
#import <UserNotifications/UNNotification.h>
|
#import <UserNotifications/UNNotification.h>
|
||||||
#import <UserNotifications/UNUserNotificationCenter.h>
|
|
||||||
#import <UserNotifications/UNNotificationContent.h>
|
#import <UserNotifications/UNNotificationContent.h>
|
||||||
#import <UserNotifications/UNNotificationTrigger.h>
|
#import <UserNotifications/UNNotificationTrigger.h>
|
||||||
|
#import <UserNotifications/UNUserNotificationCenter.h>
|
||||||
|
|
||||||
#import <QtGlobal>
|
#import <QtGlobal>
|
||||||
|
|
||||||
|
|
@ -33,86 +33,85 @@
|
||||||
void requestOSXNotificationPermission()
|
void requestOSXNotificationPermission()
|
||||||
{
|
{
|
||||||
#if OSX_DEPLOYMENT_TARGET >= 1014
|
#if OSX_DEPLOYMENT_TARGET >= 1014
|
||||||
if (isOSXDevelopmentBuild())
|
if (isOSXDevelopmentBuild()) {
|
||||||
{
|
qWarning("Not requesting notification permission in dev build");
|
||||||
qWarning("Not requesting notification permission in dev build");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
|
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
||||||
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound)
|
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound)
|
||||||
completionHandler:^(BOOL granted, NSError * _Nullable error) {
|
completionHandler:^(BOOL granted, NSError *_Nullable error) {
|
||||||
if(error != nil)
|
if (error != nil) {
|
||||||
{
|
qWarning(
|
||||||
qWarning("Notification permission request error: %s", [[NSString stringWithFormat:@"%@", error] UTF8String]);
|
"Notification permission request error: %s",
|
||||||
}
|
[[NSString stringWithFormat:@"%@", error] UTF8String]
|
||||||
}];
|
);
|
||||||
|
}
|
||||||
|
}];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool isOSXDevelopmentBuild()
|
||||||
isOSXDevelopmentBuild()
|
|
||||||
{
|
{
|
||||||
std::string bundleURL = [[[NSBundle mainBundle] bundleURL].absoluteString UTF8String];
|
std::string bundleURL = [[[NSBundle mainBundle] bundleURL].absoluteString UTF8String];
|
||||||
return (bundleURL.find("Applications/Deskflow.app") == std::string::npos);
|
return (bundleURL.find("Applications/Deskflow.app") == std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool showOSXNotification(const QString &title, const QString &body)
|
||||||
showOSXNotification(const QString& title, const QString& body)
|
|
||||||
{
|
{
|
||||||
#if OSX_DEPLOYMENT_TARGET >= 1014
|
#if OSX_DEPLOYMENT_TARGET >= 1014
|
||||||
// accessing notification center on unsigned build causes an immidiate
|
// accessing notification center on unsigned build causes an immidiate
|
||||||
// application shutodown (in this case, server) and cannot be caught
|
// application shutodown (in this case, server) and cannot be caught
|
||||||
// to avoid issues with it need to first check if this is a dev build
|
// to avoid issues with it need to first check if this is a dev build
|
||||||
if (isOSXDevelopmentBuild())
|
if (isOSXDevelopmentBuild()) {
|
||||||
{
|
qWarning("Not showing notification in dev build");
|
||||||
qWarning("Not showing notification in dev build");
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
requestOSXNotificationPermission();
|
requestOSXNotificationPermission();
|
||||||
|
|
||||||
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
|
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
||||||
|
|
||||||
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
|
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
|
||||||
content.title = title.toNSString();
|
content.title = title.toNSString();
|
||||||
content.body = body.toNSString();
|
content.body = body.toNSString();
|
||||||
|
|
||||||
// Create the request object.
|
// Create the request object.
|
||||||
UNNotificationRequest* request = [UNNotificationRequest
|
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"SecureInput"
|
||||||
requestWithIdentifier:@"SecureInput" content:content trigger:nil];
|
content:content
|
||||||
|
trigger:nil];
|
||||||
|
|
||||||
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
|
[center
|
||||||
if (error != nil) {
|
addNotificationRequest:request
|
||||||
qWarning("Notification display request error: %s", [[NSString stringWithFormat:@"%@", error] UTF8String]);
|
withCompletionHandler:^(NSError *_Nullable error) {
|
||||||
}
|
if (error != nil) {
|
||||||
}];
|
qWarning("Notification display request error: %s", [[NSString stringWithFormat:@"%@", error] UTF8String]);
|
||||||
|
}
|
||||||
|
}];
|
||||||
#else
|
#else
|
||||||
NSUserNotification* notification = [[NSUserNotification alloc] init];
|
NSUserNotification *notification = [[NSUserNotification alloc] init];
|
||||||
notification.title = title.toNSString();
|
notification.title = title.toNSString();
|
||||||
notification.informativeText = body.toNSString();
|
notification.informativeText = body.toNSString();
|
||||||
notification.soundName = NSUserNotificationDefaultSoundName; //Will play a default sound
|
notification.soundName = NSUserNotificationDefaultSoundName; // Will play a default sound
|
||||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notification];
|
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
|
||||||
[notification autorelease];
|
[notification autorelease];
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool isOSXInterfaceStyleDark()
|
||||||
isOSXInterfaceStyleDark()
|
|
||||||
{
|
{
|
||||||
// Implementation from http://stackoverflow.com/a/26472651
|
// Implementation from http://stackoverflow.com/a/26472651
|
||||||
NSDictionary* dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
|
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
|
||||||
id style = [dict objectForKey:@"AppleInterfaceStyle"];
|
id style = [dict objectForKey:@"AppleInterfaceStyle"];
|
||||||
return (style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"]);
|
return (style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
IconsTheme
|
IconsTheme getOSXIconsTheme()
|
||||||
getOSXIconsTheme()
|
|
||||||
{
|
{
|
||||||
if (@available(macOS 11, *))
|
if (@available(macOS 11, *))
|
||||||
return IconsTheme::ICONS_TEMPLATE;
|
return IconsTheme::ICONS_TEMPLATE;
|
||||||
else if(isOSXInterfaceStyleDark())
|
else if (isOSXInterfaceStyleDark())
|
||||||
return IconsTheme::ICONS_DARK;
|
return IconsTheme::ICONS_DARK;
|
||||||
return IconsTheme::ICONS_LIGHT;
|
return IconsTheme::ICONS_LIGHT;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,89 +16,85 @@
|
||||||
|
|
||||||
#import "platform/OSXDragView.h"
|
#import "platform/OSXDragView.h"
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <CoreData/CoreData.h>
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import <CoreData/CoreData.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
|
||||||
NSWindow* g_dragWindow = NULL;
|
NSWindow *g_dragWindow = NULL;
|
||||||
OSXDragView* g_dragView = NULL;
|
OSXDragView *g_dragView = NULL;
|
||||||
NSString* g_ext = NULL;
|
NSString *g_ext = NULL;
|
||||||
|
|
||||||
void
|
void runCocoaApp()
|
||||||
runCocoaApp()
|
|
||||||
{
|
{
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
[NSApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
|
|
||||||
NSWindow* window = [[NSWindow alloc]
|
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 3, 3)
|
||||||
initWithContentRect: NSMakeRect(0, 0, 3, 3)
|
styleMask:NSBorderlessWindowMask
|
||||||
styleMask: NSBorderlessWindowMask
|
backing:NSBackingStoreBuffered
|
||||||
backing: NSBackingStoreBuffered
|
defer:NO];
|
||||||
defer: NO];
|
[window setTitle:@""];
|
||||||
[window setTitle: @""];
|
[window setAlphaValue:0.1];
|
||||||
[window setAlphaValue:0.1];
|
[window makeKeyAndOrderFront:nil];
|
||||||
[window makeKeyAndOrderFront:nil];
|
|
||||||
|
|
||||||
OSXDragView* dragView = [[OSXDragView alloc] initWithFrame:NSMakeRect(0, 0, 3, 3)];
|
OSXDragView *dragView = [[OSXDragView alloc] initWithFrame:NSMakeRect(0, 0, 3, 3)];
|
||||||
|
|
||||||
g_dragWindow = window;
|
g_dragWindow = window;
|
||||||
g_dragView = dragView;
|
g_dragView = dragView;
|
||||||
[window setContentView: dragView];
|
[window setContentView:dragView];
|
||||||
|
|
||||||
NSLog(@"starting cocoa loop");
|
NSLog(@"starting cocoa loop");
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
|
|
||||||
NSLog(@"cocoa: release");
|
NSLog(@"cocoa: release");
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void stopCocoaLoop()
|
||||||
stopCocoaLoop()
|
|
||||||
{
|
{
|
||||||
[NSApp stop: g_dragWindow];
|
[NSApp stop:g_dragWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void fakeDragging(const char *str, int cursorX, int cursorY)
|
||||||
fakeDragging(const char* str, int cursorX, int cursorY)
|
|
||||||
{
|
{
|
||||||
g_ext = [NSString stringWithUTF8String:str];
|
g_ext = [NSString stringWithUTF8String:str];
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
NSRect screen = [[NSScreen mainScreen] frame];
|
NSRect screen = [[NSScreen mainScreen] frame];
|
||||||
NSLog ( @"screen size: witdh = %f height = %f", screen.size.width, screen.size.height);
|
NSLog(@"screen size: witdh = %f height = %f", screen.size.width, screen.size.height);
|
||||||
NSLog ( @"mouseLocation: %d %d", cursorX, cursorY);
|
NSLog(@"mouseLocation: %d %d", cursorX, cursorY);
|
||||||
|
|
||||||
int newPosX = 0;
|
int newPosX = 0;
|
||||||
int newPosY = 0;
|
int newPosY = 0;
|
||||||
newPosX = cursorX - 1;
|
newPosX = cursorX - 1;
|
||||||
newPosY = screen.size.height - cursorY - 1;
|
newPosY = screen.size.height - cursorY - 1;
|
||||||
|
|
||||||
NSRect rect = NSMakeRect(newPosX, newPosY, 3, 3);
|
NSRect rect = NSMakeRect(newPosX, newPosY, 3, 3);
|
||||||
NSLog ( @"newPosX: %d", newPosX);
|
NSLog(@"newPosX: %d", newPosX);
|
||||||
NSLog ( @"newPosY: %d", newPosY);
|
NSLog(@"newPosY: %d", newPosY);
|
||||||
|
|
||||||
[g_dragWindow setFrame:rect display:NO];
|
[g_dragWindow setFrame:rect display:NO];
|
||||||
[g_dragWindow makeKeyAndOrderFront:nil];
|
[g_dragWindow makeKeyAndOrderFront:nil];
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
|
|
||||||
[g_dragView setFileExt:g_ext];
|
[g_dragView setFileExt:g_ext];
|
||||||
|
|
||||||
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||||
CGEventRef down = CGEventCreateMouseEvent(source, kCGEventLeftMouseDown, CGPointMake(cursorX, cursorY), kCGMouseButtonLeft);
|
CGEventRef down =
|
||||||
CGEventPost(kCGHIDEventTap, down);
|
CGEventCreateMouseEvent(source, kCGEventLeftMouseDown, CGPointMake(cursorX, cursorY), kCGMouseButtonLeft);
|
||||||
CFRelease(down);
|
CGEventPost(kCGHIDEventTap, down);
|
||||||
CFRelease(source);
|
CFRelease(down);
|
||||||
});
|
CFRelease(source);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CFStringRef
|
CFStringRef getCocoaDropTarget()
|
||||||
getCocoaDropTarget()
|
|
||||||
{
|
{
|
||||||
// HACK: sleep, wait for cocoa drop target updated first
|
// HACK: sleep, wait for cocoa drop target updated first
|
||||||
usleep(1000000);
|
usleep(1000000);
|
||||||
return [g_dragView getDropTarget];
|
return [g_dragView getDropTarget];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,139 +28,132 @@
|
||||||
@dynamic animatesToDestination;
|
@dynamic animatesToDestination;
|
||||||
@dynamic numberOfValidItemsForDrop;
|
@dynamic numberOfValidItemsForDrop;
|
||||||
|
|
||||||
- (id)
|
- (id)initWithFrame:(NSRect)frame
|
||||||
initWithFrame:(NSRect)frame
|
|
||||||
{
|
{
|
||||||
self = [super initWithFrame:frame];
|
self = [super initWithFrame:frame];
|
||||||
m_dropTarget = [[NSMutableString alloc] initWithCapacity:0];
|
m_dropTarget = [[NSMutableString alloc] initWithCapacity:0];
|
||||||
m_dragFileExt = [[NSMutableString alloc] initWithCapacity:0];
|
m_dragFileExt = [[NSMutableString alloc] initWithCapacity:0];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)
|
- (void)drawRect:(NSRect)dirtyRect
|
||||||
drawRect:(NSRect)dirtyRect
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)
|
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|
||||||
acceptsFirstMouse:(NSEvent *)theEvent
|
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)
|
- (void)mouseDown:(NSEvent *)theEvent
|
||||||
mouseDown:(NSEvent *)theEvent
|
|
||||||
{
|
{
|
||||||
NSLog ( @"cocoa mouse down");
|
NSLog(@"cocoa mouse down");
|
||||||
NSPoint dragPosition;
|
NSPoint dragPosition;
|
||||||
NSRect imageLocation;
|
NSRect imageLocation;
|
||||||
dragPosition = [self convertPoint:[theEvent locationInWindow]
|
dragPosition = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||||
fromView:nil];
|
|
||||||
|
|
||||||
dragPosition.x -= 16;
|
dragPosition.x -= 16;
|
||||||
dragPosition.y -= 16;
|
dragPosition.y -= 16;
|
||||||
imageLocation.origin = dragPosition;
|
imageLocation.origin = dragPosition;
|
||||||
imageLocation.size = NSMakeSize(32,32);
|
imageLocation.size = NSMakeSize(32, 32);
|
||||||
[self dragPromisedFilesOfTypes:[NSArray arrayWithObject:m_dragFileExt]
|
[self dragPromisedFilesOfTypes:[NSArray arrayWithObject:m_dragFileExt]
|
||||||
fromRect:imageLocation
|
fromRect:imageLocation
|
||||||
source:self
|
source:self
|
||||||
slideBack:NO
|
slideBack:NO
|
||||||
event:theEvent];
|
event:theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray*)
|
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
|
||||||
namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
|
|
||||||
{
|
{
|
||||||
[m_dropTarget setString:@""];
|
[m_dropTarget setString:@""];
|
||||||
[m_dropTarget appendString:dropDestination.path];
|
[m_dropTarget appendString:dropDestination.path];
|
||||||
NSLog ( @"cocoa drop target: %@", m_dropTarget);
|
NSLog(@"cocoa drop target: %@", m_dropTarget);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDragOperation)
|
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag
|
||||||
draggingSourceOperationMaskForLocal:(BOOL)flag
|
|
||||||
{
|
{
|
||||||
return NSDragOperationCopy;
|
return NSDragOperationCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CFStringRef)
|
- (CFStringRef)getDropTarget
|
||||||
getDropTarget
|
|
||||||
{
|
{
|
||||||
NSMutableString* string;
|
NSMutableString *string;
|
||||||
string = [[NSMutableString alloc] initWithCapacity:0];
|
string = [[NSMutableString alloc] initWithCapacity:0];
|
||||||
[string appendString:m_dropTarget];
|
[string appendString:m_dropTarget];
|
||||||
return (CFStringRef)string;
|
return (CFStringRef)string;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)
|
- (void)clearDropTarget
|
||||||
clearDropTarget
|
|
||||||
{
|
{
|
||||||
[m_dropTarget setString:@""];
|
[m_dropTarget setString:@""];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)
|
- (void)setFileExt:(NSString *)ext
|
||||||
setFileExt:(NSString*) ext
|
|
||||||
{
|
{
|
||||||
[ext retain];
|
[ext retain];
|
||||||
[m_dragFileExt release];
|
[m_dragFileExt release];
|
||||||
m_dragFileExt = ext;
|
m_dragFileExt = ext;
|
||||||
NSLog(@"drag file ext: %@", m_dragFileExt);
|
NSLog(@"drag file ext: %@", m_dragFileExt);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSWindow *)
|
- (NSWindow *)draggingDestinationWindow
|
||||||
draggingDestinationWindow
|
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDragOperation)
|
- (NSDragOperation)draggingSourceOperationMask
|
||||||
draggingSourceOperationMask
|
|
||||||
{
|
{
|
||||||
return NSDragOperationCopy;
|
return NSDragOperationCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPoint)draggingLocation
|
- (NSPoint)draggingLocation
|
||||||
{
|
{
|
||||||
NSPoint point;
|
NSPoint point;
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPoint)draggedImageLocation
|
- (NSPoint)draggedImageLocation
|
||||||
{
|
{
|
||||||
NSPoint point;
|
NSPoint point;
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSImage *)draggedImage
|
- (NSImage *)draggedImage
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPasteboard *)draggingPasteboard
|
- (NSPasteboard *)draggingPasteboard
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)draggingSource
|
- (id)draggingSource
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger)draggingSequenceNumber
|
- (NSInteger)draggingSequenceNumber
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)slideDraggedImageTo:(NSPoint)screenPoint
|
- (void)slideDraggedImageTo:(NSPoint)screenPoint
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
|
- (NSDragOperation)draggingSession:(NSDraggingSession *)session
|
||||||
|
sourceOperationMaskForDraggingContext:(NSDraggingContext)context
|
||||||
{
|
{
|
||||||
return NSDragOperationCopy;
|
return NSDragOperationCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)enumerateDraggingItemsWithOptions:(NSDraggingItemEnumerationOptions)enumOpts forView:(NSView *)view classes:(NSArray *)classArray searchOptions:(NSDictionary *)searchOptions usingBlock:(void (^)(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop))block
|
- (void)enumerateDraggingItemsWithOptions:(NSDraggingItemEnumerationOptions)enumOpts
|
||||||
|
forView:(NSView *)view
|
||||||
|
classes:(NSArray *)classArray
|
||||||
|
searchOptions:(NSDictionary *)searchOptions
|
||||||
|
usingBlock:(void (^)(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop))block
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,137 +22,142 @@
|
||||||
|
|
||||||
int convertKeyIDToNXKeyType(KeyID id)
|
int convertKeyIDToNXKeyType(KeyID id)
|
||||||
{
|
{
|
||||||
int type = -1;
|
int type = -1;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case kKeyAudioUp:
|
case kKeyAudioUp:
|
||||||
type = NX_KEYTYPE_SOUND_UP;
|
type = NX_KEYTYPE_SOUND_UP;
|
||||||
break;
|
break;
|
||||||
case kKeyAudioDown:
|
case kKeyAudioDown:
|
||||||
type = NX_KEYTYPE_SOUND_DOWN;
|
type = NX_KEYTYPE_SOUND_DOWN;
|
||||||
break;
|
break;
|
||||||
case kKeyBrightnessUp:
|
case kKeyBrightnessUp:
|
||||||
type = NX_KEYTYPE_BRIGHTNESS_UP;
|
type = NX_KEYTYPE_BRIGHTNESS_UP;
|
||||||
break;
|
break;
|
||||||
case kKeyBrightnessDown:
|
case kKeyBrightnessDown:
|
||||||
type = NX_KEYTYPE_BRIGHTNESS_DOWN;
|
type = NX_KEYTYPE_BRIGHTNESS_DOWN;
|
||||||
break;
|
break;
|
||||||
case kKeyAudioMute:
|
case kKeyAudioMute:
|
||||||
type = NX_KEYTYPE_MUTE;
|
type = NX_KEYTYPE_MUTE;
|
||||||
break;
|
break;
|
||||||
case kKeyEject:
|
case kKeyEject:
|
||||||
type = NX_KEYTYPE_EJECT;
|
type = NX_KEYTYPE_EJECT;
|
||||||
break;
|
break;
|
||||||
case kKeyAudioPlay:
|
case kKeyAudioPlay:
|
||||||
type = NX_KEYTYPE_PLAY;
|
type = NX_KEYTYPE_PLAY;
|
||||||
break;
|
break;
|
||||||
case kKeyAudioNext:
|
case kKeyAudioNext:
|
||||||
type = NX_KEYTYPE_NEXT;
|
type = NX_KEYTYPE_NEXT;
|
||||||
break;
|
break;
|
||||||
case kKeyAudioPrev:
|
case kKeyAudioPrev:
|
||||||
type = NX_KEYTYPE_PREVIOUS;
|
type = NX_KEYTYPE_PREVIOUS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static KeyID
|
static KeyID convertNXKeyTypeToKeyID(uint32_t const type)
|
||||||
convertNXKeyTypeToKeyID(uint32_t const type)
|
|
||||||
{
|
{
|
||||||
KeyID id = 0;
|
KeyID id = 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NX_KEYTYPE_SOUND_UP:
|
case NX_KEYTYPE_SOUND_UP:
|
||||||
id = kKeyAudioUp;
|
id = kKeyAudioUp;
|
||||||
break;
|
break;
|
||||||
case NX_KEYTYPE_SOUND_DOWN:
|
case NX_KEYTYPE_SOUND_DOWN:
|
||||||
id = kKeyAudioDown;
|
id = kKeyAudioDown;
|
||||||
break;
|
break;
|
||||||
case NX_KEYTYPE_MUTE:
|
case NX_KEYTYPE_MUTE:
|
||||||
id = kKeyAudioMute;
|
id = kKeyAudioMute;
|
||||||
break;
|
break;
|
||||||
case NX_KEYTYPE_EJECT:
|
case NX_KEYTYPE_EJECT:
|
||||||
id = kKeyEject;
|
id = kKeyEject;
|
||||||
break;
|
break;
|
||||||
case NX_KEYTYPE_PLAY:
|
case NX_KEYTYPE_PLAY:
|
||||||
id = kKeyAudioPlay;
|
id = kKeyAudioPlay;
|
||||||
break;
|
break;
|
||||||
case NX_KEYTYPE_FAST:
|
case NX_KEYTYPE_FAST:
|
||||||
case NX_KEYTYPE_NEXT:
|
case NX_KEYTYPE_NEXT:
|
||||||
id = kKeyAudioNext;
|
id = kKeyAudioNext;
|
||||||
break;
|
break;
|
||||||
case NX_KEYTYPE_REWIND:
|
case NX_KEYTYPE_REWIND:
|
||||||
case NX_KEYTYPE_PREVIOUS:
|
case NX_KEYTYPE_PREVIOUS:
|
||||||
id = kKeyAudioPrev;
|
id = kKeyAudioPrev;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool isMediaKeyEvent(CGEventRef event)
|
||||||
isMediaKeyEvent(CGEventRef event) {
|
{
|
||||||
NSEvent* nsEvent = nil;
|
NSEvent *nsEvent = nil;
|
||||||
@try {
|
@try {
|
||||||
nsEvent = [NSEvent eventWithCGEvent: event];
|
nsEvent = [NSEvent eventWithCGEvent:event];
|
||||||
if ([nsEvent subtype] != 8) {
|
if ([nsEvent subtype] != 8) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint32_t const nxKeyId = ([nsEvent data1] & 0xFFFF0000) >> 16;
|
uint32_t const nxKeyId = ([nsEvent data1] & 0xFFFF0000) >> 16;
|
||||||
if (convertNXKeyTypeToKeyID (nxKeyId)) {
|
if (convertNXKeyTypeToKeyID(nxKeyId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} @catch (NSException* e) {
|
} @catch (NSException *e) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool getMediaKeyEventInfo(CGEventRef event, KeyID *const keyId, bool *const down, bool *const isRepeat)
|
||||||
getMediaKeyEventInfo(CGEventRef event, KeyID* const keyId,
|
{
|
||||||
bool* const down, bool* const isRepeat) {
|
NSEvent *nsEvent = nil;
|
||||||
NSEvent* nsEvent = nil;
|
@try {
|
||||||
@try {
|
nsEvent = [NSEvent eventWithCGEvent:event];
|
||||||
nsEvent = [NSEvent eventWithCGEvent: event];
|
} @catch (NSException *e) {
|
||||||
} @catch (NSException* e) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
if (keyId) {
|
||||||
if (keyId) {
|
*keyId = convertNXKeyTypeToKeyID(([nsEvent data1] & 0xFFFF0000) >> 16);
|
||||||
*keyId = convertNXKeyTypeToKeyID (([nsEvent data1] & 0xFFFF0000) >> 16);
|
}
|
||||||
}
|
if (down) {
|
||||||
if (down) {
|
*down = !([nsEvent data1] & 0x100);
|
||||||
*down = !([nsEvent data1] & 0x100);
|
}
|
||||||
}
|
if (isRepeat) {
|
||||||
if (isRepeat) {
|
*isRepeat = [nsEvent data1] & 0x1;
|
||||||
*isRepeat = [nsEvent data1] & 0x1;
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool fakeNativeMediaKey(KeyID id)
|
||||||
fakeNativeMediaKey(KeyID id)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
NSEvent* downRef = [NSEvent otherEventWithType:NSSystemDefined
|
NSEvent *downRef = [NSEvent otherEventWithType:NSSystemDefined
|
||||||
location: NSMakePoint(0, 0) modifierFlags:0xa00
|
location:NSMakePoint(0, 0)
|
||||||
timestamp:0 windowNumber:0 context:0 subtype:8
|
modifierFlags:0xa00
|
||||||
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8)
|
timestamp:0
|
||||||
data2:-1];
|
windowNumber:0
|
||||||
CGEventRef downEvent = [downRef CGEvent];
|
context:0
|
||||||
|
subtype:8
|
||||||
|
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8)
|
||||||
|
data2:-1];
|
||||||
|
CGEventRef downEvent = [downRef CGEvent];
|
||||||
|
|
||||||
NSEvent* upRef = [NSEvent otherEventWithType:NSSystemDefined
|
NSEvent *upRef = [NSEvent otherEventWithType:NSSystemDefined
|
||||||
location: NSMakePoint(0, 0) modifierFlags:0xa00
|
location:NSMakePoint(0, 0)
|
||||||
timestamp:0 windowNumber:0 context:0 subtype:8
|
modifierFlags:0xa00
|
||||||
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8)
|
timestamp:0
|
||||||
data2:-1];
|
windowNumber:0
|
||||||
CGEventRef upEvent = [upRef CGEvent];
|
context:0
|
||||||
|
subtype:8
|
||||||
|
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8)
|
||||||
|
data2:-1];
|
||||||
|
CGEventRef upEvent = [upRef CGEvent];
|
||||||
|
|
||||||
CGEventPost(0, downEvent);
|
CGEventPost(0, downEvent);
|
||||||
CGEventPost(0, upEvent);
|
CGEventPost(0, upEvent);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,27 +14,26 @@
|
||||||
|
|
||||||
#import "platform/OSXPasteboardPeeker.h"
|
#import "platform/OSXPasteboardPeeker.h"
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <CoreData/CoreData.h>
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import <CoreData/CoreData.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
|
||||||
CFStringRef
|
CFStringRef getDraggedFileURL()
|
||||||
getDraggedFileURL()
|
|
||||||
{
|
{
|
||||||
NSString* pbName = NSDragPboard;
|
NSString *pbName = NSDragPboard;
|
||||||
NSPasteboard* pboard = [NSPasteboard pasteboardWithName:pbName];
|
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:pbName];
|
||||||
|
|
||||||
NSMutableString* string;
|
NSMutableString *string;
|
||||||
string = [[NSMutableString alloc] initWithCapacity:0];
|
string = [[NSMutableString alloc] initWithCapacity:0];
|
||||||
|
|
||||||
NSArray* files = [pboard propertyListForType:NSFilenamesPboardType];
|
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
|
||||||
for (id file in files) {
|
for (id file in files) {
|
||||||
[string appendString: (NSString*)file];
|
[string appendString:(NSString *)file];
|
||||||
[string appendString: @"\0"];
|
[string appendString:@"\0"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CFStringRef)string;
|
return (CFStringRef)string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -26,58 +26,49 @@
|
||||||
// teach them about it.
|
// teach them about it.
|
||||||
//
|
//
|
||||||
|
|
||||||
void*
|
void *screenSaverUtilCreatePool()
|
||||||
screenSaverUtilCreatePool()
|
|
||||||
{
|
{
|
||||||
return [[NSAutoreleasePool alloc] init];
|
return [[NSAutoreleasePool alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void screenSaverUtilReleasePool(void *pool)
|
||||||
screenSaverUtilReleasePool(void* pool)
|
|
||||||
{
|
{
|
||||||
[(NSAutoreleasePool*)pool release];
|
[(NSAutoreleasePool *)pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void *screenSaverUtilCreateController()
|
||||||
screenSaverUtilCreateController()
|
|
||||||
{
|
{
|
||||||
return [[ScreenSaverController controller] retain];
|
return [[ScreenSaverController controller] retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void screenSaverUtilReleaseController(void *controller)
|
||||||
screenSaverUtilReleaseController(void* controller)
|
|
||||||
{
|
{
|
||||||
[(ScreenSaverController*)controller release];
|
[(ScreenSaverController *)controller release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void screenSaverUtilEnable(void *controller)
|
||||||
screenSaverUtilEnable(void* controller)
|
|
||||||
{
|
{
|
||||||
[(ScreenSaverController*)controller setScreenSaverCanRun:YES];
|
[(ScreenSaverController *)controller setScreenSaverCanRun:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void screenSaverUtilDisable(void *controller)
|
||||||
screenSaverUtilDisable(void* controller)
|
|
||||||
{
|
{
|
||||||
[(ScreenSaverController*)controller setScreenSaverCanRun:NO];
|
[(ScreenSaverController *)controller setScreenSaverCanRun:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void screenSaverUtilActivate(void *controller)
|
||||||
screenSaverUtilActivate(void* controller)
|
|
||||||
{
|
{
|
||||||
[(ScreenSaverController*)controller setScreenSaverCanRun:YES];
|
[(ScreenSaverController *)controller setScreenSaverCanRun:YES];
|
||||||
[(ScreenSaverController*)controller screenSaverStartNow];
|
[(ScreenSaverController *)controller screenSaverStartNow];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void screenSaverUtilDeactivate(void *controller, int isEnabled)
|
||||||
screenSaverUtilDeactivate(void* controller, int isEnabled)
|
|
||||||
{
|
{
|
||||||
[(ScreenSaverController*)controller screenSaverStopNow];
|
[(ScreenSaverController *)controller screenSaverStopNow];
|
||||||
[(ScreenSaverController*)controller setScreenSaverCanRun:isEnabled];
|
[(ScreenSaverController *)controller setScreenSaverCanRun:isEnabled];
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int screenSaverUtilIsActive(void *controller)
|
||||||
screenSaverUtilIsActive(void* controller)
|
|
||||||
{
|
{
|
||||||
return [(ScreenSaverController*)controller screenSaverIsRunning];
|
return [(ScreenSaverController *)controller screenSaverIsRunning];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue