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",
|
||||
"*.hpp",
|
||||
"*.cpp",
|
||||
"*.m",
|
||||
"*.mm",
|
||||
]
|
||||
|
||||
dirs = ["src"]
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@
|
|||
@property(strong) IBOutlet NSWindow *window;
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
{
|
||||
@implementation AppDelegate {
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
|
|
@ -17,18 +16,20 @@
|
|||
#endif
|
||||
}
|
||||
|
||||
-(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{
|
||||
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
|
||||
shouldPresentNotification:(NSUserNotification *)notification
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
#if OSX_DEPLOYMENT_TARGET >= 1014
|
||||
- (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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,8 +33,7 @@
|
|||
void requestOSXNotificationPermission()
|
||||
{
|
||||
#if OSX_DEPLOYMENT_TARGET >= 1014
|
||||
if (isOSXDevelopmentBuild())
|
||||
{
|
||||
if (isOSXDevelopmentBuild()) {
|
||||
qWarning("Not requesting notification permission in dev build");
|
||||
return;
|
||||
}
|
||||
|
|
@ -42,30 +41,29 @@ void requestOSXNotificationPermission()
|
|||
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]);
|
||||
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);
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
if (isOSXDevelopmentBuild()) {
|
||||
qWarning("Not showing notification in dev build");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -79,10 +77,13 @@ showOSXNotification(const QString& title, const QString& body)
|
|||
content.body = body.toNSString();
|
||||
|
||||
// Create the request object.
|
||||
UNNotificationRequest* request = [UNNotificationRequest
|
||||
requestWithIdentifier:@"SecureInput" content:content trigger:nil];
|
||||
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"SecureInput"
|
||||
content:content
|
||||
trigger:nil];
|
||||
|
||||
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
|
||||
[center
|
||||
addNotificationRequest:request
|
||||
withCompletionHandler:^(NSError *_Nullable error) {
|
||||
if (error != nil) {
|
||||
qWarning("Notification display request error: %s", [[NSString stringWithFormat:@"%@", error] UTF8String]);
|
||||
}
|
||||
|
|
@ -98,8 +99,7 @@ showOSXNotification(const QString& title, const QString& body)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
isOSXInterfaceStyleDark()
|
||||
bool isOSXInterfaceStyleDark()
|
||||
{
|
||||
// Implementation from http://stackoverflow.com/a/26472651
|
||||
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
|
||||
|
|
@ -107,8 +107,7 @@ isOSXInterfaceStyleDark()
|
|||
return (style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"]);
|
||||
}
|
||||
|
||||
IconsTheme
|
||||
getOSXIconsTheme()
|
||||
IconsTheme getOSXIconsTheme()
|
||||
{
|
||||
if (@available(macOS 11, *))
|
||||
return IconsTheme::ICONS_TEMPLATE;
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
#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"
|
||||
|
|
@ -27,15 +27,13 @@ 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)
|
||||
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 3, 3)
|
||||
styleMask:NSBorderlessWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
|
|
@ -56,14 +54,12 @@ runCocoaApp()
|
|||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
stopCocoaLoop()
|
||||
void stopCocoaLoop()
|
||||
{
|
||||
[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];
|
||||
|
||||
|
|
@ -88,15 +84,15 @@ fakeDragging(const char* str, int cursorX, int cursorY)
|
|||
[g_dragView setFileExt:g_ext];
|
||||
|
||||
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
CGEventRef down = CGEventCreateMouseEvent(source, kCGEventLeftMouseDown, CGPointMake(cursorX, cursorY), kCGMouseButtonLeft);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
@dynamic animatesToDestination;
|
||||
@dynamic numberOfValidItemsForDrop;
|
||||
|
||||
- (id)
|
||||
initWithFrame:(NSRect)frame
|
||||
- (id)initWithFrame:(NSRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
m_dropTarget = [[NSMutableString alloc] initWithCapacity:0];
|
||||
|
|
@ -37,25 +36,21 @@ initWithFrame:(NSRect)frame
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)
|
||||
drawRect:(NSRect)dirtyRect
|
||||
- (void)drawRect:(NSRect)dirtyRect
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL)
|
||||
acceptsFirstMouse:(NSEvent *)theEvent
|
||||
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|
||||
{
|
||||
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 = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
||||
dragPosition.x -= 16;
|
||||
dragPosition.y -= 16;
|
||||
|
|
@ -68,8 +63,7 @@ mouseDown:(NSEvent *)theEvent
|
|||
event:theEvent];
|
||||
}
|
||||
|
||||
- (NSArray*)
|
||||
namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
|
||||
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
|
||||
{
|
||||
[m_dropTarget setString:@""];
|
||||
[m_dropTarget appendString:dropDestination.path];
|
||||
|
|
@ -77,14 +71,12 @@ namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (NSDragOperation)
|
||||
draggingSourceOperationMaskForLocal:(BOOL)flag
|
||||
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag
|
||||
{
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
- (CFStringRef)
|
||||
getDropTarget
|
||||
- (CFStringRef)getDropTarget
|
||||
{
|
||||
NSMutableString *string;
|
||||
string = [[NSMutableString alloc] initWithCapacity:0];
|
||||
|
|
@ -92,14 +84,12 @@ getDropTarget
|
|||
return (CFStringRef)string;
|
||||
}
|
||||
|
||||
- (void)
|
||||
clearDropTarget
|
||||
- (void)clearDropTarget
|
||||
{
|
||||
[m_dropTarget setString:@""];
|
||||
}
|
||||
|
||||
- (void)
|
||||
setFileExt:(NSString*) ext
|
||||
- (void)setFileExt:(NSString *)ext
|
||||
{
|
||||
[ext retain];
|
||||
[m_dragFileExt release];
|
||||
|
|
@ -107,14 +97,12 @@ setFileExt:(NSString*) ext
|
|||
NSLog(@"drag file ext: %@", m_dragFileExt);
|
||||
}
|
||||
|
||||
- (NSWindow *)
|
||||
draggingDestinationWindow
|
||||
- (NSWindow *)draggingDestinationWindow
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSDragOperation)
|
||||
draggingSourceOperationMask
|
||||
- (NSDragOperation)draggingSourceOperationMask
|
||||
{
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
|
@ -155,12 +143,17 @@ draggingSourceOperationMask
|
|||
{
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
|
||||
- (NSDragOperation)draggingSession:(NSDraggingSession *)session
|
||||
sourceOperationMaskForDraggingContext:(NSDraggingContext)context
|
||||
{
|
||||
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
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ int convertKeyIDToNXKeyType(KeyID id)
|
|||
return type;
|
||||
}
|
||||
|
||||
static KeyID
|
||||
convertNXKeyTypeToKeyID(uint32_t const type)
|
||||
static KeyID convertNXKeyTypeToKeyID(uint32_t const type)
|
||||
{
|
||||
KeyID id = 0;
|
||||
|
||||
|
|
@ -95,8 +94,8 @@ convertNXKeyTypeToKeyID(uint32_t const type)
|
|||
return id;
|
||||
}
|
||||
|
||||
bool
|
||||
isMediaKeyEvent(CGEventRef event) {
|
||||
bool isMediaKeyEvent(CGEventRef event)
|
||||
{
|
||||
NSEvent *nsEvent = nil;
|
||||
@try {
|
||||
nsEvent = [NSEvent eventWithCGEvent:event];
|
||||
|
|
@ -112,9 +111,8 @@ isMediaKeyEvent(CGEventRef event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
getMediaKeyEventInfo(CGEventRef event, KeyID* const keyId,
|
||||
bool* const down, bool* const isRepeat) {
|
||||
bool getMediaKeyEventInfo(CGEventRef event, KeyID *const keyId, bool *const down, bool *const isRepeat)
|
||||
{
|
||||
NSEvent *nsEvent = nil;
|
||||
@try {
|
||||
nsEvent = [NSEvent eventWithCGEvent:event];
|
||||
|
|
@ -133,20 +131,27 @@ getMediaKeyEventInfo(CGEventRef event, KeyID* const keyId,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
fakeNativeMediaKey(KeyID id)
|
||||
bool fakeNativeMediaKey(KeyID id)
|
||||
{
|
||||
|
||||
NSEvent *downRef = [NSEvent otherEventWithType:NSSystemDefined
|
||||
location: NSMakePoint(0, 0) modifierFlags:0xa00
|
||||
timestamp:0 windowNumber:0 context:0 subtype:8
|
||||
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
|
||||
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];
|
||||
|
|
|
|||
|
|
@ -14,15 +14,14 @@
|
|||
|
||||
#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];
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -26,58 +26,49 @@
|
|||
// teach them about it.
|
||||
//
|
||||
|
||||
void*
|
||||
screenSaverUtilCreatePool()
|
||||
void *screenSaverUtilCreatePool()
|
||||
{
|
||||
return [[NSAutoreleasePool alloc] init];
|
||||
}
|
||||
|
||||
void
|
||||
screenSaverUtilReleasePool(void* pool)
|
||||
void screenSaverUtilReleasePool(void *pool)
|
||||
{
|
||||
[(NSAutoreleasePool *)pool release];
|
||||
}
|
||||
|
||||
void*
|
||||
screenSaverUtilCreateController()
|
||||
void *screenSaverUtilCreateController()
|
||||
{
|
||||
return [[ScreenSaverController controller] retain];
|
||||
}
|
||||
|
||||
void
|
||||
screenSaverUtilReleaseController(void* controller)
|
||||
void screenSaverUtilReleaseController(void *controller)
|
||||
{
|
||||
[(ScreenSaverController *)controller release];
|
||||
}
|
||||
|
||||
void
|
||||
screenSaverUtilEnable(void* controller)
|
||||
void screenSaverUtilEnable(void *controller)
|
||||
{
|
||||
[(ScreenSaverController *)controller setScreenSaverCanRun:YES];
|
||||
}
|
||||
|
||||
void
|
||||
screenSaverUtilDisable(void* controller)
|
||||
void screenSaverUtilDisable(void *controller)
|
||||
{
|
||||
[(ScreenSaverController *)controller setScreenSaverCanRun:NO];
|
||||
}
|
||||
|
||||
void
|
||||
screenSaverUtilActivate(void* controller)
|
||||
void screenSaverUtilActivate(void *controller)
|
||||
{
|
||||
[(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];
|
||||
}
|
||||
|
||||
int
|
||||
screenSaverUtilIsActive(void* controller)
|
||||
int screenSaverUtilIsActive(void *controller)
|
||||
{
|
||||
return [(ScreenSaverController *)controller screenSaverIsRunning];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue