Open Bug 388664 Opened 12 years ago Updated 4 years ago

opening link from another application raises/focuses/moves Firefox window

Categories

(Firefox :: Shell Integration, defect, P4)

x86
Linux
defect

Tracking

()

People

(Reporter: myk, Unassigned)

References

Details

(Keywords: regression, Whiteboard: [myk:catfood])

Attachments

(1 file)

When I open a link from another application with a recent trunk nightly of Firefox running, the Firefox window raises to the foreground, steals focus, and moves to the current desktop (if different than the desktop the window is currently on).  I noticed this on earlier trunk builds, but several weeks ago it stopped happening.  Several days ago, however, it started happening again.

The problem happens for every link I open from another application, like Chatzilla, Thunderbird, or GNOME Terminal, all of which presumably use /usr/bin/gnome-www-browser to open links in the "preferred application" on my Ubuntu 6.10 system, which is /usr/bin/firefox (which then forwards the link to the actual binary currently running).

I can also trigger the bug by entering the following into a terminal window or "Run Application" dialog:

  /home/myk/Applications/firefox/firefox http://www.mozilla.org/

On Firefox 2, the window doesn't raise, focus, or change desktops, although its task manager icon does start throbbing.  This seems like the optimal behavior, at least if the preference "When I open a link in a new tab, switch to it immediately" is turned off, since it mimics the behavior of Firefox itself when you open a link in a new tab (i.e. the tab doesn't raise/focus).
Keywords: regression
Whiteboard: [myk:catfood]
Running Ubuntu Gutsy Tribe 5, GNOME 2.19.7, Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a8pre) Gecko/2007090304 Minefield/3.0a8pre

This has been happening to me every time I click a link from the gnome-terminal.
A bit of clarification:

Gutsy Tribe 5 is the 5th development (alpha) release of Ubuntu 7.10 Gutsy Gibbon.

New pages are set to open in a new tab, and I am not using MOZ_NO_REMOTE/-no-remote
This is a real pain.  I find myself clicking links and quickly switching to the desktop with Firefox on it, hoping I can outrace the request so Firefox comes to the foreground on its proper desktop and I don't have to move it back into place (again).  Requesting blocking status.
Flags: blocking-firefox3?
Sounds like something that could be a regression from bug 295447 (which introduced gtk_window_present calls).
Flags: blocking-firefox3? → blocking-firefox3+
Target Milestone: --- → Firefox 3 M10
Target Milestone: Firefox 3 M10 → Firefox 3 M11
Priority: -- → P4
http://bugzilla.gnome.org/show_bug.cgi?id=482354 thanks to Mart Raudsepp for the link
 1. new-window : makes sense to open on current desktop
 2. new-tab: moving all tabs to current desktop is annoying; but opening new tab on other desktop is probably too confusing.

Thus: if new-tab is selected as open mode, use new-window if there is no firefox window on current desktop. optionally, we could add a pref to disable this auto-new-window feature for power users that want the ffox 2 behaviour.

(fwiw gedit behaves in a similar fashion)
Flags: wanted-firefox3+
Flags: blocking-firefox3-
Flags: blocking-firefox3+
Duplicate of this bug: 414879
Duplicate of this bug: 420186
(In reply to comment #6)
>  1. new-window : makes sense to open on current desktop
>  2. new-tab: moving all tabs to current desktop is annoying; but opening new
> tab on other desktop is probably too confusing.

What about opening new tab on other desktop and flashing the window title button?

> Thus: if new-tab is selected as open mode, use new-window if there is no
> firefox window on current desktop. optionally, we could add a pref to disable
> this auto-new-window feature for power users that want the ffox 2 behaviour.

I would certainly make use of that pref. :)
This isn't a bug in Firefox, it is a bug in metacity which Colin Walters at Red Hat reported and supplied a patch for.

http://bugzilla.gnome.org/show_bug.cgi?id=482354

If you see this bug on Linux, you're probably not running Fedora Rawhide/9.  But, I recommend you forward this to your distro and ask that they temporarily take the metacity patch until the upstream metacity developers decide this bug is important enough to warrant their attention.
Alternatively, switching window managers to something other than metacity is a workaround.
> Alternatively, switching window managers to something other than metacity is a
workaround.

I could say "lie". It's simply not true :P . I had this issue with Compiz running.

> If you see this bug on Linux, you're probably not running Fedora Rawhide/9. 

Fedora is innovative ^^ .
Compiz in Fedora 8 certainly doesn't have that problem.  If compiz regressed, that's unfortunate, and I'd suggest filing a bug against compiz.
Until I set an option in about:config I saw this bug. Now everything from other apps is opened in background tabs. That is great and doesn't require fixing anything.
(In reply to comment #14)
> Until I set an option in about:config I saw this bug. Now everything from other
> apps is opened in background tabs. That is great and doesn't require fixing
> anything.

Which option did you set, and what did you set it to?
browser.tabs.loadDivertedInBackground = true
I just tried every compiz version from F8 onward, and metacity from F8 onward.  No compiz version features this bug.  Metacity didn't get the fix until 2.21.5 and had it except for a day when it got accidentally removed around 2.21.8.  It's been fine ever since.
(In reply to comment #16)
> browser.tabs.loadDivertedInBackground = true

Hmm, indeed, that prevents the window from moving, although it doesn't duplicate the behavior that has regressed, since it doesn't throb the browser's taskbar button nor open the link in a foreground tab.
Duplicate of this bug: 406167
Duplicate of this bug: 429901
Hi, I have the same problem with stumpwm, although Firefox's window doesn't get moved to the current Group, I think that's stumpwm's term for a workspace, but I get switched to the group where firefox is.
(In reply to comment #6)
>  1. new-window : makes sense to open on current desktop
>  2. new-tab: moving all tabs to current desktop is annoying; but opening new
> tab on other desktop is probably too confusing.
> 
> Thus: if new-tab is selected as open mode, use new-window if there is no
> firefox window on current desktop. optionally, we could add a pref to disable
> this auto-new-window feature for power users that want the ffox 2 behaviour.
> 
> (fwiw gedit behaves in a similar fashion)

Maybe there need more options in multi-workspace environments?
E.g.:
1. new window unconditionally
2. new window if none on an active workspace, new tab otherwise [hidden in Windows]
3. new tab unconditionally

and also a checkbox to focus the window when link has been opened (having it checked would probably move the user to another workspace in case 3). Probably, the same preference mentioned in Comment #0 could be reused here.
As a substitute for a fix of this bug, I've worked around it with a shell script that uses wmctrl to get the ideal behavior. It'll check to see if there's an existing firefox window open on the current workspace, and if so, (optionally) focus it, and load a url in a new tab there. If there's no such window, it'll simply open it in a new window on the current workspace.
First, how does this bug report relate to Mozilla bug #263553? Isn't it a duplicate?

I just posted the following to http://bugs.debian.org/486570, but I found no way to update this bug report.

After reading what James wrote[0], I went to investigate this a bit.

0. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=486570#15

First, I found the single call to gtk_window_present in the Firefox
source and disabled it:

  --- a/widget/src/gtk2/nsWindow.cpp
  +++ b/widget/src/gtk2/nsWindow.cpp
  @@ -1406,7 +1406,7 @@ nsWindow::SetFocus(PRBool aRaise)
          owningWindow->mContainerBlockFocus = PR_TRUE;

          // Set focus to the window
  -        if (gRaiseWindows && aRaise && toplevelWidget &&
  +        if (0 && gRaiseWindows && aRaise && toplevelWidget &&
              !GTK_WIDGET_HAS_FOCUS(toplevelWidget) &&
              owningWindow->mIsShown && GTK_IS_WINDOW(owningWindow->mShell))
            gtk_window_present(GTK_WINDOW(owningWindow->mShell));

and built new packages, but the problem remained. However, I found
a couple of curiousities. I have three heads one two graphics cards,
and I use Zaphod mode to put them all next to each other. head 0 is
on GPU 0, and heads 1&2 are on GPU 1.

  1. the focus is never stolen when the Firefox window is on heads
     1&2, not even if the link is clicked on another head.

  2. if I move the window from head 0 to head 1 and back, then it no
     longer steals focus, not even if the click is on a separate head.

  3. if I move the window from head 0 to head 1, click a link, and
     move it back to head 0, then the focus stealing happens again.

I then went back to investigate these three points with the original
Firefox packages, i.e. without the above patch, and the behaviour is
identical.

Then I investigated the urgency hint, using xprop -spy: I started it
in a terminal, then X-pasted a link into that terminal and clicked
it. I did this to avoid changing focus with the mouse while testing.
There was nothing in the output of xprop -spy mentioning an urgency
hint. I did verify that xprop -spy shows the urgency hint, using
URxvt.urgentOnBell and echo -e '\a'.

This is starting to feel a bit like a riddle. For me, (2.) above is
an okay workaround at the moment, but it really seems like the
Firefox code needs some cleaning.
Target Milestone: Firefox 3 beta3 → ---
(In reply to Jeremy Nickurak from comment #23)
> Created attachment 343829 [details]
> Shell script to open a URL strictly in a new firefox tab on the current
> workspace
> 
> As a substitute for a fix of this bug, I've worked around it with a shell
> script that uses wmctrl to get the ideal behavior. It'll check to see if
> there's an existing firefox window open on the current workspace, and if so,
> (optionally) focus it, and load a url in a new tab there. If there's no such
> window, it'll simply open it in a new window on the current workspace.

Thanks for that script, it works very well.
This is the behavior I wish Firefox could have out of the box (Reuse-window-in-current-desktop otherwise create-new-in-current-desktop). Much better than jumping to another desktop or opening tabs hidden into another desktop. Any chance for this to happen?
You need to log in before you can comment on or make changes to this bug.