This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 177712

Summary: [focus stealing] please stop the focus stealing
Product: platform Reporter: matusdekanek <matusdekanek>
Component: Window SystemAssignee: Martin Entlicher <mentlicher>
Status: REOPENED ---    
Severity: normal CC: anebuzelsky, js.developer.undefined, pbelbin
Priority: P2 Keywords: 8.1_WAIVER_APPROVED
Version: 8.0.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description matusdekanek 2009-11-27 02:27:34 UTC
according to these links
http://www.codinghorror.com/blog/archives/001011.html
http://brainstorm.ubuntu.com/idea/400/
(and many more, just google "stealing window focus" )
there are many people who hate when the window focus is stolen by another application, me included. Starting the IDE steals the focus not just one time, but twice (splash and main window). Please disable it.

And sorry I did not post it earlier, I was not researching about this before now...
Comment 1 Peter Pis 2009-11-27 02:47:09 UTC
Reassigning.
Comment 2 Rogerborg 2010-07-20 11:08:41 UTC
100% agree. This is currently raised as an enhancement, but I'd argue that it's a design defect.

If your primary task is developing the NetBeans IDE then this may not appear to be an issue, but for anyone multitasking, it most certainly is.

It's particularly significant since during time required to start the IDE or begin debugging, I have often switched to working in another application in order to remain productive.  It's intensely aggravating to have focus stolen back to the NetBeans main code window several seconds later.

I'm sure whomever implemented this meant to be helpful, but it's simply not good behaviour to move focus, and especially jarring to steal it from other applications. I'll come back to NetBeans when I'm good and ready to deal with it - in the mean time, please don't assume that I've got nothing better to do.

Thanks for your attention.
Comment 3 coffbr01 2011-10-25 14:23:00 UTC
Focus is also stolen when files are changed by another application (SCM tool in my case). Almost annoying enough to work on in my free time.
Comment 4 js.developer.undefined 2012-12-12 03:20:35 UTC
This is highly annoying to me as well.  Please make it stop!  It seems like it would be a simple change too.  If the nb devs prefer this, then perhaps they can make it a configuration param that is set to false (don't steal) but default.  That way they can override during development for easier work on the platform.  But for the rest of us, this is REALLY undesired behavior.
Comment 5 reimius 2015-02-05 16:38:12 UTC
Is someone looking into this?  It would be great to have a setting option to completely turn off focus stealing, even from within netbeans.  Whenever I finish an SVN check, it will steal focus from the coding I'm doing to show me the log output.  This is so frustrating.

This issue is still present in 8.0.1
Comment 6 Rogerborg 2015-02-05 17:42:35 UTC
I've finally found an option for disabling this behaviour; it's called IntelliJ.
Comment 7 Alexander.Watzinger 2015-06-09 12:59:42 UTC
This issue is still present in 8.0.2

It happens multiple times at start-up which takes a while. This means it steals the focus even if you can't use netbeans because it is still starting.

Very annoying indeed.
Comment 8 pbelbin 2015-06-17 22:25:06 UTC
I am using 8.0.2 and find that the focus stealing that takes place during builds is very annoying and just 'not right'.

please fix this issue.

this is not an enhancement request, this is actually a defect!!!
Comment 9 Theofanis Oikonomou 2015-09-29 08:34:15 UTC
Initial efforts to resolve this were unsuccessful. This makes fixing this out of scope for 8.1 release. On another note you can start ide with --nosplash that will not show any splash screen when starting and thus there will at least be no focus stealing while start-up. Thank you
Comment 10 Jiri Kovalsky 2015-09-30 13:29:59 UTC
Bug waiver for 8.1 approved.
Comment 11 Martin Entlicher 2016-07-20 14:27:33 UTC
The current behavior is the Java's default one.
Comment 12 Martin Entlicher 2016-08-10 09:49:53 UTC
Fixed by changeset:   299972:c1c6384a51a8
http://hg.netbeans.org/core-main/rev/c1c6384a51a8
Comment 13 Martin Entlicher 2016-08-10 14:03:11 UTC
Unfortunately, when showing a window, Java decides to raise it to the top of the windows stack. This behavior can not be changed, it's hard-coded in XWindowPeer.xSetVisible() where it calls XlibWrapper.XMapRaised(). And that raises the window.

Therefore, unless the window/dialog is already visible, we should also request a focus. Having a raised window without focus seems silly to me.

Due to that unfortunate behavior of Java GUI we need to revise this fix...
Comment 14 Martin Entlicher 2016-08-10 14:27:39 UTC
FYI: I've submitted: https://bugs.openjdk.java.net/browse/JDK-8163591
Comment 15 Quality Engineering 2016-08-11 01:56:33 UTC
Integrated into 'main-silver', will be available in build *201608110002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/c1c6384a51a8
User: mentlicher@netbeans.org
Log: #177712: Do not steal focus.
Comment 16 Martin Entlicher 2016-08-11 06:08:49 UTC
The default behavior is more similar to the original one now:
changeset:   299996:d66cd4e5d435
http://hg.netbeans.org/core-main/rev/d66cd4e5d435

By default, new windows both move to the front and grab the focus.
However, the exception dialog does not grab the focus when already opened and new exceptions are thrown - this was annoying.

The default focus behavior can be altered by -J-Dnetbeans.winsys.auto_focus property. When -J-Dnetbeans.winsys.auto_focus=false, then new windows/dialogs will not grab focus. When -J-Dnetbeans.winsys.auto_focus=true, old behavior is restored, including grabbing focus on exceptions.

In the past, Java apps used to blink it's item on the task bar instead of forcibly fronting and grabbing the focus. That was nice, but that behavior seems to be gone... :-(

Use -J-Dnetbeans.winsys.auto_focus=<true/false> as appropriate.
Comment 17 Quality Engineering 2016-08-12 02:50:00 UTC
Integrated into 'main-silver', will be available in build *201608120002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/d66cd4e5d435
User: mentlicher@netbeans.org
Log: #177712: Due to JDK-8163591 change the default, new windows both move to the front and grab the focus.
Comment 18 mopsyd 2018-02-24 01:05:45 UTC
This can be fixed easily at least for OSX if the development team adds the following to their info.plist:

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

This should be placed next to the dict key.

This MUST be done by the actual release build to work correctly. It can also be done by individuals on their own machine, but in that case it breaks the software signature and interferes with firewall interaction significantly, which becomes significantly more cumbersome than the window stealing behavior very quickly.
Comment 19 Zom-B 2018-03-20 10:24:47 UTC
Like coffbr says Focus is also stolen when files are changed by another application.

Not only that, the 'focused' Netbeans stays BELOW my previous application until I hit certain hotkeys that Netbeans responds to and only then it will pop to the front. If I just keep typing, press tab, alt, backspace, delete, etc. the NB window doesn't pop to the front but still performs these actions.