Bug 410381 - Opening links should open a new tab in a visible browser
Summary: Opening links should open a new tab in a visible browser
Status: RESOLVED UPSTREAM
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-30 04:44 UTC by manuelchaves
Modified: 2020-04-22 07:03 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description manuelchaves 2019-07-30 04:44:33 UTC
SUMMARY


STEPS TO REPRODUCE
1. Have multiple desktops
2. Have Firefox in one virtual desktop and another Firefox in another
3. Focus one Firefox
4. Change to the other virtual desktop
5. Open a link

OBSERVED RESULT
It opens in Firefox of the inactive virtual desktop
The green indicator in the taskbar appears (to pick between instances) when clicking it it shows both Firefox instances. Clicking the one where the link opens changes the virtual desktop.

EXPECTED RESULT
I would expect the link to open in the Firefox of the current virtual desktop since it's visible.

Notes: I use 2 monitors, both Firefox are on the right monitor, I open links from applications in the left monitor.


Operating System: KDE neon 5.16
KDE Plasma Version: 5.16.3
KDE Frameworks Version: 5.60.0
Qt Version: 5.12.3
Kernel Version: 4.18.0-25-generic
OS Type: 64-bit
Processors: 4 × Intel® Core™ i5-4690K CPU @ 3.50GHz
Memory: 15,6 GiB of RAM
Comment 1 Nate Graham 2019-08-05 04:03:00 UTC
What app has the link that you're clicking on? Another web browser? Some KDE app?
Comment 2 manuelchaves 2019-08-05 04:26:19 UTC
Usually it's Hexchat, which is a GTK based desktop application.
Comment 3 Nate Graham 2019-08-05 05:15:37 UTC
Can you test with a KDE app? Every one has clickable links in Help > About KDE.
Comment 4 manuelchaves 2019-08-05 05:49:45 UTC
I tried with Konversation. Same thing, but here are some additional observation:

Not sure exactly what happens, but if I click the link in Konversation, if the the Firefox in VD1 wasn't focused last, it opens it in the Firefox at VD2, as described. The weird thing is, subsequent clicks to the link open the Firefox in the correct (VD1) Firefox, even if I force focus the other one (at VD2) (This happens after closing whatever the link opened in in the Firefox in VD2 and focusing the Firefox in VD1 and then focusing on the Firefox on VD2 again before trying to click the link). As soon as I paste a fresh new link (im testing with Imgur image links), it will open it on VD2 Firefox if it was the last focused.

Not sure if I'm explaining myself well.
Comment 5 Nate Graham 2019-08-06 03:32:04 UTC
Thanks for the info!
Comment 6 manuelchaves 2019-08-06 04:45:53 UTC
I also opened a bug in the Firefox bug tracker, since it might be a Firefox issue.
Comment 7 Christoph Feck 2019-08-20 21:37:19 UTC
I hope this is a per-browser setting. I have configured my browser (Otter Browser) to open new windows instead of new tabs, and I don't want anything to override my decision.
Comment 8 Ahmad Samir 2019-09-01 19:11:39 UTC
I "guess" it'll have to be something that firefox upstream has to implement. This is based on how kate handles opening documents, by default if you have a kate instance running on the current virtual desktop it'll open the document in that instance. Otherwise it'll open the document in a new instance, even if you have a kate instance running on a different virtual desktop.

What I want to say, it's most likely app-dependent. Upstream firefox doesn't, at the time of writing this, even support restoring windows from a firefox session to the virtual desktop that each window was open on[1].

https://bugzilla.mozilla.org/show_bug.cgi?id=372650
Comment 9 Ahmad Samir 2019-11-19 13:12:02 UTC
FWIW, you can work around the issue by making firefox open the url in a new window, which naturally will open on the current virtual desktop, instead of a tab in an already existing window by changing the default web browser to this command (systemsettings -> applications -> default applications -> web browser, "with the following command" lineedit box):

/usr/bin/firefox --new-window
Comment 10 Ahmad Samir 2020-01-22 12:24:46 UTC
This isn't a KIO bug AFAICS; it falls to the individual apps to handle such issues.

FWIW, here's a hacky bash script that I use to make firefox always open links on the current desktop:
#!/bin/bash
# get the current virtual desktop number
currDesktopNum=$(wmctrl -d | grep -F "*" | cut -d' ' -f1)

# get the title of any firefox window, if any exist, on the current desktop
ffWinTitle=$(wmctrl -l | grep Mozilla\ Firefox | grep -F "  "$currDesktopNum" " | perl -p -e 's!.+?\s+\d .+? ([/\w].+)!$1!')

# if the title isn't empty, i.e. there's a firefox window on this desktop, raise that window
# then call firefox --new-tab; otherwise call firefox --new-window
if [ ! -z "$ffWinTitle" ]; then
    wmctrl -a "$ffWinTitle"
    /usr/bin/firefox --new-tab "$@" &
else
    /usr/bin/firefox --new-window "$@" &
fi
Comment 11 Ahmad Samir 2020-04-22 07:03:32 UTC
If someone stumbles upon this report, here's a better version of my puny script that uses window ID instead of relying on title (if you have two firefox windows with the same title on two different virtual desktops, it's playing a toss-up):

#!/bin/bash
# get the current virtual desktop number
currDesktopNum=$(wmctrl -d | grep -F "*" | cut -d' ' -f1)

# get the win id of any firefox window, if any exists, on the current desktop
ffWinID=$(wmctrl -l | grep Mozilla\ Firefox | grep -F "  "$currDesktopNum" " | head -n1 | perl -p -e 's!([\S]+).+!$1!')

# if the win id isn't empty, i.e. there's a firefox window on this desktop, raise that window
# then call firefox --new-tab; otherwise call firefox --new-window
if [ ! -z "$ffWinID" ]; then
    wmctrl -i -a "$ffWinID"
    /usr/bin/firefox --new-tab "$@"
else
    /usr/bin/firefox --new-window "$@"
fi