Ciantic/AltTabAccessor

Possible to expose a wrapper for IApplicationView::set_cloak?

LGUG2Z opened this issue ยท 9 comments

LGUG2Z commented

https://github.com/Ciantic/VirtualDesktopAccessor/blob/45d66e83f4a11523faa9f2073b5241867e2a60a0/src/comapi/interfaces.rs#L157

Hi! I really appreciate the great work you are doing here. Is it possible to expose a wrapper function for cloaking and uncloaking windows by HWND with this library? Unfortunately DWMWA_CLOAKED can only be used with DwmGetWindowAttribute but not with DwmSetWindowAttribute.

I think that this set_cloak fn is what is used internally by Windows to allow cloaking of application windows when switching between virtual desktops- I would love to be able to use this in komorebi directly instead of hiding or minimizing the windows when transitioning between workspaces to make the transitions smoother and more reliable.

Howdy, I have to think about this. What is the use case for that cloaking in Virtual Desktops?

What does cloaking mean?


Generally, I don't plan to expose any of the IApplicationView things in this DLL. I try to focus on Virtual Desktop related functions for the time being. But if there is a good use case then I'll think about it.

I know it is pretty trivial to write DLL to expose all of them and sounds like that's what many want: #2

I know what it allows: Iterating programs in ALT+TAB order, and getting live previews of each app for instance, ... I did start one app called AltTabRoyal but I don't work on that at the moment.

LGUG2Z commented

This is the best article that I've been able to find about cloaking, which makes it sound like much of the Win32 Virtual Desktops switching feature is built on cloaking and uncloaking application windows.

I completely understand your desire to keep this crate focused on a specific area. If you get some time, could you share roughly how you would go about exposing a function from IApplicationView as a library function? I have to admit with some embarrassment that I cloned the repo and tried to do this myself but I got stuck very quickly. ๐Ÿ˜…

I'd be happy to make a fork in which I expose a wrapper for this fn that I'd like to use, which could also serve as a small self-contained example for others who would like to wrap the more esoteric functions of the various interfaces in an ergonomic way for use in other Rust projects.

I made simple starter:

https://github.com/Ciantic/AltTabAccessor

With just Cloaking

I don't know what to call it with, but maybe you can figure it out?

image

I hit test and it gives error from setCloak

I moved this to AltTabAccessor, SetCloak is now here, but I don't know what I'd use this DLL yet, so this is just a starter if someone wants to expose more IApplicationView related functions.

LGUG2Z commented

Thank you! With some trial and error I managed to figure out that cloak_type 1 with flags 2 cloak a window and cloak_type 1 with flags 0 uncloak a window! This is amazing!

I tried to add this crate to my Cargo.toml but I couldn't get it to play nicely with the capitalized package name. I had a quick Google around but maybe I'm missing something?

In any case this is a huge step forward for me on multiple long standing issues with how komorebi handles workspace transitions. ๐Ÿ™

I changed the crate name to "alt-tab-accessor", maybe it works now?

Sounds like you probably could fork this, I don't plan to develop this in near future. You could need a lot more functionality from IApplicationView, I know that you can get the LivePreviews with those functions too...

LivePreviews are these things:

image

What are the advantages of using cloaking instead of just SW_HIDE?

What are the advantages of using cloaking instead of just SW_HIDE?

see the Raymond Chen article linked above

or from https://www.autohotkey.com/boards/viewtopic.php?t=65170 :

// Cloaking removes the window from the view,
// while still allowing it to retain and update its bitmap.

What are the advantages of using cloaking instead of just SW_HIDE?

see the Raymond Chen article linked above

or from https://www.autohotkey.com/boards/viewtopic.php?t=65170 :

// Cloaking removes the window from the view,
// while still allowing it to retain and update its bitmap.

That's awesome!
But tbh, I don't think it works as intended.
Because if I leave the uwp version of whatsapp on a VD and switch to another, it stops syncing and only starts again when I switch back to the VD that has it.