pinnacle/src/tag.rs

48 lines
1.1 KiB
Rust
Raw Normal View History

2023-06-30 21:34:07 -05:00
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//
// SPDX-License-Identifier: MPL-2.0
2023-07-09 17:48:46 -05:00
use std::{
hash::Hash,
sync::atomic::{AtomicU32, Ordering},
};
use smithay::output::Output;
static TAG_ID_COUNTER: AtomicU32 = AtomicU32::new(0);
2023-06-30 21:34:07 -05:00
2023-07-01 19:06:37 -05:00
#[derive(Debug, Hash, PartialEq, Eq, Clone, serde::Serialize, serde::Deserialize)]
2023-07-09 17:48:46 -05:00
pub struct TagId(u32);
impl TagId {
fn next() -> Self {
Self(TAG_ID_COUNTER.fetch_add(1, Ordering::Relaxed))
}
}
2023-06-30 21:34:07 -05:00
#[derive(Debug)]
pub struct Tag {
2023-07-09 17:48:46 -05:00
/// The internal id of this tag.
2023-06-30 21:34:07 -05:00
pub id: TagId,
2023-07-09 17:48:46 -05:00
/// The name of this tag.
pub name: String,
/// The output that this tag should be on.
pub output: Output,
2023-07-09 17:48:46 -05:00
/// Whether this tag is active or not.
pub active: bool,
2023-06-30 21:34:07 -05:00
// TODO: layout
}
2023-07-09 17:48:46 -05:00
impl Tag {
pub fn new(name: String, output: Output) -> Self {
Self {
id: TagId::next(),
name,
output,
active: false,
}
2023-06-30 21:34:07 -05:00
}
}