mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-03 07:10:05 -04:00
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:
@@ -66,13 +66,26 @@ impl Window {
|
||||
event_loop: &ActiveEventLoop,
|
||||
attribs: WindowAttributes,
|
||||
) -> Result<Self, RequestError> {
|
||||
let window = Arc::new(UnownedWindow::new(event_loop, attribs)?);
|
||||
event_loop.windows.borrow_mut().insert(window.id(), Arc::downgrade(&window));
|
||||
Ok(Window(window))
|
||||
use winit_core::window::WindowType;
|
||||
match attribs.window_type() {
|
||||
WindowType::Window => {
|
||||
let window = Arc::new(UnownedWindow::new(event_loop, attribs)?);
|
||||
event_loop.windows.borrow_mut().insert(window.id(), Arc::downgrade(&window));
|
||||
Ok(Window(window))
|
||||
},
|
||||
WindowType::Popup => Err(RequestError::NotSupported(NotSupportedError::new(
|
||||
"Popups are not implemented for X11",
|
||||
))),
|
||||
_ => Err(RequestError::NotSupported(NotSupportedError::new("Unsupported window type"))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CoreWindow for Window {
|
||||
fn window_type(&self) -> winit_core::window::WindowType {
|
||||
winit_core::window::WindowType::Window
|
||||
}
|
||||
|
||||
fn id(&self) -> WindowId {
|
||||
self.0.id()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user