Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 438694

Summary: Prevent Eclipse from stealing focus on start
Product: [Eclipse Project] Platform Reporter: Martijn Dashorst <martijn.dashorst>
Component: RelengAssignee: Platform-Releng-Inbox <platform-releng-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: arunkumar.thondapu, christine, david_williams, mail, markus.kell.r
Version: 4.4   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Martijn Dashorst CLA 2014-07-02 04:38:01 EDT
Eclipse for Mac steals the focus when starting up from the active application. This is rather troublesome because when you are typing in another window, and Eclipse's select workspace dialog steals the focus you can inadvertently create workspaces all around your filesystem.

This is easily solved by adding the following two lines to the Info.plist file in the Eclipse.app package:

<key>LSBackgroundOnly</key>
<string>True</string>

This will prevent Eclipse from stealing focus and allow people to use their machines normally while waiting for Eclipse to boot.
Comment 1 Martijn Dashorst CLA 2014-07-02 04:39:47 EDT
This has been a problem in 4.3(.1/.2) as well
Comment 2 Paul Webster CLA 2014-07-02 11:34:51 EDT
*** Bug 438642 has been marked as a duplicate of this bug. ***
Comment 3 David Williams CLA 2014-07-05 14:05:47 EDT
This is a "Mac specific" solution. 

Arun (or others?), 
Is there something that could/should be done for other platforms too?
Comment 4 Christine CLA 2014-07-06 09:54:34 EDT
Funny coincidence that two bugs have been filed at about the same time for an issue that has been present for a fairly long time.
Comment 5 David Williams CLA 2014-08-16 15:29:26 EDT
Markus, you are frequent mac user, right? If so, wanted your perspective on this bug. 

I see no harm in trying it, BUT ... I do wonder if it would cause some ripple effects in Unit Tests (several assume "the workbench as focus" and not sure how to fix that in test framework). So, at a minimum, we could "try" in Mars stream, but if it starts to complicate unit tests, then back out the change until someone knows how to fix that aspect.
Comment 6 Markus Keller CLA 2014-08-18 09:35:37 EDT
(In reply to David Williams from comment #5)
> Markus, you are frequent mac user, right? If so, wanted your perspective on
> this bug.

I'm a private Mac user, and I do test/fix Eclipse on the Mac and Linux to ensure cross-platform consistency. However, I mainly develop on Windows.


https://developer.apple.com/library/ios/documentation/general/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/20001431-109268 doesn't sound like the Eclipse.app should set LSBackgroundOnly.

Note that this option has already been added and removed in the past:
https://bugs.eclipse.org/bugs/buglist.cgi?quicksearch=ALL+LSBackgroundOnly

I agree that the workspace chooser should not take focus on startup if the user switched to another app while Eclipse is starting. I'm not sure what the right solution is, but a global LSBackgroundOnly is probably not right.

-1 for "just trying it out" once again without further analysis. At least we have to be sure we don't break Shell#forceActive(), which is e.g. used by Debug to activate the debugging workbench window.
Comment 7 Markus Keller CLA 2014-08-18 18:58:07 EDT
I don't see the "focus stealing" when I launch the first Eclipse instance by opening Eclipse.app or the eclipse executable in the Finder/Dock.

But I see the problem when I launch an "Eclipse Application" launch configuration (with an empty workspace path) out of a running Eclipse.
Comment 8 Lars Vogel CLA 2019-11-27 07:40:06 EST
This bug hasn't had any activity in quite some time. Maybe the problem got
resolved, was a duplicate of something else, or became less pressing for some
reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it.
The information can be, for example, that the problem still occurs, that you
still want the feature, that more information is needed, or that the bug is
(for whatever reason) no longer relevant.

If the bug is still relevant, please remove the stalebug whiteboard tag.
Comment 9 Martijn Dashorst CLA 2020-03-23 09:20:46 EDT
Just had Eclipse stealing the focus while starting up again, so this issue is definitely not stale.