1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-09-16 03:36:58 +02:00

Merge branch 'develop' into feat/networkmanager

This commit is contained in:
Reinout Meliesie 2024-05-27 13:04:40 +02:00
commit cd8c6b33bf
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
52 changed files with 1149 additions and 280 deletions

View file

@ -149,12 +149,27 @@ impl Client {
}
{
event_listener.add_workspace_destroy_handler(move |workspace_type| {
let _lock = lock!(lock);
debug!("Received workspace destroy: {workspace_type:?}");
let tx = tx.clone();
let lock = lock.clone();
let name = get_workspace_name(workspace_type);
send!(tx, WorkspaceUpdate::Remove(name));
event_listener.add_workspace_rename_handler(move |data| {
let _lock = lock!(lock);
send!(
tx,
WorkspaceUpdate::Rename {
id: data.workspace_id as i64,
name: data.workspace_name
}
);
});
}
{
event_listener.add_workspace_destroy_handler(move |data| {
let _lock = lock!(lock);
debug!("Received workspace destroy: {data:?}");
send!(tx, WorkspaceUpdate::Remove(data.workspace_id as i64));
});
}
@ -186,6 +201,7 @@ impl Client {
fn get_workspace(name: &str, active: Option<&Workspace>) -> Option<Workspace> {
Workspaces::get()
.expect("Failed to get workspaces")
.into_iter()
.find_map(|w| {
if w.name == name {
let vis = Visibility::from((&w, active.map(|w| w.name.as_ref()), &|w| {
@ -228,6 +244,7 @@ impl WorkspaceClient for Client {
let workspaces = Workspaces::get()
.expect("Failed to get workspaces")
.into_iter()
.map(|w| {
let vis = Visibility::from((&w, active_id.as_deref(), &is_visible));
@ -262,7 +279,7 @@ fn create_is_visible() -> impl Fn(&HWorkspace) -> bool {
impl From<(Visibility, HWorkspace)> for Workspace {
fn from((visibility, workspace): (Visibility, HWorkspace)) -> Self {
Self {
id: workspace.id.to_string(),
id: workspace.id as i64,
name: workspace.name,
monitor: workspace.monitor,
visibility,

View file

@ -74,7 +74,7 @@ impl Compositor {
#[derive(Debug, Clone)]
pub struct Workspace {
/// Unique identifier
pub id: String,
pub id: i64,
/// Workspace friendly name
pub name: String,
/// Name of the monitor (output) the workspace is located on
@ -119,13 +119,19 @@ pub enum WorkspaceUpdate {
/// This is re-sent to all subscribers when a new subscription is created.
Init(Vec<Workspace>),
Add(Workspace),
Remove(String),
Remove(i64),
Move(Workspace),
/// Declares focus moved from the old workspace to the new.
Focus {
old: Option<Workspace>,
new: Workspace,
},
Rename {
id: i64,
name: String,
},
/// An update was triggered by the compositor but this was not mapped by Ironbar.
///
/// This is purely used for ergonomics within the compositor clients

View file

@ -90,7 +90,7 @@ impl From<Node> for Workspace {
let visibility = Visibility::from(&node);
Self {
id: node.id.to_string(),
id: node.id,
name: node.name.unwrap_or_default(),
monitor: node.output.unwrap_or_default(),
visibility,
@ -103,7 +103,7 @@ impl From<swayipc_async::Workspace> for Workspace {
let visibility = Visibility::from(&workspace);
Self {
id: workspace.id.to_string(),
id: workspace.id,
name: workspace.name,
monitor: workspace.output,
visibility,
@ -141,13 +141,9 @@ impl From<WorkspaceEvent> for WorkspaceUpdate {
WorkspaceChange::Init => {
Self::Add(event.current.expect("Missing current workspace").into())
}
WorkspaceChange::Empty => Self::Remove(
event
.current
.expect("Missing current workspace")
.name
.unwrap_or_default(),
),
WorkspaceChange::Empty => {
Self::Remove(event.current.expect("Missing current workspace").id)
}
WorkspaceChange::Focus => Self::Focus {
old: event.old.map(Workspace::from),
new: Workspace::from(event.current.expect("Missing current workspace")),

View file

@ -11,7 +11,7 @@ use crate::{lock, try_send, Ironbar};
use device::DataControlDevice;
use glib::Bytes;
use nix::fcntl::{fcntl, F_GETPIPE_SZ, F_SETPIPE_SZ};
use nix::sys::epoll::{Epoll, EpollCreateFlags, EpollEvent, EpollFlags};
use nix::sys::epoll::{Epoll, EpollCreateFlags, EpollEvent, EpollFlags, EpollTimeout};
use smithay_client_toolkit::data_device_manager::WritePipe;
use smithay_client_toolkit::reexports::calloop::{PostAction, RegistrationToken};
use std::cmp::min;
@ -274,7 +274,7 @@ impl DataControlDeviceHandler for Environment {
Ok(token) => {
cur_offer.token.replace(token);
}
Err(err) => error!("{err:?}"),
Err(err) => error!("Failed to insert read pipe event: {err:?}"),
}
}
}
@ -294,15 +294,15 @@ impl DataControlOfferHandler for Environment {
}
impl DataControlSourceHandler for Environment {
fn accept_mime(
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_source: &ZwlrDataControlSourceV1,
mime: Option<String>,
) {
debug!("Accepted mime type: {mime:?}");
}
// fn accept_mime(
// &mut self,
// _conn: &Connection,
// _qh: &QueueHandle<Self>,
// _source: &ZwlrDataControlSourceV1,
// mime: Option<String>,
// ) {
// debug!("Accepted mime type: {mime:?}");
// }
/// Writes the current clipboard item to 'paste' it
/// upon request from a compositor client.
@ -349,11 +349,12 @@ impl DataControlSourceHandler for Environment {
.add(fd, epoll_event)
.expect("to send valid epoll operation");
let timeout = EpollTimeout::from(100u16);
while !bytes.is_empty() {
let chunk = &bytes[..min(pipe_size as usize, bytes.len())];
epoll_fd
.wait(&mut events, 100)
.wait(&mut events, timeout)
.expect("Failed to wait to epoll");
match file.write(chunk) {

View file

@ -5,7 +5,7 @@ use nix::unistd::{close, pipe2};
use smithay_client_toolkit::data_device_manager::data_offer::DataOfferError;
use smithay_client_toolkit::data_device_manager::ReadPipe;
use std::ops::DerefMut;
use std::os::fd::{BorrowedFd, FromRawFd};
use std::os::fd::{AsFd, AsRawFd};
use std::sync::{Arc, Mutex};
use tracing::{trace, warn};
use wayland_client::{Connection, Dispatch, Proxy, QueueHandle};
@ -176,11 +176,11 @@ pub unsafe fn receive(
// create a pipe
let (readfd, writefd) = pipe2(OFlag::O_CLOEXEC)?;
offer.receive(mime_type, BorrowedFd::borrow_raw(writefd));
offer.receive(mime_type, writefd.as_fd());
if let Err(err) = close(writefd) {
if let Err(err) = close(writefd.as_raw_fd()) {
warn!("Failed to close write pipe: {}", err);
}
Ok(FromRawFd::from_raw_fd(readfd))
Ok(ReadPipe::from(readfd))
}

View file

@ -10,13 +10,13 @@ use wayland_protocols_wlr::data_control::v1::client::zwlr_data_control_source_v1
pub struct DataControlSourceData {}
pub trait DataControlSourceDataExt: Send + Sync {
fn data_source_data(&self) -> &DataControlSourceData;
// fn data_source_data(&self) -> &DataControlSourceData;
}
impl DataControlSourceDataExt for DataControlSourceData {
fn data_source_data(&self) -> &DataControlSourceData {
self
}
// fn data_source_data(&self) -> &DataControlSourceData {
// self
// }
}
/// Handler trait for `DataSource` events.
@ -24,13 +24,13 @@ impl DataControlSourceDataExt for DataControlSourceData {
/// The functions defined in this trait are called as `DataSource` events are received from the compositor.
pub trait DataControlSourceHandler: Sized {
/// This may be called multiple times, once for each accepted mime type from the destination, if any.
fn accept_mime(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
source: &ZwlrDataControlSourceV1,
mime: Option<String>,
);
// fn accept_mime(
// &mut self,
// conn: &Connection,
// qh: &QueueHandle<Self>,
// source: &ZwlrDataControlSourceV1,
// mime: Option<String>,
// );
/// The client has requested the data for this source to be sent.
/// Send the data, then close the fd.

View file

@ -77,7 +77,6 @@ impl ToplevelHandleHandler for Environment {
match handle.info() {
Some(info) => {
trace!("Updating handle: {info:?}");
self.handles.push(handle.clone());
if let Some(info) = handle.info() {
try_send!(self.event_tx, Event::Toplevel(ToplevelEvent::Update(info)));
}