Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to expose a wrapper for IApplicationView::set_cloak? #1

Open
LGUG2Z opened this issue Feb 11, 2023 · 9 comments
Open

Possible to expose a wrapper for IApplicationView::set_cloak? #1

LGUG2Z opened this issue Feb 11, 2023 · 9 comments

Comments

@LGUG2Z
Copy link

LGUG2Z commented Feb 11, 2023

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.

@Ciantic
Copy link
Owner

Ciantic commented Feb 11, 2023

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
Copy link
Author

LGUG2Z commented Feb 11, 2023

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.

@Ciantic
Copy link
Owner

Ciantic commented Feb 11, 2023

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

@Ciantic Ciantic transferred this issue from Ciantic/VirtualDesktopAccessor Feb 11, 2023
@Ciantic
Copy link
Owner

Ciantic commented Feb 11, 2023

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
Copy link
Author

LGUG2Z commented Feb 11, 2023

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. 🙏

@Ciantic
Copy link
Owner

Ciantic commented Feb 11, 2023

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

@theSoberSobber
Copy link

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

@mmikeww
Copy link

mmikeww commented Jan 16, 2024

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.

@theSoberSobber
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants