From 18bec8649919dc844395b502efd4648e6818cd03 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Tue, 22 Apr 2025 17:56:32 +0200 Subject: [PATCH] wayland: implement xdg-toplevel-tag-v1 --- docs/features.md | 1 + release-notes.md | 1 + src/globals.rs | 2 + src/ifs.rs | 1 + src/ifs/xdg_toplevel_tag_manager_v1.rs | 104 +++++++++++++++++++++++++ wire/xdg_toplevel_tag_manager_v1.txt | 13 ++++ 6 files changed, 122 insertions(+) create mode 100644 src/ifs/xdg_toplevel_tag_manager_v1.rs create mode 100644 wire/xdg_toplevel_tag_manager_v1.txt diff --git a/docs/features.md b/docs/features.md index e6d881ee..0d931716 100644 --- a/docs/features.md +++ b/docs/features.md @@ -175,6 +175,7 @@ Jay supports the following wayland protocols: | wp_viewporter | 1 | | | xdg_activation_v1 | 1 | | | xdg_toplevel_drag_manager_v1 | 1 | | +| xdg_toplevel_tag_manager_v1 | 1 | | | xdg_wm_base | 7 | | | xdg_wm_dialog_v1 | 1 | | | zwlr_data_control_manager_v1 | 2 | Yes | diff --git a/release-notes.md b/release-notes.md index 26f0d194..06b5bce8 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,6 +2,7 @@ - Floating windows can now be configured to be shown above fullscreen windows by using the `enable-float-above-fullscreen` action. +- Implement xdg-toplevel-tag-v1. # 1.10.0 (2025-04-22) diff --git a/src/globals.rs b/src/globals.rs index 738e647c..e590ee46 100644 --- a/src/globals.rs +++ b/src/globals.rs @@ -55,6 +55,7 @@ use { wp_viewporter::WpViewporterGlobal, xdg_activation_v1::XdgActivationV1Global, xdg_toplevel_drag_manager_v1::XdgToplevelDragManagerV1Global, + xdg_toplevel_tag_manager_v1::XdgToplevelTagManagerV1Global, xdg_wm_base::XdgWmBaseGlobal, xdg_wm_dialog_v1::XdgWmDialogV1Global, zwlr_layer_shell_v1::ZwlrLayerShellV1Global, @@ -221,6 +222,7 @@ impl Globals { add_singleton!(WlFixesGlobal); add_singleton!(ExtWorkspaceManagerV1Global); add_singleton!(WpColorManagerV1Global); + add_singleton!(XdgToplevelTagManagerV1Global); } pub fn add_backend_singletons(&self, backend: &Rc) { diff --git a/src/ifs.rs b/src/ifs.rs index d33343b9..5a398248 100644 --- a/src/ifs.rs +++ b/src/ifs.rs @@ -75,6 +75,7 @@ pub mod xdg_activation_v1; pub mod xdg_positioner; pub mod xdg_toplevel_drag_manager_v1; pub mod xdg_toplevel_drag_v1; +pub mod xdg_toplevel_tag_manager_v1; pub mod xdg_wm_base; pub mod xdg_wm_dialog_v1; pub mod zwlr_layer_shell_v1; diff --git a/src/ifs/xdg_toplevel_tag_manager_v1.rs b/src/ifs/xdg_toplevel_tag_manager_v1.rs new file mode 100644 index 00000000..69fc3db1 --- /dev/null +++ b/src/ifs/xdg_toplevel_tag_manager_v1.rs @@ -0,0 +1,104 @@ +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + leaks::Tracker, + object::{Object, Version}, + wire::{XdgToplevelTagManagerV1Id, xdg_toplevel_tag_manager_v1::*}, + }, + std::rc::Rc, + thiserror::Error, +}; + +pub struct XdgToplevelTagManagerV1Global { + name: GlobalName, +} + +impl XdgToplevelTagManagerV1Global { + pub fn new(name: GlobalName) -> Self { + Self { name } + } + + fn bind_( + self: Rc, + id: XdgToplevelTagManagerV1Id, + client: &Rc, + version: Version, + ) -> Result<(), XdgTopleveTagManagerV1Error> { + let obj = Rc::new(XdgToplevelTagManagerV1 { + id, + client: client.clone(), + tracker: Default::default(), + version, + }); + track!(client, obj); + client.add_client_obj(&obj)?; + Ok(()) + } +} + +global_base!( + XdgToplevelTagManagerV1Global, + XdgToplevelTagManagerV1, + XdgTopleveTagManagerV1Error +); + +impl Global for XdgToplevelTagManagerV1Global { + fn singleton(&self) -> bool { + true + } + + fn version(&self) -> u32 { + 1 + } +} + +simple_add_global!(XdgToplevelTagManagerV1Global); + +pub struct XdgToplevelTagManagerV1 { + pub id: XdgToplevelTagManagerV1Id, + pub client: Rc, + pub tracker: Tracker, + pub version: Version, +} + +impl XdgToplevelTagManagerV1RequestHandler for XdgToplevelTagManagerV1 { + type Error = XdgTopleveTagManagerV1Error; + + fn destroy(&self, _req: Destroy, _slf: &Rc) -> Result<(), Self::Error> { + self.client.remove_obj(self)?; + Ok(()) + } + + fn set_toplevel_tag( + &self, + _req: SetToplevelTag<'_>, + _slf: &Rc, + ) -> Result<(), Self::Error> { + Ok(()) + } + + fn set_toplevel_description( + &self, + _req: SetToplevelDescription<'_>, + _slf: &Rc, + ) -> Result<(), Self::Error> { + Ok(()) + } +} + +object_base! { + self = XdgToplevelTagManagerV1; + version = self.version; +} + +impl Object for XdgToplevelTagManagerV1 {} + +simple_add_obj!(XdgToplevelTagManagerV1); + +#[derive(Debug, Error)] +pub enum XdgTopleveTagManagerV1Error { + #[error(transparent)] + ClientError(Box), +} +efrom!(XdgTopleveTagManagerV1Error, ClientError); diff --git a/wire/xdg_toplevel_tag_manager_v1.txt b/wire/xdg_toplevel_tag_manager_v1.txt new file mode 100644 index 00000000..633c5db0 --- /dev/null +++ b/wire/xdg_toplevel_tag_manager_v1.txt @@ -0,0 +1,13 @@ +request destroy { + +} + +request set_toplevel_tag { + toplevel: id(xdg_toplevel), + tag: str, +} + +request set_toplevel_description { + toplevel: id(xdg_toplevel), + description: str, +}