From 0ab2b3134e34ad1c701274ee622d2b837149d8dd Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Thu, 11 Jun 2020 01:19:59 +0200 Subject: [PATCH] code: simplify view rendering --- river/View.zig | 2 +- river/render.zig | 27 +++++++-------------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/river/View.zig b/river/View.zig index 9fdae5a..171d829 100644 --- a/river/View.zig +++ b/river/View.zig @@ -56,7 +56,7 @@ wlr_surface: ?*c.wlr_surface, /// If the view is floating or not floating: bool, -/// True if the view is currentlt focused by at lease one seat +/// True if the view is currently focused by at least one seat focused: bool, /// The current output-relative coordinates and dimensions of the view diff --git a/river/render.zig b/river/render.zig index aca8b85..19ad32d 100644 --- a/river/render.zig +++ b/river/render.zig @@ -39,7 +39,6 @@ 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); @@ -68,17 +67,10 @@ pub fn renderOutput(output: *Output) void { // 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; - } + if (view.current_box.width == 0 or view.current_box.height == 0) continue; // 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; - } + if (view.focused) continue; renderView(output.*, view, &now); renderBorders(output.*, view, &now); @@ -88,19 +80,14 @@ pub fn renderOutput(output: *Output) void { 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; - } + if (view.current_box.width == 0 or view.current_box.height == 0) continue; + + // Skip unfocused views since we already rendered them + if (!view.focused) continue; - // 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); renderBorders(output.*, view, &now); }