diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-09-14 22:28:26 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-09-14 22:43:24 +0400 |
| commit | 89f9e11f65d00290029e9fb1719f2165de5e8006 (patch) | |
| tree | 626d980fc1b7ef0a2f93f10c8829411b426b3995 /src/backend | |
| parent | 092095ead005ff073344b723f00b08a5b845f186 (diff) | |
| download | niri-89f9e11f65d00290029e9fb1719f2165de5e8006.tar.gz niri-89f9e11f65d00290029e9fb1719f2165de5e8006.tar.bz2 niri-89f9e11f65d00290029e9fb1719f2165de5e8006.zip | |
Store Config as Rc<RefCell<>> field
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/mod.rs | 6 | ||||
| -rw-r--r-- | src/backend/tty.rs | 14 | ||||
| -rw-r--r-- | src/backend/winit.rs | 14 |
3 files changed, 24 insertions, 10 deletions
diff --git a/src/backend/mod.rs b/src/backend/mod.rs index ea795921..8473ccc2 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -7,7 +7,6 @@ use smithay::backend::renderer::gles::GlesRenderer; use smithay::output::Output; use smithay::wayland::dmabuf::DmabufFeedback; -use crate::config::Config; use crate::input::CompositorMod; use crate::niri::OutputRenderElements; use crate::Niri; @@ -47,14 +46,13 @@ impl Backend { pub fn render( &mut self, - config: &Config, niri: &mut Niri, output: &Output, elements: &[OutputRenderElements<GlesRenderer>], ) -> Option<&DmabufFeedback> { match self { - Backend::Tty(tty) => tty.render(config, niri, output, elements), - Backend::Winit(winit) => winit.render(config, niri, output, elements), + Backend::Tty(tty) => tty.render(niri, output, elements), + Backend::Winit(winit) => winit.render(niri, output, elements), } } diff --git a/src/backend/tty.rs b/src/backend/tty.rs index f2144770..2fd17eca 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -1,6 +1,8 @@ +use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::os::fd::FromRawFd; use std::path::{Path, PathBuf}; +use std::rc::Rc; use std::sync::{Mutex, Arc}; use std::time::Duration; @@ -42,6 +44,7 @@ const BACKGROUND_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.]; const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888]; pub struct Tty { + config: Rc<RefCell<Config>>, session: LibSeatSession, udev_dispatcher: Dispatcher<'static, UdevBackend, LoopData>, primary_gpu_path: PathBuf, @@ -88,7 +91,7 @@ struct Surface { } impl Tty { - pub fn new(event_loop: LoopHandle<'static, LoopData>) -> Self { + pub fn new(config: Rc<RefCell<Config>>, event_loop: LoopHandle<'static, LoopData>) -> Self { let (session, notifier) = LibSeatSession::new().unwrap(); let seat_name = session.seat(); @@ -237,6 +240,7 @@ impl Tty { let primary_gpu_path = udev::primary_gpu(&seat_name).unwrap().unwrap(); Self { + config, session, udev_dispatcher, primary_gpu_path, @@ -627,7 +631,6 @@ impl Tty { pub fn render( &mut self, - config: &Config, niri: &mut Niri, output: &Output, elements: &[OutputRenderElements<GlesRenderer>], @@ -647,7 +650,12 @@ impl Tty { Ok(res) => { assert!(!res.needs_sync()); - if config.debug.wait_for_frame_completion_before_queueing { + if self + .config + .borrow() + .debug + .wait_for_frame_completion_before_queueing + { if let PrimaryPlaneElement::Swapchain(element) = res.primary_element { let _span = tracy_client::span!("wait for completion"); element.sync.wait(); diff --git a/src/backend/winit.rs b/src/backend/winit.rs index f30c0784..9f591e71 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -1,4 +1,6 @@ +use std::cell::RefCell; use std::collections::HashMap; +use std::rc::Rc; use std::sync::{Arc, Mutex}; use std::time::Duration; @@ -21,6 +23,7 @@ use crate::utils::get_monotonic_time; use crate::{LoopData, Niri}; pub struct Winit { + config: Rc<RefCell<Config>>, output: Output, backend: WinitGraphicsBackend<GlesRenderer>, damage_tracker: OutputDamageTracker, @@ -28,7 +31,7 @@ pub struct Winit { } impl Winit { - pub fn new(event_loop: LoopHandle<LoopData>) -> Self { + pub fn new(config: Rc<RefCell<Config>>, event_loop: LoopHandle<LoopData>) -> Self { let builder = WindowBuilder::new() .with_inner_size(LogicalSize::new(1280.0, 800.0)) // .with_resizable(false) @@ -105,6 +108,7 @@ impl Winit { .unwrap(); Self { + config, output, backend, damage_tracker, @@ -137,7 +141,6 @@ impl Winit { pub fn render( &mut self, - config: &Config, niri: &mut Niri, output: &Output, elements: &[OutputRenderElements<GlesRenderer>], @@ -151,7 +154,12 @@ impl Winit { .render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0]) .unwrap(); if let Some(damage) = res.damage { - if config.debug.wait_for_frame_completion_before_queueing { + if self + .config + .borrow() + .debug + .wait_for_frame_completion_before_queueing + { let _span = tracy_client::span!("wait for completion"); res.sync.wait(); } |
