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