aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-03-01 09:45:57 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-03-10 07:59:14 +0300
commit12817a682d666e81e30b5a723d6419baf74cdb1c (patch)
treed679c33ea67347c868e8d081c74b91cc536ebab8
parent88614c08fe0a7833cbb749a6ecf3e703eb373c6e (diff)
downloadniri-12817a682d666e81e30b5a723d6419baf74cdb1c.tar.gz
niri-12817a682d666e81e30b5a723d6419baf74cdb1c.tar.bz2
niri-12817a682d666e81e30b5a723d6419baf74cdb1c.zip
Store offscreen element id on Mapped instead of user data
We don't need user data for this.
-rw-r--r--src/niri.rs14
-rw-r--r--src/window/mapped.rs19
2 files changed, 15 insertions, 18 deletions
diff --git a/src/niri.rs b/src/niri.rs
index ef3d8594..4575de21 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -29,7 +29,7 @@ use smithay::backend::renderer::element::utils::{
select_dmabuf_feedback, Relocate, RelocateRenderElement,
};
use smithay::backend::renderer::element::{
- default_primary_scanout_output_compare, Id, Kind, PrimaryScanoutOutput, RenderElementStates,
+ default_primary_scanout_output_compare, Kind, PrimaryScanoutOutput, RenderElementStates,
};
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::backend::renderer::sync::SyncPoint;
@@ -503,9 +503,6 @@ pub enum CenterCoords {
Both,
}
-#[derive(Default)]
-pub struct WindowOffscreenId(pub RefCell<Option<Id>>);
-
impl RedrawState {
fn queue_redraw(self) -> Self {
match self {
@@ -3796,12 +3793,7 @@ impl Niri {
for mapped in self.layout.windows_for_output(output) {
let win = &mapped.window;
- let offscreen_id = win
- .user_data()
- .get_or_insert(WindowOffscreenId::default)
- .0
- .borrow();
- let offscreen_id = offscreen_id.as_ref();
+ let offscreen_id = mapped.offscreen_element_id().clone();
win.with_surfaces(|surface, states| {
let surface_primary_scanout_output = states
@@ -3811,7 +3803,7 @@ impl Niri {
.lock()
.unwrap()
.update_from_render_element_states(
- offscreen_id.cloned().unwrap_or_else(|| surface.into()),
+ offscreen_id.clone().unwrap_or_else(|| surface.into()),
output,
render_element_states,
|_, _, output, _| output,
diff --git a/src/window/mapped.rs b/src/window/mapped.rs
index 77a08ab1..8263c078 100644
--- a/src/window/mapped.rs
+++ b/src/window/mapped.rs
@@ -1,4 +1,4 @@
-use std::cell::{Cell, RefCell};
+use std::cell::{Cell, Ref, RefCell};
use std::time::Duration;
use niri_config::{Color, CornerRadius, GradientInterpolation, WindowRule};
@@ -24,7 +24,6 @@ use crate::layout::{
ConfigureIntent, InteractiveResizeData, LayoutElement, LayoutElementRenderElement,
LayoutElementRenderSnapshot,
};
-use crate::niri::WindowOffscreenId;
use crate::niri_render_elements;
use crate::render_helpers::border::BorderRenderElement;
use crate::render_helpers::renderer::NiriRenderer;
@@ -71,6 +70,11 @@ pub struct Mapped {
/// resizes immediately, without waiting for a 1 second throttled callback.
needs_frame_callback: bool,
+ /// Id of the offscreen element rendered in place of this window.
+ ///
+ /// If `None`, then the window is not offscreened.
+ offscreen_element_id: RefCell<Option<Id>>,
+
/// Whether this window has the keyboard focus.
is_focused: bool,
@@ -188,6 +192,7 @@ impl Mapped {
need_to_recompute_rules: false,
needs_configure: false,
needs_frame_callback: false,
+ offscreen_element_id: RefCell::new(None),
is_focused: false,
is_active_in_column: true,
is_floating: false,
@@ -252,6 +257,10 @@ impl Mapped {
self.credentials.as_ref()
}
+ pub fn offscreen_element_id(&self) -> Ref<Option<Id>> {
+ self.offscreen_element_id.borrow()
+ }
+
pub fn is_focused(&self) -> bool {
self.is_focused
}
@@ -743,11 +752,7 @@ impl LayoutElement for Mapped {
}
fn set_offscreen_element_id(&self, id: Option<Id>) {
- let data = self
- .window
- .user_data()
- .get_or_insert(WindowOffscreenId::default);
- data.0.replace(id);
+ self.offscreen_element_id.replace(id);
}
fn set_activated(&mut self, active: bool) {