Send zriver_seat_status_v1.focused_view when title of focused view changes

This commit is contained in:
Leon Henrik Plickat 2020-10-25 14:54:31 +01:00 committed by Isaac Freund
parent 3f1b0dfaa9
commit ac1762567c
2 changed files with 42 additions and 0 deletions

View file

@ -46,6 +46,7 @@ listen_new_popup: c.wl_listener = undefined,
listen_request_fullscreen: c.wl_listener = undefined, listen_request_fullscreen: c.wl_listener = undefined,
listen_request_move: c.wl_listener = undefined, listen_request_move: c.wl_listener = undefined,
listen_request_resize: c.wl_listener = undefined, listen_request_resize: c.wl_listener = undefined,
listen_set_title: c.wl_listener = undefined,
pub fn init(self: *Self, view: *View, wlr_xdg_surface: *c.wlr_xdg_surface) void { pub fn init(self: *Self, view: *View, wlr_xdg_surface: *c.wlr_xdg_surface) void {
self.* = .{ .view = view, .wlr_xdg_surface = wlr_xdg_surface }; self.* = .{ .view = view, .wlr_xdg_surface = wlr_xdg_surface };
@ -177,6 +178,9 @@ fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
self.listen_request_resize.notify = handleRequestResize; self.listen_request_resize.notify = handleRequestResize;
c.wl_signal_add(&wlr_xdg_toplevel.events.request_resize, &self.listen_request_resize); c.wl_signal_add(&wlr_xdg_toplevel.events.request_resize, &self.listen_request_resize);
self.listen_set_title.notify = handleSetTitle;
c.wl_signal_add(&wlr_xdg_toplevel.events.set_title, &self.listen_set_title);
view.wlr_surface = self.wlr_xdg_surface.surface; view.wlr_surface = self.wlr_xdg_surface.surface;
// Use the view's "natural" size centered on the output as the default // Use the view's "natural" size centered on the output as the default
@ -240,6 +244,7 @@ fn handleUnmap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
c.wl_list_remove(&self.listen_request_fullscreen.link); c.wl_list_remove(&self.listen_request_fullscreen.link);
c.wl_list_remove(&self.listen_request_move.link); c.wl_list_remove(&self.listen_request_move.link);
c.wl_list_remove(&self.listen_request_resize.link); c.wl_list_remove(&self.listen_request_resize.link);
c.wl_list_remove(&self.listen_set_title.link);
} }
/// Called when the surface is comitted /// Called when the surface is comitted
@ -311,3 +316,19 @@ fn handleRequestResize(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) v
const seat = util.voidCast(Seat, event.seat.*.seat.*.data.?); const seat = util.voidCast(Seat, event.seat.*.seat.*.data.?);
seat.cursor.enterMode(.resize, self.view); seat.cursor.enterMode(.resize, self.view);
} }
/// Called when the client sets / updates its title
fn handleSetTitle(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const self = @fieldParentPtr(Self, "listen_set_title", listener.?);
// Send title to all status listeners attached to a seat which focuses this view
var seat_it = self.view.output.root.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 == self.view) {
var client_it = seat_node.data.status_trackers.first;
while (client_it) |client_node| : (client_it = client_node.next) {
client_node.data.sendFocusedView();
}
}
}
}

View file

@ -36,6 +36,7 @@ wlr_xwayland_surface: *c.wlr_xwayland_surface,
listen_destroy: c.wl_listener = undefined, listen_destroy: c.wl_listener = undefined,
listen_map: c.wl_listener = undefined, listen_map: c.wl_listener = undefined,
listen_unmap: c.wl_listener = undefined, listen_unmap: c.wl_listener = undefined,
listen_title: c.wl_listener = undefined,
// Listeners that are only active while the view is mapped // Listeners that are only active while the view is mapped
listen_commit: c.wl_listener = undefined, listen_commit: c.wl_listener = undefined,
@ -53,6 +54,9 @@ pub fn init(self: *Self, view: *View, wlr_xwayland_surface: *c.wlr_xwayland_surf
self.listen_unmap.notify = handleUnmap; self.listen_unmap.notify = handleUnmap;
c.wl_signal_add(&self.wlr_xwayland_surface.events.unmap, &self.listen_unmap); c.wl_signal_add(&self.wlr_xwayland_surface.events.unmap, &self.listen_unmap);
self.listen_title.notify = handleTitle;
c.wl_signal_add(&self.wlr_xwayland_surface.events.set_title, &self.listen_title);
} }
pub fn deinit(self: *Self) void { pub fn deinit(self: *Self) void {
@ -61,6 +65,7 @@ pub fn deinit(self: *Self) void {
c.wl_list_remove(&self.listen_destroy.link); c.wl_list_remove(&self.listen_destroy.link);
c.wl_list_remove(&self.listen_map.link); c.wl_list_remove(&self.listen_map.link);
c.wl_list_remove(&self.listen_unmap.link); c.wl_list_remove(&self.listen_unmap.link);
c.wl_list_remove(&self.listen_title.link);
} }
} }
@ -218,3 +223,19 @@ fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
view.notifyConfiguredOrApplyPending(); view.notifyConfiguredOrApplyPending();
} }
} }
/// Called then the window updates its title
fn handleTitle(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const self = @fieldParentPtr(Self, "listen_title", listener.?);
// Send title to all status listeners attached to a seat which focuses this view
var seat_it = self.view.output.root.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 == self.view) {
var client_it = seat_node.data.status_trackers.first;
while (client_it) |client_node| : (client_it = client_node.next) {
client_node.data.sendFocusedView();
}
}
}
}