mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 10:41:03 +02:00
fix: popups occasionally getting jumbled with multiple bars
This commit is contained in:
parent
e036ff03c1
commit
a5ecb363fd
5 changed files with 17 additions and 17 deletions
|
@ -3,6 +3,7 @@ use crate::modules::{
|
||||||
create_module, set_widget_identifiers, wrap_widget, ModuleInfo, ModuleLocation,
|
create_module, set_widget_identifiers, wrap_widget, ModuleInfo, ModuleLocation,
|
||||||
};
|
};
|
||||||
use crate::popup::Popup;
|
use crate::popup::Popup;
|
||||||
|
use crate::unique_id::get_unique_usize;
|
||||||
use crate::Config;
|
use crate::Config;
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use gtk::gdk::Monitor;
|
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 {
|
match config {
|
||||||
#[cfg(feature = "clipboard")]
|
#[cfg(feature = "clipboard")]
|
||||||
ModuleConfig::Clipboard(mut module) => add_module!(module, id),
|
ModuleConfig::Clipboard(mut module) => add_module!(module, id),
|
||||||
|
|
|
@ -7,6 +7,7 @@ use self::device::{DataControlDeviceDataExt, DataControlDeviceHandler};
|
||||||
use self::offer::{DataControlDeviceOffer, DataControlOfferHandler, SelectionOffer};
|
use self::offer::{DataControlDeviceOffer, DataControlOfferHandler, SelectionOffer};
|
||||||
use self::source::DataControlSourceHandler;
|
use self::source::DataControlSourceHandler;
|
||||||
use crate::clients::wayland::Environment;
|
use crate::clients::wayland::Environment;
|
||||||
|
use crate::unique_id::get_unique_usize;
|
||||||
use crate::{lock, send};
|
use crate::{lock, send};
|
||||||
use device::DataControlDevice;
|
use device::DataControlDevice;
|
||||||
use glib::Bytes;
|
use glib::Bytes;
|
||||||
|
@ -19,21 +20,14 @@ use std::fmt::{Debug, Formatter};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{ErrorKind, Read, Write};
|
use std::io::{ErrorKind, Read, Write};
|
||||||
use std::os::fd::{AsRawFd, OwnedFd, RawFd};
|
use std::os::fd::{AsRawFd, OwnedFd, RawFd};
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{fs, io};
|
use std::{fs, io};
|
||||||
use tracing::{debug, error, trace};
|
use tracing::{debug, error, trace};
|
||||||
use wayland_client::{Connection, QueueHandle};
|
use wayland_client::{Connection, QueueHandle};
|
||||||
use wayland_protocols_wlr::data_control::v1::client::zwlr_data_control_source_v1::ZwlrDataControlSourceV1;
|
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";
|
const INTERNAL_MIME_TYPE: &str = "x-ironbar-internal";
|
||||||
|
|
||||||
fn get_id() -> usize {
|
|
||||||
COUNTER.fetch_add(1, Ordering::Relaxed)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct SelectionOfferItem {
|
pub struct SelectionOfferItem {
|
||||||
offer: SelectionOffer,
|
offer: SelectionOffer,
|
||||||
token: Option<RegistrationToken>,
|
token: Option<RegistrationToken>,
|
||||||
|
@ -151,7 +145,7 @@ impl Environment {
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(ClipboardItem {
|
Ok(ClipboardItem {
|
||||||
id: get_id(),
|
id: get_unique_usize(),
|
||||||
value,
|
value,
|
||||||
mime_type: mime_type.value.clone(),
|
mime_type: mime_type.value.clone(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use super::manager::ToplevelManagerState;
|
use super::manager::ToplevelManagerState;
|
||||||
use crate::lock;
|
use crate::lock;
|
||||||
|
use crate::unique_id::get_unique_usize;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
use wayland_client::protocol::wl_output::WlOutput;
|
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,
|
Event, ZwlrForeignToplevelHandleV1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static COUNTER: AtomicUsize = AtomicUsize::new(1);
|
|
||||||
|
|
||||||
fn get_id() -> usize {
|
|
||||||
COUNTER.fetch_add(1, Ordering::Relaxed)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ToplevelHandle {
|
pub struct ToplevelHandle {
|
||||||
pub handle: ZwlrForeignToplevelHandleV1,
|
pub handle: ZwlrForeignToplevelHandleV1,
|
||||||
|
@ -74,7 +68,7 @@ pub struct ToplevelInfo {
|
||||||
impl Default for ToplevelInfo {
|
impl Default for ToplevelInfo {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: get_id(),
|
id: get_unique_usize(),
|
||||||
app_id: String::new(),
|
app_id: String::new(),
|
||||||
title: String::new(),
|
title: String::new(),
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
|
|
|
@ -15,6 +15,7 @@ mod modules;
|
||||||
mod popup;
|
mod popup;
|
||||||
mod script;
|
mod script;
|
||||||
mod style;
|
mod style;
|
||||||
|
mod unique_id;
|
||||||
|
|
||||||
use crate::bar::create_bar;
|
use crate::bar::create_bar;
|
||||||
use crate::config::{Config, MonitorConfig};
|
use crate::config::{Config, MonitorConfig};
|
||||||
|
|
9
src/unique_id.rs
Normal file
9
src/unique_id.rs
Normal 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)
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue