From 16d76ae86c87539eb88b5567964a187b98349c62 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 3 May 2024 03:02:41 -0700 Subject: [PATCH] Add tags field to focused_view event --- protocol/river-status-unstable-v1.xml | 5 +++-- river/SeatStatus.zig | 16 +++++++++++----- river/View.zig | 4 ++-- river/XdgToplevel.zig | 2 +- river/XwaylandView.zig | 2 +- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/protocol/river-status-unstable-v1.xml b/protocol/river-status-unstable-v1.xml index e9629dd..8ba02dc 100644 --- a/protocol/river-status-unstable-v1.xml +++ b/protocol/river-status-unstable-v1.xml @@ -100,7 +100,7 @@ - + This interface allows clients to receive information about the current focus of a seat. Note that (un)focused_output events will only be sent @@ -128,13 +128,14 @@ - + Sent once on binding the interface and again whenever the focused view or a property thereof changes. The title may be an empty string if no view is focused or the focused view did not set a title. + diff --git a/river/SeatStatus.zig b/river/SeatStatus.zig index 1941774..ff5fa39 100644 --- a/river/SeatStatus.zig +++ b/river/SeatStatus.zig @@ -17,6 +17,8 @@ const SeatStatus = @This(); const std = @import("std"); +const assert = std.debug.assert; + const wayland = @import("wayland"); const wl = wayland.server.wl; const zriver = wayland.server.zriver; @@ -66,11 +68,15 @@ pub fn sendOutput(seat_status: SeatStatus, output: *Output, state: enum { focuse } pub fn sendFocusedView(seat_status: SeatStatus) void { - const title: [*:0]const u8 = if (seat_status.seat.focused == .view) - seat_status.seat.focused.view.getTitle() orelse "" - else - ""; - seat_status.seat_status_v1.sendFocusedView(title); + if (seat_status.seat_status_v1.getVersion() >= 4) { + switch (seat_status.seat.focused) { + .view => |view| { + assert(view.inflight.tags == view.current.tags); + seat_status.seat_status_v1.sendFocusedView(view.getTitle() orelse "", view.current.tags); + }, + else => seat_status.seat_status_v1.sendFocusedView("", 0), + } + } } pub fn sendMode(seat_status: SeatStatus, mode: [*:0]const u8) void { diff --git a/river/View.zig b/river/View.zig index b0542ad..a5fe755 100644 --- a/river/View.zig +++ b/river/View.zig @@ -717,11 +717,11 @@ pub fn unmap(view: *View) void { server.root.applyPending(); } -pub fn notifyTitle(view: *const View) void { +pub fn notifyState(view: *const View) void { if (view.foreign_toplevel_handle.wlr_handle) |wlr_handle| { if (view.getTitle()) |title| wlr_handle.setTitle(title); } - // Send title to all status listeners attached to a seat which focuses this view + // Send title and tags to all status listeners attached to a seat which focuses this view var seat_it = server.input_manager.seats.first; while (seat_it) |seat_node| : (seat_it = seat_node.next) { if (seat_node.data.focused == .view and seat_node.data.focused.view == view) { diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig index 909845a..459ac12 100644 --- a/river/XdgToplevel.zig +++ b/river/XdgToplevel.zig @@ -454,7 +454,7 @@ fn handleRequestResize(listener: *wl.Listener(*wlr.XdgToplevel.event.Resize), ev /// Called when the client sets / updates its title fn handleSetTitle(listener: *wl.Listener(void)) void { const toplevel = @fieldParentPtr(XdgToplevel, "set_title", listener); - toplevel.view.notifyTitle(); + toplevel.view.notifyState(); } /// Called when the client sets / updates its app_id diff --git a/river/XwaylandView.zig b/river/XwaylandView.zig index 7155868..308f950 100644 --- a/river/XwaylandView.zig +++ b/river/XwaylandView.zig @@ -277,7 +277,7 @@ fn handleSetOverrideRedirect(listener: *wl.Listener(void)) void { fn handleSetTitle(listener: *wl.Listener(void)) void { const xwayland_view = @fieldParentPtr(XwaylandView, "set_title", listener); - xwayland_view.view.notifyTitle(); + xwayland_view.view.notifyState(); } fn handleSetClass(listener: *wl.Listener(void)) void {