tao
tao copied to clipboard
feat: `with_has_shadow`, `has_shadow` and `set_has_shadow`
Is your feature request related to a problem? Please describe.
When using decorations: false the app removes not only the topbar & border, but also the shadow.
Describe the solution you'd like I would like to see the shadow separated into it's own config property. So you could e.g. do:
"windows": [
{
"shadow": true,
"decorations": false
}
]
Which would result in a window without the top bar, without borders but with the OS shadow.
Describe alternatives you've considered I tried building this in my app, but this comes with a lot of edge cases. You can't click through the shadow, you have to dynamically change the spacing/shadow when you are full screen, etc.
Additional context This was experienced on Windows, I have not tested behavior on other OS'.
Windows:
I tried electron and found that:
- Shadows on electron are always ON no matter what whether the window is regular or frameless (without decorations), the only way to turn it OFF is to have a frameless transparent window.
Then I wrote a c++ app to experiment more with win32 apis
- Shadows can't be turned off for regular windows and they are off by default for frameless windows.
- We can add shadow to a frameless window whether it is transparent or not and turn it off too.
MacOS:
- From electron docs:
On Mac, the native window shadow will not be shown on a transparent window.
- We already has
set_has_shadow,with_has_shadowandhas_shadowexposed in Mac specific platform traits.
Linux:
- Linux's shadows/transparency/blur is controlled by the compositor installed on the user system so we might not have much control over this at all.
- (Not tested) GTK3 has
set_shadow_widthmethod and GTK supports CSS so we can usebox-shadowto add shadow to the window. Both of these methods might be able to bypass the compositor configuration but if they bypassed the compositor, they still can be overridden/controlled by whatever GTK theme is installed on the user system.- More info: https://askubuntu.com/a/1151079
@amrbashir Does the shadow configuration include the semi-transparent border in Windows 10/11, or would that require a separate set of methods (e.g. has_border, et al)? Wondering if it's worth filing a separate issue for the border or if this would cover that
Not sure what you mean, but if you mean that tiny little white border in the screenshot you posted in the other issue, then yes adding the shadows will also add that white border, unfortunately we can't separate them from each other and I thnk MS Teams uses the same method I know and plan to use. (for reference: DWMExtendFrameIntoClientarea())
Yeah, the tiny white border is what I meant. 🙂 I don't have a use case for separately modifying the border and shadow, I just wanted a way to get all of the native chrome minus the titlebar, and it sounds like this will do the trick. Thanks for working on this!
The white border is not a native chrome btw. In Windows, the way to remove the titlebar also removes any borders and resizing handlers so we still need use manual detection of mouse click in the first few pixels of the window to allow it to resize and I am pretty sure any frameless app on windows does that even electron and MS Teams.
- Linux's shadows/transparency/blur is controlled by the compositor installed on the user system so we might not have much control over this at all.
@amrbashir Does decorations: false currently keep the shadow around on Linux?
@amrbashir Does
decorations: falsecurrently keep the shadow around on Linux?
I have a custom setup on Linux (awesomewm & picom) and tao windows have shadows but that doesn't necessary mean it has it on full DEs and I haven't tested this on full DE like Gnome or KDE but in theory it should have shadows. I guess I need someone to confirm this.
I made https://github.com/tauri-apps/window-shadows to add shadows on Windows and macOS using a single method, until we implement Windows directly in the core TAO codebase.
Would borders be a better name for the API? In general I consider the shadow of the window part of it's border, and in most cases it's not just a shadow being added/removed (in windows and mac's case).