OSX: fix cursor visibility for sharing service
This commit is contained in:
@@ -50,7 +50,7 @@ std::mutex task_mutex;
|
|||||||
if (cursor_visible == visible)
|
if (cursor_visible == visible)
|
||||||
return;
|
return;
|
||||||
cursor_visible = visible;
|
cursor_visible = visible;
|
||||||
if (cursor_inside)
|
if (cursor_inside && !cursor_ignore)
|
||||||
visible ? [NSCursor unhide] : [NSCursor hide];
|
visible ? [NSCursor unhide] : [NSCursor hide];
|
||||||
}
|
}
|
||||||
- (std::string)pick_file:(NSArray<NSString*>*)types
|
- (std::string)pick_file:(NSArray<NSString*>*)types
|
||||||
@@ -63,7 +63,15 @@ std::mutex task_mutex;
|
|||||||
//NSArray* fileTypes = [NSArray arrayWithObjects:@"png", @"PNG", @"jpg", @"JPG", @"jpeg", nil];
|
//NSArray* fileTypes = [NSArray arrayWithObjects:@"png", @"PNG", @"jpg", @"JPG", @"jpeg", nil];
|
||||||
[panel setAllowedFileTypes:types];
|
[panel setAllowedFileTypes:types];
|
||||||
|
|
||||||
|
[self removeTrackingArea:trackingArea];
|
||||||
|
if (!cursor_visible)
|
||||||
|
[NSCursor unhide];
|
||||||
|
|
||||||
NSInteger clicked = [panel runModal];
|
NSInteger clicked = [panel runModal];
|
||||||
|
|
||||||
|
[self addTrackingArea:trackingArea];
|
||||||
|
if (!cursor_visible)
|
||||||
|
[NSCursor hide];
|
||||||
|
|
||||||
std::string ret;
|
std::string ret;
|
||||||
if (clicked == NSFileHandlingPanelOKButton)
|
if (clicked == NSFileHandlingPanelOKButton)
|
||||||
@@ -83,8 +91,16 @@ std::mutex task_mutex;
|
|||||||
[panel setCanChooseDirectories:YES];
|
[panel setCanChooseDirectories:YES];
|
||||||
[panel setAllowsMultipleSelection:NO]; // yes if more than one dir is allowed
|
[panel setAllowsMultipleSelection:NO]; // yes if more than one dir is allowed
|
||||||
|
|
||||||
|
[self removeTrackingArea:trackingArea];
|
||||||
|
if (!cursor_visible)
|
||||||
|
[NSCursor unhide];
|
||||||
|
|
||||||
NSInteger clicked = [panel runModal];
|
NSInteger clicked = [panel runModal];
|
||||||
|
|
||||||
|
[self addTrackingArea:trackingArea];
|
||||||
|
if (!cursor_visible)
|
||||||
|
[NSCursor hide];
|
||||||
|
|
||||||
std::string ret;
|
std::string ret;
|
||||||
if (clicked == NSFileHandlingPanelOKButton)
|
if (clicked == NSFileHandlingPanelOKButton)
|
||||||
{
|
{
|
||||||
@@ -100,6 +116,12 @@ std::mutex task_mutex;
|
|||||||
{
|
{
|
||||||
NSURL *url = [NSURL fileURLWithPath:file_path];
|
NSURL *url = [NSURL fileURLWithPath:file_path];
|
||||||
NSArray *objectsToShare = @[url];
|
NSArray *objectsToShare = @[url];
|
||||||
|
|
||||||
|
[self removeTrackingArea:trackingArea];
|
||||||
|
cursor_ignore = true;
|
||||||
|
if (!cursor_visible)
|
||||||
|
[NSCursor unhide];
|
||||||
|
|
||||||
[airdrop_service performWithItems:objectsToShare];
|
[airdrop_service performWithItems:objectsToShare];
|
||||||
}
|
}
|
||||||
- (NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope
|
- (NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope
|
||||||
@@ -110,6 +132,23 @@ std::mutex task_mutex;
|
|||||||
{
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
-(void)sharingService:(NSSharingService *)sharingService willShareItems:(NSArray *)items
|
||||||
|
{
|
||||||
|
}
|
||||||
|
- (void)sharingService:(NSSharingService *)sharingService didFailToShareItems:(NSArray *)items error:(NSError *)error
|
||||||
|
{
|
||||||
|
[self addTrackingArea:trackingArea];
|
||||||
|
cursor_ignore = false;
|
||||||
|
if (!cursor_visible)
|
||||||
|
[NSCursor hide];
|
||||||
|
}
|
||||||
|
- (void)sharingService:(NSSharingService *)sharingService didShareItems:(NSArray *)items
|
||||||
|
{
|
||||||
|
[self addTrackingArea:trackingArea];
|
||||||
|
cursor_ignore = false;
|
||||||
|
if (!cursor_visible)
|
||||||
|
[NSCursor hide];
|
||||||
|
}
|
||||||
- (instancetype)initWithFrame:(NSRect)frameRect
|
- (instancetype)initWithFrame:(NSRect)frameRect
|
||||||
{
|
{
|
||||||
airdrop_service = [NSSharingService sharingServiceNamed:NSSharingServiceNameSendViaAirDrop];
|
airdrop_service = [NSSharingService sharingServiceNamed:NSSharingServiceNameSendViaAirDrop];
|
||||||
@@ -117,6 +156,7 @@ std::mutex task_mutex;
|
|||||||
gl_ready = false;
|
gl_ready = false;
|
||||||
cursor_visible = CGCursorIsVisible();
|
cursor_visible = CGCursorIsVisible();
|
||||||
cursor_inside = false;
|
cursor_inside = false;
|
||||||
|
cursor_ignore = false;
|
||||||
NSOpenGLPixelFormatAttribute attrs[] =
|
NSOpenGLPixelFormatAttribute attrs[] =
|
||||||
{
|
{
|
||||||
NSOpenGLPFADoubleBuffer,
|
NSOpenGLPFADoubleBuffer,
|
||||||
@@ -135,10 +175,7 @@ std::mutex task_mutex;
|
|||||||
[self setPixelFormat:pf];
|
[self setPixelFormat:pf];
|
||||||
[self setOpenGLContext:context];
|
[self setOpenGLContext:context];
|
||||||
|
|
||||||
trackingArea = [[NSTrackingArea alloc] initWithRect:frameRect
|
[self updateTrackingAreas];
|
||||||
options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow )
|
|
||||||
owner:self userInfo:nil];
|
|
||||||
[self addTrackingArea:trackingArea];
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
- (void)prepareOpenGL
|
- (void)prepareOpenGL
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
bool gl_ready;
|
bool gl_ready;
|
||||||
bool cursor_visible;
|
bool cursor_visible;
|
||||||
bool cursor_inside;
|
bool cursor_inside;
|
||||||
|
bool cursor_ignore;
|
||||||
NSTrackingArea* trackingArea;
|
NSTrackingArea* trackingArea;
|
||||||
@public NSString* file2open;
|
@public NSString* file2open;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user