Skip to content

Pet window shows in the taskbar on Linux and closing it removes the pet (#228 side effect) #233

Description

@pinoybear

Summary

Since the rebuilt v4.0.0 Linux packages (which include #228), the default pet shows up as a normal window on Linux: it gets a taskbar entry ("electron / OpenPets Default Pet"), appears in Alt+Tab and the pager, and closing it from the taskbar destroys the pet. This happens even with the chat button turned off, which is the v4 default.

Reproduce

  1. Install the current OpenPets-4.0.0-linux-x86_64.AppImage (SHA256 7004d8c7fb67be02a6f50d68c56dcd5c39b609e8408c2c73d869bfbfc6c6f49a) on KDE Plasma.
  2. Launch it. The pet appears as expected, but there is also a taskbar entry for it.
  3. Close that taskbar entry. The pet disappears.

A build from the v4.0.0 tag (before #228) does not have a taskbar entry.

Cause

#228 changed shouldPetWindowBeFocusable() so the pet window is always focusable on X11/XWayland. In Electron on Linux, a window created with focusable: false isn't managed by the window manager at all, and that was the only thing keeping the pet out of the taskbar. The skipTaskbar: true option in pet-window.ts has never had any effect on Linux: Electron 42 documents both skipTaskbar and setSkipTaskbar() as macOS/Windows only.

KWin confirms it. On a build from the v4.0.0 tag the pet window is unmanaged (managed: false). On the rebuilt AppImage it's a normal managed window with skipTaskbar: false and demandsAttention: true. pet-window.ts is identical between the tag and main; wayland-backend.ts is the only non-fix change in between.

Since OpenPets forces --ozone-platform=x11 on Linux by default, I'd expect this to affect most Linux setups regardless of desktop. I've only verified it on KDE Plasma, though.

What I tried

On a dev build from main:

  • Calling window.setSkipTaskbar(true) after the window is shown: no effect (as the docs say).
  • type: "toolbar" on Linux X11: still in the taskbar. It did clear the attention flag, and chat input still worked.
  • A throwaway Electron test with focusable windows of every Linux window type (normal, toolbar, dock, splash, notification): all of them appear in the Plasma taskbar.

So there doesn't seem to be an Electron-options fix. Hiding the pet at the window-manager level does work, though, and chat input still takes typing with it hidden. Staying out of the taskbar and accepting keyboard focus aren't in conflict; Electron just can't request it on Linux.

Possible directions

  • Only make the pet focusable while chat or a plugin input is actually in use, e.g. by recreating the window, since KWin won't pick up a runtime setFocusable() change (as fix(desktop): keep X11/XWayland pet windows focusable to fix chat input (#227) #228 found).
  • Keep the pet unfocusable on X11 and host the chat input in its own small focusable window.
  • Set _NET_WM_STATE_SKIP_TASKBAR on the X11 window before it's first mapped. That needs native code.

At minimum: make closing the pet harmless

Even if the taskbar entry stays for now, closing it shouldn't destroy the pet. Right now the default pet window's close handler in pet-window.ts only saves the pet's position and then lets the close go through, so the window is gone until OpenPets restarts.

The usual Electron pattern would fix that:

  • In the pet window's close handler, call event.preventDefault() and hide the pet instead, the same way the tray's "Hide Default Pet" does (hideDefaultPet()).
  • Set an "app is quitting" flag in app.on("before-quit") and only cancel the close when it isn't set, so the tray's Quit, logging out and shutting down still close the app normally. OpenPets' own teardown uses destroy(), which doesn't fire close, so it wouldn't be affected.

With that, closing the pet's taskbar entry (or pressing Alt+F4 while the pet has focus) would just hide the pet. Its taskbar entry goes away with it, and "Show Default Pet" in the tray brings it back. It doesn't remove the taskbar entry while the pet is visible, but it turns an easy accident into something harmless.

One thing to decide: hideDefaultPet() also turns off showing the pet at the next launch, so a close would be remembered across restarts. A plain window.hide() would only hide it until OpenPets restarts. I'm not sure which you'd prefer.

Workaround (KDE only)

A KWin window rule restores the old behavior without breaking chat input: System Settings > Window Management > Window Rules > Add New, match window class open-pets-desktop (exact) and window title OpenPets Default Pet (exact), then force "Skip taskbar", "Skip pager", and "Skip switcher" to Yes. The title match matters because Control Center uses the same window class. This doesn't cover extra agent/plugin pets, which have other titles.

Environment

  • CachyOS Linux (rolling), kernel 7.2.7-1-cachyos
  • KDE Plasma 6.7.5, KWin 6.7.5
  • OpenPets v4.0.0 (rebuilt Linux packages), Electron 42.0.0
  • Launched with --ozone-platform=x11 (XWayland)

Activity

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