render: sync with Cursor.surfaceAt(), draw all view popups

This was slightly out of sync with Cursor.surfaceAt() which did not
fullscreen or xwayland unmanaged views properly. Also simplify things
and improve correctness by always rendering all xdg popups. A view
losing focus does not always mean that all popups will be destroyed.
This commit is contained in:
Isaac Freund
2021-07-23 13:40:54 +02:00
parent a3c6571326
commit f62eedb048
4 changed files with 67 additions and 51 deletions

View File

@ -242,9 +242,9 @@ pub fn dropSavedBuffers(self: *Self) void {
}
pub fn saveBuffers(self: *Self) void {
std.debug.assert(self.saved_buffers.items.len == 0);
assert(self.saved_buffers.items.len == 0);
self.saved_surface_box = self.surface_box;
self.surface.?.forEachSurface(*std.ArrayList(SavedBuffer), saveBuffersIterator, &self.saved_buffers);
self.forEachSurface(*std.ArrayList(SavedBuffer), saveBuffersIterator, &self.saved_buffers);
}
fn saveBuffersIterator(
@ -322,15 +322,21 @@ pub fn setResizing(self: Self, resizing: bool) void {
}
}
pub inline fn forEachPopupSurface(
/// Iterates over all surfaces, subsurfaces, and popups in the tree
pub inline fn forEachSurface(
self: Self,
comptime T: type,
iterator: fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: T) callconv(.C) void,
user_data: T,
) void {
switch (self.impl) {
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.forEachPopupSurface(T, iterator, user_data),
.xwayland_view => {},
.xdg_toplevel => |xdg_toplevel| {
xdg_toplevel.xdg_surface.forEachSurface(T, iterator, user_data);
},
.xwayland_view => {
assert(build_options.xwayland);
self.surface.?.forEachSurface(T, iterator, user_data);
},
}
}