aboutsummaryrefslogtreecommitdiff
path: root/src/window
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-06-26 10:06:26 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-06-28 10:39:35 +0400
commit6c5f10035a24963336d99f801164e7437ebffa77 (patch)
treef80d0befd54b28a2aeebe84abb578d7f18c8c09c /src/window
parent96d2baa2b55a02dec3476791c6553fe2035d4825 (diff)
downloadniri-6c5f10035a24963336d99f801164e7437ebffa77.tar.gz
niri-6c5f10035a24963336d99f801164e7437ebffa77.tar.bz2
niri-6c5f10035a24963336d99f801164e7437ebffa77.zip
mapped: Add id
Diffstat (limited to 'src/window')
-rw-r--r--src/window/mapped.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/window/mapped.rs b/src/window/mapped.rs
index 59a71044..18ace780 100644
--- a/src/window/mapped.rs
+++ b/src/window/mapped.rs
@@ -27,12 +27,16 @@ use crate::render_helpers::snapshot::RenderSnapshot;
use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement};
use crate::render_helpers::surface::render_snapshot_from_surface_tree;
use crate::render_helpers::{BakedBuffer, RenderTarget, SplitElements};
+use crate::utils::id::IdCounter;
use crate::utils::{send_scale_transform, ResizeEdge};
#[derive(Debug)]
pub struct Mapped {
pub window: Window,
+ /// Unique ID of this `Mapped`.
+ id: MappedId,
+
/// Pre-commit hook that we have on all mapped toplevel surfaces.
pre_commit_hook: HookId,
@@ -72,6 +76,21 @@ pub struct Mapped {
last_interactive_resize_start: Cell<Option<(Duration, ResizeEdge)>>,
}
+static MAPPED_ID_COUNTER: IdCounter = IdCounter::new();
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct MappedId(u32);
+
+impl MappedId {
+ fn next() -> MappedId {
+ MappedId(MAPPED_ID_COUNTER.next())
+ }
+
+ pub fn get(self) -> u32 {
+ self.0
+ }
+}
+
/// Interactive resize state.
#[derive(Debug)]
enum InteractiveResize {
@@ -100,6 +119,7 @@ impl Mapped {
pub fn new(window: Window, rules: ResolvedWindowRules, hook: HookId) -> Self {
Self {
window,
+ id: MappedId::next(),
pre_commit_hook: hook,
rules,
need_to_recompute_rules: false,
@@ -143,6 +163,10 @@ impl Mapped {
self.recompute_window_rules(rules, is_at_startup)
}
+ pub fn id(&self) -> MappedId {
+ self.id
+ }
+
pub fn is_focused(&self) -> bool {
self.is_focused
}