From ff219c7d8d33838bd004b99c3ab246e7be1776db Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Thu, 11 Jun 2020 00:09:42 +0200 Subject: [PATCH] render: floating as normal, focused views on top This means that floating views can be (partially) obscured by normal views if they are low in the stack, and that the "full" layout will work a little nicer as the focused view is always the top rendered. --- river/render.zig | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/river/render.zig b/river/render.zig index fd87e51..aca8b85 100644 --- a/river/render.zig +++ b/river/render.zig @@ -39,6 +39,7 @@ const SurfaceRenderData = struct { pub fn renderOutput(output: *Output) void { const wlr_renderer = output.getRenderer(); + const input_manager = output.root.server.input_manager; var now: c.timespec = undefined; _ = c.clock_gettime(c.CLOCK_MONOTONIC, &now); @@ -64,20 +65,26 @@ pub fn renderOutput(output: *Output) void { var it = ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags); while (it.next()) |node| { const view = &node.view; + // This check prevents a race condition when a frame is requested // between mapping of a view and the first configure being handled. if (view.current_box.width == 0 or view.current_box.height == 0) { continue; } - // Floating views are rendered on top of normal views - if (view.floating) { + + // Focused views are rendered on top of normal views, skip them for now + var seat_it = input_manager.seats.first; + if (while (seat_it) |seat_node| : (seat_it = seat_node.next) { + if (seat_node.data.focused_view == view) break true; + } else false) { continue; } + renderView(output.*, view, &now); renderBorders(output.*, view, &now); } - // Render floating views + // Render focused views it = ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags); while (it.next()) |node| { const view = &node.view; @@ -86,7 +93,12 @@ pub fn renderOutput(output: *Output) void { if (view.current_box.width == 0 or view.current_box.height == 0) { continue; } - if (!view.floating) { + + // Skip unfocused views + var seat_it = input_manager.seats.first; + if (while (seat_it) |seat_node| : (seat_it = seat_node.next) { + if (seat_node.data.focused_view == view) break false; + } else true) { continue; } renderView(output.*, view, &now);