KDE Plasma prepares crackdown on focus-stealing window behavior under Wayland

KDE Plasma prepares crackdown on focus-stealing window behavior under Wayland

Home » News » KDE Plasma prepares crackdown on focus-stealing window behavior under Wayland
Table of Contents

KDE Plasma

One of the vital attention-grabbing issues about Wayland is the way it handles window focus, not like X11, the place focus stealing might be irritating and even a safety threat. Its major benefit is a mechanism that forestalls focus stealing. The protocol that performs a job on this is called “XDG Activation.”

This works by having an app request a novel token from the compositor. The compositor can create this token in response to person enter. The brand new utility then presents the token to get focus, which is granted if the token is legitimate and the request is deemed applicable. If it is denied, the window is marked as “wants consideration,” and that is whenever you see a flashing icon on the taskbar.

KWrite text editor window window has no focus colors are softened Task bar with a couple of apps KWrite icon has an orange background behind it indicating KWrite is demanding attention
Flashing icon within the taskbar | Picture: Kai-Uwe Broulik

Kai-Uwe Broulik, a KDE developer, just lately wrote concerning the plan to “swap on KWin’s focus stealing on Wayland at a low degree”. This implies KWin, the window supervisor for KDE Plasma, will start implementing this correctly.

Below X11, new or dialog home windows can solely seize focus if their utility was most just lately energetic, a verify usually based mostly on a timestamp known as _NET_WM_USER_TIME. It was a flimsy system at finest. For instance, Kai cited how the prevention logic on X11 would typically cease the Adobe Flash Participant fullscreen window from displaying on high of a YouTube video. On X11, an utility might simply name XSetInputFocus on one other app’s window, and whereas KWin would attempt to undo it, focus did flicker for a second.

Over on Wayland, issues are a lot better with XDG Activation, however some apps nonetheless violate the protocol via improper utilization. In conditions like that, KWin would, by default, simply focus any new window that opened. That is altering.

A brand new “Excessive” setting for “Focus Stealing Prevention” within the Window Administration settings will pressure KWin to activate a window if and provided that it requests activation with a legitimate token.

Window Behavior configuration dialog various window-related tabs and options mouse cursor pointing at a combo box Focus stealing prevention whose current item is Extreme
Picture: Kai-Uwe Broulik

Utilizing this stricter mode, builders Xaver Hugl and Kai-Uwe Broulik have already mounted a ton of points, introducing a number of key modifications:

  • Dolphin now not discards its activation token when launching a brand new occasion.
  • KRunner, Kickoff, and different Plasmoid popups now accurately request activation.
  • LayerShell-Qt now requests activation on present and correctly reads the XDG_ACTIVATION_TOKEN from the atmosphere.
  • Permitting privileged purchasers like Plasma to request tokens accurately.
  • Ignoring modifier key presses for focus prevention logic, since they’re usually a part of a worldwide shortcut.

The work extends to the backend as nicely, with the DBusRunner specification now gaining a SetActivationToken methodology that known as simply earlier than an motion runs. Baloo, the desktop search runner, now makes use of this to make sure that opening information in an current utility window works accurately.

You’ll be able to be taught extra on Kai’s weblog publish.

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

share this article.

Enjoying my articles?

Sign up to get new content delivered straight to your inbox.

Please enable JavaScript in your browser to complete this form.
Name