1
0
Fork 0
forked from wry/wry

wayland: implement xdg-activation

This commit is contained in:
Julian Orth 2024-02-14 17:42:59 +01:00
parent 0628a9d393
commit 41d7531cd5
26 changed files with 667 additions and 50 deletions

View file

@ -0,0 +1,28 @@
use crate::utils::numcell::NumCell;
#[derive(Default)]
pub struct ThresholdCounter {
counter: NumCell<usize>,
}
impl ThresholdCounter {
pub fn inc(&self) -> bool {
self.counter.fetch_add(1) == 0
}
pub fn dec(&self) -> bool {
self.counter.fetch_sub(1) == 1
}
pub fn adj(&self, inc: bool) -> bool {
if inc {
self.inc()
} else {
self.dec()
}
}
pub fn active(&self) -> bool {
self.counter.get() > 0
}
}