mirror of
https://github.com/openjdk/jdk16u.git
synced 2025-12-10 14:50:36 -06:00
8264786: [macos] All Swing/AWT apps cause Allow Notifications prompt to appear when app is launched
Reviewed-by: vkempik, mdoerr, mbaesken Backport-of: 020236cb9825bf4fa91a495a179623e3fcdc0149
This commit is contained in:
parent
6f948a7b02
commit
375be1710a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -42,7 +42,7 @@ extern "C" {
|
||||
/*
|
||||
* AWTTrayIcon
|
||||
*/
|
||||
@interface AWTTrayIcon : NSObject {
|
||||
@interface AWTTrayIcon : NSObject <NSUserNotificationCenterDelegate>{
|
||||
jobject peer;
|
||||
AWTTrayIconView *view;
|
||||
NSStatusItem *theItem;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -69,11 +69,14 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
|
||||
|
||||
view = [[AWTTrayIconView alloc] initWithTrayIcon:self];
|
||||
[theItem setView:view];
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) dealloc {
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
|
||||
JNFDeleteGlobalRef(env, peer);
|
||||
|
||||
@ -166,6 +169,12 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
|
||||
(*env)->DeleteLocalRef(env, jEvent);
|
||||
}
|
||||
|
||||
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
|
||||
shouldPresentNotification:(NSUserNotification *)notification
|
||||
{
|
||||
return YES; // We always show notifications to the user
|
||||
}
|
||||
|
||||
@end //AWTTrayIcon
|
||||
//================================================
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,7 +32,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
|
||||
JNIEXPORT @interface NSApplicationAWT : NSApplication <NSUserNotificationCenterDelegate> {
|
||||
JNIEXPORT @interface NSApplicationAWT : NSApplication {
|
||||
NSString *fApplicationName;
|
||||
NSWindow *eventTransparentWindow;
|
||||
NSTimeInterval dummyEventTimestamp;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -77,8 +77,6 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil];
|
||||
|
||||
[fApplicationName release];
|
||||
fApplicationName = nil;
|
||||
|
||||
@ -159,17 +157,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
[super finishLaunching];
|
||||
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
|
||||
|
||||
// inform any interested parties that the AWT has arrived and is pumping
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:JNFRunLoopDidStartNotification object:self];
|
||||
}
|
||||
|
||||
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
|
||||
shouldPresentNotification:(NSUserNotification *)notification
|
||||
{
|
||||
return YES; // We always show notifications to the user
|
||||
}
|
||||
|
||||
- (void) registerWithProcessManager
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user