From cc785da980cff0dc6125e30df74fbd3c6fe53624 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Mon, 21 Jul 2025 23:45:10 +0200 Subject: [PATCH] cli: print content type in tree query --- src/cli/tree.rs | 6 ++++++ src/ifs/jay_compositor.rs | 2 +- src/ifs/jay_tree_query.rs | 28 +++++++++++++++++++++++----- src/tools/tool_client.rs | 2 +- wire/jay_tree_query.txt | 4 ++++ 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/cli/tree.rs b/src/cli/tree.rs index f751a8e5..1ee94d93 100644 --- a/src/cli/tree.rs +++ b/src/cli/tree.rs @@ -133,6 +133,7 @@ struct Node { urgent: bool, fullscreen: bool, output: Option, + content_type: Option, } impl Query<'_> { @@ -267,6 +268,10 @@ impl Query<'_> { last!(d, n); n.placeholder_for = Some(event.id.to_string()); }); + ContentType::handle(tl, id, d.clone(), |d, event| { + last!(d, n); + n.content_type = Some(event.ty.to_string()); + }); if args.recursive { tl.send(SetRecursive { self_id: id, @@ -384,6 +389,7 @@ impl Printer { opt!(title, "title"); opt!(app_id, "app-id"); opt!(tag, "tag"); + opt!(content_type, "content-type"); opt!(x_class, "x-class"); opt!(x_instance, "x-instance"); opt!(x_role, "x-role"); diff --git a/src/ifs/jay_compositor.rs b/src/ifs/jay_compositor.rs index e3b35b0f..927be203 100644 --- a/src/ifs/jay_compositor.rs +++ b/src/ifs/jay_compositor.rs @@ -79,7 +79,7 @@ impl Global for JayCompositorGlobal { } fn version(&self) -> u32 { - 19 + 20 } fn required_caps(&self) -> ClientCaps { diff --git a/src/ifs/jay_tree_query.rs b/src/ifs/jay_tree_query.rs index a6cd940c..1a381b35 100644 --- a/src/ifs/jay_tree_query.rs +++ b/src/ifs/jay_tree_query.rs @@ -2,11 +2,14 @@ use { crate::{ client::{Client, ClientError}, globals::GlobalBase, - ifs::wl_surface::{ - ext_session_lock_surface_v1::ExtSessionLockSurfaceV1, - x_surface::xwindow::Xwindow, - xdg_surface::{xdg_popup::XdgPopup, xdg_toplevel::XdgToplevel}, - zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, + ifs::{ + wl_surface::{ + ext_session_lock_surface_v1::ExtSessionLockSurfaceV1, + x_surface::xwindow::Xwindow, + xdg_surface::{xdg_popup::XdgPopup, xdg_toplevel::XdgToplevel}, + zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, + }, + wp_content_type_v1, }, leaks::Tracker, object::{Object, Version}, @@ -40,6 +43,8 @@ pub const TREE_TY_XDG_POPUP: u32 = 9; pub const TREE_TY_LAYER_SURFACE: u32 = 10; pub const TREE_TY_LOCK_SURFACE: u32 = 11; +const CONTENT_TYPE_SINCE: Version = Version(20); + pub struct JayTreeQuery { pub id: JayTreeQueryId, pub client: Rc, @@ -225,6 +230,19 @@ impl JayTreeQuery { name: &ws.name, }); } + if self.version >= CONTENT_TYPE_SINCE + && let Some(ct) = data.content_type.get() + { + use wp_content_type_v1::ContentType::*; + self.client.event(ContentType { + self_id: self.id, + ty: match ct { + Photo => "photo", + Video => "video", + Game => "game", + }, + }); + } } } diff --git a/src/tools/tool_client.rs b/src/tools/tool_client.rs index 1913a7e3..0014d743 100644 --- a/src/tools/tool_client.rs +++ b/src/tools/tool_client.rs @@ -335,7 +335,7 @@ impl ToolClient { self_id: s.registry, name: s.jay_compositor.0, interface: JayCompositor.name(), - version: s.jay_compositor.1.min(19), + version: s.jay_compositor.1.min(20), id: id.into(), }); self.jay_compositor.set(Some(id)); diff --git a/wire/jay_tree_query.txt b/wire/jay_tree_query.txt index 2919ba46..97082d2b 100644 --- a/wire/jay_tree_query.txt +++ b/wire/jay_tree_query.txt @@ -100,3 +100,7 @@ event workspace { event placeholder_for { id: str, } + +event content_type (since = 20) { + ty: str, +}