Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8264786: [macos] All Swing/AWT apps cause Allow Notifications prompt to appear when app is launched #3707

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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
@@ -68,11 +68,14 @@ - (id) initWithPeer:(jobject)thePeer {

view = [[AWTTrayIconView alloc] initWithTrayIcon:self];
[theItem setView:view];
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];

return self;
}

-(void) dealloc {
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil];

JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
(*env)->DeleteGlobalRef(env, peer);

@@ -167,6 +170,12 @@ -(void) deliverJavaMouseEvent: (NSEvent *) event {
(*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
@@ -26,7 +26,7 @@
#import "JNIUtilities.h"
#import <Cocoa/Cocoa.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 @@ - (id) init

- (void)dealloc
{
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil];

[fApplicationName release];
fApplicationName = nil;

@@ -158,15 +156,8 @@ - (void)finishLaunching
}

[super finishLaunching];

[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
}

- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
shouldPresentNotification:(NSUserNotification *)notification
{
return YES; // We always show notifications to the user
}

- (void) registerWithProcessManager
{