Add tags field to focused_view event

This commit is contained in:
Alexander Rosenberg 2024-05-03 03:02:41 -07:00
parent e29d66f1de
commit 16d76ae86c
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
5 changed files with 18 additions and 11 deletions

View File

@ -100,7 +100,7 @@
</event>
</interface>
<interface name="zriver_seat_status_v1" version="3">
<interface name="zriver_seat_status_v1" version="4">
<description summary="track seat focus">
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 @@
<arg name="output" type="object" interface="wl_output"/>
</event>
<event name="focused_view">
<event name="focused_view" since="4">
<description summary="information on the focused view">
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.
</description>
<arg name="title" type="string" summary="title of the focused view"/>
<arg name="tags" type="uint" summary="32-bit bitfield"/>
</event>
<event name="mode" since="3">

View File

@ -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 {

View File

@ -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) {

View File

@ -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

View File

@ -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 {