Closed Bug 1767546 Opened 3 years ago Closed 2 years ago

[Wayland] Support XDG_ACTIVATION_TOKEN env var

Categories

(Core :: Widget: Gtk, enhancement)

Firefox 100
enhancement

Tracking

()

RESOLVED FIXED
108 Branch
Tracking Status
firefox108 --- fixed

People

(Reporter: contact, Assigned: emilio)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101 Firefox/100.0

Steps to reproduce:

There's no way to raise firefox from other apps from what I can see or the way of doing so is unclear. Firefox already implemented xdg-activation-v1, however the XDG_ACTIVATION_TOKEN was left alone.

The xdg-activation-v1 protocol states the following.

This token is then forwarded to the client, which is supposed to activate one of its surfaces, through a separate band of communication.

One established way of doing this is through the XDG_ACTIVATION_TOKEN environment variable of a newly launched child process. The child process should unset the environment variable again right after reading it out in order to avoid propagating it to other child processes.

Another established way exists for Applications implementing the D-Bus interface org.freedesktop.Application, which should get their token under XDG_ACTIVATION_TOKEN on their platform_data.

It's similar to X11 DESKTOP_STARTUP_ID(which firefox has some handling for), and is supported by gtk from what I can see.

Actual results:

Firefox isn't activated when passing XDG_ACTIVATION_TOKEN token to it.

Expected results:

Firefox should activate with when the token was provided to it.

The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

Gentle ping on this :)
I suppose this won't be hard since firefox already has code for activating itself.

https://searchfox.org/mozilla-central/rev/ed02e6e84e433cd283e86377524462b4e8b1597b/toolkit/xre/nsAppRunner.cpp#3798 is the desktop-startup-id-handling code, probably similar code could be added to wayland.

This ought to work but I'm not sure how to best test this?

Assignee: nobody → emilio
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Hmm, but that already works for me on GNOME at least... what gives?

I can try kwin too, let's see.

Ok, so after the patch I can raise the Firefox window from foot, while I couldn't do so (this is on Kwin, on Mutter it all just works). So the patch is working as expected.

That said, it's a bit sad that programs are expected to get a token and set the environment variable before spawning another process... Presumably we should do the same when opening third-party applications (from LaunchWithURI).

Vlad, do you know the difference between KWin and Mutter here? Mutter's behavior seems a bit nicer for users at least.

Flags: needinfo?(vlad.zahorodnii)

Oh, nice I started looking into this myself yesterday. I tested your patch on my machine and it works fine. If I click a link in Konsole, firefox gets the activation token through the XDG_ACTIVATION_TOKEN environment variable.

Flags: needinfo?(vlad.zahorodnii)

That said, it's a bit sad that programs are expected to get a token and set the environment variable before spawning another process... Presumably we should do the same when opening third-party applications (from LaunchWithURI).

At the moment, the two most popular options are either to set the XDG_ACTIVATION_TOKEN environment variable or set "activation-token" property in platform_data in org.freedesktop.Application requests. You're obviously not limited by those two options and could use IPC of choice if it's more suitable for your needs.

Attachment #9299743 - Attachment description: Bug 1767546 - Support XDG_STARTUP_TOKEN. r=stransky → Bug 1767546 - Support XDG_ACTIVATION_TOKEN. r=stransky

Hmm, but that already works for me on GNOME at least... what gives?
There could be some kind of GTK-specific mechanism involved

Presumably we should do the same when opening third-party applications (from LaunchWithURI).
Yes, you should. The exact mechanism to be used depends on how these apps are launched. When launching them by invoking the executable then pass the token via XDG_ACTIVATION_TOKEN evironment variable.

When launching them using DBus-activation then set "activation-token" property in platform_data in org.freedesktop.Application requests.

When launching the file manager via org.freedesktop.FileManager1 then pass it as StartupId parameter

Duplicate of this bug: 1798747
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 108 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: