From ef4efbcadff30ce3bfd7ea28b61a136dba5a1393 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 1 Aug 2020 19:56:34 +0200 Subject: [PATCH] view: fix xdg_toplevel fullscreen request handling --- river/View.zig | 24 ++++++++++++++++++++++-- river/XdgToplevel.zig | 1 - river/command/toggle_fullscreen.zig | 20 -------------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/river/View.zig b/river/View.zig index 2dd3cd3..e6f2d2a 100644 --- a/river/View.zig +++ b/river/View.zig @@ -215,10 +215,30 @@ pub fn setFocused(self: *Self, focused: bool) void { } } -/// Set the pending state to fullscren and inform the client. Should be -/// followed by starting a transaction to apply the pending state. +/// Set the pending state, set the size, and inform the client. pub fn setFullscreen(self: *Self, fullscreen: bool) void { self.pending.fullscreen = fullscreen; + + if (fullscreen) { + // If transitioning from float -> fullscreen, save the floating + // dimensions. + if (self.pending.float) self.float_box = self.current.box; + + const output = self.output; + self.pending.box = Box.fromWlrBox( + c.wlr_output_layout_get_box(output.root.wlr_output_layout, output.wlr_output).*, + ); + self.configure(); + } else if (self.pending.float) { + // If transitioning from fullscreen -> float, return to the saved + // floating dimensions. + self.pending.box = self.float_box; + self.configure(); + } else { + // Transitioning to layout, arrange and start a transaction + self.output.root.arrange(); + } + switch (self.impl) { .xdg_toplevel => |xdg_toplevel| xdg_toplevel.setFullscreen(fullscreen), .xwayland_view => |xwayland_view| xwayland_view.setFullscreen(fullscreen), diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig index bf01edc..12c5034 100644 --- a/river/XdgToplevel.zig +++ b/river/XdgToplevel.zig @@ -287,5 +287,4 @@ fn handleRequestFullscreen(listener: ?*c.wl_listener, data: ?*c_void) callconv(. const self = @fieldParentPtr(Self, "listen_request_fullscreen", listener.?); const event = util.voidCast(c.wlr_xdg_toplevel_set_fullscreen_event, data.?); self.view.setFullscreen(event.fullscreen); - self.view.output.root.arrange(); } diff --git a/river/command/toggle_fullscreen.zig b/river/command/toggle_fullscreen.zig index 92f99f3..c778876 100644 --- a/river/command/toggle_fullscreen.zig +++ b/river/command/toggle_fullscreen.zig @@ -39,25 +39,5 @@ pub fn toggleFullscreen( if (seat.input_manager.isCursorActionTarget(view)) return; view.setFullscreen(!view.pending.fullscreen); - - if (view.pending.fullscreen) { - // If transitioning from float -> fullscreen, save the floating - // dimensions. - if (view.pending.float) view.float_box = view.current.box; - - const output = view.output; - view.pending.box = Box.fromWlrBox( - c.wlr_output_layout_get_box(output.root.wlr_output_layout, output.wlr_output).*, - ); - view.configure(); - } else if (view.pending.float) { - // If transitioning from fullscreen -> float, return to the saved - // floating dimensions. - view.pending.box = view.float_box; - view.configure(); - } else { - // Transitioning to layout, arrange and start a transaction - view.output.root.arrange(); - } } }