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

refactor: use new smart pointer macros throughout codebase

This commit is contained in:
Jake Stanger 2023-06-29 23:16:31 +01:00
parent ac04cc27ce
commit 7016f7f79e
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
10 changed files with 23 additions and 25 deletions

View file

@ -1,5 +1,5 @@
use super::wayland::{self, ClipboardItem};
use crate::{lock, try_send};
use crate::{arc_mut, lock, try_send};
use indexmap::map::Iter;
use indexmap::IndexMap;
use lazy_static::lazy_static;
@ -28,9 +28,9 @@ impl ClipboardClient {
fn new() -> Self {
trace!("Initializing clipboard client");
let senders = Arc::new(Mutex::new(Vec::<(EventSender, usize)>::new()));
let senders = arc_mut!(Vec::<(EventSender, usize)>::new());
let cache = Arc::new(Mutex::new(ClipboardCache::new()));
let cache = arc_mut!(ClipboardCache::new());
{
let senders = senders.clone();

View file

@ -1,5 +1,5 @@
use super::{Workspace, WorkspaceClient, WorkspaceUpdate};
use crate::{lock, send};
use crate::{arc_mut, lock, send};
use color_eyre::Result;
use hyprland::data::{Workspace as HWorkspace, Workspaces};
use hyprland::dispatch::{Dispatch, DispatchType, WorkspaceIdentifierWithSpecial};
@ -7,7 +7,6 @@ use hyprland::event_listener::EventListenerMutable as EventListener;
use hyprland::prelude::*;
use hyprland::shared::WorkspaceType;
use lazy_static::lazy_static;
use std::sync::{Arc, Mutex};
use tokio::sync::broadcast::{channel, Receiver, Sender};
use tokio::task::spawn_blocking;
use tracing::{debug, error, info};
@ -36,11 +35,11 @@ impl EventClient {
let mut event_listener = EventListener::new();
// we need a lock to ensure events don't run at the same time
let lock = Arc::new(Mutex::new(()));
let lock = arc_mut!(());
// cache the active workspace since Hyprland doesn't give us the prev active
let active = Self::get_active_workspace().expect("Failed to get active workspace");
let active = Arc::new(Mutex::new(Some(active)));
let active = arc_mut!(Some(active));
{
let tx = tx.clone();

View file

@ -1,6 +1,6 @@
use super::{MusicClient, PlayerUpdate, Status, Track};
use crate::clients::music::PlayerState;
use crate::{lock, send};
use crate::{arc_mut, lock, send};
use color_eyre::Result;
use lazy_static::lazy_static;
use mpris::{DBusError, Event, Metadata, PlaybackStatus, Player, PlayerFinder};
@ -27,10 +27,10 @@ impl Client {
fn new() -> Self {
let (tx, rx) = channel(32);
let current_player = Arc::new(Mutex::new(None));
let current_player = arc_mut!(None);
{
let players_list = Arc::new(Mutex::new(HashSet::new()));
let players_list = arc_mut!(HashSet::new());
let current_player = current_player.clone();
let tx = tx.clone();

View file

@ -1,5 +1,5 @@
use crate::unique_id::get_unique_usize;
use crate::{lock, send};
use crate::{arc_mut, lock, send};
use async_once::AsyncOnce;
use color_eyre::Report;
use lazy_static::lazy_static;
@ -33,7 +33,7 @@ impl TrayEventReceiver {
let tray = StatusNotifierWatcher::new(rx).await?;
let mut host = Box::pin(tray.create_notifier_host(&id)).await?;
let tray = Arc::new(Mutex::new(BTreeMap::new()));
let tray = arc_mut!(BTreeMap::new());
{
let b_tx = b_tx.clone();

View file

@ -25,7 +25,7 @@ cfg_if! {
use super::ClipboardItem;
use super::wlr_data_control::manager::DataControlDeviceManagerState;
use crate::lock;
use std::sync::{Arc, Mutex};
use std::sync::Arc;
}
}
@ -138,7 +138,7 @@ impl WaylandClient {
seats: vec![],
handles: HashMap::new(),
#[cfg(feature = "clipboard")]
clipboard: Arc::new(Mutex::new(None)),
clipboard: crate::arc_mut!(None),
toplevel_tx,
#[cfg(feature = "clipboard")]
clipboard_tx,

View file

@ -6,7 +6,7 @@ mod wl_seat;
mod wlr_foreign_toplevel;
use self::wlr_foreign_toplevel::manager::ToplevelManagerState;
use crate::{delegate_foreign_toplevel_handle, delegate_foreign_toplevel_manager};
use crate::{arc_mut, delegate_foreign_toplevel_handle, delegate_foreign_toplevel_manager};
use cfg_if::cfg_if;
use lazy_static::lazy_static;
use smithay_client_toolkit::output::OutputState;
@ -105,7 +105,7 @@ impl ProvidesRegistryState for Environment {
}
lazy_static! {
static ref CLIENT: Arc<Mutex<WaylandClient>> = Arc::new(Mutex::new(WaylandClient::new()));
static ref CLIENT: Arc<Mutex<WaylandClient>> = arc_mut!(WaylandClient::new());
}
pub fn get_client() -> Arc<Mutex<WaylandClient>> {