diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-13 13:30:11 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-24 15:06:07 +0400 |
| commit | b20d8e7062ce1cbbffdfa64a7b32d2393237ea26 (patch) | |
| tree | bc71ba769934573d35695848ce4afb4d614e5481 /src/handlers | |
| parent | 3fd421f13fb823a5dd2b75d0d8649d190f932b2d (diff) | |
| download | niri-b20d8e7062ce1cbbffdfa64a7b32d2393237ea26.tar.gz niri-b20d8e7062ce1cbbffdfa64a7b32d2393237ea26.tar.bz2 niri-b20d8e7062ce1cbbffdfa64a7b32d2393237ea26.zip | |
Implement ext-session-lock
Diffstat (limited to 'src/handlers')
| -rw-r--r-- | src/handlers/compositor.rs | 12 | ||||
| -rw-r--r-- | src/handlers/mod.rs | 43 |
2 files changed, 53 insertions, 2 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index d8d93d9c..034f1ca5 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -160,6 +160,18 @@ impl CompositorHandler for State { // FIXME: granular redraws for cursors. self.niri.queue_redraw_all(); } + + // This might be a lock surface. + if self.niri.is_locked() { + for (output, state) in &self.niri.output_state { + if let Some(lock_surface) = &state.lock_surface { + if lock_surface.wl_surface() == surface { + self.niri.queue_redraw(output.clone()); + break; + } + } + } + } } } diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index d14650c1..81ef9806 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -13,10 +13,12 @@ use smithay::backend::renderer::ImportDma; use smithay::desktop::PopupKind; use smithay::input::pointer::CursorImageStatus; use smithay::input::{Seat, SeatHandler, SeatState}; +use smithay::output::Output; use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource; +use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; use smithay::reexports::wayland_server::Resource; -use smithay::utils::{Logical, Rectangle}; +use smithay::utils::{Logical, Rectangle, Size}; use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError}; use smithay::wayland::input_method::{InputMethodHandler, PopupSurface}; use smithay::wayland::selection::data_device::{ @@ -28,13 +30,17 @@ use smithay::wayland::selection::primary_selection::{ }; use smithay::wayland::selection::wlr_data_control::{DataControlHandler, DataControlState}; use smithay::wayland::selection::{SelectionHandler, SelectionTarget}; +use smithay::wayland::session_lock::{ + LockSurface, SessionLockHandler, SessionLockManagerState, SessionLocker, +}; use smithay::{ delegate_data_control, delegate_data_device, delegate_dmabuf, delegate_input_method_manager, delegate_output, delegate_pointer_gestures, delegate_presentation, delegate_primary_selection, - delegate_seat, delegate_tablet_manager, delegate_text_input_manager, + delegate_seat, delegate_session_lock, delegate_tablet_manager, delegate_text_input_manager, delegate_virtual_keyboard_manager, }; +use crate::layout::output_size; use crate::niri::State; impl SeatHandler for State { @@ -174,3 +180,36 @@ impl DmabufHandler for State { } } delegate_dmabuf!(State); + +impl SessionLockHandler for State { + fn lock_state(&mut self) -> &mut SessionLockManagerState { + &mut self.niri.session_lock_state + } + + fn lock(&mut self, confirmation: SessionLocker) { + self.niri.lock(confirmation); + } + + fn unlock(&mut self) { + self.niri.unlock(); + } + + fn new_surface(&mut self, surface: LockSurface, output: WlOutput) { + let Some(output) = Output::from_resource(&output) else { + error!("no Output matching WlOutput"); + return; + }; + + configure_lock_surface(&surface, &output); + self.niri.new_lock_surface(surface, &output); + } +} +delegate_session_lock!(State); + +pub fn configure_lock_surface(surface: &LockSurface, output: &Output) { + surface.with_pending_state(|states| { + let size = output_size(output); + states.size = Some(Size::from((size.w as u32, size.h as u32))); + }); + surface.send_configure(); +} |
