git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commitf41aa276fabc5f99f4e9395ee8369469b2904927
parent9aa5063073
authorHugo Machet <[email protected]>
date2023-01-12 16:29
View: fix pointer comparison in notifyTitle()

Curently since the struct is semantically passed by value not reference,
there is no guarantee that the `seat_node.data.focused.view == &self`
comparison will work as intended. Since updating to Zig 0.10.0, it seems
this latent bug has now manifested and the focused view title is no
longer sent to the client when it changes.

Fix this by taking the view argument by constant pointer instead.

 river/View.zig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/river/View.zig b/river/View.zig
index 56740f8..e666265 100644
--- a/river/View.zig
+++ b/river/View.zig
@@ -551,14 +551,14 @@ pub fn unmap(self: *Self) void {
     server.root.startTransaction();
 }
 
-pub fn notifyTitle(self: Self) void {
+pub fn notifyTitle(self: *const Self) void {
     if (self.foreign_toplevel_handle) |handle| {
         if (self.getTitle()) |s| handle.setTitle(s);
     }
     // Send title 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 == &self) {
+        if (seat_node.data.focused == .view and seat_node.data.focused.view == self) {
             var client_it = seat_node.data.status_trackers.first;
             while (client_it) |client_node| : (client_it = client_node.next) {
                 client_node.data.sendFocusedView();