Root: keep all fullscreen views the correct size

Currently we may resize fullscreen views when they become visible/not
visible when switching tags even if their fullscreen state remains
constant. This is suboptimal, and as it turns out also much more complex
to implement.
This commit is contained in:
Isaac Freund 2023-03-03 13:40:44 +01:00
parent 9ce1847d32
commit 0be43ad45f
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
3 changed files with 16 additions and 41 deletions

View File

@ -121,9 +121,6 @@ pending: struct {
/// ///
/// This includes both floating/fullscreen views and those arranged in the layout. /// This includes both floating/fullscreen views and those arranged in the layout.
wm_stack: wl.list.Head(View, .pending_wm_stack_link), wm_stack: wl.list.Head(View, .pending_wm_stack_link),
/// The view to be made fullscreen, if any.
/// This state should only be read/written inside Root.applyPending()
fullscreen: ?*View = null,
}, },
/// The state most recently sent to the layout generator and clients. /// The state most recently sent to the layout generator and clients.

View File

@ -391,7 +391,7 @@ pub fn applyPending(root: *Self) void {
// Iterate the focus stack in order to ensure the currently focused/most // Iterate the focus stack in order to ensure the currently focused/most
// recently focused view that requests fullscreen is given fullscreen. // recently focused view that requests fullscreen is given fullscreen.
output.pending.fullscreen = null; output.inflight.fullscreen = null;
{ {
var it = output.pending.focus_stack.iterator(.forward); var it = output.pending.focus_stack.iterator(.forward);
while (it.next()) |view| { while (it.next()) |view| {
@ -406,10 +406,19 @@ pub fn applyPending(root: *Self) void {
view.pending.clampToOutput(); view.pending.clampToOutput();
} }
if (output.pending.fullscreen == null and view.pending.fullscreen and if (!view.current.fullscreen and view.pending.fullscreen) {
view.post_fullscreen_box = view.pending.box;
view.pending.box = .{ .x = 0, .y = 0, .width = undefined, .height = undefined };
output.wlr_output.effectiveResolution(&view.pending.box.width, &view.pending.box.height);
} else if (view.current.fullscreen and !view.pending.fullscreen) {
view.pending.box = view.post_fullscreen_box;
view.pending.clampToOutput();
}
if (output.inflight.fullscreen == null and view.pending.fullscreen and
view.pending.tags & output.pending.tags != 0) view.pending.tags & output.pending.tags != 0)
{ {
output.pending.fullscreen = view; output.inflight.fullscreen = view;
} }
view.inflight_focus_stack_link.remove(); view.inflight_focus_stack_link.remove();
@ -418,14 +427,6 @@ pub fn applyPending(root: *Self) void {
view.inflight = view.pending; view.inflight = view.pending;
} }
} }
if (output.pending.fullscreen != output.inflight.fullscreen) {
if (output.inflight.fullscreen) |view| {
view.pending.box = view.post_fullscreen_box;
view.pending.clampToOutput();
view.inflight.box = view.pending.box;
}
}
{ {
var it = output.pending.wm_stack.iterator(.forward); var it = output.pending.wm_stack.iterator(.forward);
@ -439,32 +440,6 @@ pub fn applyPending(root: *Self) void {
} }
} }
{
// This must be done after the original loop completes to handle the
// case where a fullscreen is moved between outputs.
var output_it = root.outputs.first;
while (output_it) |node| : (output_it = node.next) {
const output = &node.data;
if (output.pending.fullscreen != output.inflight.fullscreen) {
if (output.pending.fullscreen) |view| {
view.post_fullscreen_box = view.pending.box;
view.pending.box = .{
.x = 0,
.y = 0,
.width = undefined,
.height = undefined,
};
output.wlr_output.effectiveResolution(
&view.pending.box.width,
&view.pending.box.height,
);
view.inflight.box = view.pending.box;
}
output.inflight.fullscreen = output.pending.fullscreen;
}
}
}
{ {
// Layout demands can't be sent until after the inflight stacks of // Layout demands can't be sent until after the inflight stacks of
// all outputs have been updated. // all outputs have been updated.

View File

@ -341,7 +341,10 @@ pub fn setPendingOutput(view: *Self, output: *Output) void {
} }
output.pending.focus_stack.prepend(view); output.pending.focus_stack.prepend(view);
if (view.pending.float) { if (view.pending.fullscreen) {
view.pending.box = .{ .x = 0, .y = 0, .width = undefined, .height = undefined };
output.wlr_output.effectiveResolution(&view.pending.box.width, &view.pending.box.height);
} else if (view.pending.float) {
view.pending.clampToOutput(); view.pending.clampToOutput();
} }
} }