pub struct WindowStateUnit<T> { /* private fields */ }Implementations§
Source§impl<T> WindowStateUnit<T>
impl<T> WindowStateUnit<T>
pub fn try_set_viewport_destination( &self, width: i32, height: i32, ) -> Option<()>
pub fn try_set_viewport_source( &self, x: f64, y: f64, width: f64, height: f64, ) -> Option<()>
Sourcepub fn gen_wrapper(&self) -> WindowWrapper
pub fn gen_wrapper(&self) -> WindowWrapper
gen the WindowState WindowWrapper
Source§impl<T> WindowStateUnit<T>
impl<T> WindowStateUnit<T>
pub fn raw_window_handle_rwh_06(&self) -> Result<RawWindowHandle, HandleError>
pub fn raw_display_handle_rwh_06(&self) -> Result<RawDisplayHandle, HandleError>
Source§impl<T> WindowStateUnit<T>
impl<T> WindowStateUnit<T>
Sourcepub fn get_wlsurface(&self) -> &WlSurface
pub fn get_wlsurface(&self) -> &WlSurface
get the wl surface from WindowState
Examples found in repository?
8fn main() {
9 let ev: WindowState<()> = WindowState::new("Hello")
10 .with_allscreens()
11 .with_size((0, 400))
12 .with_layer(Layer::Top)
13 .with_margin((20, 20, 100, 20))
14 .with_anchor(Anchor::Bottom | Anchor::Left | Anchor::Right)
15 .with_keyboard_interacivity(KeyboardInteractivity::Exclusive)
16 .with_exclusize_zone(-1)
17 .build()
18 .unwrap();
19
20 let mut virtual_keyboard_manager = None;
21 ev.running(|event, ev, index| {
22 match event {
23 // NOTE: this will send when init, you can request bind extra object from here
24 LayerEvent::InitRequest => ReturnData::RequestBind,
25 LayerEvent::BindProvide(globals, qh) => {
26 // NOTE: you can get implied wayland object from here
27 virtual_keyboard_manager = Some(
28 globals
29 .bind::<zwp_virtual_keyboard_v1::ZwpVirtualKeyboardManagerV1, _, _>(
30 qh,
31 1..=1,
32 (),
33 )
34 .unwrap(),
35 );
36 println!("{:?}", virtual_keyboard_manager);
37 ReturnData::RequestCompositor
38 }
39 LayerEvent::CompositorProvide(compositor, qh) => {
40 // NOTE: you can set input region to limit area which gets input events
41 // surface outside region becomes transparent for input events
42 // To ignore all input events use region with (0,0) size
43 for x in ev.get_unit_iter() {
44 let region = compositor.create_region(qh, ());
45 region.add(0, 0, 0, 0);
46 x.get_wlsurface().set_input_region(Some(®ion));
47 }
48 ReturnData::None
49 }
50 LayerEvent::XdgInfoChanged(_) => {
51 let index = index.unwrap();
52 let unit = ev.get_unit_with_id(index).unwrap();
53 println!("{:?}", unit.get_xdgoutput_info());
54 ReturnData::None
55 }
56 LayerEvent::RequestBuffer(file, shm, qh, init_w, init_h) => {
57 draw(file, (init_w, init_h));
58 let pool = shm.create_pool(file.as_fd(), (init_w * init_h * 4) as i32, qh, ());
59 ReturnData::WlBuffer(pool.create_buffer(
60 0,
61 init_w as i32,
62 init_h as i32,
63 (init_w * 4) as i32,
64 wl_shm::Format::Argb8888,
65 qh,
66 (),
67 ))
68 }
69 LayerEvent::RequestMessages(DispatchMessage::RequestRefresh {
70 width, height, ..
71 }) => {
72 println!("{width}, {height}");
73 ReturnData::None
74 }
75 LayerEvent::RequestMessages(DispatchMessage::MouseButton { .. }) => ReturnData::None,
76 LayerEvent::RequestMessages(DispatchMessage::MouseEnter {
77 serial, pointer, ..
78 }) => ReturnData::RequestSetCursorShape((
79 "crosshair".to_owned(),
80 pointer.clone(),
81 *serial,
82 )),
83 LayerEvent::RequestMessages(DispatchMessage::MouseMotion {
84 time,
85 surface_x,
86 surface_y,
87 }) => {
88 println!("{time}, {surface_x}, {surface_y}");
89 ReturnData::None
90 }
91 LayerEvent::RequestMessages(DispatchMessage::KeyboardInput { event, .. }) => {
92 if let PhysicalKey::Code(KeyCode::Escape) = event.physical_key {
93 ReturnData::RequestExit
94 } else {
95 ReturnData::None
96 }
97 }
98 _ => ReturnData::None,
99 }
100 })
101 .unwrap();
102}Sourcepub fn get_xdgoutput_info(&self) -> Option<&ZxdgOutputInfo>
pub fn get_xdgoutput_info(&self) -> Option<&ZxdgOutputInfo>
get the xdg_output info related to this unit
Examples found in repository?
8fn main() {
9 let ev: WindowState<()> = WindowState::new("Hello")
10 .with_allscreens()
11 .with_size((0, 400))
12 .with_layer(Layer::Top)
13 .with_margin((20, 20, 100, 20))
14 .with_anchor(Anchor::Bottom | Anchor::Left | Anchor::Right)
15 .with_keyboard_interacivity(KeyboardInteractivity::Exclusive)
16 .with_exclusize_zone(-1)
17 .build()
18 .unwrap();
19
20 let mut virtual_keyboard_manager = None;
21 ev.running(|event, ev, index| {
22 match event {
23 // NOTE: this will send when init, you can request bind extra object from here
24 LayerEvent::InitRequest => ReturnData::RequestBind,
25 LayerEvent::BindProvide(globals, qh) => {
26 // NOTE: you can get implied wayland object from here
27 virtual_keyboard_manager = Some(
28 globals
29 .bind::<zwp_virtual_keyboard_v1::ZwpVirtualKeyboardManagerV1, _, _>(
30 qh,
31 1..=1,
32 (),
33 )
34 .unwrap(),
35 );
36 println!("{:?}", virtual_keyboard_manager);
37 ReturnData::RequestCompositor
38 }
39 LayerEvent::CompositorProvide(compositor, qh) => {
40 // NOTE: you can set input region to limit area which gets input events
41 // surface outside region becomes transparent for input events
42 // To ignore all input events use region with (0,0) size
43 for x in ev.get_unit_iter() {
44 let region = compositor.create_region(qh, ());
45 region.add(0, 0, 0, 0);
46 x.get_wlsurface().set_input_region(Some(®ion));
47 }
48 ReturnData::None
49 }
50 LayerEvent::XdgInfoChanged(_) => {
51 let index = index.unwrap();
52 let unit = ev.get_unit_with_id(index).unwrap();
53 println!("{:?}", unit.get_xdgoutput_info());
54 ReturnData::None
55 }
56 LayerEvent::RequestBuffer(file, shm, qh, init_w, init_h) => {
57 draw(file, (init_w, init_h));
58 let pool = shm.create_pool(file.as_fd(), (init_w * init_h * 4) as i32, qh, ());
59 ReturnData::WlBuffer(pool.create_buffer(
60 0,
61 init_w as i32,
62 init_h as i32,
63 (init_w * 4) as i32,
64 wl_shm::Format::Argb8888,
65 qh,
66 (),
67 ))
68 }
69 LayerEvent::RequestMessages(DispatchMessage::RequestRefresh {
70 width, height, ..
71 }) => {
72 println!("{width}, {height}");
73 ReturnData::None
74 }
75 LayerEvent::RequestMessages(DispatchMessage::MouseButton { .. }) => ReturnData::None,
76 LayerEvent::RequestMessages(DispatchMessage::MouseEnter {
77 serial, pointer, ..
78 }) => ReturnData::RequestSetCursorShape((
79 "crosshair".to_owned(),
80 pointer.clone(),
81 *serial,
82 )),
83 LayerEvent::RequestMessages(DispatchMessage::MouseMotion {
84 time,
85 surface_x,
86 surface_y,
87 }) => {
88 println!("{time}, {surface_x}, {surface_y}");
89 ReturnData::None
90 }
91 LayerEvent::RequestMessages(DispatchMessage::KeyboardInput { event, .. }) => {
92 if let PhysicalKey::Code(KeyCode::Escape) = event.physical_key {
93 ReturnData::RequestExit
94 } else {
95 ReturnData::None
96 }
97 }
98 _ => ReturnData::None,
99 }
100 })
101 .unwrap();
102}Sourcepub fn set_anchor(&self, anchor: Anchor)
pub fn set_anchor(&self, anchor: Anchor)
set the anchor of the current unit. please take the simple.rs as reference
Sourcepub fn set_margin(&self, (top, right, bottom, left): (i32, i32, i32, i32))
pub fn set_margin(&self, (top, right, bottom, left): (i32, i32, i32, i32))
you can reset the margin which bind to the surface
Sourcepub fn set_anchor_with_size(&self, anchor: Anchor, (width, height): (u32, u32))
pub fn set_anchor_with_size(&self, anchor: Anchor, (width, height): (u32, u32))
set the anchor and set the size together When you want to change layer from LEFT|RIGHT|BOTTOM to TOP|LEFT|BOTTOM, use it
Sourcepub fn set_exclusive_zone(&self, zone: i32)
pub fn set_exclusive_zone(&self, zone: i32)
set current exclusive_zone
Sourcepub fn set_binding(&mut self, binding: T)
pub fn set_binding(&mut self, binding: T)
you can use this function to set a binding data. the message passed back contain a index, you can use that to get the unit. It will be very useful, because you can use the binding data to operate the file binding to the buffer. you can take startcolorkeyboard as reference.
Sourcepub fn get_binding_mut(&mut self) -> Option<&mut T>
pub fn get_binding_mut(&mut self) -> Option<&mut T>
return the binding data, with mut reference
Sourcepub fn get_binding(&self) -> Option<&T>
pub fn get_binding(&self) -> Option<&T>
get the binding data
Sourcepub fn request_refresh(&self, (width, height): (i32, i32))
pub fn request_refresh(&self, (width, height): (i32, i32))
this function will refresh whole surface. it will reattach the buffer, and damage whole, and final commit
pub fn scale_u32(&self) -> u32
pub fn scale_float(&self) -> f64
Trait Implementations§
Source§impl<T: Debug> Debug for WindowStateUnit<T>
impl<T: Debug> Debug for WindowStateUnit<T>
Source§impl<T> HasDisplayHandle for WindowStateUnit<T>
impl<T> HasDisplayHandle for WindowStateUnit<T>
Source§fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
Source§impl<T> HasWindowHandle for WindowStateUnit<T>
impl<T> HasWindowHandle for WindowStateUnit<T>
Source§fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
Auto Trait Implementations§
impl<T> Freeze for WindowStateUnit<T>where
T: Freeze,
impl<T> !RefUnwindSafe for WindowStateUnit<T>
impl<T> Send for WindowStateUnit<T>where
T: Send,
impl<T> Sync for WindowStateUnit<T>where
T: Sync,
impl<T> Unpin for WindowStateUnit<T>where
T: Unpin,
impl<T> !UnwindSafe for WindowStateUnit<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> HasRawDisplayHandle for Twhere
T: HasDisplayHandle + ?Sized,
impl<T> HasRawDisplayHandle for Twhere
T: HasDisplayHandle + ?Sized,
Source§fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>
fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>
HasDisplayHandle insteadSource§impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
Source§fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
HasWindowHandle instead