view: save and restore floating dimensions

When a floating view is fullscreened and returned to floating, it should
remember its previous floating size/position.
This commit is contained in:
Isaac Freund
2020-06-29 11:15:55 +02:00
parent 5474b656ee
commit c78d31acf4
5 changed files with 25 additions and 23 deletions

View File

@ -142,8 +142,14 @@ fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
view.wlr_surface = self.wlr_xwayland_surface.surface;
view.natural_width = self.wlr_xwayland_surface.width;
view.natural_height = self.wlr_xwayland_surface.height;
// Use the view's "natural" size centered on the output as the default
// floating dimensions
view.float_box.width = self.wlr_xwayland_surface.width;
view.float_box.height = self.wlr_xwayland_surface.height;
view.float_box.x = std.math.max(0, @divTrunc(@intCast(i32, view.output.usable_box.width) -
@intCast(i32, view.float_box.width), 2));
view.float_box.y = std.math.max(0, @divTrunc(@intCast(i32, view.output.usable_box.height) -
@intCast(i32, view.float_box.height), 2));
view.map();
}