Wayland: Popup Implementation#4543
Conversation
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.
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>, |
Reason: So when adding another type it is clear where changes are required
| let window_id = super::make_wid(popup.wl_surface()); | ||
| println!("Finished configuring the popup: {:?}", window_id); | ||
|
|
||
| // let index = |
There was a problem hiding this comment.
| // let index = |
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy, Default, PartialEq)] | ||
| pub enum WindowType { |
There was a problem hiding this comment.
Should be #[non_exhaustive] as i'm expecting more type will be added later
There was a problem hiding this comment.
Thanks for the review. I will have a look into your comments
| /// 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 { |
There was a problem hiding this comment.
Shouldn't this be called with_type for consistency with the other setters?
Or with_window_type
There was a problem hiding this comment.
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
|
|
||
| /// Returns if the window type is a popup or a normal window | ||
| #[inline] | ||
| pub fn popup(&self) -> bool { |
There was a problem hiding this comment.
Should be replace with a window_type(&self) -> WindowType getter.
| } | ||
|
|
||
| fn request_redraw(&self) { | ||
| // // NOTE: try to not wake up the loop when the event was already scheduled and not yet |
| } | ||
|
|
||
| fn set_min_surface_size(&self, min_size: Option<Size>) { | ||
| // let scale_factor = self.scale_factor(); |
There was a problem hiding this comment.
There are still a lot of commented code that needs cleanup
|
|
||
| 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); |
There was a problem hiding this comment.
Also don't forget to remove the println
| } | ||
|
|
||
| fn drag_resize_window(&self, direction: ResizeDirection) -> Result<(), RequestError> { | ||
| // TODO: implement |
There was a problem hiding this comment.
there is also a lot of TODO that might need to be addressed.
…n is not because we can't access the parent but because we're going to position it later anyway
Add support for WindowType::Popup on macOS
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
changelogmodule if knowledge of this change could be valuable to usersTODO:
Platforms