view: use a mode enum instead of floating bool

This is in preperation for fullscreen support which will add another
mode to this enum.

This commit also fixes a bug that allowed clicking floating views though
layout views in some cases.
This commit is contained in:
Isaac Freund
2020-06-27 17:33:09 +02:00
parent 3904275373
commit 89d0fb012d
7 changed files with 58 additions and 73 deletions

View File

@ -30,7 +30,10 @@ pub fn toggleFloat(
) Error!void {
if (args.len > 1) return Error.TooManyArguments;
if (seat.focused_view) |view| {
view.setFloating(!view.floating);
switch (view.mode) {
.layout => view.setMode(.float),
.float => view.setMode(.layout),
}
view.output.root.arrange();
}
}

View File

@ -36,8 +36,8 @@ pub fn zoom(
const output = seat.focused_output;
const focused_node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus);
// Don't zoom floating views
if (current_focus.floating) return;
// Only zoom views that are part of the layout
if (current_focus.mode != .layout) return;
var it = ViewStack(View).iterator(output.views.first, output.current_focused_tags);
const zoom_node = if (focused_node == it.next())