Repository navigation
Modal Dialog - #4627
Modal Dialog#4627Murmele wants to merge 2 commits into
Conversation
Was that #4543 ? |
Yes it was |
1a70787 to
e33c0e8
Compare
|
@dhardy , since you had opinions about the Popup change, maybe you want to have a look at this? |
dhardy
left a comment
There was a problem hiding this comment.
Looking just at the API, this seems acceptable.
That said, I'm not wildly enthusiastic about pushing all of the window properties into WindowAttributes: it is left to documentation to describe which attributes are applicable to which window types. I can see two possible alternatives here:
- Moving attributes applicable to only one window type into
WindowTypevariant fields (e.g.titleandiconshould only be applicable to full windows). - Having separate
create_window,create_popupandcreate_dialogmethods, each with their own_Attributesstruct. - (Variant of above):
create_window+create_subwindowwithWindowTypeonly used in the latter case; the rationale being that all subwindows need a parent.
| // Dialogs are placed at creation, relative to their parent (an explicit position is relative to | ||
| // the parent's client area, otherwise the dialog is centered over the parent). This can't be | ||
| // done afterwards: the parent isn't yet queryable via `GetParent` during `WM_CREATE`, and a | ||
| // position set before the first show is overridden by the `CW_USEDEFAULT` cascade. |
There was a problem hiding this comment.
I don't think that's a good behavior.
IMHO, the position from the attribue and the outer_position later should be in the same coordinate system (either global or parent). But mixing both is confusing.
Imagine you have a parent windoc located at, say (500, 300)
Then you create a modal window with
WindowAttributes::default()
.with_window_type(WindowType::Dialog)
.with_parent_window(Some(parent_handle))
.with_position(LogicalPosition::new(10, 10)),Here you pass (10,10), then it will show on the screen at 510, 310 (relative to the parent)
dialog.outer_position();
// Returns 510,310 not 10,10 which was the input.// Will set the position to absolute coordinate 10,10 instead of relative to the parent
dialog.set_outer_position(LogicalPosition::new(10, 10));So this makes an asymmetry between the position in WindowAttribues and the position afterwards, and i'm not sure it is a good.
|
A few notes from my agent: Wayland
Windows
Example
|
Thanks I am handling now by using a normal window instead in that case. wl_surface is not leaked, because in sctk it is owned and dropped if the creation of the dialog fails.
Thanks done
I refactored to make as much as possible common between normal windows and dialogs. So now all attributes are handled
No sctk release was created since my PR there
Fixed in dad3941 |
I disabled for X11 |
Thanks for the considerations. Implemented in the last commits |
… weak state Move the setup of a `Window` into `Window::setup`, and the registration with the event loop plus the wait for the initial configure into `finish_window_setup`, which `Popup` now uses as well. When the compositor dismisses the surface before the initial configure, `finish_window_setup` also removes it from the event loop again. A popup is now only added as a child of its parent once its setup succeeded. Move the handling of an `xdg_toplevel` configure into `WinitState::configure_xdg_toplevel` and rename `WindowState::configure_window` to `configure_xdg_toplevel`, so that other `xdg_toplevel`-based surfaces can share them. A window created with a parent window now calls `xdg_toplevel.set_parent` with that parent and is registered as its child, so it is closed together with its parent. A parent that is not a Wayland window, not a window of the same event loop, or a popup is now an error instead of being ignored. `Window` now only holds a `Weak` to its state, like `Popup`. The event loop owns the state, and with it the SCTK window and its surface, so a window closed together with its parent is actually destroyed, even while the application still holds its handle. Because of that, `Window::surface()` now returns `Option<WlSurface>`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add dialog windows, which are placed relative to a parent window and can be modal, i.e. block interaction with the parent while open. - Wayland: implemented with `xdg-dialog-v1`; `with_modal` sets the dialog's modal state. If the compositor lacks `xdg-dialog-v1`, a normal window with the same parent is created instead. - Windows: a dialog is an owned window of the parent's top-level ancestor, centered over the parent unless a position is given. A modal dialog disables its owner while visible, has no minimize button and moves its owner along when it is moved. - macOS: a modal dialog is presented as a sheet on its parent. - X11, Web, Android, iOS and Orbital don't implement dialogs. Also add a `dialog` example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1f79bf4 to
2133927
Compare
Implement modal dialogs. This branch is based on the work of the Popup branch so this must be merged first. Only the last commit here is relevant for dialog
changelogmodule if knowledge of this change could be valuable to usersWhat is missing to be ready
Os
X11