view: fix xdg_toplevel fullscreen request handling

This commit is contained in:
Isaac Freund 2020-08-01 19:56:34 +02:00
parent 845fcad9e6
commit ef4efbcadf
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
3 changed files with 22 additions and 23 deletions

View file

@ -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),

View file

@ -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();
}

View file

@ -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();
}
}
}