1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-03 03:31:03 +02:00

refactor: begin restructuring core code to better encapsulate

This is a first pass towards trying to structure things a bit better, with data generally encapsulated under a single hierarchical tree, rather than lots of globals all over the place. Lots of work is still required.

The plan is that with this and some more work, #291 should become a lot easier to sort.
This commit is contained in:
Jake Stanger 2023-12-08 22:39:27 +00:00
parent 08e354e019
commit b2fa19ab6c
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
14 changed files with 490 additions and 415 deletions

View file

@ -1,5 +1,4 @@
use crate::unique_id::get_unique_usize;
use crate::{arc_mut, lock, send};
use crate::{arc_mut, lock, send, Ironbar};
use async_once::AsyncOnce;
use color_eyre::Report;
use lazy_static::lazy_static;
@ -25,7 +24,7 @@ pub struct TrayEventReceiver {
impl TrayEventReceiver {
async fn new() -> system_tray::error::Result<Self> {
let id = format!("ironbar-{}", get_unique_usize());
let id = format!("ironbar-{}", Ironbar::unique_id());
let (tx, rx) = mpsc::channel(16);
let (b_tx, b_rx) = broadcast::channel(16);

View file

@ -7,8 +7,7 @@ use self::device::{DataControlDeviceDataExt, DataControlDeviceHandler};
use self::offer::{DataControlDeviceOffer, DataControlOfferHandler, SelectionOffer};
use self::source::DataControlSourceHandler;
use crate::clients::wayland::Environment;
use crate::unique_id::get_unique_usize;
use crate::{lock, send};
use crate::{lock, send, Ironbar};
use device::DataControlDevice;
use glib::Bytes;
use nix::fcntl::{fcntl, F_GETPIPE_SZ, F_SETPIPE_SZ};
@ -145,7 +144,7 @@ impl Environment {
};
Ok(ClipboardItem {
id: get_unique_usize(),
id: Ironbar::unique_id(),
value,
mime_type: mime_type.value.clone(),
})

View file

@ -1,6 +1,5 @@
use super::manager::ToplevelManagerState;
use crate::lock;
use crate::unique_id::get_unique_usize;
use crate::{lock, Ironbar};
use std::collections::HashSet;
use std::sync::{Arc, Mutex};
use tracing::trace;
@ -68,7 +67,7 @@ pub struct ToplevelInfo {
impl Default for ToplevelInfo {
fn default() -> Self {
Self {
id: get_unique_usize(),
id: Ironbar::unique_id(),
app_id: String::new(),
title: String::new(),
fullscreen: false,