Open Bug 1090416 Opened 10 years ago Updated 1 year ago

middle mouse click to open URL in new window causes new window to steal focus

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

33 Branch
x86_64
Linux
defect

Tracking

()

People

(Reporter: gak, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0 Build ID: 20141013200257 Steps to reproduce: with middle mouse button configured to open a new window, i.e. browser.link.open_newwindow = 2 browser.link.open_newwindow.override.external = 2 browser.link.open_newwindow.restriction = 0 browser.tabs.opentabfor.middleclick = false middlemouse.openNewWindow = true and using a linux X11 window manager set to focus-follows-mouse, center click on a link in some web page. Actual results: the new window always takes focus. Expected results: if the new window does not overlap the mouse location, the new window should not take focus from the original window. i.e. the focus should be on the topmost window under the mouse location.
Interestingly, if I left-click on a link that has <a target="_blank" ... or <a target="_new" ... to automatically open a new window, the focus is *not* grabbed by the new firefox window. With center-click the new window always grabs focus.
Can someone please comment on this? If I could get confirmation that this is indeed a bug, and any kind of vague pointer to where this might be occurring or even what code is being invoked by the left and center URL clicks which exhibit differing behavior, I can probably fix it and submit a patch.
Hi reporter, Can you please provide a download link for the window manager you are using? Does this bug reproduce without the window manager? Also, please try to reproduce this on the latest release(43.0.3) and latest Nightly(46.0a1) and provide the results. When doing this, please try to reproduce with a new clean Firefox profile, maybe even in safe mode, as some of this issues may be caused by third party installed add-ons or custom settings(https://support.mozilla.org/en-US/kb/troubleshoot-and-diagnose-firefox-problems). Thanks, Paul.
Flags: needinfo?(gak)
Since the reporter didn't provide the requested information, I will mark this issue as RESOLVED INCOMPLETE. If you still encounter this problem, please feel free to reopen this bug, or file a new one.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Flags: needinfo?(gak)
Resolution: --- → INCOMPLETE
Hi Paul, sorry for the delay. This bug still exists in 44.0.2 on Ubuntu 14.04 Trusty. I am running fvwm 2.6.3, available here: ftp://ftp.fvwm.org/pub/fvwm/version-2/ or you can probably run 2.6.5 which is packaged with Ubuntu Trusty, it looks like very few changes were made, and development looks to have pretty much stopped several years ago. You will need to set focus-follows-mouse. When I have a chance, I will check if the default Unity window manager with focus-follows-mouse turned on reproduces the problem. Since this bug is a problem with overriding default window manager behavior, I'm not sure what it would mean to reproduce it with no window manager running, but let me know if you want me to try something specific. I just grabbed the nightly, firefox-47.0a1.en-US.linux-x86_64.tar.bz2, and ran as follows: % ./firefox -no-remote -CreateProfile foobar % ./firefox -no-remote -P foobar then go to about:config and make these changes: browser.link.open_newwindow = 2 browser.link.open_newwindow.override.external = 2 browser.link.open_newwindow.restriction = 0 browser.tabs.opentabfor.middleclick = false middlemouse.openNewWindow = true and middle click on a link, with the existing firefox window positioned such that the newly opened window will not be under the mouse pointer, and the newly created window incorrectly gets the focus. The difference in behavior I noted in comment #1 no longer seems to exist: when left clicking on a link with target="_new", the focus is grabbed by the new firefox window just as with middle click now. That is also the case for 44.0.2.
Status: RESOLVED → UNCONFIRMED
Resolution: INCOMPLETE → ---
The following will probably be necessary, and possibly sufficient for your .fvwmrc: Style "*" FocusFollowsMouse Style "*" RandomPlacement As I said, I will check if I can reproduce with Unity as that should be more mainstream for others to reproduce.
Hi Paul, I have confirmed that using the firefox nightly, on Ubuntu 14.04 Trusty and default Unity window manager, if I do the following to enable focus follows mouse: gsettings set org.gnome.desktop.wm.preferences focus-mode 'mouse' gsettings set org.gnome.desktop.wm.preferences auto-raise false gsettings set org.gnome.desktop.wm.preferences raise-on-click true then follow the recipe in comment 5, the bug also can be reproduced.
Hi reporter, I was able to reproduce this issue on the latest release(44.0.2) and the latest Nightly(47.0a1). After I've installed fvwm 2.6.3 and applied the settings you provide in comment 5, Firefox changed the focus on the newly opened window, regardless if it was a middle mouse click or right-click and open link in new window. The new window did not overlap the mouse location. User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0 Build ID: 20160210153822 User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0 Build ID: 20160306030215 But this also happens if you don't install fvwm 2.6.3 and don't apply the settings from comment 5. If you right click on a link and select open in a new window, the newly opened Firefox window will have the focus as well. I believe that this is the desired behavior in Firefox, since I was not able to find a build on which this does not reproduces. I went back to Firefox 30.0, and it has the same behavior as the latest versions and as your provided version 33.0. Could you please point out a version where this worked as you described in the expected results? Thanks, Paul.
Flags: needinfo?(gak)
Hi Paul, I'm glad you were able to reproduce the issue. > But this also happens if you don't install fvwm 2.6.3 and don't apply the > settings from comment 5. well yes, this is expected behavior when focus-follows-mouse is not on and possibly depending on other window manager settings. I do not see why this has to have worked correctly under focus-follows-mouse previously for it to be considered a bug. The whole point of focus-follows-mouse is that the window UNDER THE MOUSE POINTER should always have focus. If a firefox window which is not under the mouse steals the focus in this mode, it is a bug. Applications should leave it to the window manager to manage focus; if an application actively takes focus that is a bug. I don't actually remember if it ever worked right, if it did it was probably many years ago. I filed the bug because I finally got fed up with this behavior, not because it was a new issue in 33.0. Around the time of the original report (see comment #1), I did note that left clicking a link which contains the tag <a target="_blank" ... or <a target="_new" ... to automatically open a new window, the focus was not being grabbed by the new firefox window. In current versions it is. Are you able to test that with 33.0 or 30.0? Or is there an archive of older firefox linux binaries? Can I at least download a 30.0 or 33.0 binary somewhere?
Flags: needinfo?(gak)
Hi reporter, You can download older builds from this link: http://archive.mozilla.org/pub/firefox/releases/ , you select a Firefox version, the platform and you're done. I was asking if this worked correctly in the past, so I could perform a regression on this issue to find where it got broken. However, considering last comment, I will mark this issue as new and assign the appropriate component. If anyone considers that the component is not the right one, please change it to a more appropriate one. Thanks, Paul.
Status: UNCONFIRMED → NEW
Component: Untriaged → Event Handling
Ever confirmed: true
Product: Firefox → Core
Great, thank you Paul! I'll try some older versions later this week and post results.
Component: Event Handling → User events and focus handling

Sorry, "later this week" turned into just over three years but in the course of just reporting https://bugzilla.mozilla.org/show_bug.cgi?id=1544072, related to focus stealing when starting a new window from firefox shell command line invocation, I downloaded a ton of old release versions to test with, and have also tracked down when this bug was introduced.

I used the test.html file I will attach momentarily as well as the about:config settings in comment #5:

browser.link.open_newwindow = 2
browser.link.open_newwindow.override.external = 2
browser.link.open_newwindow.restriction = 0
browser.tabs.opentabfor.middleclick = false
middlemouse.openNewWindow = true

to test three cases of opening a new window via mouse click on a link:

  1. center-click on a regular link: <a href="url">
  2. left-click on a target="_blank" link: <a href="url" target="_blank">
  3. window.open() via onclick" <a ... onclick="window.open('url','_blank')

For case 1, i.e. the bug originally reported here, this bug still exists in 66.0.1. I have traced it, and found that it was introduced between 18.0 and 19.0. Interestingly, the secondary bug reported in comments 1 and 2 of https://bugzilla.mozilla.org/show_bug.cgi?id=1544072 was also introduced between those same versions.

For case 2, whereas I had previously reported at the end of comment #5 that left-click on a target="_blank" link was no longer working correctly in 44.0.2 and the 47.0a1 nightly, having regresses from the initial report against 33.0, I am no longer seeing that problem, and all versions tested through 66.0.1 are working correctly: the new window is created and does not grab focus.

For case 3, similarly, for the window.open() case, all versions are working correctly thru current stable release 66.0.1.

see description in comment #12

Severity: normal → S3
Attachment #9383498 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: