tauri_runtime/window.rs
1// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
2// SPDX-License-Identifier: Apache-2.0
3// SPDX-License-Identifier: MIT
4
5//! A layer between raw [`Runtime`] windows and Tauri.
6
7use crate::{
8 Icon, Runtime, UserEvent, WindowDispatch,
9 webview::{DetachedWebview, PendingWebview},
10};
11
12use dpi::PixelUnit;
13use serde::{Deserialize, Deserializer, Serialize};
14use tauri_utils::{
15 Theme,
16 config::{Color, WindowConfig},
17};
18#[cfg(windows)]
19use windows::Win32::Foundation::HWND;
20
21use std::{
22 hash::{Hash, Hasher},
23 marker::PhantomData,
24 path::PathBuf,
25 sync::mpsc::Sender,
26};
27
28/// An event from a window.
29#[derive(Debug, Clone)]
30pub enum WindowEvent {
31 /// The size of the window has changed. Contains the client area's new dimensions.
32 Resized(dpi::PhysicalSize<u32>),
33 /// The position of the window has changed. Contains the window's new position.
34 Moved(dpi::PhysicalPosition<i32>),
35 /// The window has been requested to close.
36 CloseRequested {
37 /// A signal sender. If a `true` value is emitted, the window won't be closed.
38 signal_tx: Sender<bool>,
39 },
40 /// The window has been destroyed.
41 Destroyed,
42 /// The window gained or lost focus.
43 ///
44 /// The parameter is true if the window has gained focus, and false if it has lost focus.
45 Focused(bool),
46 /// The window's scale factor has changed.
47 ///
48 /// The following user actions can cause DPI changes:
49 ///
50 /// - Changing the display's resolution.
51 /// - Changing the display's scale factor (e.g. in Control Panel on Windows).
52 /// - Moving the window to a display with a different scale factor.
53 ScaleFactorChanged {
54 /// The new scale factor.
55 scale_factor: f64,
56 /// The window inner size.
57 new_inner_size: dpi::PhysicalSize<u32>,
58 },
59 /// An event associated with the drag and drop action.
60 DragDrop(DragDropEvent),
61 /// The system window theme has changed.
62 ///
63 /// Applications might wish to react to this to change the theme of the content of the window when the system changes the window theme.
64 ThemeChanged(Theme),
65
66 /// Emitted when the application has been suspended.
67 ///
68 /// ## Platform-specific
69 ///
70 /// - **Android**: This is triggered by `onPause` method of the Activity.
71 /// - **iOS**: This is triggered by `applicationWillResignActive` method of the UIApplicationDelegate.
72 /// - **Linux / macOS / Windows**: Unsupported.
73 #[cfg(mobile)]
74 #[cfg_attr(docsrs, doc(cfg(any(target_os = "android", target_os = "ios"))))]
75 Suspended,
76
77 /// Emitted when the application has been resumed.
78 ///
79 /// ## Platform-specific
80 ///
81 /// - **Android**: This is triggered by `onResume` method of the Activity. The first onResume() is ignored to match the iOS implementation, since that is called on activity creation.
82 /// - **iOS**: This is triggered by `applicationWillEnterForeground` method of the UIApplicationDelegate.
83 /// - **Linux / macOS / Windows**: Unsupported.
84 #[cfg(mobile)]
85 #[cfg_attr(docsrs, doc(cfg(any(target_os = "android", target_os = "ios"))))]
86 Resumed,
87}
88
89/// An event from a window.
90#[derive(Debug, Clone)]
91pub enum WebviewEvent {
92 /// An event associated with the drag and drop action.
93 DragDrop(DragDropEvent),
94}
95
96/// The drag drop event payload.
97#[derive(Debug, Clone)]
98#[non_exhaustive]
99pub enum DragDropEvent {
100 /// A drag operation has entered the webview.
101 Enter {
102 /// List of paths that are being dragged onto the webview.
103 paths: Vec<PathBuf>,
104 /// The position of the mouse cursor.
105 position: dpi::PhysicalPosition<f64>,
106 },
107 /// A drag operation is moving over the webview.
108 Over {
109 /// The position of the mouse cursor.
110 position: dpi::PhysicalPosition<f64>,
111 },
112 /// The file(s) have been dropped onto the webview.
113 Drop {
114 /// List of paths that are being dropped onto the window.
115 paths: Vec<PathBuf>,
116 /// The position of the mouse cursor.
117 position: dpi::PhysicalPosition<f64>,
118 },
119 /// The drag operation has been cancelled or left the window.
120 Leave,
121}
122
123/// Describes the appearance of the mouse cursor.
124#[non_exhaustive]
125#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)]
126pub enum CursorIcon {
127 /// The platform-dependent default cursor.
128 #[default]
129 Default,
130 /// A simple crosshair.
131 Crosshair,
132 /// A hand (often used to indicate links in web browsers).
133 Hand,
134 /// Self explanatory.
135 Arrow,
136 /// Indicates something is to be moved.
137 Move,
138 /// Indicates text that may be selected or edited.
139 Text,
140 /// Program busy indicator.
141 Wait,
142 /// Help indicator (often rendered as a "?")
143 Help,
144 /// Progress indicator. Shows that processing is being done. But in contrast
145 /// with "Wait" the user may still interact with the program. Often rendered
146 /// as a spinning beach ball, or an arrow with a watch or hourglass.
147 Progress,
148
149 /// Cursor showing that something cannot be done.
150 NotAllowed,
151 ContextMenu,
152 Cell,
153 VerticalText,
154 Alias,
155 Copy,
156 NoDrop,
157 /// Indicates something can be grabbed.
158 Grab,
159 /// Indicates something is grabbed.
160 Grabbing,
161 AllScroll,
162 ZoomIn,
163 ZoomOut,
164
165 /// Indicate that some edge is to be moved. For example, the 'SeResize' cursor
166 /// is used when the movement starts from the south-east corner of the box.
167 EResize,
168 NResize,
169 NeResize,
170 NwResize,
171 SResize,
172 SeResize,
173 SwResize,
174 WResize,
175 EwResize,
176 NsResize,
177 NeswResize,
178 NwseResize,
179 ColResize,
180 RowResize,
181}
182
183impl<'de> Deserialize<'de> for CursorIcon {
184 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
185 where
186 D: Deserializer<'de>,
187 {
188 let s = String::deserialize(deserializer)?;
189 Ok(match s.to_lowercase().as_str() {
190 "default" => CursorIcon::Default,
191 "crosshair" => CursorIcon::Crosshair,
192 "hand" => CursorIcon::Hand,
193 "arrow" => CursorIcon::Arrow,
194 "move" => CursorIcon::Move,
195 "text" => CursorIcon::Text,
196 "wait" => CursorIcon::Wait,
197 "help" => CursorIcon::Help,
198 "progress" => CursorIcon::Progress,
199 "notallowed" => CursorIcon::NotAllowed,
200 "contextmenu" => CursorIcon::ContextMenu,
201 "cell" => CursorIcon::Cell,
202 "verticaltext" => CursorIcon::VerticalText,
203 "alias" => CursorIcon::Alias,
204 "copy" => CursorIcon::Copy,
205 "nodrop" => CursorIcon::NoDrop,
206 "grab" => CursorIcon::Grab,
207 "grabbing" => CursorIcon::Grabbing,
208 "allscroll" => CursorIcon::AllScroll,
209 "zoomin" => CursorIcon::ZoomIn,
210 "zoomout" => CursorIcon::ZoomOut,
211 "eresize" => CursorIcon::EResize,
212 "nresize" => CursorIcon::NResize,
213 "neresize" => CursorIcon::NeResize,
214 "nwresize" => CursorIcon::NwResize,
215 "sresize" => CursorIcon::SResize,
216 "seresize" => CursorIcon::SeResize,
217 "swresize" => CursorIcon::SwResize,
218 "wresize" => CursorIcon::WResize,
219 "ewresize" => CursorIcon::EwResize,
220 "nsresize" => CursorIcon::NsResize,
221 "neswresize" => CursorIcon::NeswResize,
222 "nwseresize" => CursorIcon::NwseResize,
223 "colresize" => CursorIcon::ColResize,
224 "rowresize" => CursorIcon::RowResize,
225 _ => CursorIcon::Default,
226 })
227 }
228}
229
230/// Window size constraints
231#[derive(Clone, Copy, PartialEq, Debug, Default, Serialize, Deserialize)]
232#[serde(rename_all = "camelCase")]
233pub struct WindowSizeConstraints {
234 /// The minimum width a window can be, If this is `None`, the window will have no minimum width.
235 ///
236 /// The default is `None`.
237 pub min_width: Option<PixelUnit>,
238 /// The minimum height a window can be, If this is `None`, the window will have no minimum height.
239 ///
240 /// The default is `None`.
241 pub min_height: Option<PixelUnit>,
242 /// The maximum width a window can be, If this is `None`, the window will have no maximum width.
243 ///
244 /// The default is `None`.
245 pub max_width: Option<PixelUnit>,
246 /// The maximum height a window can be, If this is `None`, the window will have no maximum height.
247 ///
248 /// The default is `None`.
249 pub max_height: Option<PixelUnit>,
250}
251
252/// Do **NOT** implement this trait except for use in a custom [`Runtime`]
253///
254/// This trait is separate from [`WindowBuilder`] to prevent "accidental" implementation.
255pub trait WindowBuilderBase: std::fmt::Debug + Clone + Sized + 'static {}
256
257/// A builder for all attributes related to a single window.
258///
259/// This trait is only meant to be implemented by a custom [`Runtime`]
260/// and not by applications.
261pub trait WindowBuilder: WindowBuilderBase {
262 /// Initializes a new window attributes builder.
263 fn new() -> Self;
264
265 /// Initializes a new window builder from a [`WindowConfig`]
266 fn with_config(config: &WindowConfig) -> Self;
267
268 /// Show window in the center of the screen.
269 #[must_use]
270 fn center(self) -> Self;
271
272 /// The initial position of the window in logical pixels.
273 #[must_use]
274 fn position(self, x: f64, y: f64) -> Self;
275
276 /// Window size in logical pixels.
277 #[must_use]
278 fn inner_size(self, width: f64, height: f64) -> Self;
279
280 /// Window min inner size in logical pixels.
281 #[must_use]
282 fn min_inner_size(self, min_width: f64, min_height: f64) -> Self;
283
284 /// Window max inner size in logical pixels.
285 #[must_use]
286 fn max_inner_size(self, max_width: f64, max_height: f64) -> Self;
287
288 /// Window inner size constraints.
289 #[must_use]
290 fn inner_size_constraints(self, constraints: WindowSizeConstraints) -> Self;
291
292 /// Prevent the window from overflowing the working area (e.g. monitor size - taskbar size) on creation
293 ///
294 /// ## Platform-specific
295 ///
296 /// - **iOS / Android:** Unsupported.
297 #[must_use]
298 fn prevent_overflow(self) -> Self;
299
300 /// Prevent the window from overflowing the working area (e.g. monitor size - taskbar size)
301 /// on creation with a margin
302 ///
303 /// ## Platform-specific
304 ///
305 /// - **iOS / Android:** Unsupported.
306 #[must_use]
307 fn prevent_overflow_with_margin(self, margin: dpi::Size) -> Self;
308
309 /// Whether the window is resizable or not.
310 /// When resizable is set to false, native window's maximize button is automatically disabled.
311 #[must_use]
312 fn resizable(self, resizable: bool) -> Self;
313
314 /// Whether the window's native maximize button is enabled or not.
315 /// If resizable is set to false, this setting is ignored.
316 ///
317 /// ## Platform-specific
318 ///
319 /// - **macOS:** Disables the "zoom" button in the window titlebar, which is also used to enter fullscreen mode.
320 /// - **Linux / iOS / Android:** Unsupported.
321 #[must_use]
322 fn maximizable(self, maximizable: bool) -> Self;
323
324 /// Whether the window's native minimize button is enabled or not.
325 ///
326 /// ## Platform-specific
327 ///
328 /// - **Linux / iOS / Android:** Unsupported.
329 #[must_use]
330 fn minimizable(self, minimizable: bool) -> Self;
331
332 /// Whether the window's native close button is enabled or not.
333 ///
334 /// ## Platform-specific
335 ///
336 /// - **Linux:** "GTK+ will do its best to convince the window manager not to show a close button.
337 /// Depending on the system, this function may not have any effect when called on a window that is already visible"
338 /// - **iOS / Android:** Unsupported.
339 #[must_use]
340 fn closable(self, closable: bool) -> Self;
341
342 /// The title of the window in the title bar.
343 #[must_use]
344 fn title<S: Into<String>>(self, title: S) -> Self;
345
346 /// Whether to start the window in fullscreen or not.
347 #[must_use]
348 fn fullscreen(self, fullscreen: bool) -> Self;
349
350 /// Whether the window will be initially focused or not.
351 #[must_use]
352 fn focused(self, focused: bool) -> Self;
353
354 /// Whether the window will be focusable or not.
355 #[must_use]
356 fn focusable(self, focusable: bool) -> Self;
357
358 /// Whether the window should be maximized upon creation.
359 #[must_use]
360 fn maximized(self, maximized: bool) -> Self;
361
362 /// Whether the window should be immediately visible upon creation.
363 #[must_use]
364 fn visible(self, visible: bool) -> Self;
365
366 /// Whether the window should be transparent. If this is true, writing colors
367 /// with alpha values different than `1.0` will produce a transparent window.
368 ///
369 /// On Windows, using `no_redirection_bitmap` can help avoid a white flash when
370 /// creating a transparent window.
371 ///
372 /// Not gated on the `macos-private-api` feature so a runtime crate always implements it, even
373 /// when feature unification enables this crate's feature but not the runtime's. On macOS,
374 /// runtimes must make this a no-op unless their own `macos-private-api` feature is enabled.
375 #[must_use]
376 fn transparent(self, transparent: bool) -> Self;
377
378 /// Whether the window should have borders and bars.
379 #[must_use]
380 fn decorations(self, decorations: bool) -> Self;
381
382 /// Whether the window should always be below other windows.
383 #[must_use]
384 fn always_on_bottom(self, always_on_bottom: bool) -> Self;
385
386 /// Whether the window should always be on top of other windows.
387 #[must_use]
388 fn always_on_top(self, always_on_top: bool) -> Self;
389
390 /// Whether the window should be visible on all workspaces or virtual desktops.
391 #[must_use]
392 fn visible_on_all_workspaces(self, visible_on_all_workspaces: bool) -> Self;
393
394 /// Prevents the window contents from being captured by other apps.
395 #[must_use]
396 fn content_protected(self, protected: bool) -> Self;
397
398 /// Sets the window icon.
399 fn icon(self, icon: Icon) -> crate::Result<Self>;
400
401 /// Sets whether or not the window icon should be added to the taskbar.
402 #[must_use]
403 fn skip_taskbar(self, skip: bool) -> Self;
404
405 /// Set the window background color.
406 #[must_use]
407 fn background_color(self, color: Color) -> Self;
408
409 /// Sets whether or not the window has shadow.
410 ///
411 /// ## Platform-specific
412 ///
413 /// - **Windows:**
414 /// - `false` has no effect on decorated window, shadows are always ON.
415 /// - `true` will make undecorated window have a 1px white border,
416 /// and on Windows 11, it will have a rounded corners.
417 /// - **Linux:** Unsupported.
418 #[must_use]
419 fn shadow(self, enable: bool) -> Self;
420
421 /// Set an owner to the window to be created.
422 ///
423 /// From MSDN:
424 /// - An owned window is always above its owner in the z-order.
425 /// - The system automatically destroys an owned window when its owner is destroyed.
426 /// - An owned window is hidden when its owner is minimized.
427 ///
428 /// For more information, see <https://docs.microsoft.com/en-us/windows/win32/winmsg/window-features#owned-windows>
429 #[cfg(windows)]
430 #[must_use]
431 fn owner(self, owner: HWND) -> Self;
432
433 /// Sets a parent to the window to be created.
434 ///
435 /// A child window has the WS_CHILD style and is confined to the client area of its parent window.
436 ///
437 /// For more information, see <https://docs.microsoft.com/en-us/windows/win32/winmsg/window-features#child-windows>
438 #[cfg(windows)]
439 #[must_use]
440 fn parent(self, parent: HWND) -> Self;
441
442 /// Sets a parent to the window to be created.
443 ///
444 /// See <https://developer.apple.com/documentation/appkit/nswindow/1419152-addchildwindow?language=objc>
445 #[cfg(target_os = "macos")]
446 #[must_use]
447 fn parent(self, parent: *mut std::ffi::c_void) -> Self;
448
449 /// Sets the window to be created transient for parent.
450 ///
451 /// See <https://docs.gtk.org/gtk3/method.Window.set_transient_for.html>
452 ///
453 /// # Ownership
454 ///
455 /// `parent` is a `GtkWindow*` passed as *transfer full*: the implementation takes ownership of
456 /// the strong reference and must release it (`g_object_unref`, i.e. glib's `from_glib_full`),
457 /// including when it does not support transient windows.
458 #[cfg(any(
459 target_os = "linux",
460 target_os = "dragonfly",
461 target_os = "freebsd",
462 target_os = "netbsd",
463 target_os = "openbsd"
464 ))]
465 fn transient_for(self, parent: *mut std::ffi::c_void) -> Self;
466
467 /// Enables or disables drag and drop support.
468 #[cfg(windows)]
469 #[must_use]
470 fn drag_and_drop(self, enabled: bool) -> Self;
471
472 /// Hide the titlebar. Titlebar buttons will still be visible.
473 #[cfg(target_os = "macos")]
474 #[must_use]
475 fn title_bar_style(self, style: tauri_utils::TitleBarStyle) -> Self;
476
477 /// Change the position of the window controls on macOS.
478 ///
479 /// Requires titleBarStyle: Overlay and decorations: true.
480 #[cfg(target_os = "macos")]
481 #[must_use]
482 fn traffic_light_position<P: Into<dpi::Position>>(self, position: P) -> Self;
483
484 /// Hide the window title.
485 #[cfg(target_os = "macos")]
486 #[must_use]
487 fn hidden_title(self, hidden: bool) -> Self;
488
489 /// Defines the window [tabbing identifier] for macOS.
490 ///
491 /// Windows with matching tabbing identifiers will be grouped together.
492 /// If the tabbing identifier is not set, automatic tabbing will be disabled.
493 ///
494 /// [tabbing identifier]: <https://developer.apple.com/documentation/appkit/nswindow/1644704-tabbingidentifier>
495 #[cfg(target_os = "macos")]
496 #[must_use]
497 fn tabbing_identifier(self, identifier: &str) -> Self;
498
499 /// Forces a theme or uses the system settings if None was provided.
500 fn theme(self, theme: Option<Theme>) -> Self;
501
502 /// Whether the icon was set or not.
503 fn has_icon(&self) -> bool;
504
505 fn get_theme(&self) -> Option<Theme>;
506
507 /// Sets custom name for Windows' window class. **Windows only**.
508 #[must_use]
509 fn window_classname<S: Into<String>>(self, window_classname: S) -> Self;
510
511 /// This sets `WS_EX_NOREDIRECTIONBITMAP`.
512 ///
513 /// This can avoid the white flash that may appear before the webview content is rendered
514 /// when using a transparent window. **Windows only**.
515 #[must_use]
516 fn no_redirection_bitmap(self, enable: bool) -> Self;
517
518 /// The name of the activity to create for this webview window.
519 #[cfg(target_os = "android")]
520 fn activity_name<S: Into<String>>(self, class_name: S) -> Self;
521
522 /// Sets the name of the activity that is creating this webview window.
523 ///
524 /// This is important to determine which stack the activity will belong to.
525 #[cfg(target_os = "android")]
526 fn created_by_activity_name<S: Into<String>>(self, class_name: S) -> Self;
527
528 /// Sets the identifier of the UIScene that is requesting the creation of this new scene,
529 /// establishing a relationship between the two scenes.
530 ///
531 /// By default the system uses the foreground scene.
532 #[cfg(target_os = "ios")]
533 fn requested_by_scene_identifier<S: Into<String>>(self, identifier: S) -> Self;
534}
535
536/// A window that has yet to be built.
537pub struct PendingWindow<T: UserEvent, R: Runtime<T>> {
538 /// The label that the window will be named.
539 pub label: String,
540
541 /// The [`WindowBuilder`] that the window will be created with.
542 pub window_builder: <R::WindowDispatcher as WindowDispatch<T>>::WindowBuilder,
543
544 /// The webview that gets added to the window. Optional in case you want to use child webviews or other window content instead.
545 pub webview: Option<PendingWebview<T, R>>,
546}
547
548pub fn is_label_valid(label: &str) -> bool {
549 label
550 .chars()
551 .all(|c| char::is_alphanumeric(c) || c == '-' || c == '/' || c == ':' || c == '_')
552}
553
554pub fn assert_label_is_valid(label: &str) {
555 assert!(
556 is_label_valid(label),
557 "Window label must include only alphanumeric characters, `-`, `/`, `:` and `_`."
558 );
559}
560
561impl<T: UserEvent, R: Runtime<T>> PendingWindow<T, R> {
562 /// Create a new [`PendingWindow`] with a label from the given [`WindowBuilder`].
563 pub fn new(
564 window_builder: <R::WindowDispatcher as WindowDispatch<T>>::WindowBuilder,
565 label: impl Into<String>,
566 ) -> crate::Result<Self> {
567 let label = label.into();
568 if !is_label_valid(&label) {
569 Err(crate::Error::InvalidWindowLabel)
570 } else {
571 Ok(Self {
572 window_builder,
573 label,
574 webview: None,
575 })
576 }
577 }
578
579 /// Sets a webview to be created on the window.
580 pub fn set_webview(&mut self, webview: PendingWebview<T, R>) -> &mut Self {
581 self.webview.replace(webview);
582 self
583 }
584}
585
586/// Identifier of a window.
587#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq, Ord, PartialOrd)]
588pub struct WindowId(u32);
589
590impl From<u32> for WindowId {
591 fn from(value: u32) -> Self {
592 Self(value)
593 }
594}
595
596/// A window that is not yet managed by Tauri.
597#[derive(Debug)]
598pub struct DetachedWindow<T: UserEvent, R: Runtime<T>> {
599 /// The identifier of the window.
600 pub id: WindowId,
601 /// Name of the window
602 pub label: String,
603
604 /// The [`WindowDispatch`] associated with the window.
605 pub dispatcher: R::WindowDispatcher,
606
607 /// The webview dispatcher in case this window has an attached webview.
608 pub webview: Option<DetachedWindowWebview<T, R>>,
609}
610
611/// A detached webview associated with a window.
612#[derive(Debug)]
613pub struct DetachedWindowWebview<T: UserEvent, R: Runtime<T>> {
614 pub webview: DetachedWebview<T, R>,
615 pub use_https_scheme: bool,
616 /// Whether devtools was enabled in [`crate::webview::WebviewAttributes`]. `Some(false)` disables the inspector.
617 pub devtools: Option<bool>,
618}
619
620impl<T: UserEvent, R: Runtime<T>> Clone for DetachedWindowWebview<T, R> {
621 fn clone(&self) -> Self {
622 Self {
623 webview: self.webview.clone(),
624 use_https_scheme: self.use_https_scheme,
625 devtools: self.devtools,
626 }
627 }
628}
629
630impl<T: UserEvent, R: Runtime<T>> Clone for DetachedWindow<T, R> {
631 fn clone(&self) -> Self {
632 Self {
633 id: self.id,
634 label: self.label.clone(),
635 dispatcher: self.dispatcher.clone(),
636 webview: self.webview.clone(),
637 }
638 }
639}
640
641impl<T: UserEvent, R: Runtime<T>> Hash for DetachedWindow<T, R> {
642 /// Only use the [`DetachedWindow`]'s label to represent its hash.
643 fn hash<H: Hasher>(&self, state: &mut H) {
644 self.label.hash(state)
645 }
646}
647
648impl<T: UserEvent, R: Runtime<T>> Eq for DetachedWindow<T, R> {}
649impl<T: UserEvent, R: Runtime<T>> PartialEq for DetachedWindow<T, R> {
650 /// Only use the [`DetachedWindow`]'s label to compare equality.
651 fn eq(&self, other: &Self) -> bool {
652 self.label.eq(&other.label)
653 }
654}
655
656/// A raw window type that contains fields to access
657/// the HWND on Windows, GTK object pointers on Linux
658///
659/// # Ownership
660///
661/// Unlike the [`WindowDispatch`](crate::WindowDispatch) getters, the GTK pointers here are
662/// *transfer none*: they are borrowed from the window that is being created and are only valid for
663/// the duration of the callback that receives this struct. Wrap them with glib's `from_glib_none`
664/// (which takes its own reference) and do not store them - the `'a` lifetime is not enforced by
665/// the raw pointers, so retaining one past the callback dereferences freed memory.
666///
667/// The GTK major version of the objects is the one the runtime was built against, so consumers must
668/// wrap them with matching bindings.
669pub struct RawWindow<'a> {
670 /// The window handle on Windows.
671 #[cfg(windows)]
672 pub hwnd: isize,
673 /// A borrowed `GtkApplicationWindow*`. Never null.
674 #[cfg(any(
675 target_os = "linux",
676 target_os = "dragonfly",
677 target_os = "freebsd",
678 target_os = "netbsd",
679 target_os = "openbsd"
680 ))]
681 pub gtk_window: *mut std::ffi::c_void,
682 /// A borrowed `GtkBox*`, or [`None`] when the runtime does not add a default vertical box.
683 /// When set, it is never null.
684 #[cfg(any(
685 target_os = "linux",
686 target_os = "dragonfly",
687 target_os = "freebsd",
688 target_os = "netbsd",
689 target_os = "openbsd"
690 ))]
691 pub default_vbox: Option<*mut std::ffi::c_void>,
692 /// Ties this struct to the lifetime of the window the pointers above are borrowed from.
693 pub _marker: &'a PhantomData<()>,
694}