diff options
| author | MaxVerevkin <maxxverrr@gmail.com> | 2022-11-27 21:06:35 +0200 |
|---|---|---|
| committer | MaxVerevkin <maxxverrr@gmail.com> | 2022-11-27 21:06:35 +0200 |
| commit | d45a4ef408c0f5a2071194d4c3285f0b7cb27dd0 (patch) | |
| tree | 0794e56251e223388463a84d09616ef47a918bb4 /src | |
| parent | a5baa2574ac0f8ff9ca8fbec0ff57145641ded47 (diff) | |
| download | i3bar-mango-d45a4ef408c0f5a2071194d4c3285f0b7cb27dd0.tar.gz | |
update wayland libs & readd set_cursor
Diffstat (limited to 'src')
| -rw-r--r-- | src/bar.rs | 10 | ||||
| -rw-r--r-- | src/main.rs | 5 | ||||
| -rw-r--r-- | src/river_protocols/control.rs | 115 | ||||
| -rw-r--r-- | src/river_protocols/control/dispatch.rs | 70 | ||||
| -rw-r--r-- | src/river_protocols/status.rs | 129 | ||||
| -rw-r--r-- | src/river_protocols/status/dispatch.rs | 92 | ||||
| -rw-r--r-- | src/state.rs | 81 | ||||
| -rw-r--r-- | src/text.rs | 2 |
8 files changed, 208 insertions, 296 deletions
@@ -27,7 +27,7 @@ pub struct Bar { pub layer: LayerSurface, pub blocks_btns: ButtonManager<(Option<String>, Option<String>)>, pub river_output_status: Option<RiverOutputStatus>, - pub river_control: RiverControlState, + pub river_control: Option<RiverControlState>, pub tags_btns: ButtonManager, pub tags_info: TagsInfo, pub tags_computed: Vec<ComputedText>, @@ -58,17 +58,13 @@ impl Bar { _y: f64, ) -> anyhow::Result<()> { if let Some(tag) = self.tags_btns.click(x) { - if self.river_control.is_available() { + if let Some(river_control) = &self.river_control { let cmd = match button { PointerBtn::Left => "set-focused-tags", PointerBtn::Right => "toggle-focused-tags", _ => return Ok(()), }; - self.river_control.run_command( - &ss.qh, - seat, - [cmd.into(), (1u32 << tag).to_string()], - )?; + river_control.run_command(&ss.qh, seat, [cmd.into(), (1u32 << tag).to_string()]); } } else if let Some((name, instance)) = self.blocks_btns.click(x) { if let Some(cmd) = &mut ss.status_cmd { diff --git a/src/main.rs b/src/main.rs index fb52f07..8ae31aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,14 +24,15 @@ use smithay_client_toolkit::reexports::client::Connection; use tokio::io::{unix::AsyncFd, Interest}; use state::State; +use wayland_client::globals::registry_queue_init; #[tokio::main(flavor = "current_thread")] async fn main() -> anyhow::Result<()> { env_logger::init(); let conn = Connection::connect_to_env()?; - let mut event_queue = conn.new_event_queue(); - let mut state = State::new(&conn, &mut event_queue); + let (globals, mut event_queue) = registry_queue_init(&conn).unwrap(); + let mut state = State::new(&mut event_queue, &globals); let async_fd = AsyncFd::with_interest( event_queue.prepare_read()?.connection_fd().as_raw_fd(), diff --git a/src/river_protocols/control.rs b/src/river_protocols/control.rs index 525a9db..7cce23d 100644 --- a/src/river_protocols/control.rs +++ b/src/river_protocols/control.rs @@ -1,67 +1,34 @@ -pub mod protocol { - use smithay_client_toolkit::reexports::client as wayland_client; - use smithay_client_toolkit::reexports::client::protocol::*; - - pub mod __interfaces { - use smithay_client_toolkit::reexports::client::protocol::__interfaces::*; - wayland_scanner::generate_interfaces!("protocols/river-control-unstable-v1.xml"); - } - use self::__interfaces::*; - - wayland_scanner::generate_client_code!("protocols/river-control-unstable-v1.xml"); -} - -mod dispatch; - -use std::sync::Arc; - -use smithay_client_toolkit::globals::GlobalData; +use wayland_client::globals::{BindError, GlobalList}; use wayland_client::{protocol::wl_seat, Connection, Dispatch, QueueHandle}; use protocol::{zriver_command_callback_v1, zriver_control_v1}; -use smithay_client_toolkit::error::GlobalError; -use smithay_client_toolkit::registry::GlobalProxy; - #[derive(Debug, Clone)] pub struct RiverControlState { - control: Arc<GlobalProxy<zriver_control_v1::ZriverControlV1>>, + control: zriver_control_v1::ZriverControlV1, } impl RiverControlState { - pub fn new() -> Self { - Self { - control: Arc::new(GlobalProxy::NotReady), - } - } - - pub fn is_available(&self) -> bool { - self.control.get().is_ok() - } - - pub fn control(&self) -> Result<&zriver_control_v1::ZriverControlV1, GlobalError> { - self.control.get() + pub fn new<D>(globals: &GlobalList, qh: &QueueHandle<D>) -> Result<Self, BindError> + where + D: Dispatch<zriver_control_v1::ZriverControlV1, (), D> + 'static, + { + let control = globals.bind(qh, 1..=1, ())?; + Ok(Self { control }) } - pub fn run_command<D, Args, Arg>( - &self, - qh: &QueueHandle<D>, - seat: &wl_seat::WlSeat, - args: Args, - ) -> Result<(), GlobalError> + pub fn run_command<D, Args, Arg>(&self, qh: &QueueHandle<D>, seat: &wl_seat::WlSeat, args: Args) where - D: Dispatch<zriver_control_v1::ZriverControlV1, GlobalData> - + Dispatch<zriver_command_callback_v1::ZriverCommandCallbackV1, RiverCommandCallbackData> + D: Dispatch<zriver_command_callback_v1::ZriverCommandCallbackV1, RiverCommandCallbackData> + 'static, Args: IntoIterator<Item = Arg>, Arg: Into<String>, { - let control = self.control()?; for arg in args { - control.add_argument(arg.into()); + self.control.add_argument(arg.into()); } - control.run_command(seat, qh, RiverCommandCallbackData {}); - Ok(()) + self.control + .run_command(seat, qh, RiverCommandCallbackData {}); } } @@ -82,10 +49,64 @@ pub struct RiverCommandCallbackData { macro_rules! delegate_river_control { ($ty: ty) => { ::smithay_client_toolkit::reexports::client::delegate_dispatch!($ty: [ - $crate::river_protocols::control::protocol::zriver_control_v1::ZriverControlV1: ::smithay_client_toolkit::globals::GlobalData + $crate::river_protocols::control::protocol::zriver_control_v1::ZriverControlV1: () ] => $crate::river_protocols::control::RiverControlState); ::smithay_client_toolkit::reexports::client::delegate_dispatch!($ty: [ $crate::river_protocols::control::protocol::zriver_command_callback_v1::ZriverCommandCallbackV1: $crate::river_protocols::control::RiverCommandCallbackData ] => $crate::river_protocols::control::RiverControlState); }; } + +impl<D> Dispatch<zriver_control_v1::ZriverControlV1, (), D> for RiverControlState +where + D: Dispatch<zriver_control_v1::ZriverControlV1, ()> + RiverControlHandler + 'static, +{ + fn event( + _: &mut D, + _: &zriver_control_v1::ZriverControlV1, + _: zriver_control_v1::Event, + _: &(), + _: &Connection, + _: &QueueHandle<D>, + ) { + unreachable!("zriver_control_v1 has no events") + } +} + +impl<D> Dispatch<zriver_command_callback_v1::ZriverCommandCallbackV1, RiverCommandCallbackData, D> + for RiverControlState +where + D: Dispatch<zriver_command_callback_v1::ZriverCommandCallbackV1, RiverCommandCallbackData> + + RiverControlHandler + + 'static, +{ + fn event( + data: &mut D, + _callback: &zriver_command_callback_v1::ZriverCommandCallbackV1, + event: zriver_command_callback_v1::Event, + _udata: &RiverCommandCallbackData, + conn: &Connection, + qh: &QueueHandle<D>, + ) { + use zriver_command_callback_v1::Event; + match event { + Event::Success { output } => data.command_success(conn, qh, output), + Event::Failure { failure_message } => data.command_success(conn, qh, failure_message), + } + } +} + +pub mod protocol { + #![allow(non_upper_case_globals)] + + use smithay_client_toolkit::reexports::client as wayland_client; + use smithay_client_toolkit::reexports::client::protocol::*; + + pub mod __interfaces { + use smithay_client_toolkit::reexports::client::protocol::__interfaces::*; + wayland_scanner::generate_interfaces!("protocols/river-control-unstable-v1.xml"); + } + use self::__interfaces::*; + + wayland_scanner::generate_client_code!("protocols/river-control-unstable-v1.xml"); +} diff --git a/src/river_protocols/control/dispatch.rs b/src/river_protocols/control/dispatch.rs deleted file mode 100644 index 14759e7..0000000 --- a/src/river_protocols/control/dispatch.rs +++ /dev/null @@ -1,70 +0,0 @@ -use std::sync::Arc; - -use super::protocol::{zriver_command_callback_v1, zriver_control_v1}; -use wayland_client::{Connection, Dispatch, QueueHandle}; - -use smithay_client_toolkit::{ - error::GlobalError, - globals::{GlobalData, ProvidesBoundGlobal}, - registry::{ProvidesRegistryState, RegistryHandler}, -}; - -use super::{RiverCommandCallbackData, RiverControlHandler, RiverControlState}; - -impl<D> RegistryHandler<D> for RiverControlState -where - D: Dispatch<zriver_control_v1::ZriverControlV1, GlobalData> - + RiverControlHandler - + ProvidesRegistryState - + 'static, -{ - fn ready(data: &mut D, _conn: &Connection, qh: &QueueHandle<D>) { - data.river_control_state().control = - Arc::new(data.registry().bind_one(qh, 1..=1, GlobalData).into()); - } -} - -impl ProvidesBoundGlobal<zriver_control_v1::ZriverControlV1, 1> for RiverControlState { - fn bound_global(&self) -> Result<zriver_control_v1::ZriverControlV1, GlobalError> { - self.control.get().cloned() - } -} - -impl<D> Dispatch<zriver_control_v1::ZriverControlV1, GlobalData, D> for RiverControlState -where - D: Dispatch<zriver_control_v1::ZriverControlV1, GlobalData> + RiverControlHandler + 'static, -{ - fn event( - _: &mut D, - _: &zriver_control_v1::ZriverControlV1, - _: zriver_control_v1::Event, - _: &GlobalData, - _: &Connection, - _: &QueueHandle<D>, - ) { - unreachable!("zriver_control_v1 has no events") - } -} - -impl<D> Dispatch<zriver_command_callback_v1::ZriverCommandCallbackV1, RiverCommandCallbackData, D> - for RiverControlState -where - D: Dispatch<zriver_command_callback_v1::ZriverCommandCallbackV1, RiverCommandCallbackData> - + RiverControlHandler - + 'static, -{ - fn event( - data: &mut D, - _callback: &zriver_command_callback_v1::ZriverCommandCallbackV1, - event: zriver_command_callback_v1::Event, - _udata: &RiverCommandCallbackData, - conn: &Connection, - qh: &QueueHandle<D>, - ) { - use zriver_command_callback_v1::Event; - match event { - Event::Success { output } => data.command_success(conn, qh, output), - Event::Failure { failure_message } => data.command_success(conn, qh, failure_message), - } - } -} diff --git a/src/river_protocols/status.rs b/src/river_protocols/status.rs index 079572a..1779719 100644 --- a/src/river_protocols/status.rs +++ b/src/river_protocols/status.rs @@ -1,46 +1,29 @@ -pub mod protocol { - use smithay_client_toolkit::reexports::client as wayland_client; - use smithay_client_toolkit::reexports::client::protocol::*; - - pub mod __interfaces { - use smithay_client_toolkit::reexports::client::protocol::__interfaces::*; - wayland_scanner::generate_interfaces!("protocols/river-status-unstable-v1.xml"); - } - use self::__interfaces::*; - - wayland_scanner::generate_client_code!("protocols/river-status-unstable-v1.xml"); -} - -mod dispatch; - use std::sync::{Arc, Weak}; -use smithay_client_toolkit::globals::GlobalData; -use wayland_client::{protocol::wl_output, Connection, Dispatch, QueueHandle}; +use wayland_client::{ + globals::{BindError, GlobalList}, + protocol::wl_output, + Connection, Dispatch, QueueHandle, +}; use protocol::{zriver_output_status_v1, zriver_status_manager_v1}; -use smithay_client_toolkit::error::GlobalError; -use smithay_client_toolkit::registry::GlobalProxy; - -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct RiverStatusState { - status_manager: GlobalProxy<zriver_status_manager_v1::ZriverStatusManagerV1>, + status_manager: zriver_status_manager_v1::ZriverStatusManagerV1, output_statuses: Vec<Weak<OutputStatusInner>>, } impl RiverStatusState { - pub fn new() -> Self { - Self { - status_manager: GlobalProxy::NotReady, + pub fn new<D>(globals: &GlobalList, qh: &QueueHandle<D>) -> Result<Self, BindError> + where + D: Dispatch<zriver_status_manager_v1::ZriverStatusManagerV1, (), D> + 'static, + { + let status_manager = globals.bind(qh, 1..=1, ())?; + Ok(Self { + status_manager, output_statuses: Vec::new(), - } - } - - pub fn status_manager( - &self, - ) -> Result<&zriver_status_manager_v1::ZriverStatusManagerV1, GlobalError> { - self.status_manager.get() + }) } pub fn get_output_status( @@ -59,14 +42,15 @@ impl RiverStatusState { &mut self, qh: &QueueHandle<D>, output: &wl_output::WlOutput, - ) -> Result<RiverOutputStatus, GlobalError> + ) -> RiverOutputStatus where - D: Dispatch<zriver_status_manager_v1::ZriverStatusManagerV1, GlobalData> + D: Dispatch<zriver_status_manager_v1::ZriverStatusManagerV1, ()> + Dispatch<zriver_output_status_v1::ZriverOutputStatusV1, RiverStatusData> + 'static, { - let manager = self.status_manager()?; - let output_status = manager.get_river_output_status(output, qh, RiverStatusData {}); + let output_status = + self.status_manager + .get_river_output_status(output, qh, RiverStatusData {}); let output_status = RiverOutputStatus(Arc::new(OutputStatusInner { status: output_status, @@ -74,7 +58,7 @@ impl RiverStatusState { self.output_statuses.push(Arc::downgrade(&output_status.0)); - Ok(output_status) + output_status } } @@ -124,7 +108,7 @@ pub struct RiverStatusData { macro_rules! delegate_river_status { ($ty: ty) => { ::smithay_client_toolkit::reexports::client::delegate_dispatch!($ty: [ - $crate::river_protocols::status::protocol::zriver_status_manager_v1::ZriverStatusManagerV1: ::smithay_client_toolkit::globals::GlobalData + $crate::river_protocols::status::protocol::zriver_status_manager_v1::ZriverStatusManagerV1: () ] => $crate::river_protocols::status::RiverStatusState); ::smithay_client_toolkit::reexports::client::delegate_dispatch!($ty: [ $crate::river_protocols::status::protocol::zriver_output_status_v1::ZriverOutputStatusV1: $crate::river_protocols::status::RiverStatusData @@ -142,3 +126,72 @@ impl Drop for OutputStatusInner { self.status.destroy(); } } + +impl<D> Dispatch<zriver_status_manager_v1::ZriverStatusManagerV1, (), D> for RiverStatusState +where + D: Dispatch<zriver_status_manager_v1::ZriverStatusManagerV1, ()> + RiverStatusHandler + 'static, +{ + fn event( + _: &mut D, + _: &zriver_status_manager_v1::ZriverStatusManagerV1, + _: zriver_status_manager_v1::Event, + _: &(), + _: &Connection, + _: &QueueHandle<D>, + ) { + unreachable!("zriver_status_manager_v1 has no events") + } +} + +impl<D> Dispatch<zriver_output_status_v1::ZriverOutputStatusV1, RiverStatusData, D> + for RiverStatusState +where + D: Dispatch<zriver_output_status_v1::ZriverOutputStatusV1, RiverStatusData> + + RiverStatusHandler + + 'static, +{ + fn event( + data: &mut D, + status: &zriver_output_status_v1::ZriverOutputStatusV1, + event: zriver_output_status_v1::Event, + _udata: &RiverStatusData, + conn: &Connection, + qh: &QueueHandle<D>, + ) { + use zriver_output_status_v1::Event; + + // Remove any statuses that have been dropped + data.river_status_state() + .output_statuses + .retain(|status| status.upgrade().is_some()); + + if let Some(status) = data.river_status_state().get_output_status(status) { + match event { + Event::FocusedTags { tags } => data.focused_tags_updated(conn, qh, &status, tags), + Event::UrgentTags { tags } => data.urgent_tags_updated(conn, qh, &status, tags), + Event::ViewTags { tags } => { + let tags = tags + .chunks_exact(4) + .map(|bytes| u32::from_ne_bytes(bytes.try_into().unwrap())) + .collect(); + data.views_tags_updated(conn, qh, &status, tags); + } + } + } + } +} + +pub mod protocol { + #![allow(non_upper_case_globals)] + + use smithay_client_toolkit::reexports::client as wayland_client; + use smithay_client_toolkit::reexports::client::protocol::*; + + pub mod __interfaces { + use smithay_client_toolkit::reexports::client::protocol::__interfaces::*; + wayland_scanner::generate_interfaces!("protocols/river-status-unstable-v1.xml"); + } + use self::__interfaces::*; + + wayland_scanner::generate_client_code!("protocols/river-status-unstable-v1.xml"); +} diff --git a/src/river_protocols/status/dispatch.rs b/src/river_protocols/status/dispatch.rs deleted file mode 100644 index 65d6e0c..0000000 --- a/src/river_protocols/status/dispatch.rs +++ /dev/null @@ -1,92 +0,0 @@ -use super::protocol::{zriver_output_status_v1, zriver_status_manager_v1}; -use wayland_client::{Connection, Dispatch, QueueHandle}; - -use smithay_client_toolkit::{ - error::GlobalError, - globals::{GlobalData, ProvidesBoundGlobal}, - registry::{ProvidesRegistryState, RegistryHandler}, -}; - -use super::{RiverStatusData, RiverStatusHandler, RiverStatusState}; - -impl<D> RegistryHandler<D> for RiverStatusState -where - D: Dispatch<zriver_status_manager_v1::ZriverStatusManagerV1, GlobalData> - + RiverStatusHandler - + ProvidesRegistryState - + 'static, -{ - fn ready(data: &mut D, _conn: &Connection, qh: &QueueHandle<D>) { - data.river_status_state().status_manager = - data.registry().bind_one(qh, 1..=2, GlobalData).into(); - } -} - -impl ProvidesBoundGlobal<zriver_status_manager_v1::ZriverStatusManagerV1, 1> for RiverStatusState { - fn bound_global(&self) -> Result<zriver_status_manager_v1::ZriverStatusManagerV1, GlobalError> { - self.status_manager.get().cloned() - } -} - -impl ProvidesBoundGlobal<zriver_status_manager_v1::ZriverStatusManagerV1, 2> for RiverStatusState { - fn bound_global(&self) -> Result<zriver_status_manager_v1::ZriverStatusManagerV1, GlobalError> { - self.status_manager.get().cloned() - } -} - -impl<D> Dispatch<zriver_status_manager_v1::ZriverStatusManagerV1, GlobalData, D> - for RiverStatusState -where - D: Dispatch<zriver_status_manager_v1::ZriverStatusManagerV1, GlobalData> - + RiverStatusHandler - + 'static, -{ - fn event( - _: &mut D, - _: &zriver_status_manager_v1::ZriverStatusManagerV1, - _: zriver_status_manager_v1::Event, - _: &GlobalData, - _: &Connection, - _: &QueueHandle<D>, - ) { - unreachable!("zriver_status_manager_v1 has no events") - } -} - -impl<D> Dispatch<zriver_output_status_v1::ZriverOutputStatusV1, RiverStatusData, D> - for RiverStatusState -where - D: Dispatch<zriver_output_status_v1::ZriverOutputStatusV1, RiverStatusData> - + RiverStatusHandler - + 'static, -{ - fn event( - data: &mut D, - status: &zriver_output_status_v1::ZriverOutputStatusV1, - event: zriver_output_status_v1::Event, - _udata: &RiverStatusData, - conn: &Connection, - qh: &QueueHandle<D>, - ) { - use zriver_output_status_v1::Event; - - // Remove any statuses that have been dropped - data.river_status_state() - .output_statuses - .retain(|status| status.upgrade().is_some()); - - if let Some(status) = data.river_status_state().get_output_status(status) { - match event { - Event::FocusedTags { tags } => data.focused_tags_updated(conn, qh, &status, tags), - Event::UrgentTags { tags } => data.urgent_tags_updated(conn, qh, &status, tags), - Event::ViewTags { tags } => { - let tags = tags - .chunks_exact(4) - .map(|bytes| u32::from_ne_bytes(bytes.try_into().unwrap())) - .collect(); - data.views_tags_updated(conn, qh, &status, tags); - } - } - } - } -} diff --git a/src/state.rs b/src/state.rs index 3d5b2d4..ed6c3d1 100644 --- a/src/state.rs +++ b/src/state.rs @@ -12,13 +12,16 @@ use smithay_client_toolkit::{ registry::{ProvidesRegistryState, RegistryState}, registry_handlers, seat::{ - pointer::{PointerEvent, PointerEventKind, PointerHandler}, + pointer::{PointerEvent, PointerEventKind, PointerHandler, ThemeSpec, ThemedPointer}, Capability, SeatHandler, SeatState, }, - shell::layer::{Anchor, Layer, LayerHandler, LayerState, LayerSurface, LayerSurfaceConfigure}, + shell::layer::{ + Anchor, Layer, LayerShell, LayerShellHandler, LayerSurface, LayerSurfaceConfigure, + }, shm::{ShmHandler, ShmState}, }; use tokio::io::unix::AsyncFdReadyGuard; +use wayland_client::globals::GlobalList; use crate::{ bar::Bar, @@ -40,9 +43,9 @@ pub struct State { seat_state: SeatState, output_state: OutputState, compositor_state: CompositorState, - layer_state: LayerState, - river_status_state: RiverStatusState, - river_control_state: RiverControlState, + layer_state: LayerShell, + river_status_state: Option<RiverStatusState>, + river_control_state: Option<RiverControlState>, seats: Vec<Seat>, bars: Vec<Bar>, @@ -52,13 +55,17 @@ pub struct State { struct Seat { seat: wl_seat::WlSeat, pointer: wl_pointer::WlPointer, + themed_pointer: ThemedPointer, + pointer_surface: wl_surface::WlSurface, finger_scroll: f64, } impl State { - pub fn new(conn: &Connection, event_queue: &mut EventQueue<Self>) -> Self { + pub fn new(event_queue: &mut EventQueue<Self>, globals: &GlobalList) -> Self { let mut error = Ok(()); + let qh = event_queue.handle(); + let config = Config::new() .map_err(|e| error = Err(e)) .unwrap_or_default(); @@ -73,19 +80,19 @@ impl State { }; let mut this = Self { - registry_state: RegistryState::new(conn, &event_queue.handle()), - seat_state: SeatState::new(), - output_state: OutputState::new(), - compositor_state: CompositorState::new(), - layer_state: LayerState::new(), - river_status_state: RiverStatusState::new(), - river_control_state: RiverControlState::new(), + registry_state: RegistryState::new(globals), + seat_state: SeatState::new(globals, &qh), + output_state: OutputState::new(globals, &qh), + compositor_state: CompositorState::bind(globals, &qh).unwrap(), + layer_state: LayerShell::bind(globals, &qh).unwrap(), + river_status_state: RiverStatusState::new(globals, &qh).ok(), + river_control_state: RiverControlState::new(globals, &qh).ok(), seats: Vec::new(), bars: Vec::new(), shared_state: SharedState { qh: event_queue.handle(), - shm_state: ShmState::new(), + shm_state: ShmState::bind(globals, &qh).unwrap(), pool: None, config, status_cmd, @@ -140,10 +147,6 @@ impl State { } impl CompositorHandler for State { - fn compositor_state(&mut self) -> &mut CompositorState { - &mut self.compositor_state - } - fn scale_factor_changed( &mut self, _conn: &Connection, @@ -191,7 +194,10 @@ impl OutputHandler for State { .namespace("i3bar-river") .map(qh, &self.layer_state, surface, Layer::Top) .expect("layer surface creation"); - let river_output_status = self.river_status_state.new_output_status(qh, &output).ok(); + let river_output_status = self + .river_status_state + .as_mut() + .map(|s| s.new_output_status(qh, &output)); self.bars.push(Bar { configured: false, width: 0, @@ -224,11 +230,7 @@ impl OutputHandler for State { } } -impl LayerHandler for State { - fn layer_state(&mut self) -> &mut LayerState { - &mut self.layer_state - } - +impl LayerShellHandler for State { fn closed(&mut self, _conn: &Connection, _qh: &QueueHandle<Self>, layer: &LayerSurface) { self.bars.retain(|b| &b.layer != layer) } @@ -264,13 +266,15 @@ impl SeatHandler for State { capability: Capability, ) { if capability == Capability::Pointer { - let pointer = self + let (pointer, themed_pointer) = self .seat_state - .get_pointer(qh, &seat) + .get_pointer_with_theme(qh, &seat, ThemeSpec::System, 1) .expect("Failed to create pointer"); self.seats.push(Seat { seat, pointer, + themed_pointer, + pointer_surface: self.compositor_state.create_surface(qh).unwrap(), // TODO: make a PR to remove this unwrap finger_scroll: 0.0, }); } @@ -294,7 +298,7 @@ impl SeatHandler for State { impl PointerHandler for State { fn pointer_frame( &mut self, - _conn: &Connection, + conn: &Connection, _qh: &QueueHandle<Self>, pointer: &wl_pointer::WlPointer, events: &[PointerEvent], @@ -312,7 +316,14 @@ impl PointerHandler for State { { match event.kind { PointerEventKind::Enter { .. } => { - // TODO: set_cursor() + seat.themed_pointer + .set_cursor( + conn, + "default", + self.shared_state.shm_state.wl_shm(), + &seat.pointer_surface, + ) + .unwrap(); } PointerEventKind::Press { button, .. } => { bar.click( @@ -376,7 +387,7 @@ impl ShmHandler for State { impl RiverStatusHandler for State { fn river_status_state(&mut self) -> &mut RiverStatusState { - &mut self.river_status_state + self.river_status_state.as_mut().unwrap() } fn focused_tags_updated( @@ -430,7 +441,7 @@ impl RiverStatusHandler for State { impl RiverControlHandler for State { fn river_control_state(&mut self) -> &mut RiverControlState { - &mut self.river_control_state + self.river_control_state.as_mut().unwrap() } fn command_failure(&mut self, _: &Connection, _: &QueueHandle<Self>, message: String) { @@ -456,15 +467,7 @@ impl ProvidesRegistryState for State { fn registry(&mut self) -> &mut RegistryState { &mut self.registry_state } - registry_handlers![ - CompositorState, - OutputState, - ShmState, - SeatState, - LayerState, - RiverStatusState, - RiverControlState, - ]; + registry_handlers![OutputState,]; } #[derive(Debug)] diff --git a/src/text.rs b/src/text.rs index 7a3b7fc..9b27a11 100644 --- a/src/text.rs +++ b/src/text.rs @@ -49,7 +49,7 @@ pub struct ComputedText { impl ComputedText { pub fn new(text: &str, mut attr: Attributes, context: &cairo::Context) -> Self { - let layout = pangocairo::create_layout(context).unwrap(); + let layout = pangocairo::create_layout(context); layout.set_font_description(Some(attr.font)); if attr.markup { layout.set_markup(text); |
