1use glib::IsA;
2
3use crate::{
4 event_loop::EventLoopWindowTarget,
5 platform_impl::ApplicationName,
6 window::{Window, WindowBuilder},
7};
8
9pub use crate::platform_impl::hit_test;
10
11pub trait WindowExtUnix {
13 fn gtk_window(&self) -> >k::ApplicationWindow;
15
16 fn default_vbox(&self) -> Option<>k::Box>;
19
20 fn set_skip_taskbar(&self, skip: bool);
22}
23
24impl WindowExtUnix for Window {
25 fn gtk_window(&self) -> >k::ApplicationWindow {
26 &self.window.window
27 }
28
29 fn default_vbox(&self) -> Option<>k::Box> {
30 self.window.default_vbox.as_ref()
31 }
32
33 fn set_skip_taskbar(&self, skip: bool) {
34 self.window.set_skip_taskbar(skip);
35 }
36}
37
38pub trait WindowBuilderExtUnix {
39 fn with_name(self, general: impl Into<String>, instance: impl Into<String>) -> Self;
47
48 fn with_skip_taskbar(self, skip: bool) -> WindowBuilder;
50
51 fn with_transient_for(self, parent: &impl IsA<gtk::Window>) -> WindowBuilder;
54
55 fn with_transparent_draw(self, draw: bool) -> WindowBuilder;
61
62 fn with_double_buffered(self, double_buffered: bool) -> WindowBuilder;
66
67 fn with_rgba_visual(self, rgba_visual: bool) -> WindowBuilder;
71
72 fn with_app_paintable(self, app_paintable: bool) -> WindowBuilder;
78
79 fn with_default_vbox(self, add: bool) -> WindowBuilder;
82}
83
84impl WindowBuilderExtUnix for WindowBuilder {
85 fn with_name(mut self, general: impl Into<String>, instance: impl Into<String>) -> Self {
86 self.platform_specific.name = Some(ApplicationName::new(general.into(), instance.into()));
88 self
89 }
90
91 fn with_transient_for(mut self, parent: &impl IsA<gtk::Window>) -> WindowBuilder {
92 self.platform_specific.parent = Some(parent.clone().into());
93 self
94 }
95
96 fn with_skip_taskbar(mut self, skip: bool) -> WindowBuilder {
97 self.platform_specific.skip_taskbar = skip;
98 self
99 }
100
101 fn with_transparent_draw(mut self, draw: bool) -> WindowBuilder {
102 self.platform_specific.auto_transparent = draw;
103 self
104 }
105
106 fn with_double_buffered(mut self, double_buffered: bool) -> WindowBuilder {
107 self.platform_specific.double_buffered = double_buffered;
108 self
109 }
110
111 fn with_rgba_visual(mut self, rgba_visual: bool) -> WindowBuilder {
112 self.platform_specific.rgba_visual = rgba_visual;
113 self
114 }
115
116 fn with_app_paintable(mut self, app_paintable: bool) -> WindowBuilder {
117 self.platform_specific.app_paintable = app_paintable;
118 self
119 }
120
121 fn with_default_vbox(mut self, add: bool) -> WindowBuilder {
122 self.platform_specific.default_vbox = add;
123 self
124 }
125}
126
127pub trait EventLoopWindowTargetExtUnix {
129 fn is_wayland(&self) -> bool;
131}
132
133impl<T> EventLoopWindowTargetExtUnix for EventLoopWindowTarget<T> {
134 #[inline]
135 fn is_wayland(&self) -> bool {
136 self.p.is_wayland()
137 }
138}