Francesco149 / weebp

free and open-source wallpaper engine, set any window as your wallpaper
The Unlicense
547 stars 60 forks source link

idea: storing the windows' previous style as a window property #3

Open Francesco149 opened 5 years ago

Francesco149 commented 5 years ago

win32 allows storing string properties into windows:

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setpropa

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getpropa

in theory I could serialize the current window attributes and store them in the window itself when i capture it so it can be restored without having to implement a system to store the window attributes on disk or having to run a daemon process to keep track of them

this only works if you have enough privileges to mess with the window, so if you run a program as admin and then weebp as a user it will fail to store the window properties, but that's fine, I don't think capturing the window would work either in such a situation

this is a bit of a hack but I think it's still more elegant than making weebp rely on any files/locations on disk and adding a bunch of code to serialize, deserialize and clean up this cache

another option is GWL_USERDATA but it's only the size of a pointer and it's used by many programs to store their own data (such as instance pointers) so SetProp is better