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

feat: with_has_shadow, has_shadow and set_has_shadow #157

Closed
michaelowens opened this issue Jul 22, 2021 · 9 comments · Fixed by #664
Closed

feat: with_has_shadow, has_shadow and set_has_shadow #157

michaelowens opened this issue Jul 22, 2021 · 9 comments · Fixed by #664

Comments

@michaelowens
Copy link

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

@amrbashir amrbashir transferred this issue from tauri-apps/tauri Jul 22, 2021
@amrbashir amrbashir changed the title Separate window shadow config from decorations feat: with_shadow and set_shadow Jul 22, 2021
@amrbashir
Copy link
Member

amrbashir commented Aug 3, 2021

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_shadow and has_shadow exposed 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_width method and GTK supports CSS so we can use box-shadow to 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.

@amrbashir amrbashir changed the title feat: with_shadow and set_shadow feat: has_shadow and set_has_shadow Aug 12, 2021
@amrbashir amrbashir changed the title feat: has_shadow and set_has_shadow feat: with_has_shadow, has_shadow and set_has_shadow Aug 12, 2021
@dannymcgee
Copy link

@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

@amrbashir
Copy link
Member

amrbashir commented Dec 7, 2021

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())

@dannymcgee
Copy link

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!

@amrbashir
Copy link
Member

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.

@probablykasper
Copy link
Member

  • 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
Copy link
Member

@amrbashir Does decorations: false currently 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.

@amrbashir
Copy link
Member

amrbashir commented Dec 30, 2021

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.

@Tropix126
Copy link

Tropix126 commented Feb 23, 2022

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

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