1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

fix: popups occasionally getting jumbled with multiple bars

This commit is contained in:
Jake Stanger 2023-05-29 14:01:42 +01:00
parent e036ff03c1
commit a5ecb363fd
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
5 changed files with 17 additions and 17 deletions

View file

@ -3,6 +3,7 @@ use crate::modules::{
create_module, set_widget_identifiers, wrap_widget, ModuleInfo, ModuleLocation,
};
use crate::popup::Popup;
use crate::unique_id::get_unique_usize;
use crate::Config;
use color_eyre::Result;
use gtk::gdk::Monitor;
@ -206,7 +207,8 @@ fn add_modules(
}};
}
for (id, config) in modules.into_iter().enumerate() {
for config in modules.into_iter() {
let id = get_unique_usize();
match config {
#[cfg(feature = "clipboard")]
ModuleConfig::Clipboard(mut module) => add_module!(module, id),

View file

@ -7,6 +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 device::DataControlDevice;
use glib::Bytes;
@ -19,21 +20,14 @@ use std::fmt::{Debug, Formatter};
use std::fs::File;
use std::io::{ErrorKind, Read, Write};
use std::os::fd::{AsRawFd, OwnedFd, RawFd};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::{fs, io};
use tracing::{debug, error, trace};
use wayland_client::{Connection, QueueHandle};
use wayland_protocols_wlr::data_control::v1::client::zwlr_data_control_source_v1::ZwlrDataControlSourceV1;
static COUNTER: AtomicUsize = AtomicUsize::new(1);
const INTERNAL_MIME_TYPE: &str = "x-ironbar-internal";
fn get_id() -> usize {
COUNTER.fetch_add(1, Ordering::Relaxed)
}
pub struct SelectionOfferItem {
offer: SelectionOffer,
token: Option<RegistrationToken>,
@ -151,7 +145,7 @@ impl Environment {
};
Ok(ClipboardItem {
id: get_id(),
id: get_unique_usize(),
value,
mime_type: mime_type.value.clone(),
})

View file

@ -1,7 +1,7 @@
use super::manager::ToplevelManagerState;
use crate::lock;
use crate::unique_id::get_unique_usize;
use std::collections::HashSet;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use tracing::trace;
use wayland_client::protocol::wl_output::WlOutput;
@ -11,12 +11,6 @@ use wayland_protocols_wlr::foreign_toplevel::v1::client::zwlr_foreign_toplevel_h
Event, ZwlrForeignToplevelHandleV1,
};
static COUNTER: AtomicUsize = AtomicUsize::new(1);
fn get_id() -> usize {
COUNTER.fetch_add(1, Ordering::Relaxed)
}
#[derive(Debug, Clone)]
pub struct ToplevelHandle {
pub handle: ZwlrForeignToplevelHandleV1,
@ -74,7 +68,7 @@ pub struct ToplevelInfo {
impl Default for ToplevelInfo {
fn default() -> Self {
Self {
id: get_id(),
id: get_unique_usize(),
app_id: String::new(),
title: String::new(),
fullscreen: false,

View file

@ -15,6 +15,7 @@ mod modules;
mod popup;
mod script;
mod style;
mod unique_id;
use crate::bar::create_bar;
use crate::config::{Config, MonitorConfig};

9
src/unique_id.rs Normal file
View file

@ -0,0 +1,9 @@
use std::sync::atomic::{AtomicUsize, Ordering};
static COUNTER: AtomicUsize = AtomicUsize::new(1);
/// Gets a `usize` ID value that is unique to the entire Ironbar instance.
/// This is just an `AtomicUsize` that increments every time this function is called.
pub fn get_unique_usize() -> usize {
COUNTER.fetch_add(1, Ordering::Relaxed)
}