From 82a444a7c06c16ff7bc423830344851c925db018 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 28 Jun 2020 20:45:17 +0200 Subject: [PATCH] view: use saved geometry for borders if needed This fixes the issues caused by 60f06a1 and greatly simplifies the code. Turns out we were already tracking the dimensions needed. --- river/View.zig | 10 ---------- river/VoidView.zig | 4 ---- river/XdgToplevel.zig | 9 --------- river/XwaylandView.zig | 9 --------- river/render.zig | 5 +++-- 5 files changed, 3 insertions(+), 34 deletions(-) diff --git a/river/View.zig b/river/View.zig index 10622ee..5d9cd52 100644 --- a/river/View.zig +++ b/river/View.zig @@ -262,16 +262,6 @@ pub fn getDefaultFloatBox(self: Self) Box { }; } -/// Return the dimensions of the actual "visible bounds" that the client has -/// committed. This excludes any "invisible" areas of the surface that show -/// useless stuff like CSD shadows. -pub fn getActualBox(self: Self) Box { - return switch (self.impl) { - .xdg_toplevel => |xdg_toplevel| xdg_toplevel.getActualBox(), - .xwayland_view => |xwayland_view| xwayland_view.getActualBox(), - }; -} - /// Called by the impl when the surface is ready to be displayed pub fn map(self: *Self) void { const root = self.output.root; diff --git a/river/VoidView.zig b/river/VoidView.zig index 1ddc8bf..81392ff 100644 --- a/river/VoidView.zig +++ b/river/VoidView.zig @@ -54,7 +54,3 @@ pub fn surfaceAt(self: Self, ox: f64, oy: f64, sx: *f64, sy: *f64) ?*c.wlr_surfa pub fn getTitle(self: Self) [*:0]const u8 { unreachable; } - -pub fn getActualBox(self: Self) Box { - unreachable; -} diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig index 40463d5..7243454 100644 --- a/river/XdgToplevel.zig +++ b/river/XdgToplevel.zig @@ -123,15 +123,6 @@ pub fn getTitle(self: Self) [*:0]const u8 { return wlr_xdg_toplevel.title orelse "NULL"; } -pub fn getActualBox(self: Self) Box { - return .{ - .x = self.wlr_xdg_surface.geometry.x, - .y = self.wlr_xdg_surface.geometry.y, - .width = @intCast(u32, self.wlr_xdg_surface.geometry.width), - .height = @intCast(u32, self.wlr_xdg_surface.geometry.height), - }; -} - /// Called when the xdg surface is destroyed fn handleDestroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { const self = @fieldParentPtr(Self, "listen_destroy", listener.?); diff --git a/river/XwaylandView.zig b/river/XwaylandView.zig index fdc6ddf..1cd0143 100644 --- a/river/XwaylandView.zig +++ b/river/XwaylandView.zig @@ -114,15 +114,6 @@ pub fn getTitle(self: Self) [*:0]const u8 { return self.wlr_xwayland_surface.title; } -pub fn getActualBox(self: Self) Box { - return .{ - .x = self.wlr_xwayland_surface.x, - .y = self.wlr_xwayland_surface.y, - .width = self.wlr_xwayland_surface.width, - .height = self.wlr_xwayland_surface.height, - }; -} - /// Called when the xwayland surface is destroyed fn handleDestroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { const self = @fieldParentPtr(Self, "listen_destroy", listener.?); diff --git a/river/render.zig b/river/render.zig index 433ce9c..98512db 100644 --- a/river/render.zig +++ b/river/render.zig @@ -240,10 +240,11 @@ fn renderTexture( fn renderBorders(output: Output, view: *View, now: *c.timespec) void { const config = &output.root.server.config; - var border: Box = undefined; const color = if (view.focused) &config.border_color_focused else &config.border_color_unfocused; const border_width = config.border_width; - const actual_box = view.getActualBox(); + const actual_box = if (view.saved_buffers.items.len != 0) view.saved_surface_box else view.surface_box; + + var border: Box = undefined; // left and right, covering the corners as well border.y = view.current.box.y - @intCast(i32, border_width);