Community
Participate
Working Groups
This happens even with the simplest snippets such as this: ---------------- public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } ---------------- Steps: 1) Start snippet 2) Try to click menu 3) Switch to some other app and back 4) Menu is now responsive. I also managed to reproduce it with a simple native snippet: ---------------- #import <Cocoa/Cocoa.h> @interface AppDelegate : NSObject<NSApplicationDelegate> { } @end @implementation AppDelegate : NSObject -(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)app { return YES; } @end int main () { NSApplication* app = [NSApplication sharedApplication]; // Appliaction should close when last window is closed AppDelegate* appDelegate = [[AppDelegate alloc] init]; [app setDelegate:appDelegate]; // Programs without application bundles and Info.plist files don't get a menubar and can't be brought to the front without this [app setActivationPolicy:NSApplicationActivationPolicyRegular]; NSRect windowRect = NSMakeRect(0, 0, 200, 200); id window = [[NSWindow alloc] initWithContentRect: windowRect styleMask: NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable backing: NSBackingStoreBuffered defer:NO ]; [window setTitle:[[NSProcessInfo processInfo] processName]]; [window makeKeyAndOrderFront:nil]; [app run]; return 0; } ---------------- Compile it with: clang -framework snippet.m -o snippet I also found reports in other places: https://bugs.openjdk.java.net/browse/JDK-8233678 http://www.androwish.org/index.html/info/3583d49f8642eac557517123d6f573ae106e6ce9 The latter uses `[NSApp deactivate]` + `[NSApp activateIgnoringOtherApps: YES]` as workaround.
I suspect that this may be related to non-bundled applications.
(In reply to Alexandr Miloslavskiy from comment #0) > http://www.androwish.org/index.html/info/ > 3583d49f8642eac557517123d6f573ae106e6ce9 > > The latter uses `[NSApp deactivate]` + `[NSApp activateIgnoringOtherApps: > YES]` as workaround. I'll try if this fixes the problem in SWT. *** This bug has been marked as a duplicate of bug 552063 ***
I've condensed this code into a Git repository: https://github.com/alblue/Bugger I've attempted to do the [NSApp deactivate]+[NSApp activateIgnoringOtherApps] combinations, but neither seems to work. I'll see if I can do something further to get it working with the snippet provided by Alexandr or report it to Apple.
What's interesting is that with a 'real' macOS app, if you run the app binary directly it does /not/ bring it to the front and give it focus, so you have to tap on it. If on the other hand you use 'open' to open the app, then macOS gives it the focus.