diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-09-08 17:54:02 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-09-08 23:53:56 +0400 |
| commit | d52ca23caa4345ddf768da5af24f47eae6fd4738 (patch) | |
| tree | c0e3f3f4c99b0dfd5bd739e349890081cba2187e /src/backend/tty.rs | |
| parent | bd0ecf917489a84efa51bb1272ca27039256fe21 (diff) | |
| download | niri-d52ca23caa4345ddf768da5af24f47eae6fd4738.tar.gz niri-d52ca23caa4345ddf768da5af24f47eae6fd4738.tar.bz2 niri-d52ca23caa4345ddf768da5af24f47eae6fd4738.zip | |
Add initial monitor screencast portal impl
DmaBuf monitor screencasting through xdg-dekstop-portal-gnome!
Somewhat limited currently, e.g. the cursor is always embedded. But gets
most of the job done.
Diffstat (limited to 'src/backend/tty.rs')
| -rw-r--r-- | src/backend/tty.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/backend/tty.rs b/src/backend/tty.rs index a3298655..343da54e 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -1,6 +1,7 @@ use std::collections::{HashMap, HashSet}; use std::os::fd::FromRawFd; use std::path::{Path, PathBuf}; +use std::sync::{Mutex, Arc}; use std::time::Duration; use anyhow::{anyhow, Context}; @@ -44,6 +45,7 @@ pub struct Tty { udev_dispatcher: Dispatcher<'static, UdevBackend, LoopData>, primary_gpu_path: PathBuf, output_device: Option<OutputDevice>, + connectors: Arc<Mutex<HashMap<String, Output>>>, } type GbmDrmCompositor = DrmCompositor< @@ -236,6 +238,7 @@ impl Tty { udev_dispatcher, primary_gpu_path, output_device: None, + connectors: Arc::new(Mutex::new(HashMap::new())), } } @@ -549,6 +552,11 @@ impl Tty { tracy_client::internal::create_frame_name(format!("vblank on {output_name}\0").leak()) }; + self.connectors + .lock() + .unwrap() + .insert(output_name.clone(), output.clone()); + let surface = Surface { name: output_name, compositor, @@ -574,10 +582,10 @@ impl Tty { debug!("disconnecting connector: {connector:?}"); let device = self.output_device.as_mut().unwrap(); - if device.surfaces.remove(&crtc).is_none() { - debug!("crts wasn't enabled"); + let Some(surface) = device.surfaces.remove(&crtc) else { + debug!("crtc wasn't enabled"); return; - } + }; let output = niri .global_space @@ -590,6 +598,8 @@ impl Tty { .clone(); niri.remove_output(&output); + + self.connectors.lock().unwrap().remove(&surface.name); } pub fn seat_name(&self) -> String { @@ -680,6 +690,14 @@ impl Tty { pub fn dmabuf_state(&mut self) -> &mut DmabufState { &mut self.output_device.as_mut().unwrap().dmabuf_state } + + pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> { + self.connectors.clone() + } + + pub fn gbm_device(&self) -> Option<GbmDevice<DrmDeviceFd>> { + self.output_device.as_ref().map(|d| d.gbm.clone()) + } } fn refresh_interval(mode: DrmMode) -> Duration { |
