Add WindowBuilder::with_parent_window (#2548)
* On macOS, add `WindowBuilderExtMacOS::with_parent_window` * Replace Parent with Option<Id<NSWindow, Shared>> * Add addChildWindow method on NSWindow instead * Update with_parent_window to be unsafe fn * Add unified `with_parent_window` * Remove `WindowBuilderExtUnix::with_parent` * Remove `WindowBuilderExtWindows::with_parent_window` * Clean up CI warnings * Update CHANGELOG.md It's `WindowBuilderExtX11` rather than `WindowBuilderExtUnix` * Rename parent to owner * Make with_parent_window unsafe and update its doc * Add another way to get window on mac * Add more documentations * Add match arm and panic on invalid varients * Add Xcb arm * Update child_window example to make it safer and work in i686 * Remove duplicate entry in CHANGELOG.md * Propogate error instead of expect * Replace unreachable to panic * Add platform note to X11 Co-authored-by: Wu Yu Wei <wusyong9104@gmail.com>
This commit is contained in:
parent
8934d2765d
commit
da7422c6e1
13 changed files with 151 additions and 97 deletions
|
|
@ -138,6 +138,7 @@ pub(crate) struct WindowAttributes {
|
|||
pub resize_increments: Option<Size>,
|
||||
pub content_protected: bool,
|
||||
pub window_level: WindowLevel,
|
||||
pub parent_window: Option<RawWindowHandle>,
|
||||
}
|
||||
|
||||
impl Default for WindowAttributes {
|
||||
|
|
@ -161,6 +162,7 @@ impl Default for WindowAttributes {
|
|||
preferred_theme: None,
|
||||
resize_increments: None,
|
||||
content_protected: false,
|
||||
parent_window: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -401,6 +403,27 @@ impl WindowBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// Build window with parent window.
|
||||
///
|
||||
/// The default is `None`.
|
||||
///
|
||||
/// ## Safety
|
||||
///
|
||||
/// `parent_window` must be a valid window handle.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Windows** : A child window has the WS_CHILD style and is confined
|
||||
/// to the client area of its parent window. For more information, see
|
||||
/// <https://docs.microsoft.com/en-us/windows/win32/winmsg/window-features#child-windows>
|
||||
/// - **X11**: A child window is confined to the client area of its parent window.
|
||||
/// - **Android / iOS / Wayland:** Unsupported.
|
||||
#[inline]
|
||||
pub unsafe fn with_parent_window(mut self, parent_window: Option<RawWindowHandle>) -> Self {
|
||||
self.window.parent_window = parent_window;
|
||||
self
|
||||
}
|
||||
|
||||
/// Builds the window.
|
||||
///
|
||||
/// Possible causes of error include denied permission, incompatible system, and lack of memory.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue