Skip to content

[Windows] Transparent Desktop Mode #3

@honza0777

Description

@honza0777
Image Image

✅ What this Pull Request adds

This PR introduces an optional transparent desktop mode for Windows, making PyDeskMates behave much closer to original DeskMate-style companions:

✔ Borderless & transparent window (no grey background)
✔ Character appears directly on the desktop instead of an opaque window
✔ Window can optionally attach to WorkerW (behind desktop icons)
✔ Still interactive – sprite can be clicked or dragged
✔ No effect on Linux/macOS (code runs only if sys.platform == "win32")


💡 Why this is useful

  • Characters look like they are “walking freely on the desktop”
  • Much closer to the original Japanese DeskMate behaviour
  • Keeps full interactivity (drag & drop character, mouse interactions)
  • Does not break existing code or platforms

⚙ Technical Summary

  • Uses Win32 layered window + color key (SetLayeredWindowAttributes)
  • Default background color (64,64,64) is made fully transparent
  • Pygame window is created with pg.NOFRAME | pg.SRCALPHA on Windows
  • Window can be attached to desktop surface (WorkerW)

To disable desktop embedding, just comment this line:

put_window_on_desktop(hwnd)

**Modified file (example implementation):**  
➡️ View: https://gist.github.com/honza0777/5228c1af4ff9d16457e8a084d0667f9c  
➡️ Raw (download): https://gist.githubusercontent.com/honza0777/5228c1af4ff9d16457e8a084d0667f9c/raw/main.py

Tested on: Windows 11 (Python 3.10 + pygame 2.6.1)
Likely compatible with: Windows 10, but not explicitly tested

This feature is optional and can be easily disabled by commenting out one line.

Let me know if you'd prefer this behind a config option (e.g. in config.ini), or if I should convert it into a toggle instead of default behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions