After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 582931 - nautilus steals eog focus when opening second image
nautilus steals eog focus when opening second image
Status: RESOLVED FIXED
Product: eog
Classification: Core
Component: general
3.4.x
Other All
: Normal minor
: ---
Assigned To: EOG Maintainers
EOG Maintainers
: 608755 612839 627979 743800 747357 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-05-17 10:29 UTC by Albert Vilella
Modified: 2015-04-05 17:42 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
move initialization later to avoid losing event timestamp (6.13 KB, patch)
2013-09-07 01:02 UTC, John Hiesey
none Details | Review

Description Albert Vilella 2009-05-17 10:29:48 UTC
I download 2 images from the web into my Desktop. I open a web browser that occupies most of the desktop space but where the images are, then double-click on the first of them, eog stays on top of the browser, double-click the second one, new eog stays on top of browser and first image.

Now I open a nautilus window and go to Desktop. Double-click on the first image, eog stays on top of the browser. Double-click on the second image, and it's hidden behind the nautilus window.

Other information:
Comment 1 André Klapper 2009-05-18 07:22:17 UTC
Which distribution is this? Do you have desktop effects activated?
Comment 2 Albert Vilella 2009-05-18 07:39:19 UTC
Ubuntu 8.10. And no Desktop effects at all. I've tried the same with Ubuntu 9.04 LiveCD, and I get the same results.
Comment 3 Cosimo Cecchi 2009-05-28 16:00:31 UTC
-> eog

This is a bug in EOG, as Evince works good with the same testcase.
Comment 4 Felix Riemann 2009-05-29 19:43:04 UTC
I don't see this with eog either here. Double-clicking the second image in the nautilus window correctly raises it above all other windows (browser,eog-1, nautilus).

Cosimo, did you just try Evince or eog also?
Comment 5 Felix Riemann 2010-02-02 16:43:25 UTC
(In reply to comment #4)
> I don't see this with eog either here. Double-clicking the second image in the
> nautilus window correctly raises it above all other windows (browser,eog-1,
> nautilus).

Strike that. I experienced it myself now.

Wonder, what's changed since May.
Comment 6 Felix Riemann 2010-02-04 15:23:04 UTC
It's really strange. There seems to be some randomness involved.
Sometimes it's working correctly and sometimes it fails.
Comment 7 Felix Riemann 2010-03-07 17:22:00 UTC
*** Bug 608755 has been marked as a duplicate of this bug. ***
Comment 8 Felix Riemann 2010-03-15 19:42:04 UTC
*** Bug 612839 has been marked as a duplicate of this bug. ***
Comment 9 Felix Riemann 2010-03-15 20:17:41 UTC
I was now also able to reproduce it with The Gimp, which is like eog a single-instance-multiple-windows-app. 

Interestingly it makes a difference if the initial instance of eog/gimp was started from the terminal or by nautilus. If it's started from the terminal
it's working as expected.

Apparently evince does things a little bit different than eog as it's not affected.
Comment 10 jameshfisher 2010-03-15 21:22:58 UTC
(I posted this a few minutes ago but for some reason wasn't successful.)

Just to say, I'm not sure this is a case of nautilus "stealing" focus -- the same issue happens when I try:

* opening with Konqueror
* opening using `xdg-open <image>'
* opening directly using `eog <image>'

I can't confirm that there's any randomness involved.

The "single-instance-multiple-windows-app" thing is something to look at -- the issue doesn't exist with any instance-per-window apps AFAICS.

I can confirm that the case also exists with the GIMP.  It also exists with the GIMP when opening from other sources.

So, this is neither an issue with nautilus, nor with eog!

My guess is that this is something like an issue with the window manager?
Comment 11 Felix Riemann 2010-03-15 22:03:08 UTC
Bug reporting this with GIMP: bug 562495.
This report with Evo seems to be related as well: bug 559449
It mentions bug 273912, which connects this with metacity's focus stealing prevention. We'll have to check Elijah's instructions from bug 273912 comment 3 against eog. AFAIK we are sending the timestamp to the existing instance as Elijah recommends.

Bug 573922 seems to be related as well.
Comment 12 Cosimo Cecchi 2010-08-30 17:29:24 UTC
*** Bug 627979 has been marked as a duplicate of this bug. ***
Comment 13 nodiscc 2012-07-31 20:07:00 UTC
Confirmed in eog 3.4.2-1 in Debian
Comment 14 Matt Reid 2012-08-24 14:21:40 UTC
Happens to me with eog-3.4.3-2.fc17.x86_64 on 64 bit Fedora 17.

Every image I open after the first opens underneath nautilus. Even if I open the first on my laptop display (image opens on top), move nautilus to my external display, and try to open another image, the second window will still open underneath nautilus. I get a notification from shell, saying that the file opened and is ready. This has driven me to switch back to Shotwell.
Comment 15 John Hiesey 2013-09-07 01:01:58 UTC
This is happening because the user interaction timestamp of the event that opens the second image isn't being passed to the primary instance of eog. This timestamp is needed when opening the new window to allow the window to come to the top.

The timestamp should be getting passed automatically, but when the display is opened, the DESKTOP_STARTUP_ID environment variable gets cleared, which prevents the timestamp from being forwarded over dbus.

To fix this, the display needs to be not opened until the variable is read, which requires moving a bunch of initialization out of main() and into eog_application_startup(). Patch below.
Comment 16 John Hiesey 2013-09-07 01:02:51 UTC
Created attachment 254324 [details] [review]
move initialization later to avoid losing event timestamp
Comment 17 Felix Riemann 2013-10-06 13:40:39 UTC
Nice catch, John! :)
Moving that code to EogApplication also makes sense, as only the primary instance should need to call it.

Thanks for patching.

commit 997742b4f0d9023d402f5e7a519aca12fba2be46
Author: John Hiesey <>
Date:   Sat Sep 7 01:02:51 2013 +0000

    Delay display initialization to avoid losing event timestamp
    
    Should fix a new window not receiving focus when opening another
    image from Nautilus.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=582931
---
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 18 Felix Riemann 2015-02-02 18:19:28 UTC
*** Bug 743800 has been marked as a duplicate of this bug. ***
Comment 19 Felix Riemann 2015-04-05 17:42:55 UTC
*** Bug 747357 has been marked as a duplicate of this bug. ***