diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-01 09:45:57 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-10 07:59:14 +0300 |
| commit | 12817a682d666e81e30b5a723d6419baf74cdb1c (patch) | |
| tree | d679c33ea67347c868e8d081c74b91cc536ebab8 /src/window | |
| parent | 88614c08fe0a7833cbb749a6ecf3e703eb373c6e (diff) | |
| download | niri-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.
Diffstat (limited to 'src/window')
| -rw-r--r-- | src/window/mapped.rs | 19 |
1 files changed, 12 insertions, 7 deletions
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) { |
