# Supporting Wayland's XDG activation protocol with Gtk/Glib

DevFeed: [Supporting Wayland's XDG activation protocol with Gtk/Glib](<https://devfeed.tech/articles/supporting-wayland-s-xdg-activation-protocol-with-gtk-glib-36631.md>)

Original publisher: [Read original article](<https://palant.info/2026/02/03/supporting-waylands-xdg-activation-protocol-with-gtk/glib/>)

Author: Wladimir Palant

Published: 2026-02-03T10:55:20Z

Content type: tutorial

Language: en

Sources: [Almost Secure](<https://devfeed.tech/sources/almost-secure.md>)

Topics: [Wayland](<https://devfeed.tech/topics/wayland.md>), [GTK](<https://devfeed.tech/topics/gtk.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [browser](<https://devfeed.tech/topics/browser.md>)

Tags: [application](<https://devfeed.tech/tags/application.md>), [browser](<https://devfeed.tech/tags/browser.md>), [protocol](<https://devfeed.tech/tags/protocol.md>), [required](<https://devfeed.tech/tags/required.md>), [using](<https://devfeed.tech/tags/using.md>), [wayland](<https://devfeed.tech/tags/wayland.md>)

## AI overview

This tutorial explains how Wayland's XDG activation protocol transfers focus between applications with consent, and documents its implementation in Gtk/Glib. It covers activation tokens, Gio.AppInfo launch contexts, StartupNotify, and manual environment-variable handling.

## Source excerpt

One of the biggest sore points with Wayland is its focus stealing protection. The idea is good: an application should not be able to bring itself into focus at an unexpected time, only when the currently active application allows it. Support is still lacking however, which might also be due to Gtk/Glib implementing the required XDG activation protocol but not really documenting it. It took me a bit of time to figure this out without any public information, this article will hopefully make things easier for other people. Contents How the XDG activation protocol works State of implementation in Gtk/Glib Starting applications via Gio.AppInfo Starting applications by other means How the XDG activation protocol works The main idea behind the XDG activation protocol is that focus transfer from one application to another requires consent. With X11 a file manager could just launch the browser for an HTML file and the browser would immediately take focus, even if that browser was already running. With Wayland the file manager has to indicate that the browser is allowed to take focus. It does that by giving the browser its XDG activation token, typically via XDG_ACTIVATION_TOKEN environment variable. The browser can then use that activation token to prove consent and take focus. For this to work the protocol has to be supported on both ends: the file manager must know how to retrieve an activation token and pass it on via XDG_ACTIVATION_TOKEN environment variable, and the browser has to know how to use that token. State of implementation in Gtk/Glib The receiving side has been implemented in Gtk with merge request 7118 and is available starting with Gtk 4.14.6 and 4.15.1. This is the unproblematic part: it is handled automatically and doesn't require the application developer to change anything. The sending side has been implemented in Gtk with merge request 3502 and Glib with merge request 3090, so it is available starting with Gtk 4.10.0 and Glib 2.75.1. This is the part wh