From 6e7d51972ee781b37e65b362063f4e3aebefa28e Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Thu, 9 Jan 2025 01:20:25 +0200 Subject: update wayrs-client and other deps --- src/main.rs | 6 ++++-- src/output.rs | 4 ++-- src/state.rs | 25 ++++++++++--------------- src/wm_info_provider.rs | 9 ++------- src/wm_info_provider/river.rs | 33 ++++++++++----------------------- 5 files changed, 28 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 076d17b..598864a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,9 +43,11 @@ fn main() -> anyhow::Result<()> { let [sig_read, sig_write] = pipe(libc::O_NONBLOCK | libc::O_CLOEXEC)?; signal_hook::low_level::pipe::register(SIGUSR1, sig_write)?; - let (mut conn, globals) = Connection::connect_and_collect_globals()?; + let mut conn = Connection::connect()?; + conn.blocking_roundtrip()?; + let mut el = EventLoop::new(); - let mut state = State::new(&mut conn, &globals, &mut el, args.config.as_deref()); + let mut state = State::new(&mut conn, &mut el, args.config.as_deref()); conn.flush(IoMode::Blocking)?; el.add_on_idle(|ctx| { diff --git a/src/output.rs b/src/output.rs index d243d52..222245c 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,6 +1,6 @@ use wayrs_client::global::{Global, GlobalExt}; -use wayrs_client::Connection; -use wayrs_client::{protocol::*, EventCtx}; +use wayrs_client::protocol::*; +use wayrs_client::{Connection, EventCtx}; use crate::state::State; diff --git a/src/state.rs b/src/state.rs index 72bf3f0..19d6434 100644 --- a/src/state.rs +++ b/src/state.rs @@ -8,7 +8,7 @@ use std::fmt::Display; use std::os::unix::io::{AsRawFd, RawFd}; use std::path::Path; -use wayrs_client::global::{GlobalExt, Globals, GlobalsExt}; +use wayrs_client::global::GlobalExt; use wayrs_client::proxy::Proxy; use wayrs_client::{Connection, EventCtx}; use wayrs_utils::cursor::{CursorImage, CursorShape, CursorTheme, ThemedPointer}; @@ -57,7 +57,6 @@ struct Pointer { impl State { pub fn new( conn: &mut Connection, - globals: &Globals, event_loop: &mut EventLoop, config_path: Option<&Path>, ) -> Self { @@ -73,38 +72,34 @@ impl State { .and_then(|cmd| StatusCmd::new(cmd).map_err(|e| error = Err(e)).ok()); conn.add_registry_cb(wl_registry_cb); - let wl_compositor = globals.bind(conn, 4..=5).unwrap(); + let wl_compositor = conn.bind_singleton(4..=5).unwrap(); - let cursor_theme = CursorTheme::new(conn, globals, wl_compositor); + let cursor_theme = CursorTheme::new(conn, wl_compositor); let default_cursor = cursor_theme .get_image(CursorShape::Default) .map_err(|e| error = Err(e.into())) .ok(); - let wm_info_provider = wm_info_provider::bind(conn, globals, &config.wm); + let wm_info_provider = wm_info_provider::bind(conn, &config.wm); wm_info_provider.register(event_loop); let mut this = Self { wl_compositor, - layer_shell: globals.bind(conn, 1..=4).unwrap(), - viewporter: globals.bind(conn, 1..=1).unwrap(), - fractional_scale_manager: globals.bind(conn, 1..=1).ok(), + layer_shell: conn.bind_singleton(1..=4).unwrap(), + viewporter: conn.bind_singleton(1).unwrap(), + fractional_scale_manager: conn.bind_singleton(1).ok(), - seats: Seats::bind(conn, globals), + seats: Seats::bind(conn), pointers: Vec::new(), - pending_outputs: globals - .iter() - .filter(|g| g.is::()) - .map(|g| PendingOutput::bind(conn, g)) - .collect(), + pending_outputs: Vec::new(), hidden: false, has_error: false, bars: Vec::new(), shared_state: SharedState { - shm: ShmAlloc::bind(conn, globals).unwrap(), + shm: ShmAlloc::bind(conn).unwrap(), config, status_cmd, blocks_cache: BlocksCache::default(), diff --git a/src/wm_info_provider.rs b/src/wm_info_provider.rs index b3c6618..eb8b51a 100644 --- a/src/wm_info_provider.rs +++ b/src/wm_info_provider.rs @@ -1,6 +1,5 @@ use std::any::Any; -use wayrs_client::global::*; use wayrs_client::Connection; use crate::config::WmConfig; @@ -52,12 +51,8 @@ pub trait WmInfoProvider { fn as_any(&mut self) -> &mut dyn Any; } -pub fn bind( - conn: &mut Connection, - globals: &Globals, - config: &WmConfig, -) -> Box { - if let Some(river) = RiverInfoProvider::bind(conn, globals, config) { +pub fn bind(conn: &mut Connection, config: &WmConfig) -> Box { + if let Some(river) = RiverInfoProvider::bind(conn, config) { return Box::new(river); } diff --git a/src/wm_info_provider/river.rs b/src/wm_info_provider/river.rs index 61b7e2b..9cf8c47 100644 --- a/src/wm_info_provider/river.rs +++ b/src/wm_info_provider/river.rs @@ -1,6 +1,5 @@ use std::ffi::CString; -use wayrs_client::global::*; use wayrs_client::proxy::Proxy; use wayrs_client::EventCtx; @@ -11,7 +10,7 @@ pub struct RiverInfoProvider { control: ZriverControlV1, output_statuses: Vec, max_tag: u8, - seat_status: SeatStatus, + mode: Option, } struct OutputStatus { @@ -23,33 +22,21 @@ struct OutputStatus { layout_name: Option, } -struct SeatStatus { - _status: ZriverSeatStatusV1, - mode: Option, -} - impl RiverInfoProvider { - pub fn bind( - conn: &mut Connection, - globals: &Globals, - config: &WmConfig, - ) -> Option { - let status_manager: ZriverStatusManagerV1 = globals.bind(conn, 1..=4).ok()?; - let wl_seat: WlSeat = globals.bind(conn, ..=5).ok()?; // river supports just one seat - let seat_status = - status_manager.get_river_seat_status_with_cb(conn, wl_seat, seat_status_cb); + pub fn bind(conn: &mut Connection, config: &WmConfig) -> Option { + let control = conn.bind_singleton(1).ok()?; + let status_manager: ZriverStatusManagerV1 = conn.bind_singleton(..=4).ok()?; + let wl_seat = conn.bind_singleton(..=5).ok()?; // river supports just one seat + status_manager.get_river_seat_status_with_cb(conn, wl_seat, seat_status_cb); if wl_seat.version() >= 5 { wl_seat.release(conn); } Some(Self { status_manager, - control: globals.bind(conn, 1).ok()?, + control, output_statuses: Vec::new(), max_tag: config.river.max_tag, - seat_status: SeatStatus { - _status: seat_status, - mode: None, - }, + mode: None, }) } @@ -112,7 +99,7 @@ impl WmInfoProvider for RiverInfoProvider { } fn get_mode_name(&self, _output: &Output) -> Option { - self.seat_status.mode.clone() + self.mode.clone() } fn click_on_tag( @@ -204,7 +191,7 @@ fn seat_status_cb(ctx: EventCtx) { if let zriver_seat_status_v1::Event::Mode(mode) = ctx.event { let river = ctx.state.shared_state.get_river().unwrap(); let mode = mode.to_string_lossy().into_owned(); - river.seat_status.mode = (mode != "normal").then_some(mode); + river.mode = (mode != "normal").then_some(mode); ctx.state.mode_name_updated(ctx.conn, None); } } -- cgit v1.3.1