Nautilus window opens behind current window

Bug #1168858 reported by Ibrahim Rasheed
32
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Unity
Won't Fix
Undecided
Unassigned
deluge (Ubuntu)
Fix Released
Undecided
Marco Trevisan (Treviño)
nautilus (Ubuntu)
Invalid
Low
Unassigned

Bug Description

Since I have upgraded to Ubuntu 13.04 (FINAL BETA), whenever I right click on my torrent file and chose OPEN FOLDER option, the folder opens in background and not on top of the window like I used to have it in Ubuntu 12.10.

Tags: patch raring
affects: launchpad → ubuntu
affects: ubuntu → deluge (Ubuntu)
Revision history for this message
Cas (calumlind) wrote :

This is a nautilus issue, to replicate, open a terminal and run:

    nautilus ~/Desktop

Testing on 12.04 opens and focuses but 13.04 is opens behind.

Changed in deluge (Ubuntu):
status: New → Invalid
Changed in nautilus (Ubuntu):
status: New → Confirmed
Cas (calumlind)
summary: - Deluge open folder
+ Nautilus window opens behind current window
Cas (calumlind)
tags: added: raring
removed: deluge
Changed in nautilus (Ubuntu):
importance: Undecided → Low
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

This is not a nautilus or unity bug, deluge should launch it properly using g_app_info_launch with proper GAppLaunchContext in order to make it focus (if needed).

Changed in unity:
status: New → Invalid
Changed in deluge (Ubuntu):
status: Invalid → Confirmed
Changed in nautilus (Ubuntu):
status: Confirmed → Invalid
Revision history for this message
Cas (calumlind) wrote :

No.

Changed in deluge (Ubuntu):
status: Confirmed → Invalid
Changed in nautilus (Ubuntu):
status: Invalid → New
Changed in unity:
status: Invalid → New
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Please, don't revert this.

Nautilus won't be "fixed" (nor downstream or upstream), since it's already fixed (see https://bugzilla.gnome.org/show_bug.cgi?id=693815 or https://bugzilla.gnome.org/show_bug.cgi?id=674816 for example).

Also compiz is right in not giving the focus to Nautilus if it is opened with an old action timestamp, that's how focus stealing prevention works according to Gtk.

So, please, fix deluge. This is what you need to do to have proper startup notification: http://is.gd/gqV7uN

Changed in unity:
status: New → Won't Fix
Changed in nautilus (Ubuntu):
status: New → Invalid
Changed in deluge (Ubuntu):
status: Invalid → Confirmed
Revision history for this message
Cas (calumlind) wrote :

This is a regression from 12.04 to 13.04 and you are determined to pin the blame on Deluge despite my example that simply opening Nautilus from the terminal displays this regression and Deluge does nothing more than call xdg-open.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Opening from terminal is not a valid example, since the terminals we currently have, do not set correctly the environment variable needed to pass to nautilus the startup-notification with the event timestamp that caused nautilus to open.

I know this, and as you can see I tried to change this upstream, but it's not the case since this is the wanted policy.
An application that launches another one should say when this has happened in order to make the WM to focus it (this is important to avoid that applications that takes much time to load won't steal the focus, while you're currently doing something else).

Revision history for this message
Cas (calumlind) wrote :

How does that work with xdg-open?

Revision history for this message
Cas (calumlind) wrote :

I have just realised how ridiculous this is after testing any application. Basically ANY application that the user wishes to open a folder to view the location of a file will be affected in 13.04.

This will annoy the hell out of a large number of users.

Revision history for this message
Cas (calumlind) wrote :

This is absolutely not a Deluge issue and I would like the Unity team to investigate this.

Changed in deluge (Ubuntu):
status: Confirmed → Won't Fix
status: Won't Fix → Invalid
Changed in nautilus (Ubuntu):
status: Invalid → New
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

We already investigated it, and nor unity or nautilus will change at this point.

What you need on deluge is just properly calling xdg-open with a proper DESKTOP_STARTUP_ID env set.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

So it seems you don't want to fix it... Since this is trivial, here's what deluge needs.

Patch attached.

Changed in nautilus (Ubuntu):
status: New → Invalid
Changed in deluge (Ubuntu):
assignee: nobody → Marco Trevisan (Treviño) (3v1n0)
status: Invalid → In Progress
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "add_desktop_startup_id.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Cas (calumlind) wrote :

From my position the logic behind the changes just don't make sense and I am thinking of the bigger picture not just Deluge.

I can open any file with xdg-open, with the associated application opening focused, file-roller, image viewer, firefox etc... So that begs the question why is Nautilus a special case and we have to jump through hoops to open a Nautilus window focused?

An application developer when using xdg-open should not have to worry about special cases involving Nautilus file manager to have the new window focused like every other application.

With 13.04 so close to release all the applications that use the 'open folder' feature will encounter this issue and users (inc devs?) will be irate but you have not addressed this concern?

Revision history for this message
Cas (calumlind) wrote :

I was chatting with another dev and the idea of modifying xdg-open came up, could this be a possible solution?

--- /usr/bin/xdg-open
+++ xdg-open
@@ -489,6 +489,7 @@

 open_gnome()
 {
+ export DESKTOP_STARTUP_ID=i_am_unique_$(date '+%s%N')_TIME$(date '+%s')
     if gvfs-open --help 2>/dev/null 1>&2; then
         gvfs-open "$1"
     else

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote : Re: [Bug 1168858] Re: Nautilus window opens behind current window

2013/4/24 Cas <email address hidden>:
> >From my position the logic behind the changes just don't make sense and
> I am thinking of the bigger picture not just Deluge.
>
> I can open any file with xdg-open, with the associated application
> opening focused, file-roller, image viewer, firefox etc... So that begs
> the question why is Nautilus a special case and we have to jump through
> hoops to open a Nautilus window focused?

I see your point, and I also was thinking the same, but there's some
rationale over it and what we eventually want is that if you run a
program you should pass some platform-data to it, that in general
includes the timestamp of the event that triggered that action in
order to define if the newly opened window should or not befocused by
WM.

In general the WM always focuses new windows, but Nautilus is a
particular case because it stays always opened in background (to draw
the desktop) and so, when called, in order to be able to focus a new
window it needs to say to the WM when this request has been done.

This is not only a problem that affects Nautilus, btw. Also Empaty was
affected (I proposed a patch for it as well, as for the
indicator-messages), Rythmbox and more.
See bug lp:627195

FYI, the same behavior is applied by gnome-shell as well (to say that
it's not a compiz problem, but a feature).

> An application developer when using xdg-open should not have to worry
> about special cases involving Nautilus file manager to have the new
> window focused like every other application.

Well, in general it should not use xdg-open directly I think, but he
should use the APIs that the environment is providing to open files
and folders. And everybody should start thinking that if an action
could leads to opening a new window, then that should be properly
formed in order to have the WM to focus it.

> With 13.04 so close to release all the applications that use the 'open
> folder' feature will encounter this issue and users (inc devs?) will be
> irate but you have not addressed this concern?

I see the point, and as said, I've put all my efforts to fix this
properly, but not WM or Nautilus side, but Application side (that is
where it must fixed).
Standard has changed since long time, and developers should sync with it.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> I was chatting with another dev and the idea of modifying xdg-open came
> up, could this be a possible solution?
>
> --- /usr/bin/xdg-open
> +++ xdg-open
> @@ -489,6 +489,7 @@
>
> open_gnome()
> {
> + export DESKTOP_STARTUP_ID=i_am_unique_$(date '+%s%N')_TIME$(date '+%s')
> if gvfs-open --help 2>/dev/null 1>&2; then

No, because DESKTOP_STARTUP_ID should use the Display Server time (X,
for now), not the current time, so this won't work as expected, also
there's not a way to pass to it the event time of the event that
caused its call.

Also gnome-open could, in theory, easily use GAppLaunchContext, but it
doesn't it since it's not possible beca - at the current state - to
know the event that triggered that.

Revision history for this message
Cas (calumlind) wrote :

xdg-open is the tool used in linux to open the default application but how can it be used by user/scripts/applications (without an api) if it doesn't behave as expected with nautilus? Following on from that if you then set the env var (as per my xdg-open change) in scripts then we have gone full circle and those scripts will then steal focus.

Why does it matter if gnome-open knows which event as long as a correct timestamp is issued if no timestamp has been set? If it is possible to modify gnome-open to correctly set a timestamp that seems like a good solution and it does mention in the gtk api that the timestamp is only ideally from the event so it's not a requirement.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Cas, any hope to include the patch I sent into deluge git? It would allow to get this fixed at least.

Cas (calumlind)
Changed in deluge (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.