Add macOS-specific has_shadow and with_has_shadow to ViewportBuilder#6850
Merged
emilk merged 1 commit intoemilk:masterfrom Apr 29, 2025
Merged
Add macOS-specific has_shadow and with_has_shadow to ViewportBuilder#6850emilk merged 1 commit intoemilk:masterfrom
has_shadow and with_has_shadow to ViewportBuilder#6850emilk merged 1 commit intoemilk:masterfrom
Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/6850-viewporthasshadow |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_shadowto theViewportBuildervia a newwith_has_shadowoption.Example of Ghosting Issue
Before
ViewportBuilder::with_has_shadowBy default, the underlying
winitwindow's.has_shadow()defaults totrue.Screen.Recording.2025-04-22.at.4.00.54.PM.mov
After
ViewportBuilder::with_has_shadowScreen.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,
winitwindows 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 ofbevy, another Rust project that has an upstream dependency onwinit: bevyengine/bevy#18673