view: arrange when exiting fullscreen to layout

This arrange is actually required because the post_fullscreen box might
not hold the correct dimensions if the view was made fullscreen while
a transaction was already in progress.
This commit is contained in:
Isaac Freund 2021-07-25 22:25:31 +02:00
parent 988a4623ab
commit bbfd0c334c
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
3 changed files with 20 additions and 26 deletions

View file

@ -129,11 +129,7 @@ pub fn apply(self: *Self, layout: *Layout) void {
var it = ViewStack(View).iter(output.views.first, .forward, output.pending.tags, Output.arrangeFilter); var it = ViewStack(View).iter(output.views.first, .forward, output.pending.tags, Output.arrangeFilter);
var i: u32 = 0; var i: u32 = 0;
while (it.next()) |view| : (i += 1) { while (it.next()) |view| : (i += 1) {
if (view.pending.fullscreen) {
view.post_fullscreen_box = self.view_boxen[i];
} else {
view.pending.box = self.view_boxen[i]; view.pending.box = self.view_boxen[i];
}
view.applyConstraints(); view.applyConstraints();
} }
assert(i == self.view_boxen.len); assert(i == self.view_boxen.len);

View file

@ -156,7 +156,7 @@ pub fn sendViewTags(self: Self) void {
} }
pub fn arrangeFilter(view: *View, filter_tags: u32) bool { pub fn arrangeFilter(view: *View, filter_tags: u32) bool {
return !view.destroying and !view.pending.float and return !view.destroying and !view.pending.float and !view.pending.fullscreen and
view.pending.tags & filter_tags != 0; view.pending.tags & filter_tags != 0;
} }

View file

@ -115,10 +115,8 @@ saved_buffers: std.ArrayList(SavedBuffer),
/// view returns to floating mode. /// view returns to floating mode.
float_box: Box = undefined, float_box: Box = undefined,
/// While a view is in fullscreen, it is still arranged if a layout is active but /// This state exists purely to allow for more intuitive behavior when
/// the resulting dimensions are stored here instead of being applied to the view's /// exiting fullscreen if there is no active layout.
/// state. This allows us to avoid an arrange when the view returns from fullscreen
/// and for more intuitive behavior if there is no active layout for the output.
post_fullscreen_box: Box = undefined, post_fullscreen_box: Box = undefined,
draw_borders: bool = true, draw_borders: bool = true,
@ -175,40 +173,40 @@ pub fn destroy(self: *Self) void {
pub fn applyPending(self: *Self) void { pub fn applyPending(self: *Self) void {
var arrange_output = false; var arrange_output = false;
if (self.current.tags != self.pending.tags) if (self.current.tags != self.pending.tags) arrange_output = true;
arrange_output = true;
// If switching from float -> layout or layout -> float arrange the output // If switching from float -> layout or layout -> float arrange the output
// to get assigned a new size or fill the hole in the layout left behind // to get assigned a new size or fill the hole in the layout left behind.
if (self.current.float != self.pending.float) if (self.current.float != self.pending.float) {
assert(!self.pending.fullscreen); // float state modifed while in fullscreen
arrange_output = true; arrange_output = true;
}
// If switching from float to non-float, save the dimensions // If switching from float to non-float, save the dimensions.
if (self.current.float and !self.pending.float) if (self.current.float and !self.pending.float) self.float_box = self.current.box;
self.float_box = self.current.box;
// If switching from non-float to float, apply the saved float dimensions // If switching from non-float to float, apply the saved float dimensions.
if (!self.current.float and self.pending.float) if (!self.current.float and self.pending.float) self.pending.box = self.float_box;
self.pending.box = self.float_box;
// If switching to fullscreen set the dimensions to the full area of the output // If switching to fullscreen, set the dimensions to the full area of the output
// and turn the view fully opaque // Since no other views will be visible, we can skip arranging the output.
if (!self.current.fullscreen and self.pending.fullscreen) { if (!self.current.fullscreen and self.pending.fullscreen) {
self.setFullscreen(true); self.setFullscreen(true);
self.post_fullscreen_box = self.current.box; self.post_fullscreen_box = self.current.box;
const dimensions = self.output.getEffectiveResolution();
const layout_box = server.root.output_layout.getBox(self.output.wlr_output).?;
self.pending.box = .{ self.pending.box = .{
.x = 0, .x = 0,
.y = 0, .y = 0,
.width = @intCast(u32, layout_box.width), .width = dimensions.width,
.height = @intCast(u32, layout_box.height), .height = dimensions.height,
}; };
} }
if (self.current.fullscreen and !self.pending.fullscreen) { if (self.current.fullscreen and !self.pending.fullscreen) {
self.setFullscreen(false); self.setFullscreen(false);
self.pending.box = self.post_fullscreen_box; self.pending.box = self.post_fullscreen_box;
// If switching from fullscreen to layout, we need to arrange the output.
if (!self.pending.float) arrange_output = true;
} }
if (arrange_output) self.output.arrangeViews(); if (arrange_output) self.output.arrangeViews();