wayland: implement xdg-activation
This commit is contained in:
parent
0628a9d393
commit
41d7531cd5
26 changed files with 667 additions and 50 deletions
28
src/utils/threshold_counter.rs
Normal file
28
src/utils/threshold_counter.rs
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue