Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
41379f1
initial commit to implement popup
Murmele Mar 24, 2026
c1b049e
Fix compilation
Murmele Mar 24, 2026
0bdfd51
WIP
Murmele Mar 25, 2026
baf8202
Fix that PopupHandle::configure will be called
Murmele Mar 25, 2026
7750bf0
send window_requests to redraw to draw the background. Now it crashed…
Murmele Mar 25, 2026
1988825
initial commit to use a WindowType and using the WindowState also for…
Murmele Mar 25, 2026
568550a
WIP
Murmele Mar 25, 2026
7557189
got the popups working but they are not yet at the desired position
Murmele Mar 26, 2026
d9340a8
use dedicated type to determine if the window is a popup or not
Murmele Mar 26, 2026
81b39e5
determine the scale factor from the parent window
Murmele Mar 26, 2026
322f8ed
add comment, thtat positioning is now also working on wayland with po…
Murmele Mar 26, 2026
263399e
set the positioner gravity
Murmele Mar 26, 2026
f222cf6
remnove popup::state
Murmele Mar 26, 2026
b321ecf
no need to store the positioner
Murmele Mar 26, 2026
cd2fbdd
add comment
Murmele Mar 26, 2026
7affc66
use official sctk
Murmele Mar 26, 2026
261194b
consider the location of the frame for client side decoration
Murmele Mar 26, 2026
b84939c
extend comment
Murmele Mar 31, 2026
10fd84f
fix closing popups
Murmele Apr 7, 2026
977beb2
no need to store the SctkPopup inside the Popup, it is already in th…
Murmele Apr 7, 2026
d006c17
implement resizing of the popup using the positioner
Murmele Apr 7, 2026
e15dd13
enable redraw requests for the popup
Murmele Apr 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions winit-core/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ impl fmt::Debug for WindowId {
}
}

#[derive(Debug, Clone, Copy, Default, PartialEq)]
pub enum WindowType {
#[default]
Window,
Popup,
}

/// Attributes used when creating a window.
#[derive(Debug)]
#[non_exhaustive]
Expand All @@ -72,6 +79,7 @@ pub struct WindowAttributes {
pub(crate) parent_window: Option<SendSyncRawWindowHandle>,
pub fullscreen: Option<Fullscreen>,
pub platform: Option<Box<dyn PlatformWindowAttributes>>,
pub window_type: WindowType,
}

impl WindowAttributes {
Expand Down Expand Up @@ -145,6 +153,7 @@ impl WindowAttributes {
/// position. There may be a small gap between this position and the window due to the
/// specifics of the Window Manager.
/// - **X11:** The top left corner of the window, the window's "outer" position.
/// - **Wayland:** The top left corner of the window if the window type is `WindowType::Popup` otherwise ignored
/// - **Others:** Ignored.
#[inline]
pub fn with_position<P: Into<Position>>(mut self, position: P) -> Self {
Expand Down Expand Up @@ -378,6 +387,22 @@ impl WindowAttributes {
self.platform = Some(platform);
self
}

/// Sets the window type of the object
///
/// Currently only wayland is using this type. On X11 popups are also just normal windows
/// Note: If the type is set to `WindowType::Popup` the parent must be set as well with
/// `with_parent_window()`.
pub fn as_type(mut self, window_type: WindowType) -> Self {
self.window_type = window_type;
self
}

/// Returns if the window type is a popup or a normal window
#[inline]
pub fn popup(&self) -> bool {
self.window_type == WindowType::Popup
}
}

impl Clone for WindowAttributes {
Expand Down Expand Up @@ -405,6 +430,7 @@ impl Clone for WindowAttributes {
parent_window: self.parent_window.clone(),
fullscreen: self.fullscreen.clone(),
platform: self.platform.as_ref().map(|platform| platform.box_clone()),
window_type: self.window_type,
}
}
}
Expand Down Expand Up @@ -435,6 +461,7 @@ impl Default for WindowAttributes {
platform: Default::default(),
cursor: Cursor::default(),
blur: Default::default(),
window_type: Default::default(),
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions winit-wayland/src/event_loop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,13 @@ impl RootActiveEventLoop for ActiveEventLoop {
&self,
window_attributes: winit_core::window::WindowAttributes,
) -> Result<Box<dyn winit_core::window::Window>, RequestError> {
let window = crate::Window::new(self, window_attributes)?;
Ok(Box::new(window))
if window_attributes.popup() {
let popup = crate::Popup::new(self, window_attributes)?;
Ok(Box::new(popup))
} else {
let window = crate::Window::new(self, window_attributes)?;
Ok(Box::new(window))
}
}

fn available_monitors(&self) -> Box<dyn Iterator<Item = CoreMonitorHandle>> {
Expand Down
2 changes: 2 additions & 0 deletions winit-wayland/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ mod seat;
mod state;
mod types;
mod window;
mod popup;

pub use self::event_loop::{ActiveEventLoop, EventLoop};
pub use self::window::Window;
pub use self::popup::Popup;

/// Additional methods on [`ActiveEventLoop`] that are specific to Wayland.
pub trait ActiveEventLoopExtWayland {
Expand Down
Loading
Loading