aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-06-29 01:46:24 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2020-06-29 01:46:24 +0200
commit7b6e05005d2838a185e41d287b46a11c7ffc8753 (patch)
tree4b56260c253197fbac59f2c0cbb27e962f095d90
parenteb1e66b0feaa755bc701ac140f6ac0dba417c1c1 (diff)
downloadriver-7b6e05005d2838a185e41d287b46a11c7ffc8753.tar.gz
river-7b6e05005d2838a185e41d287b46a11c7ffc8753.tar.xz
render: draw fullscreen views properly
- use a solid black background - only draw the overlay layer
-rw-r--r--river/render.zig82
1 files changed, 48 insertions, 34 deletions
diff --git a/river/render.zig b/river/render.zig
index 98512db..975db52 100644
--- a/river/render.zig
+++ b/river/render.zig
@@ -46,59 +46,73 @@ pub fn renderOutput(output: *Output) void {
_ = c.clock_gettime(c.CLOCK_MONOTONIC, &now);
// wlr_output_attach_render makes the OpenGL context current.
- if (!c.wlr_output_attach_render(output.wlr_output, null)) {
- return;
- }
+ if (!c.wlr_output_attach_render(output.wlr_output, null)) return;
+
// The "effective" resolution can change if you rotate your outputs.
var width: c_int = undefined;
var height: c_int = undefined;
c.wlr_output_effective_resolution(output.wlr_output, &width, &height);
+
// Begin the renderer (calls glViewport and some other GL sanity checks)
c.wlr_renderer_begin(wlr_renderer, width, height);
- c.wlr_renderer_clear(wlr_renderer, &config.background_color);
+ // Find the first visible fullscreen view in the stack if there is one
+ var it = ViewStack(View).iterator(output.views.first, output.current_focused_tags);
+ const fullscreen_view = while (it.next()) |node| {
+ if (node.view.current.fullscreen) break &node.view;
+ } else null;
- renderLayer(output.*, output.layers[c.ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &now);
- renderLayer(output.*, output.layers[c.ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &now);
+ // If we have a fullscreen view to render, render it.
+ if (fullscreen_view) |view| {
+ // Always clear with solid black for fullscreen
+ c.wlr_renderer_clear(wlr_renderer, &[_]f32{ 0, 0, 0, 1 });
+ renderView(output.*, view, &now);
+ if (build_options.xwayland) renderXwaylandUnmanaged(output.*, &now);
+ } else {
+ // No fullscreen view, so render normal layers/views
+ c.wlr_renderer_clear(wlr_renderer, &config.background_color);
- // The first view in the list is "on top" so iterate in reverse.
- var it = ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags);
- while (it.next()) |node| {
- const view = &node.view;
+ renderLayer(output.*, output.layers[c.ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &now);
+ renderLayer(output.*, output.layers[c.ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &now);
- // 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;
+ // The first view in the list is "on top" so iterate in reverse.
+ it = ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags);
+ while (it.next()) |node| {
+ const view = &node.view;
- // Focused views are rendered on top of normal views, skip them for now
- if (view.focused) continue;
+ // 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;
- renderView(output.*, view, &now);
- renderBorders(output.*, view, &now);
- }
+ // Focused views are rendered on top of normal views, skip them for now
+ if (view.focused) continue;
- // Render focused views
- it = ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags);
- while (it.next()) |node| {
- const view = &node.view;
+ renderView(output.*, view, &now);
+ renderBorders(output.*, view, &now);
+ }
- // 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;
+ // Render focused views
+ it = ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags);
+ while (it.next()) |node| {
+ const view = &node.view;
- // Skip unfocused views since we already rendered them
- if (!view.focused) continue;
+ // 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;
- renderView(output.*, view, &now);
- renderBorders(output.*, view, &now);
- }
+ // Skip unfocused views since we already rendered them
+ if (!view.focused) continue;
+
+ renderView(output.*, view, &now);
+ renderBorders(output.*, view, &now);
+ }
+
+ if (build_options.xwayland) renderXwaylandUnmanaged(output.*, &now);
- // Render xwayland unmanged views
- if (build_options.xwayland) {
- renderXwaylandUnmanaged(output.*, &now);
+ renderLayer(output.*, output.layers[c.ZWLR_LAYER_SHELL_V1_LAYER_TOP], &now);
}
- renderLayer(output.*, output.layers[c.ZWLR_LAYER_SHELL_V1_LAYER_TOP], &now);
+ // The overlay layer is rendered in both fullscreen and normal cases
renderLayer(output.*, output.layers[c.ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &now);
// Hardware cursors are rendered by the GPU on a separate plane, and can be