view: replace mode with float/fullscreen bools
The enum would be awkward here since if a view is fullscreened while floating it should still be floating when defullscreened.
This commit is contained in:
@ -29,14 +29,13 @@ pub fn toggleFloat(
|
||||
out: *?[]const u8,
|
||||
) Error!void {
|
||||
if (args.len > 1) return Error.TooManyArguments;
|
||||
|
||||
if (seat.focused_view) |view| {
|
||||
switch (view.current.mode) {
|
||||
.layout => {
|
||||
view.pending.mode = .float;
|
||||
view.pending.box = view.getDefaultFloatBox();
|
||||
},
|
||||
.float => view.pending.mode = .layout,
|
||||
}
|
||||
// Don't float fullscreen views
|
||||
if (view.pending.fullscreen) return;
|
||||
|
||||
if (!view.pending.float) view.pending.box = view.getDefaultFloatBox();
|
||||
view.pending.float = !view.pending.float;
|
||||
view.output.root.arrange();
|
||||
}
|
||||
}
|
||||
|
@ -37,13 +37,21 @@ pub fn zoom(
|
||||
const focused_node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus);
|
||||
|
||||
// Only zoom views that are part of the layout
|
||||
if (current_focus.current.mode != .layout) return;
|
||||
if (current_focus.pending.float or current_focus.pending.fullscreen) return;
|
||||
|
||||
// If the the first view that is part of the layout is focused, zoom
|
||||
// the next view in the layout. Otherwise zoom the focused view.
|
||||
var it = ViewStack(View).iterator(output.views.first, output.current_focused_tags);
|
||||
const zoom_node = if (focused_node == it.next())
|
||||
if (it.next()) |second| second else null
|
||||
else
|
||||
focused_node;
|
||||
const layout_first = while (it.next()) |node| {
|
||||
if (!node.view.pending.float and !node.view.pending.fullscreen) break node;
|
||||
} else unreachable;
|
||||
const zoom_node = if (focused_node == layout_first) blk: {
|
||||
while (it.next()) |node| {
|
||||
if (!node.view.pending.float and !node.view.pending.fullscreen) break :blk node;
|
||||
} else {
|
||||
break :blk null;
|
||||
}
|
||||
} else focused_node;
|
||||
|
||||
if (zoom_node) |to_bump| {
|
||||
output.views.remove(to_bump);
|
||||
|
Reference in New Issue
Block a user