meslzy / electron-as-wallpaper

set your electron window as wallpaper behind desktop icons
MIT License
68 stars 10 forks source link

document.addEventListener('visibilitychange', visibilityListener) not work after attach() #20

Open Jarvay opened 5 months ago

Jarvay commented 5 months ago

I want to play the video when the document is visible and pause when hidden Is there any way to make it work?

meslzy commented 5 months ago

When you attach your window it's now part of the desktop window, so if you want to implement the visibility, here what you have to do.

The window is visible when user have no foreground windows.

The window is invisible when user open full screen app or focus another app.

I have already implemented this logic for the mouse and keyboard forward, as it only works when user focus the desktop

https://github.com/meslzy/electron-as-wallpaper/blob/48bd45d959f8fc35977a202a1f5e5fb42153eea4/library/platforms/windows.cpp#L25

So you probably need c++ to check when the desktop is focused or not.

Jarvay commented 5 months ago

Thanks, maybe i should try another way, i don't know c++

meslzy commented 4 months ago

I had the same issue, and i didn't want to create native addon for it. so i think its better to include the features.

Reponing to close once solved.