summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock130
-rw-r--r--Cargo.toml8
-rw-r--r--src/bar.rs10
-rw-r--r--src/main.rs5
-rw-r--r--src/river_protocols/control.rs115
-rw-r--r--src/river_protocols/control/dispatch.rs70
-rw-r--r--src/river_protocols/status.rs129
-rw-r--r--src/river_protocols/status/dispatch.rs92
-rw-r--r--src/state.rs81
-rw-r--r--src/text.rs2
10 files changed, 305 insertions, 337 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c0dcd48..15e4189 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -42,22 +42,23 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cairo-rs"
-version = "0.15.12"
+version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc"
+checksum = "08f9ee4a4ca9239c9a839453dce04b7ddee2f859ec4cd7acd1f5703b68db549c"
dependencies = [
"bitflags",
"cairo-sys-rs",
"glib",
"libc",
+ "once_cell",
"thiserror",
]
[[package]]
name = "cairo-sys-rs"
-version = "0.15.1"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8"
+checksum = "5119ea655ec777b523f0b57279e70f8a4542f61b0e98a48f892b4ef043fd4c5d"
dependencies = [
"glib-sys",
"libc",
@@ -161,6 +162,23 @@ dependencies = [
]
[[package]]
+name = "futures-io"
+version = "0.3.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb"
+
+[[package]]
+name = "futures-macro"
+version = "0.3.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "futures-task"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -173,6 +191,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90"
dependencies = [
"futures-core",
+ "futures-macro",
"futures-task",
"pin-project-lite",
"pin-utils",
@@ -191,16 +210,51 @@ dependencies = [
]
[[package]]
+name = "gio"
+version = "0.16.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33c1debf8d0315d69be0153aa76249db3c858ef69b7778ad3cc669e6d370c485"
+dependencies = [
+ "bitflags",
+ "futures-channel",
+ "futures-core",
+ "futures-io",
+ "futures-util",
+ "gio-sys",
+ "glib",
+ "libc",
+ "once_cell",
+ "pin-project-lite",
+ "smallvec",
+ "thiserror",
+]
+
+[[package]]
+name = "gio-sys"
+version = "0.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6da1bba9d3f2ab13a6e9932c40f240dc99ebc9f0bdc35cfb130d1a3df36f374c"
+dependencies = [
+ "glib-sys",
+ "gobject-sys",
+ "libc",
+ "system-deps",
+ "winapi",
+]
+
+[[package]]
name = "glib"
-version = "0.15.12"
+version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d"
+checksum = "d5abffa711471e015eb93d65d6ea20e7e9f6f7951fc0a1042280439319b2de06"
dependencies = [
"bitflags",
"futures-channel",
"futures-core",
"futures-executor",
"futures-task",
+ "futures-util",
+ "gio-sys",
"glib-macros",
"glib-sys",
"gobject-sys",
@@ -212,9 +266,9 @@ dependencies = [
[[package]]
name = "glib-macros"
-version = "0.15.11"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25a68131a662b04931e71891fb14aaf65ee4b44d08e8abc10f49e77418c86c64"
+checksum = "e195c1311fa6b04d7b896ea39385f6bd60ef5d25bf74a7c11c8c3f94f6c1a572"
dependencies = [
"anyhow",
"heck",
@@ -227,9 +281,9 @@ dependencies = [
[[package]]
name = "glib-sys"
-version = "0.15.10"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4"
+checksum = "b33357bb421a77bd849f6a0bfcaf3b4b256a2577802971bb5dd522d530f27021"
dependencies = [
"libc",
"system-deps",
@@ -237,9 +291,9 @@ dependencies = [
[[package]]
name = "gobject-sys"
-version = "0.15.10"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a"
+checksum = "63ca11a57400f3d4fda594e002844be47900c9fb8b29e2155c6e37a1f24e51b3"
dependencies = [
"glib-sys",
"libc",
@@ -378,10 +432,11 @@ dependencies = [
[[package]]
name = "nix"
-version = "0.24.2"
+version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc"
+checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb"
dependencies = [
+ "autocfg",
"bitflags",
"cfg-if",
"libc",
@@ -406,11 +461,12 @@ checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
[[package]]
name = "pango"
-version = "0.15.10"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f"
+checksum = "7208c60f224cf6e44c551df5ee2ef38f9da0fd29d7c5a0402000b8ab0520e798"
dependencies = [
"bitflags",
+ "gio",
"glib",
"libc",
"once_cell",
@@ -419,9 +475,9 @@ dependencies = [
[[package]]
name = "pango-sys"
-version = "0.15.10"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa"
+checksum = "922441c228366ed98d3534b87bc7c987c50564094c3abbc3513717786419252d"
dependencies = [
"glib-sys",
"gobject-sys",
@@ -431,9 +487,9 @@ dependencies = [
[[package]]
name = "pangocairo"
-version = "0.15.1"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7876a45c1f1d1a75a2601dc6d9ef2cb5a8be0e3d76f909d82450759929035366"
+checksum = "a726760a29e5e17d965d5d7573548e385ae9ce99cb7adcf70d75d4627f23fc7a"
dependencies = [
"bitflags",
"cairo-rs",
@@ -445,9 +501,9 @@ dependencies = [
[[package]]
name = "pangocairo-sys"
-version = "0.15.1"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "78cf746594916c81d5f739af9335c5f55a1f4606d80b3e1d821f18cf95a29494"
+checksum = "b8281198ea4596bdc6e22b0d3565471c9456d7125e423a785f866640c18b57ec"
dependencies = [
"cairo-sys-rs",
"glib-sys",
@@ -634,7 +690,7 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
[[package]]
name = "smithay-client-toolkit"
version = "0.16.0"
-source = "git+https://github.com/Smithay/client-toolkit#1cc11af8538040f46173bf021ac079c342ddeebb"
+source = "git+https://github.com/Smithay/client-toolkit#e5d7c9084f8d80bef4c625c6ef52ec42dde4e211"
dependencies = [
"bitflags",
"dlib",
@@ -777,9 +833,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wayland-backend"
-version = "0.1.0-beta.10"
+version = "0.1.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "30c089c872513a8dcc2b5cc26209d83f5ffab1841d8c7973edf2583620ebc018"
+checksum = "f3f96c52ca34b33e6bb55497327428be54dad648973aa5d3d1e02982d2fcc298"
dependencies = [
"cc",
"downcast-rs",
@@ -792,9 +848,9 @@ dependencies = [
[[package]]
name = "wayland-client"
-version = "0.30.0-beta.10"
+version = "0.30.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd71253f97d86ac930fb296ba995e31c178f1be6a7026244c3b3f3811d5086be"
+checksum = "0f6ab5911cc8a28e9d781933c1afe0f97ffa6885ad8941294784d025f06e5ad9"
dependencies = [
"bitflags",
"futures-channel",
@@ -807,9 +863,9 @@ dependencies = [
[[package]]
name = "wayland-cursor"
-version = "0.30.0-beta.10"
+version = "0.30.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e39f4325f2ea5c1548cda2a6edabb74c68b072c9d6db7d7363cd9fe4994b124b"
+checksum = "fa5ce1bbc13a3d806648974cba1d53481fea2ac29483eb147e4cce1250fc5263"
dependencies = [
"nix",
"wayland-client",
@@ -818,9 +874,9 @@ dependencies = [
[[package]]
name = "wayland-protocols"
-version = "0.30.0-beta.10"
+version = "0.30.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "60406a2fb43ff670ece4976cdd0537bbcd1e583b54c3cd9a1b61065e966df0a7"
+checksum = "e32104ba51988754f4429dbb59c7b7fd2ccf1feaa0009bb59e49a5e2f91e985d"
dependencies = [
"bitflags",
"wayland-backend",
@@ -830,9 +886,9 @@ dependencies = [
[[package]]
name = "wayland-protocols-wlr"
-version = "0.1.0-beta.10"
+version = "0.1.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1cfe42e0cfcce47a421844ee82e49316cfab3ec6bcbb3a1076a0a2dd6c8d61e"
+checksum = "130613a48629204e4ab50ea4b5de2efa2e17c58f71a5af15b39535f99421f8c3"
dependencies = [
"bitflags",
"wayland-backend",
@@ -843,9 +899,9 @@ dependencies = [
[[package]]
name = "wayland-scanner"
-version = "0.30.0-beta.10"
+version = "0.30.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1398566f240c3ef845bdfd310c8ee6ba800d4db695d007f23f2190eeedfff93"
+checksum = "1fb55ca28710dcc155078db4e2bd29aacf24bd311261c48750f38c6c5430bf1f"
dependencies = [
"proc-macro2",
"quick-xml",
@@ -855,9 +911,9 @@ dependencies = [
[[package]]
name = "wayland-sys"
-version = "0.30.0-beta.10"
+version = "0.30.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bacc6b678c3350910e5ad6c057b7503666080952c4ece0a7e8958fd33937b1f5"
+checksum = "882bda56e8397384ad66ec0ebe763e0b3b53153a6327344f7d74b85981a271e1"
dependencies = [
"dlib",
"log",
diff --git a/Cargo.toml b/Cargo.toml
index 90ea6c7..40a46bc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,13 +9,13 @@ env_logger = "0.9"
anyhow = "1"
dirs-next = "2"
toml = "0.5"
-pangocairo = "0.15"
+pangocairo = "0.16"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
memchr = "2"
-wayland-client = "0.30.0-beta.10"
-wayland-scanner = "0.30.0-beta.10"
-wayland-backend = "0.1.0-beta.10"
+wayland-client = "0.30.0-beta.13"
+wayland-scanner = "0.30.0-beta.13"
+wayland-backend = "0.1.0-beta.13"
[dependencies.smithay-client-toolkit]
git = "https://github.com/Smithay/client-toolkit"
diff --git a/src/bar.rs b/src/bar.rs
index 0569b71..dfa63a3 100644
--- a/src/bar.rs
+++ b/src/bar.rs
@@ -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);