1use crate::globals::GlobalData;
2use std::sync::atomic::Ordering;
3use wayland_client::{Connection, Dispatch, QueueHandle};
4use wayland_protocols::ext::session_lock::v1::client::{
5 ext_session_lock_manager_v1, ext_session_lock_surface_v1, ext_session_lock_v1,
6};
7
8use super::{
9 SessionLock, SessionLockData, SessionLockHandler, SessionLockState, SessionLockSurface,
10 SessionLockSurfaceConfigure, SessionLockSurfaceData,
11};
12
13impl<D> Dispatch<ext_session_lock_manager_v1::ExtSessionLockManagerV1, GlobalData, D>
14 for SessionLockState
15where
16 D: Dispatch<ext_session_lock_manager_v1::ExtSessionLockManagerV1, GlobalData>,
17{
18 fn event(
19 _state: &mut D,
20 _proxy: &ext_session_lock_manager_v1::ExtSessionLockManagerV1,
21 _event: ext_session_lock_manager_v1::Event,
22 _: &GlobalData,
23 _: &Connection,
24 _: &QueueHandle<D>,
25 ) {
26 unreachable!()
27 }
28}
29
30impl<D> Dispatch<ext_session_lock_v1::ExtSessionLockV1, SessionLockData, D> for SessionLockState
31where
32 D: Dispatch<ext_session_lock_v1::ExtSessionLockV1, SessionLockData> + SessionLockHandler,
33{
34 fn event(
35 state: &mut D,
36 proxy: &ext_session_lock_v1::ExtSessionLockV1,
37 event: ext_session_lock_v1::Event,
38 _: &SessionLockData,
39 conn: &Connection,
40 qh: &QueueHandle<D>,
41 ) {
42 if let Some(session_lock: SessionLock) = SessionLock::from_ext_session_lock(surface:proxy) {
43 match event {
44 ext_session_lock_v1::Event::Locked => {
45 session_lock.0.locked.store(val:true, order:Ordering::SeqCst);
46 state.locked(conn, qh, session_lock);
47 }
48 ext_session_lock_v1::Event::Finished => {
49 state.finished(conn, qh, session_lock);
50 }
51 _ => unreachable!(),
52 }
53 }
54 }
55}
56
57impl<D> Dispatch<ext_session_lock_surface_v1::ExtSessionLockSurfaceV1, SessionLockSurfaceData, D>
58 for SessionLockState
59where
60 D: Dispatch<ext_session_lock_surface_v1::ExtSessionLockSurfaceV1, SessionLockSurfaceData>
61 + SessionLockHandler,
62{
63 fn event(
64 state: &mut D,
65 proxy: &ext_session_lock_surface_v1::ExtSessionLockSurfaceV1,
66 event: ext_session_lock_surface_v1::Event,
67 _: &SessionLockSurfaceData,
68 conn: &Connection,
69 qh: &QueueHandle<D>,
70 ) {
71 if let Some(session_lock_surface) = SessionLockSurface::from_ext_session_lock_surface(proxy)
72 {
73 match event {
74 ext_session_lock_surface_v1::Event::Configure { serial, width, height } => {
75 proxy.ack_configure(serial);
76 state.configure(
77 conn,
78 qh,
79 session_lock_surface,
80 SessionLockSurfaceConfigure { new_size: (width, height) },
81 serial,
82 );
83 }
84 _ => unreachable!(),
85 }
86 }
87 }
88}
89