Skip to content

Wayland: Popup Implementation#4543

Open
Murmele wants to merge 39 commits into
rust-windowing:masterfrom
Murmele:popup
Open

Wayland: Popup Implementation#4543
Murmele wants to merge 39 commits into
rust-windowing:masterfrom
Murmele:popup

Conversation

@Murmele
Copy link
Copy Markdown

@Murmele Murmele commented Mar 25, 2026

This is just an initial work and is far away from finished. It is just to state that I am working on it.
The idea is to keep using the WindowState also for the popup, just extending it for the popup. So I don't have to change anything in the winit code

Related issues: #403 and #4256

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

TODO:

  • Correct location positioning. Partially done. The window decoration is still considered which is not correct
  • Option to hide the popup when loosing focus
  • Option to specify if the child window is a popup or a dedicated window

Platforms

  • Wayland
  • Windows
  • MacOs
  • X11

Murmele added 7 commits March 24, 2026 16:46
Description: The PopupHandler trait must not be implemented for a new type but for the WinitState. In this case the events get forwarded to this implementation
Description: wl_surface commit must be called
… because the windowid is not in the windows list.
@madsmtm madsmtm added DS - wayland Affects the Wayland backend, or generally free Unix platforms S - platform parity Unintended platform differences labels Mar 26, 2026
Murmele added 16 commits March 26, 2026 08:59
Reason: Because a normal window can have a parent window as well, like a Dialog
Reason: otherwise the child surface is anchored to the center
Reason: Because we are using the window state
Reason: it is not required after configuration anymore
Reason: otherwise the height of the client side decoration is not considered and therefore the location is shifted
Reason: There are multiple pointers to the smithay popup. Once in state.windows and one time in the popup object it self. Just dropping the popup object releases only one pointer but we have to notify the state to release also the other
Reason: Otherwise the window gets not updated for example for layout changes
pub shm: WlShm,

/// The last received configure.
pub last_configure: Option<WindowConfigure>,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

moved into the WindowType enum

Reason: So when adding another type it is clear where changes are required
Comment thread winit-wayland/src/window/state.rs Outdated
@Murmele Murmele marked this pull request as ready for review May 18, 2026 08:06
@Murmele Murmele requested a review from kchibisov as a code owner May 18, 2026 08:06
Comment thread winit-wayland/src/state.rs Outdated
let window_id = super::make_wid(popup.wl_surface());
println!("Finished configuring the popup: {:?}", window_id);

// let index =
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Suggested change
// let index =

Comment thread winit-core/src/window.rs
}

#[derive(Debug, Clone, Copy, Default, PartialEq)]
pub enum WindowType {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be #[non_exhaustive] as i'm expecting more type will be added later

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the review. I will have a look into your comments

Comment thread winit-core/src/window.rs Outdated
/// 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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be called with_type for consistency with the other setters?
Or with_window_type

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

A lot of the other with_ are more adding something. In this case I am changing something. So I thought using as_type. But I see it is used also for with_active so I can align this as well

Comment thread winit-core/src/window.rs Outdated

/// Returns if the window type is a popup or a normal window
#[inline]
pub fn popup(&self) -> bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be replace with a window_type(&self) -> WindowType getter.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Comment thread winit-wayland/src/popup.rs Outdated
}

fn request_redraw(&self) {
// // NOTE: try to not wake up the loop when the event was already scheduled and not yet
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

double comment

Comment thread winit-wayland/src/popup.rs Outdated
}

fn set_min_surface_size(&self, min_size: Option<Size>) {
// let scale_factor = self.scale_factor();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are still a lot of commented code that needs cleanup

Comment thread winit-wayland/src/state.rs Outdated

fn done(&mut self, _: &Connection, _: &QueueHandle<Self>, popup: &XdgPopup) {
let window_id = super::make_wid(popup.wl_surface());
println!("Destroying popup with id: {:?}", window_id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also don't forget to remove the println

Comment thread winit-wayland/src/popup.rs Outdated
}

fn drag_resize_window(&self, direction: ResizeDirection) -> Result<(), RequestError> {
// TODO: implement
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there is also a lot of TODO that might need to be addressed.

Comment thread winit-win32/src/window.rs
@Murmele Murmele requested a review from madsmtm as a code owner May 28, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - wayland Affects the Wayland backend, or generally free Unix platforms S - platform parity Unintended platform differences

Development

Successfully merging this pull request may close these issues.

4 participants