Repository navigation
wayland: share window setup, handle the parent window - #4819
Merged
Merged
Conversation
… 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 <noreply@anthropic.com>
Murmele
marked this pull request as draft
November 6, 2026 10:00
…the window could be destroyed but wgpu or glutin still have raw pointers on the surface
Reason: So the parent cannot be deleted before the child is deleted
Murmele
marked this pull request as ready for review
November 6, 2026 13:14
1 of 4 tasks
joeleaver
pushed a commit
to joeleaver/winit-fork
that referenced
this pull request
Nov 12, 2026
…#4819) 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>`. (cherry picked from commit 6d0e541) Note for rinch-patch-beta4: this squash's message describes an earlier round of the upstream PR. The code holds the state strongly (`WindowCommon` keeps an `Arc`, a child keeps its parent), and `Window::surface()` still returns `&WlSurface`. Conflicts with the fork's layer-shell role, resolved here: - `Window::new` picks the role (layer surface or xdg-toplevel) and hands the attributes' Wayland part to `Window::setup`, which now sets up either: the parent, the app id and the startup mode only where there is an `xdg_toplevel`. A layer surface with a parent window is an error (`InvalidInput`), since it has no `xdg_toplevel` to give one to. - `Window` no longer keeps the role object: the state owns it, as upstream's window does, so `ShellSurface` goes. `surface_role` reads the state's `WindowType`. - `LayerShellHandler` ignores a configure or close for a window the event loop no longer manages, as upstream's handlers now do. - `configure_xdg_toplevel` refuses a layer surface as it refuses a popup. - Only this PR's changelog entries are taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joeleaver
added a commit
to joeleaver/winit-fork
that referenced
this pull request
Nov 12, 2026
The cherry-picked rust-windowing#4819 checks for a surface dismissed before its first configure with a let chain. Upstream master can use one; this branch keeps beta.4's rust-version, 1.86, which has none, and CI's 1.86 rows failed on it (E0658). The same check as two ifs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joeleaver
added a commit
to joeleaver/winit-fork
that referenced
this pull request
Nov 12, 2026
wayland: popup fixes for rinch: upstream rust-windowing#4819, the grab's press, placement and repositions (rinch#2552)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This was pulled out from the #4627 branch
I had to replace the weak pointer again by a strong Arc. The problem is that we are exposing raw pointers and surfaces to the user application so when winit destroys the surface but used by glutin / wgpu it has a dangling pointer.
So now every child holds a strong pointer to the parent to ensure that a parent can only be deleted when the child was destroyed before.
The parent holds only the id to the child to prevent a circular dependency
changelogmodule if knowledge of this change could be valuable to usersCreated or updated an example program if it would help users understand this functionality