Skip to content

Commit cfa1193

Browse files
8236685: [macOs] Remove obsolete file dialog subclasses
Reviewed-by: arapte, prr
1 parent f25e8cf commit cfa1193

File tree

3 files changed

+3
-121
lines changed

3 files changed

+3
-121
lines changed

modules/javafx.graphics/src/main/native-glass/mac/GlassApplication.h

-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,4 @@
6060

6161
+ (BOOL)syncRenderingDisabled;
6262

63-
+ (BOOL)isSandboxed;
64-
6563
@end

modules/javafx.graphics/src/main/native-glass/mac/GlassApplication.m

-38
Original file line numberDiff line numberDiff line change
@@ -755,44 +755,6 @@ + (BOOL)syncRenderingDisabled {
755755
return disableSyncRendering;
756756
}
757757

758-
+ (BOOL)isSandboxed
759-
{
760-
static int isSandboxed = -1;
761-
762-
if (isSandboxed == -1) {
763-
isSandboxed = 0;
764-
765-
NSBundle *mainBundle = [NSBundle mainBundle];
766-
NSURL *url = [mainBundle bundleURL];
767-
SecStaticCodeRef staticCodeRef = NULL;
768-
SecStaticCodeCreateWithPath((CFURLRef)url, kSecCSDefaultFlags, &staticCodeRef);
769-
770-
if (staticCodeRef) {
771-
// Check if the app is signed
772-
OSStatus res_signed = SecStaticCodeCheckValidityWithErrors(staticCodeRef, kSecCSBasicValidateOnly, NULL, NULL);
773-
if (res_signed == errSecSuccess) {
774-
// It is signed, now check if it's sandboxed
775-
SecRequirementRef sandboxRequirementRef = NULL;
776-
SecRequirementCreateWithString(CFSTR("entitlement[\"com.apple.security.app-sandbox\"] exists"), kSecCSDefaultFlags, &sandboxRequirementRef);
777-
778-
if (sandboxRequirementRef) {
779-
OSStatus res_sandboxed = SecStaticCodeCheckValidityWithErrors(staticCodeRef, kSecCSBasicValidateOnly, sandboxRequirementRef, NULL);
780-
if (res_sandboxed == errSecSuccess) {
781-
// Yep, sandboxed
782-
isSandboxed = 1;
783-
}
784-
785-
CFRelease(sandboxRequirementRef);
786-
}
787-
}
788-
789-
CFRelease(staticCodeRef);
790-
}
791-
}
792-
793-
return isSandboxed == 1 ? YES : NO;
794-
}
795-
796758
@end
797759

798760
#pragma mark --- JNI

modules/javafx.graphics/src/main/native-glass/mac/GlassDialogs.m

+3-81
Original file line numberDiff line numberDiff line change
@@ -38,84 +38,6 @@
3838
#define LOG(MSG, ...) GLASS_LOG(MSG, ## __VA_ARGS__);
3939
#endif
4040

41-
static BOOL doPerformKeyEquivalent(NSEvent* theEvent, NSWindow* panel)
42-
{
43-
NSResponder* responder = [panel firstResponder];
44-
if ([responder isKindOfClass:[NSText class]])
45-
{
46-
NSText* text = (NSText*)responder;
47-
if ([theEvent type] == NSKeyDown
48-
&& ([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask)
49-
{
50-
NSRange range = [text selectedRange];
51-
BOOL hasSelectedText = range.length > 0;
52-
if ([theEvent keyCode] == 7 && hasSelectedText) // Cmd + X - Cut
53-
{
54-
[text cut:panel];
55-
return true;
56-
}
57-
if ([theEvent keyCode] == 8 && hasSelectedText) // Cmd + C - Copy
58-
{
59-
[text copy:panel];
60-
return true;
61-
}
62-
if ([theEvent keyCode] == 9) // Cmd + V - Paste
63-
{
64-
[text paste:panel];
65-
return true;
66-
}
67-
}
68-
}
69-
return false;
70-
}
71-
72-
/*
73-
* Function to determine whether or not to use raw NSPanel classes
74-
* (either NSSavePanel or NSOpenPanel).
75-
*
76-
* Return: YES if we need to use the raw NSPanel classes; NO if we
77-
* can use the Glass subclasses
78-
*/
79-
static BOOL useNSPanel()
80-
{
81-
// As of macOS 10.15 all file dialogs are out of process, so we
82-
// effectively can't subclass them.
83-
if (@available(macOS 10.15, *)) {
84-
return YES;
85-
} else {
86-
return [GlassApplication isSandboxed];
87-
}
88-
}
89-
90-
@interface GlassSavePanel : NSSavePanel
91-
@end
92-
93-
@implementation GlassSavePanel
94-
95-
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
96-
{
97-
if (doPerformKeyEquivalent(theEvent, self)) {
98-
return true;
99-
}
100-
return [super performKeyEquivalent:theEvent];
101-
}
102-
@end
103-
104-
@interface GlassOpenPanel : NSOpenPanel
105-
@end
106-
107-
@implementation GlassOpenPanel
108-
109-
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
110-
{
111-
if (doPerformKeyEquivalent(theEvent, self)) {
112-
return true;
113-
}
114-
return [super performKeyEquivalent:theEvent];
115-
}
116-
@end
117-
118-
11941
#pragma mark --- Dispatcher
12042

12143
@interface DialogDispatcher : NSObject
@@ -503,7 +425,7 @@ static jobject convertNSURLtoFile(JNIEnv *env, NSURL *url)
503425
GLASS_ASSERT_MAIN_JAVA_THREAD(env);
504426
GLASS_POOL_ENTER;
505427
{
506-
NSOpenPanel *panel = useNSPanel() ? [NSOpenPanel openPanel] : [GlassOpenPanel openPanel];
428+
NSOpenPanel *panel = [NSOpenPanel openPanel];
507429
[panel setAllowsMultipleSelection:(jMultipleMode==JNI_TRUE)];
508430
[panel setTitle:[GlassHelper nsStringWithJavaString:jTitle withEnv:env]];
509431
NSString *folder = [GlassHelper nsStringWithJavaString:jFolder withEnv:env];
@@ -579,7 +501,7 @@ static jobject convertNSURLtoFile(JNIEnv *env, NSURL *url)
579501
GLASS_ASSERT_MAIN_JAVA_THREAD(env);
580502
GLASS_POOL_ENTER;
581503
{
582-
NSSavePanel *panel = useNSPanel() ? [NSSavePanel savePanel] : [GlassSavePanel savePanel];
504+
NSSavePanel *panel = [NSSavePanel savePanel];
583505
[panel setTitle:[GlassHelper nsStringWithJavaString:jTitle withEnv:env]];
584506
NSString *folder = [GlassHelper nsStringWithJavaString:jFolder withEnv:env];
585507
if ([folder length] > 0)
@@ -651,7 +573,7 @@ static jobject convertNSURLtoFile(JNIEnv *env, NSURL *url)
651573
GLASS_ASSERT_MAIN_JAVA_THREAD(env);
652574
GLASS_POOL_ENTER;
653575
{
654-
NSOpenPanel *panel = useNSPanel() ? [NSOpenPanel openPanel] : [GlassOpenPanel openPanel];
576+
NSOpenPanel *panel = [NSOpenPanel openPanel];
655577
[panel setTitle:[GlassHelper nsStringWithJavaString:jTitle withEnv:env]];
656578
NSString *folder = [GlassHelper nsStringWithJavaString:jFolder withEnv:env];
657579
if ([folder length] > 0)

0 commit comments

Comments
 (0)