Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 119743 - Eclipse losing focus after open resource dialog.
Summary: Eclipse losing focus after open resource dialog.
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Linux-GTK
: P3 normal with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: Bogdan Gheorghe CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-07 16:19 EST by Alex Burmester CLA
Modified: 2018-10-20 16:50 EDT (History)
12 users (show)

See Also:


Attachments
Dual monitor setup screenshot (83.15 KB, image/png)
2013-01-31 11:52 EST, Bryan Parker CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Burmester CLA 2005-12-07 16:19:10 EST
Not sure if this is an eclipse or gnome problem.
I've tried both 1.4.1 jdk and 1.5 so I don't think its a java issue.

It is easily reproducable on my machine but may not be on other systems.
I have eclipse 3.1.1 on fedora 4 with gnome 2.10.0 
I am using focus follows mouse.

If I hit Ctrl-Shift-R and open the open resource window, if I then cross the open resource window boundry with the mouse before hitting enter on the resource I am opening, when the open resource window closes, focus jumps to my other monitor.

I don't know if this is an eclipse bug, but any pointers as to how to figure out the cause of this or how to fix it would be great since it's driving me nuts.

Thanks,

Alex.

Ps.  maybe my multi desktop setting have something to do with it?
In xorg.conf I have :
Section "ServerLayout"
    Identifier     "Multihead layout"
    Screen      0  "Screen0" LeftOf "Screen1"
    Screen      1  "Screen1" 0 0
    InputDevice    "Mouse0" "CorePointer"
    InputDevice    "Keyboard0" "CoreKeyboard"
    Option      "Xinerama" "off"
    Option      "Clone" "on"
Comment 1 Billy Biggs CLA 2005-12-07 16:27:43 EST
metacity in 2.10 has some focus-stealing prevention code which is tricky, so this is likely related.  Presumably it does not happen in click-to-focus mode :)
Comment 2 Billy Biggs CLA 2005-12-07 16:31:03 EST
I cannot reproduce any weirdness here with the open-resource dialog and focus-follows-mouse mode.  On my FC4 machine, I have metacity-2.10.3-1.  Which version do you have installed?

Also, can you give clearer steps regarding the problem?  What exactly is the sequence of events that triggers this?  When your mouse leaves the open resource window, where does it go?  Is it still above Eclipse?  When you say that focus jumps to your other monitor, where on the other monitor does it go, exactly?
Comment 3 Alex Burmester CLA 2005-12-07 17:18:22 EST
I appear to have metacity-2.10.0-2.fc4

To reproduce I have eclipse in java perspective.
I am editing a file and the eclipse window and editor have focus.
I hit Ctrl-Shift-R,  locate another file, hit return and when the window goes away my focus instead of going to the editor with the new file, jumps to the other monitor and firefox or whatever window is on my second screen becomes active.
The mouse pointer stays in the eclipse editor but my keystrokes go to the firefox window.  Originally I thought this was occasionally happening.  Then I figured out that the trick for my system to get it to happen was to make sure that my mouse pointer was in the editor but not overlapping with the open resource window when it pops up.  Then after it pops up I move the mouse into the open resource window ( like when I have to select which resource of a bunch named the same with the mouse) then when I hit return I lose the focus.
If my mouse does not cross the window boundry, before closing the window, things work fine.  It's like the follow focus triggers some event which gets suppressed because the open resource window already has focus but then when it closes something weird happens.

Alex. 
Comment 4 Billy Biggs CLA 2005-12-08 14:43:42 EST
Please get the latest update for metacity from FC4, I cannot reproduce this here and I am pretty sure it is a bug in 2.10.0 that is fixed in 2.10.3.
Comment 5 Bryan Parker CLA 2013-01-31 11:52:26 EST
Created attachment 226400 [details]
Dual monitor setup screenshot
Comment 6 Bryan Parker CLA 2013-01-31 11:55:02 EST
I realize that this is several years after the fact, but I'm experiencing the same issue. My setup consists of Ubuntu 12.04.1 LTS and Eclipse Juno build 20121004-1855. Similar to Alex, I'm running a dual monitor setup with the main editor window on one monitor and several views on the other (see attachment). The cursor and focus is in the main editor window, however, when I open a resource (Ctrl + Shift + R) and hit enter, the resource is opened, but the focus moves from the editor to a different view (in the case of screenshot, to the package explorer). If you need any additional information, please let me know, and I would be happy to provide it.
Comment 7 Bryan Parker CLA 2013-01-31 11:57:56 EST
Regarding my last comment, if it helps to note, this is a recent Ubuntu installation, so aside from Eclipse, it is a standard, vanilla setup.
Comment 8 Eric Sirianni CLA 2014-06-23 11:18:12 EDT
I'm experiencing the same issue with Kepler on a fresh Ubuntu Trusty install.  The Eclipse window loses focus after closing any dialog (e.g. "Open Resource", "Open Type", etc.).

I've turned "focus prevention level" to off in Compiz, but it doesn't fix the situation.
Comment 9 Eric Sirianni CLA 2014-06-23 11:22:09 EDT
Actually, I think my issue may be being caused by the Ubuntu bug: https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1125442
Comment 10 Didier Loiseau CLA 2014-10-27 13:16:42 EDT
Eric, I am experiencing exactly the same issue as you with Eclipse 4.4 on a fresh install of Ubuntu Trusty, did you find a workaround?

Apparently the issue goes away if I set the focus prevention level to "Very High" but the side effects make the rest of the environment unusable (e.g. when you launch a new application, it does not get the focus!).

The Launchpad issue you are referring to does not seem related for me: it concerns focus stealing when switching workspaces, which is not the case here.

I think the main issue is that when you detach a view in Eclipse, it becomes a (non-modal) dialog, and dialogs are always on top of their main window.

BTW this is also annoying when you disconnect your secondary screen: the detached views come above the main window, so you have to hide them or move them around if you want to see the main window again (I have observed this on both Ubuntu and Windows).
Comment 11 Eric Sirianni CLA 2014-10-27 13:45:23 EDT
Didier,

Are you, by chance, using the Google Chrome Hangouts extension?  I believe I worked around the issue by unchecking the "Keep hangouts on top of other windows" checkbox.
Comment 12 Didier Loiseau CLA 2014-11-25 07:31:42 EST
No I'm not, but this issue does not seem to be related to other running applications…
Comment 13 Eric Sirianni CLA 2014-12-16 09:53:28 EST
This issue can be reproduced by the following steps:
1. Open Eclipse
2. Open another application window (e.g. gnome-terminal)
3. Set the other application window as "Always on top"
4. Switch back to Eclipse
5. Open a modal dialog in Eclipse (e.g. 'Open Type')
6. Close the modal dialog

Expected behavior: Focus is returned to the parent Eclipse window

Actual behavior: Focus is shifted to the "Always on top" window (gnome-terminal in my example)
Comment 14 Didier Loiseau CLA 2014-12-16 10:15:27 EST
OK I'm figuring my issue is similar but a little bit different though. Actually it is more like Bryan Parker's in comment #6 (maybe I made a mistake in my first comment). I don't know whether those 2 issues are related, maybe a separate bug report should be created.

Anyway, here are the steps to reproduce it:
1) detach any view (e.g. the console) from the main eclipse window
2) hit ctrl+shift+r to open the resource dialog
3) select any resource and validate the dialog (with the keyboard)

Expected result: focus goes to the newly open editor

Actual result: focus goes to the detached view, and you have to press F12 to give it to the new editor

Also, the detached views are always shown on top of the main window, which is really annoying when you change the screen configuration or when you want to move windows around.
Comment 15 Guilherme Melo CLA 2015-05-27 20:22:23 EDT
(In reply to Didier Loiseau from comment #14)
> OK I'm figuring my issue is similar but a little bit different though.
> Actually it is more like Bryan Parker's in comment #6 (maybe I made a
> mistake in my first comment). I don't know whether those 2 issues are
> related, maybe a separate bug report should be created.
> 
> Anyway, here are the steps to reproduce it:
> 1) detach any view (e.g. the console) from the main eclipse window
> 2) hit ctrl+shift+r to open the resource dialog
> 3) select any resource and validate the dialog (with the keyboard)
> 
> Expected result: focus goes to the newly open editor
> 
> Actual result: focus goes to the detached view, and you have to press F12 to
> give it to the new editor
> 
> Also, the detached views are always shown on top of the main window, which
> is really annoying when you change the screen configuration or when you want
> to move windows around.

I get this same odd behaviour. Focus always go the detached view instead of editor after a dialog is closed.
Comment 16 Guilherme Melo CLA 2015-05-29 10:19:25 EDT
As I suspect this may be a Unity bug (I could not reproduce it on Gnome 3, KDE, LXDE), I reported a bug on launchpad: https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1459671, please vote it up if it affects you.
Comment 17 Eric Sirianni CLA 2015-05-29 10:22:29 EDT
(In reply to Guilherme Melo from comment #16)
> As I suspect this may be a Unity bug (I could not reproduce it on Gnome 3,
> KDE, LXDE), I reported a bug on launchpad:
> https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1459671, please vote it
> up if it affects you.

Thanks Guilherme.  It may be a unity bug, however, I've yet to experience this behavior in any other multi-window application -- just Eclipse.
Comment 18 Guilherme Melo CLA 2015-05-29 10:42:34 EDT
(In reply to Eric Sirianni from comment #17)
> (In reply to Guilherme Melo from comment #16)
> > As I suspect this may be a Unity bug (I could not reproduce it on Gnome 3,
> > KDE, LXDE), I reported a bug on launchpad:
> > https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1459671, please vote it
> > up if it affects you.
> 
> Thanks Guilherme.  It may be a unity bug, however, I've yet to experience
> this behavior in any other multi-window application -- just Eclipse.

Well, I just tested it with gimp alone, and the same problem occurs on Unity only.
Comment 19 Noam Cohen CLA 2016-05-10 04:47:11 EDT
It's not a Unity bug. I'm experiencing the same behavior on Ubuntu Gnome 16.04 (Gnome Shell version = 3.18).
Comment 20 Guilherme Melo CLA 2016-05-10 06:45:11 EDT
(In reply to Noam Cohen from comment #19)
> It's not a Unity bug. I'm experiencing the same behavior on Ubuntu Gnome
> 16.04 (Gnome Shell version = 3.18).

Hi Noam, as I detailed on the bug report, I found a line of code on compiz which is responsible for this wrong behaviour.

It seems this code is only executed when not using compiz' window manager. Unity has its own window manager and I guess that now Gnome3 has one two.

Unfortunately I got no response on the bug report and could not contact any compiz developer to find out what would be the right fix.

I think that if eclipse used normal windows instead of floating docks this problem would not happen. So maybe an option on eclipse to change the type of the docks would be a workaround
Comment 21 Reginaldo Santos CLA 2017-05-05 10:25:52 EDT
I have the very same issue with Ubuntu 16.10 (GTK 3) and eclipse Neon.

As a workaround I've configure eclipse to use GTK 2 as below:

```
openFile
--launcher.GTK_version
2
```

Hope it helps.
Comment 22 Hugo Eustáquio CLA 2017-12-26 12:30:27 EST
I'm having the same issue running Slackware64 14.2, i3wm and eclipse on gtk3.
I'm also using two monitors.
Comment 23 Hugo Eustáquio CLA 2017-12-26 12:31:21 EST
(In reply to Hugo Eustáquio from comment #22)
> I'm having the same issue running Slackware64 14.2, i3wm and eclipse on gtk3.
> I'm also using two monitors.

I forgot, my eclipse is Oxygen.2, recently updated.
Comment 24 Hugo Eustáquio CLA 2017-12-26 13:25:12 EST
(In reply to Hugo Eustáquio from comment #23)
> (In reply to Hugo Eustáquio from comment #22)
> > I'm having the same issue running Slackware64 14.2, i3wm and eclipse on gtk3.
> > I'm also using two monitors.
> 
> I forgot, my eclipse is Oxygen.2, recently updated.

Also, it's not happening with every editor. It works correctly opening '.java' files. This bug is affecting xhtml, html, jsp, properties and xml editors.
Comment 25 Xi Yan CLA 2018-07-27 12:55:53 EDT
I cannot reproduce the issue on Fedora 28. Please reopen this ticket if the issue reoccurs.

Version: 4.9
Build id: I20180712-2000
OS: Linux, v.4.17.3-200.fc28.x86_64, x86_64 / gtk 3.22.30, WebKit 2.20.3
Java version: 1.8.0_172
Comment 26 Mario Charest CLA 2018-10-20 16:50:09 EDT
Same issue.

XUbuntu 18
Oxygen.2

Most obvious on dialog like preferences.

Forcing GTK2 seems to solve it.