mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-03 19:51:03 +02:00
feat: load bars on monitor when it connects
Finally, Ironbar will respond to events of monitors being (dis)connected, and will create bars when a monitor connects. This means at last - resolves #291 yaay
This commit is contained in:
parent
3dc198ee41
commit
8371a92204
6 changed files with 139 additions and 96 deletions
|
@ -13,7 +13,7 @@ use std::sync::{Arc, Mutex};
|
|||
use calloop_channel::Event::Msg;
|
||||
use cfg_if::cfg_if;
|
||||
use color_eyre::Report;
|
||||
use smithay_client_toolkit::output::{OutputInfo, OutputState};
|
||||
use smithay_client_toolkit::output::OutputState;
|
||||
use smithay_client_toolkit::reexports::calloop::channel as calloop_channel;
|
||||
use smithay_client_toolkit::reexports::calloop::{EventLoop, LoopHandle};
|
||||
use smithay_client_toolkit::reexports::calloop_wayland_source::WaylandSource;
|
||||
|
@ -25,12 +25,11 @@ use smithay_client_toolkit::{
|
|||
use tokio::sync::{broadcast, mpsc};
|
||||
use tracing::{debug, error, trace};
|
||||
use wayland_client::globals::registry_queue_init;
|
||||
use wayland_client::protocol::wl_seat::WlSeat;
|
||||
use wayland_client::{Connection, QueueHandle};
|
||||
|
||||
use wlr_foreign_toplevel::manager::ToplevelManagerState;
|
||||
|
||||
pub use wl_output::OutputEvent;
|
||||
pub use wl_output::{OutputEvent, OutputEventType};
|
||||
pub use wlr_foreign_toplevel::{ToplevelEvent, ToplevelHandle, ToplevelInfo};
|
||||
|
||||
cfg_if! {
|
||||
|
@ -42,6 +41,7 @@ cfg_if! {
|
|||
use self::wlr_data_control::manager::DataControlDeviceManagerState;
|
||||
use self::wlr_data_control::source::CopyPasteSource;
|
||||
use self::wlr_data_control::SelectionOfferItem;
|
||||
use wayland_client::protocol::wl_seat::WlSeat;
|
||||
|
||||
pub use wlr_data_control::{ClipboardItem, ClipboardValue};
|
||||
|
||||
|
@ -65,6 +65,7 @@ pub enum Event {
|
|||
pub enum Request {
|
||||
Roundtrip,
|
||||
|
||||
#[cfg(feature = "ipc")]
|
||||
OutputInfoAll,
|
||||
|
||||
ToplevelInfoAll,
|
||||
|
@ -81,16 +82,13 @@ pub enum Response {
|
|||
/// An empty success response
|
||||
Ok,
|
||||
|
||||
OutputInfo(Option<OutputInfo>),
|
||||
OutputInfoAll(Vec<OutputInfo>),
|
||||
#[cfg(feature = "ipc")]
|
||||
OutputInfoAll(Vec<smithay_client_toolkit::output::OutputInfo>),
|
||||
|
||||
ToplevelInfo(Option<ToplevelInfo>),
|
||||
ToplevelInfoAll(Vec<ToplevelInfo>),
|
||||
|
||||
#[cfg(feature = "clipboard")]
|
||||
ClipboardItem(Option<ClipboardItem>),
|
||||
|
||||
Seat(WlSeat),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -303,6 +301,7 @@ impl Environment {
|
|||
debug!("received roundtrip request");
|
||||
send!(env.response_tx, Response::Ok);
|
||||
}
|
||||
#[cfg(feature = "ipc")]
|
||||
Msg(Request::OutputInfoAll) => {
|
||||
let infos = env.output_info_all();
|
||||
send!(env.response_tx, Response::OutputInfoAll(infos));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{Client, Environment, Event, Request, Response};
|
||||
use super::{Client, Environment, Event};
|
||||
use crate::try_send;
|
||||
use smithay_client_toolkit::output::{OutputHandler, OutputInfo, OutputState};
|
||||
use tokio::sync::broadcast;
|
||||
|
@ -8,8 +8,8 @@ use wayland_client::{Connection, QueueHandle};
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OutputEvent {
|
||||
output: OutputInfo,
|
||||
event_type: OutputEventType,
|
||||
pub output: OutputInfo,
|
||||
pub event_type: OutputEventType,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
@ -21,7 +21,9 @@ pub enum OutputEventType {
|
|||
|
||||
impl Client {
|
||||
/// Gets the information for all outputs.
|
||||
#[cfg(feature = "ipc")]
|
||||
pub fn output_info_all(&self) -> Vec<OutputInfo> {
|
||||
use super::{Request, Response};
|
||||
match self.send_request(Request::OutputInfoAll) {
|
||||
Response::OutputInfoAll(info) => info,
|
||||
_ => unreachable!(),
|
||||
|
@ -35,6 +37,7 @@ impl Client {
|
|||
}
|
||||
|
||||
impl Environment {
|
||||
#[cfg(feature = "ipc")]
|
||||
pub fn output_info_all(&mut self) -> Vec<OutputInfo> {
|
||||
self.output_state
|
||||
.outputs()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue