Skip to content

Hyprland: toplevels created from windowtitlev2 for never-mapped windows are never removed (refreshToplevels does not prune) #1450

Open

Description

@TechDufus

Summary

Hyprland.toplevels accumulates entries that Hyprland never reports as clients. They are created by windowtitlev2 events for XWayland windows that are never mapped, so Hyprland never sends openwindow or closewindow for them. Nothing ever removes them: closewindow never arrives, and refreshToplevels() only adds/updates from j/clients, never prunes. They persist until the shell restarts.

Wine/Proton apps trigger this heavily (hidden helper windows like Default IME, QTrayIconMessageWindow, etc.), so any window switcher or taskbar built on Hyprland.toplevels fills up with dead entries that have a title but no workspace and can't be focused.

Versions

  • Quickshell 0.3.2 (revision 2b4501a, distro build)
  • Hyprland 0.56.2
  • Trigger app: Battle.net under GE-Proton (umu-launcher), XWayland

Minimal repro

Run with quickshell -p shell.qml, then start and quit any Wine app (Battle.net reproduces it every time):

import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Io

// Logs Quickshell's Hyprland.toplevels next to Hyprland's own j/clients every 3s.
ShellRoot {
  property var hyprAddresses: []

  Process {
    id: clients
    command: ["hyprctl", "clients", "-j"]
    stdout: StdioCollector {
      onStreamFinished: {
        var list = JSON.parse(text);
        var out = [];
        for (var i = 0; i < list.length; i++) out.push(list[i].address.replace(/^0x/, ""));
        hyprAddresses = out;
      }
    }
  }

  Timer {
    interval: 3000
    running: true
    repeat: true
    onTriggered: {
      Hyprland.refreshToplevels();
      clients.running = true;
      var values = Hyprland.toplevels.values;
      var ghosts = [];
      for (var i = 0; i < values.length; i++) {
        var t = values[i];
        if (hyprAddresses.indexOf(t.address) === -1)
          ghosts.push(t.address + " ws=" + (t.workspace ? t.workspace.name : "null") + " title=" + JSON.stringify(t.title));
      }
      console.log("qs_toplevels=" + values.length + " hypr_clients=" + hyprAddresses.length + " ghosts=" + ghosts.length);
      for (var j = 0; j < ghosts.length; j++) console.log("  GHOST " + ghosts[j]);
    }
  }
}

Observed

Baseline: qs_toplevels=4 hypr_clients=4 ghosts=0.

While Battle.net was starting, Hyprland.toplevels grew to 30 entries while j/clients reported 5. After Battle.net exited (all processes gone), it stayed at 29 vs 4 for every subsequent 3s tick, despite refreshToplevels() being called each time. The 25 leftovers all have workspace == null:

GHOST 562a80c64330 ws=null title="Input"
GHOST 562a7d24aa60 ws=null title="Default IME"        (x7 distinct addresses)
GHOST 562a80d5ece0 ws=null title="C:\\ProgramData\\Battle.net\\Agent\\Agent.9852\\Agent.exe"
GHOST 562a7d24c9b0 ws=null title="Agent"
GHOST 562a80d59e80 ws=null title="C:\\ProgramData\\Battle.net\\Agent\\AgentHelper.exe"
GHOST 562a80d04330 ws=null title="QTrayIconMessageWindow"
GHOST 562a80f48100 ws=null title="Battle.net"         (x14 distinct addresses)

Hyprland socket2 events (captured in parallel)

Every leaked address received only title events, e.g.:

windowtitle>>562a7d24aa60
windowtitlev2>>562a7d24aa60,Default IME
windowtitle>>562a80d04330
windowtitlev2>>562a80d04330,QTrayIconMessageWindow
windowtitle>>562a80f48100
windowtitlev2>>562a80f48100,Battle.net
windowtitle>>562a80f48100
windowtitlev2>>562a80f48100,Battle.net

No openwindow, closewindow, movewindowv2 or activewindowv2 was ever emitted for any of them, including when the Wine process exited. For contrast, the real window got the normal sequence and was cleaned up correctly:

windowtitlev2>>562a7d237b60,Battle.net
openwindow>>562a7d237b60,11,steam_app_battlenet,Battle.net
...
closewindow>>562a7d237b60

Cause (src/wayland/hyprland/ipc/connection.cpp)

  • The windowtitlev2 handler calls findToplevelByAddress(windowAddress, /*createIfMissing=*/true), which is intentional because Hyprland can send the title before openwindow (visible above for the real window too). activewindowv2 and urgent do the same.
  • A toplevel is only removed on closewindow, which Hyprland never sends for a window it never mapped.
  • refreshToplevels() iterates j/clients and creates/updates entries, but never removes entries absent from the response, so it can't recover from this.

Possible fixes

  1. Make refreshToplevels() authoritative: remove toplevels not present in j/clients. This needs to coexist with the in-flight-request race described in Hyprland: refreshToplevels() resurrects a window closed while the j/clients request is in flight #1268 (e.g. only prune entries whose last event predates the request).
  2. Treat toplevels created by windowtitlev2/activewindowv2/urgent as pending: keep them out of Hyprland.toplevels until openwindow arrives, and drop pending entries that aren't in the next j/clients refresh.

(2) keeps the "title before openwindow" handling while preventing never-mapped windows from ever reaching consumers.

Related: #1268 (refreshToplevels resurrecting a closed window).

Activity

  1. immindich commented on Nov 9, 2026

    @immindich

    I was running into the same issue myself with Steam and just submitted a PR for it (#1465) which you're welcome to test. I took a slightly different approach from the ones you suggested and just had Quickshell not preemptively track the toplevel on windowtitlev2. Having refreshToplevels prune is probably worth doing, but not really sufficient to solve this problem on its own, since the state is supposed to stay up to date without manually refreshing. I explained my reasoning a bit more in the PR description.

  2. bmaltais commented on Dec 2, 2026

    @bmaltais

    Another way this shows up, with windows that were actually mapped.

    StartBar only renders Hyprland.toplevels. It kept two C:\Windows\System32\cmd.exe entries after those windows were gone. They were real consoles from an LSW Windows VM. Once the VM was shut off, hyprctl clients listed only the two apps still open (Edge and Herdr). The taskbar still showed one icon with two window marks for the consoles. Restarting the shell built a fresh toplevel list and the marks disappeared.

    Quickshell 0.3.2, revision 2b4501a, Omarchy package. Hyprland 0.57.2.

    I did not capture whether Hyprland emitted closewindow. The clients list and Hyprland.toplevels had already diverged, and the running shell never brought them back together. refreshToplevels() only adds and updates, so a later call would not have dropped them either.

    Same missing prune as this issue, for windows that did exist as clients and then did not. #1501 would remove them the next time refreshToplevels() runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions