Wayland, Windows, MacOS: Popup Implementation (#4543)

Implement proper decorationless popups by specifying the type of the child window with with_type()

With this commit, different kind of child windows can be created

-  Popups: Special windows without any decoration which can be positioned relative to the parent
-  Window: Normal window with a parent or not

The type can be specified during creation of the Window using the window_attributes and the with_type() function. As default a normal Window is used. If Popup is choosen a parent must be specified, otherwise the Popup creation fails with an Error returned by the new() function.

Related issues: #403 and #4256
This commit is contained in:
Martin Marmsoler
2026-07-27 15:43:51 +02:00
committed by GitHub
parent 1fe178b2a6
commit 9674d8ceef
22 changed files with 2035 additions and 368 deletions

View File

@@ -25,7 +25,7 @@ use winit_core::monitor::{Fullscreen, MonitorHandle as CoreMonitorHandle};
use winit_core::window::{
CursorGrabMode, ImeCapabilities, ImeRequest, ImeRequestError, ResizeDirection, Theme,
UserAttentionType, Window as CoreWindow, WindowAttributes, WindowButtons, WindowId,
WindowLevel,
WindowLevel, WindowType,
};
use super::app_state::EventWrapper;
@@ -490,6 +490,12 @@ impl Window {
event_loop: &ActiveEventLoop,
mut window_attributes: WindowAttributes,
) -> Result<Window, RequestError> {
if window_attributes.window_type() == WindowType::Popup {
return Err(RequestError::NotSupported(NotSupportedError::new(
"Popups are not implemented for iOS",
)));
}
let mtm = event_loop.mtm;
if window_attributes.min_surface_size.is_some() {
@@ -590,6 +596,10 @@ impl rwh_06::HasWindowHandle for Window {
}
impl CoreWindow for Window {
fn window_type(&self) -> WindowType {
WindowType::Window
}
fn id(&self) -> winit_core::window::WindowId {
self.maybe_wait_on_main(|delegate| delegate.id())
}