Skip to content

Add macOS-specific has_shadow and with_has_shadow to ViewportBuilder#6850

Merged
emilk merged 1 commit intoemilk:masterfrom
gaelanmcmillan:viewport_has_shadow
Apr 29, 2025
Merged

Add macOS-specific has_shadow and with_has_shadow to ViewportBuilder#6850
emilk merged 1 commit intoemilk:masterfrom
gaelanmcmillan:viewport_has_shadow

Conversation

@gaelanmcmillan
Copy link
Contributor

  • I have followed the instructions in the PR template

This PR fixes a ghosting issue I encountered while making a native macOS transparent overlay app using egui and eframe by exposing the existing macOS window attribute has_shadow to the ViewportBuilder via a new with_has_shadow option.

Example of Ghosting Issue

Before ViewportBuilder::with_has_shadow

By default, the underlying winit window's .has_shadow() defaults to true.

Screen.Recording.2025-04-22.at.4.00.54.PM.mov

After ViewportBuilder::with_has_shadow

Screen.Recording.2025-04-22.at.4.25.18.PM.mov

Source code for the above example can be found here:
https://github.com/gaelanmcmillan/egui-overlay-app-with-shadow-artifacts-example/blob/main/src/main.rs

Further background

By default on macOS, winit windows have a drop-shadow effect. When creating a fully transparent overlay GUI, this drop-shadow can create a ghosting effect, as the window content has a drop shadow which is not cleared by the app itself. This issue has been experienced by users of bevy, another Rust project that has an upstream dependency on winit: bevyengine/bevy#18673

@gaelanmcmillan gaelanmcmillan marked this pull request as ready for review April 23, 2025 14:10
Copy link
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@github-actions
Copy link

Preview available at https://egui-pr-preview.github.io/pr/6850-viewporthasshadow
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@lucasmerlin lucasmerlin added eframe Relates to epi and eframe egui-winit porblems related to winit feature New feature or request labels Apr 28, 2025
@emilk emilk merged commit 3a02963 into emilk:master Apr 29, 2025
27 of 28 checks passed
darkwater pushed a commit to darkwater/egui that referenced this pull request Aug 24, 2025
…der (emilk#6850)

* [X] I have followed the instructions in the PR template

This PR fixes a ghosting issue I encountered while making a native macOS
transparent overlay app using egui and eframe by exposing the [existing
macOS window attribute
`has_shadow`](https://docs.rs/winit/latest/winit/platform/macos/trait.WindowExtMacOS.html#tymethod.has_shadow)
to the `ViewportBuilder` via a new `with_has_shadow` option.

## Example of Ghosting Issue

### Before `ViewportBuilder::with_has_shadow`
By default, the underlying `winit` window's `.has_shadow()` defaults to
`true`.


https://github.com/user-attachments/assets/c3dcc2bd-535a-4960-918e-3ae5df503b12

### After `ViewportBuilder::with_has_shadow`


https://github.com/user-attachments/assets/484462a1-ea88-43e6-85b4-0bb9724e5f14

Source code for the above example can be found here:

https://github.com/gaelanmcmillan/egui-overlay-app-with-shadow-artifacts-example/blob/main/src/main.rs


### Further background
By default on macOS, `winit` windows have a drop-shadow effect. When
creating a fully transparent overlay GUI, this drop-shadow can create a
ghosting effect, as the window content has a drop shadow which is not
cleared by the app itself. This issue has been experienced by users of
`bevy`, another Rust project that has an upstream dependency on `winit`:
bevyengine/bevy#18673
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eframe Relates to epi and eframe egui-winit porblems related to winit feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants