Move CastTarget to src/niri.rs
Browse files at this commit9e560e7e607638da4f47b6dfef5a83b18711f75dParent: cee2ec74 changed files +19 -22
- src/handlers/compositor.rs +2 -6
- src/handlers/xdg_shell.rs +4 -6
- src/niri.rs +11 -2
- src/pw_utils.rs +2 -8
src/handlers/compositor.rsmodified+2 -6
| @@ -21,7 +21,7 @@ use smithay::{delegate_compositor, delegate_shm}; | |||
| 21 | use super::xdg_shell::add_mapped_toplevel_pre_commit_hook; | 21 | use super::xdg_shell::add_mapped_toplevel_pre_commit_hook; |
| 22 | use crate::handlers::XDG_ACTIVATION_TOKEN_TIMEOUT; | 22 | use crate::handlers::XDG_ACTIVATION_TOKEN_TIMEOUT; |
| 23 | use crate::layout::{ActivateWindow, AddWindowTarget}; | 23 | use crate::layout::{ActivateWindow, AddWindowTarget}; |
| 24 | -use crate::niri::{ClientState, LockState, State}; | 24 | +use crate::niri::{CastTarget, ClientState, LockState, State}; |
| 25 | use crate::utils::transaction::Transaction; | 25 | use crate::utils::transaction::Transaction; |
| 26 | use crate::utils::{is_mapped, send_scale_transform}; | 26 | use crate::utils::{is_mapped, send_scale_transform}; |
| 27 | use crate::window::{InitialConfigureState, Mapped, ResolvedWindowRules, Unmapped}; | 27 | use crate::window::{InitialConfigureState, Mapped, ResolvedWindowRules, Unmapped}; |
| @@ -220,7 +220,6 @@ impl CompositorHandler for State { | |||
| 220 | let window = mapped.window.clone(); | 220 | let window = mapped.window.clone(); |
| 221 | let output = output.cloned(); | 221 | let output = output.cloned(); |
| 222 | 222 | ||
| 223 | - #[cfg(feature = "xdp-gnome-screencast")] | ||
| 224 | let id = mapped.id(); | 223 | let id = mapped.id(); |
| 225 | 224 | ||
| 226 | // This is a commit of a previously-mapped toplevel. | 225 | // This is a commit of a previously-mapped toplevel. |
| @@ -246,11 +245,8 @@ impl CompositorHandler for State { | |||
| 246 | let active_window = self.niri.layout.focus().map(|m| &m.window); | 245 | let active_window = self.niri.layout.focus().map(|m| &m.window); |
| 247 | let was_active = active_window == Some(&window); | 246 | let was_active = active_window == Some(&window); |
| 248 | 247 | ||
| 249 | - #[cfg(feature = "xdp-gnome-screencast")] | ||
| 250 | self.niri | 248 | self.niri |
| 251 | - .stop_casts_for_target(crate::pw_utils::CastTarget::Window { | 249 | + .stop_casts_for_target(CastTarget::Window { id: id.get() }); |
| 252 | - id: id.get(), | ||
| 253 | - }); | ||
| 254 | 250 | ||
| 255 | self.niri.layout.remove_window(&window, transaction.clone()); | 251 | self.niri.layout.remove_window(&window, transaction.clone()); |
| 256 | self.add_default_dmabuf_pre_commit_hook(surface); | 252 | self.add_default_dmabuf_pre_commit_hook(surface); |
src/handlers/xdg_shell.rsmodified+4 -6
| @@ -43,7 +43,7 @@ use crate::input::resize_grab::ResizeGrab; | |||
| 43 | use crate::input::touch_move_grab::TouchMoveGrab; | 43 | use crate::input::touch_move_grab::TouchMoveGrab; |
| 44 | use crate::input::touch_resize_grab::TouchResizeGrab; | 44 | use crate::input::touch_resize_grab::TouchResizeGrab; |
| 45 | use crate::input::{PointerOrTouchStartData, DOUBLE_CLICK_TIME}; | 45 | use crate::input::{PointerOrTouchStartData, DOUBLE_CLICK_TIME}; |
| 46 | -use crate::niri::{PopupGrabState, State}; | 46 | +use crate::niri::{CastTarget, PopupGrabState, State}; |
| 47 | use crate::utils::transaction::Transaction; | 47 | use crate::utils::transaction::Transaction; |
| 48 | use crate::utils::{ | 48 | use crate::utils::{ |
| 49 | get_monotonic_time, output_matches_name, send_scale_transform, update_tiled_state, ResizeEdge, | 49 | get_monotonic_time, output_matches_name, send_scale_transform, update_tiled_state, ResizeEdge, |
| @@ -647,11 +647,9 @@ impl XdgShellHandler for State { | |||
| 647 | let window = mapped.window.clone(); | 647 | let window = mapped.window.clone(); |
| 648 | let output = output.cloned(); | 648 | let output = output.cloned(); |
| 649 | 649 | ||
| 650 | - #[cfg(feature = "xdp-gnome-screencast")] | 650 | + self.niri.stop_casts_for_target(CastTarget::Window { |
| 651 | - self.niri | 651 | + id: mapped.id().get(), |
| 652 | - .stop_casts_for_target(crate::pw_utils::CastTarget::Window { | 652 | + }); |
| 653 | - id: mapped.id().get(), | ||
| 654 | - }); | ||
| 655 | 653 | ||
| 656 | self.backend.with_primary_renderer(|renderer| { | 654 | self.backend.with_primary_renderer(|renderer| { |
| 657 | self.niri.layout.store_unmap_snapshot(renderer, &window); | 655 | self.niri.layout.store_unmap_snapshot(renderer, &window); |
src/niri.rsmodified+11 -2
| @@ -47,7 +47,7 @@ use smithay::desktop::{ | |||
| 47 | use smithay::input::keyboard::Layout as KeyboardLayout; | 47 | use smithay::input::keyboard::Layout as KeyboardLayout; |
| 48 | use smithay::input::pointer::{CursorIcon, CursorImageStatus, CursorImageSurfaceData, MotionEvent}; | 48 | use smithay::input::pointer::{CursorIcon, CursorImageStatus, CursorImageSurfaceData, MotionEvent}; |
| 49 | use smithay::input::{Seat, SeatState}; | 49 | use smithay::input::{Seat, SeatState}; |
| 50 | -use smithay::output::{self, Output, OutputModeSource, PhysicalProperties, Subpixel}; | 50 | +use smithay::output::{self, Output, OutputModeSource, PhysicalProperties, Subpixel, WeakOutput}; |
| 51 | use smithay::reexports::calloop::generic::Generic; | 51 | use smithay::reexports::calloop::generic::Generic; |
| 52 | use smithay::reexports::calloop::timer::{TimeoutAction, Timer}; | 52 | use smithay::reexports::calloop::timer::{TimeoutAction, Timer}; |
| 53 | use smithay::reexports::calloop::{ | 53 | use smithay::reexports::calloop::{ |
| @@ -138,7 +138,7 @@ use crate::protocols::screencopy::{Screencopy, ScreencopyBuffer, ScreencopyManag | |||
| 138 | use crate::protocols::virtual_pointer::VirtualPointerManagerState; | 138 | use crate::protocols::virtual_pointer::VirtualPointerManagerState; |
| 139 | use crate::pw_utils::{Cast, PipeWire}; | 139 | use crate::pw_utils::{Cast, PipeWire}; |
| 140 | #[cfg(feature = "xdp-gnome-screencast")] | 140 | #[cfg(feature = "xdp-gnome-screencast")] |
| 141 | -use crate::pw_utils::{CastSizeChange, CastTarget, PwToNiri}; | 141 | +use crate::pw_utils::{CastSizeChange, PwToNiri}; |
| 142 | use crate::render_helpers::debug::draw_opaque_regions; | 142 | use crate::render_helpers::debug::draw_opaque_regions; |
| 143 | use crate::render_helpers::primary_gpu_texture::PrimaryGpuTextureRenderElement; | 143 | use crate::render_helpers::primary_gpu_texture::PrimaryGpuTextureRenderElement; |
| 144 | use crate::render_helpers::renderer::NiriRenderer; | 144 | use crate::render_helpers::renderer::NiriRenderer; |
| @@ -508,6 +508,12 @@ pub enum CenterCoords { | |||
| 508 | Both, | 508 | Both, |
| 509 | } | 509 | } |
| 510 | 510 | ||
| 511 | +#[derive(Clone, PartialEq, Eq)] | ||
| 512 | +pub enum CastTarget { | ||
| 513 | + Output(WeakOutput), | ||
| 514 | + Window { id: u64 }, | ||
| 515 | +} | ||
| 516 | + | ||
| 511 | impl RedrawState { | 517 | impl RedrawState { |
| 512 | fn queue_redraw(self) -> Self { | 518 | fn queue_redraw(self) -> Self { |
| 513 | match self { | 519 | match self { |
| @@ -4584,6 +4590,9 @@ impl Niri { | |||
| 4584 | } | 4590 | } |
| 4585 | } | 4591 | } |
| 4586 | 4592 | ||
| 4593 | + #[cfg(not(feature = "xdp-gnome-screencast"))] | ||
| 4594 | + pub fn stop_casts_for_target(&mut self, _target: CastTarget) {} | ||
| 4595 | + | ||
| 4587 | #[cfg(feature = "xdp-gnome-screencast")] | 4596 | #[cfg(feature = "xdp-gnome-screencast")] |
| 4588 | pub fn stop_casts_for_target(&mut self, target: CastTarget) { | 4597 | pub fn stop_casts_for_target(&mut self, target: CastTarget) { |
| 4589 | let _span = tracy_client::span!("Niri::stop_casts_for_target"); | 4598 | let _span = tracy_client::span!("Niri::stop_casts_for_target"); |
src/pw_utils.rsmodified+2 -8
| @@ -36,7 +36,7 @@ use smithay::backend::drm::DrmDeviceFd; | |||
| 36 | use smithay::backend::renderer::damage::OutputDamageTracker; | 36 | use smithay::backend::renderer::damage::OutputDamageTracker; |
| 37 | use smithay::backend::renderer::element::RenderElement; | 37 | use smithay::backend::renderer::element::RenderElement; |
| 38 | use smithay::backend::renderer::gles::GlesRenderer; | 38 | use smithay::backend::renderer::gles::GlesRenderer; |
| 39 | -use smithay::output::{Output, OutputModeSource, WeakOutput}; | 39 | +use smithay::output::{Output, OutputModeSource}; |
| 40 | use smithay::reexports::calloop::generic::Generic; | 40 | use smithay::reexports::calloop::generic::Generic; |
| 41 | use smithay::reexports::calloop::{Interest, LoopHandle, Mode, PostAction}; | 41 | use smithay::reexports::calloop::{Interest, LoopHandle, Mode, PostAction}; |
| 42 | use smithay::reexports::gbm::Modifier; | 42 | use smithay::reexports::gbm::Modifier; |
| @@ -44,7 +44,7 @@ use smithay::utils::{Physical, Scale, Size, Transform}; | |||
| 44 | use zbus::object_server::SignalEmitter; | 44 | use zbus::object_server::SignalEmitter; |
| 45 | 45 | ||
| 46 | use crate::dbus::mutter_screen_cast::{self, CursorMode}; | 46 | use crate::dbus::mutter_screen_cast::{self, CursorMode}; |
| 47 | -use crate::niri::State; | 47 | +use crate::niri::{CastTarget, State}; |
| 48 | use crate::render_helpers::render_to_dmabuf; | 48 | use crate::render_helpers::render_to_dmabuf; |
| 49 | use crate::utils::get_monotonic_time; | 49 | use crate::utils::get_monotonic_time; |
| 50 | 50 | ||
| @@ -109,12 +109,6 @@ pub enum CastSizeChange { | |||
| 109 | Pending, | 109 | Pending, |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | -#[derive(Clone, PartialEq, Eq)] | ||
| 113 | -pub enum CastTarget { | ||
| 114 | - Output(WeakOutput), | ||
| 115 | - Window { id: u64 }, | ||
| 116 | -} | ||
| 117 | - | ||
| 118 | macro_rules! make_params { | 112 | macro_rules! make_params { |
| 119 | ($params:ident, $formats:expr, $size:expr, $refresh:expr, $alpha:expr) => { | 113 | ($params:ident, $formats:expr, $size:expr, $refresh:expr, $alpha:expr) => { |
| 120 | let mut b1 = Vec::new(); | 114 | let mut b1 = Vec::new(); |