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 197349 - Focus steal of NetBeans if opened file deleted
Summary: Focus steal of NetBeans if opened file deleted
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 7.0
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-02 03:26 UTC by speedogoo
Modified: 2011-12-13 10:35 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE profiling during focus stealing event (31.50 KB, application/octet-stream)
2011-12-06 19:57 UTC, daveistooshort
Details

Note You need to log in before you can comment on or make changes to this bug.
Description speedogoo 2011-04-02 03:26:16 UTC
Suppose I've opened a a file inside NetBeans. Now I switch to a terminal window and delete the file. (In my case, I "hg qpop" a patch)

Old behavior of NetBeans:

Nothing looks happened. When I switch my focus back to NetBeans, the opened file automatically closes itself.

Current behavior:

As soon as the file is deleted. NetBeans steals the focus, and the opened file closes itself.

Stealing focus is always a bad thing.
Comment 1 Jaroslav Tulach 2011-04-06 13:08:43 UTC
I am running Kubuntu 10.10. I did:

$ echo >X
$ netbeans X
$ rm X

the file X indeed closes automatically in NetBeans 7.0. However I see no focus stealing.
Comment 2 speedogoo 2011-04-08 08:47:25 UTC
I'm on Ubuntu 10.04.

Some more experiments: it seems the focus stealing happens when the file is inside the current opened project. If I open an independent file, it's fine.

Also, it seems on my system auto close and focus stealing always happen at the same time. That is to say, when an independent file is removed, auto close does not happen immediately. Only when I manually switch my focus to NetBeans, the file closes itself.

(In reply to comment #1)
> I am running Kubuntu 10.10. I did:
> 
> $ echo >X
> $ netbeans X
> $ rm X
> 
> the file X indeed closes automatically in NetBeans 7.0. However I see no focus
> stealing.
Comment 3 Jaroslav Tulach 2011-08-01 07:27:01 UTC
As far as I can tell, it is not happing in 100% of cases. I've seen the behavior once, but right now, when I want to investigate who is stealing the focus, I can't reproduce.
Comment 4 daveistooshort 2011-10-18 20:41:18 UTC
I seem to be able to reproduce this every time. It typically happens when I use a terminal to switch my git branch (inevitably removing some new file I had in the branch I was working on), which is aggravating as I end up typing into a netbeans window I cannot see on some other desktop workspace.

But to create a simple example that I can reproduce simply I do this:

General setup is a gnome terminal on one desktop workspace with netbeans open on a different desktop workspace, netbeans is setup to include all files under src/ in the current project and other source files are already open for editing

  $ gvim src/com/Foo.java

write some random text in the file and save it.
open the file in netbeans
return to the terminal

  $ rm src/com/Foo.java

now wait a second, and you should notice the terminal lose keyboard focus. If you start typing it will go into one of the other open source files in the netbeans project.

Other potentially relevant info:
I use focus follows mouse (but not auto raise), I'm running Ubuntu 11.04 64bit. And here's some stuff from Help->About

Product Version: NetBeans IDE 7.0.1 (Build 201107282000)
Java: 1.6.0_26; Java HotSpot(TM) 64-Bit Server VM 20.1-b02
System: Linux version 2.6.38-11-generic running on amd64; UTF-8; en_NZ (nb)
Comment 5 Jaroslav Tulach 2011-12-05 11:41:28 UTC
If you can reproduce it every time, please turn on self-profiling for a while, so I know where to look. Attache the npss file then. See: http://wiki.netbeans.org/FaqProfileMeNow
Comment 6 daveistooshort 2011-12-06 19:57:35 UTC
Created attachment 113891 [details]
IDE profiling during focus stealing event

This profiling was done on a brand new project. Left the default JavaApplication1.java open and created a separate file Foo.java which I opened as well and left with focus in netbeans.

Used the following steps:

1. Turned on IDE profiling
2. Switched to desktop workspace with terminal and deleted Foo.java (rm src/javaapplication1/Foo.java)
3. Wait a second, focus to terminal is lost automatically (the bug).
4. Return to desktop workspace with netbeans and disable IDE profiling.

Let me know if you need anything else.
Comment 7 Jaroslav Tulach 2011-12-07 07:21:17 UTC
The snapshot is good, and I see what is happening. 

The file was opened in editor. In response to its external deletion, the TopComponent representing the file is closed and the window system tries to find another component to focus. 

Probably this is done so agressively that the focus is stolen from the terminal window. Passing to WinSys.
Comment 8 Jesse Glick 2011-12-07 17:32:15 UTC

*** This bug has been marked as a duplicate of bug 194147 ***
Comment 9 Jaroslav Tulach 2011-12-07 17:39:48 UTC
Bug 194147 is one of possible solutions of the problem described in this bug. I don't think it is a good solution. Thus I am not going to let this bug be duplicated against bug 194147 and I hope the windowsystem will be able to handle the component close more gently when it is known the main window does not have focus at all.
Comment 10 Stanislav Aubrecht 2011-12-08 14:17:35 UTC
core-main a3cbb64e8a4f
Comment 11 Quality Engineering 2011-12-13 10:35:42 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/a3cbb64e8a4f
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #197349 - stolen focus when an opened file is deleted outside of NetBeans