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:
parent
60f06a1a40
commit
5b96d831d3
@ -181,7 +181,7 @@ fn layoutFull(self: *Self, visible_count: u32, output_tags: u32) void {
|
|||||||
var it = ViewStack(View).pendingIterator(self.views.first, output_tags);
|
var it = ViewStack(View).pendingIterator(self.views.first, output_tags);
|
||||||
while (it.next()) |node| {
|
while (it.next()) |node| {
|
||||||
const view = &node.view;
|
const view = &node.view;
|
||||||
if (view.pending.mode == .layout) view.pending.box = full_box;
|
if (!view.pending.float and !view.pending.fullscreen) view.pending.box = full_box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ fn layoutExternal(self: *Self, visible_count: u32, output_tags: u32) !void {
|
|||||||
var view_it = ViewStack(View).pendingIterator(self.views.first, output_tags);
|
var view_it = ViewStack(View).pendingIterator(self.views.first, output_tags);
|
||||||
while (view_it.next()) |node| {
|
while (view_it.next()) |node| {
|
||||||
const view = &node.view;
|
const view = &node.view;
|
||||||
if (view.pending.mode == .layout) {
|
if (!view.pending.float and !view.pending.fullscreen) {
|
||||||
view.pending.box = view_boxen.items[i];
|
view.pending.box = view_boxen.items[i];
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ pub fn arrangeViews(self: *Self) void {
|
|||||||
var count: u32 = 0;
|
var count: u32 = 0;
|
||||||
var it = ViewStack(View).pendingIterator(self.views.first, output_tags);
|
var it = ViewStack(View).pendingIterator(self.views.first, output_tags);
|
||||||
while (it.next()) |node| {
|
while (it.next()) |node| {
|
||||||
if (node.view.pending.mode == .layout) count += 1;
|
if (!node.view.pending.float and !node.view.pending.fullscreen) count += 1;
|
||||||
}
|
}
|
||||||
break :blk count;
|
break :blk count;
|
||||||
};
|
};
|
||||||
|
@ -36,11 +36,6 @@ const Impl = union(enum) {
|
|||||||
xwayland_view: XwaylandView,
|
xwayland_view: XwaylandView,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Mode = enum {
|
|
||||||
layout,
|
|
||||||
float,
|
|
||||||
};
|
|
||||||
|
|
||||||
const State = struct {
|
const State = struct {
|
||||||
/// The output-relative coordinates and dimensions of the view. The
|
/// The output-relative coordinates and dimensions of the view. The
|
||||||
/// surface itself may have other dimensions which are stored in the
|
/// surface itself may have other dimensions which are stored in the
|
||||||
@ -50,7 +45,8 @@ const State = struct {
|
|||||||
/// The tags of the view, as a bitmask
|
/// The tags of the view, as a bitmask
|
||||||
tags: u32,
|
tags: u32,
|
||||||
|
|
||||||
mode: Mode,
|
float: bool,
|
||||||
|
fullscreen: bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SavedBuffer = struct {
|
const SavedBuffer = struct {
|
||||||
@ -108,8 +104,10 @@ pub fn init(self: *Self, output: *Output, tags: u32, surface: var) void {
|
|||||||
.width = 0,
|
.width = 0,
|
||||||
},
|
},
|
||||||
.tags = tags,
|
.tags = tags,
|
||||||
.mode = .layout,
|
.float = false,
|
||||||
|
.fullscreen = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.pending = self.current;
|
self.pending = self.current;
|
||||||
|
|
||||||
self.pending_serial = null;
|
self.pending_serial = null;
|
||||||
|
@ -174,13 +174,13 @@ fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
|||||||
|
|
||||||
if (wlr_xdg_toplevel.parent != null or has_fixed_size) {
|
if (wlr_xdg_toplevel.parent != null or has_fixed_size) {
|
||||||
// If the toplevel has a parent or has a fixed size make it float
|
// If the toplevel has a parent or has a fixed size make it float
|
||||||
view.pending.mode = .float;
|
view.pending.float = true;
|
||||||
view.pending.box = view.getDefaultFloatBox();
|
view.pending.box = view.getDefaultFloatBox();
|
||||||
} else {
|
} else {
|
||||||
// Make views with app_ids listed in the float filter float
|
// Make views with app_ids listed in the float filter float
|
||||||
for (root.server.config.float_filter.items) |filter_app_id| {
|
for (root.server.config.float_filter.items) |filter_app_id| {
|
||||||
if (std.mem.eql(u8, std.mem.span(app_id), std.mem.span(filter_app_id))) {
|
if (std.mem.eql(u8, std.mem.span(app_id), std.mem.span(filter_app_id))) {
|
||||||
view.pending.mode = .float;
|
view.pending.float = true;
|
||||||
view.pending.box = view.getDefaultFloatBox();
|
view.pending.box = view.getDefaultFloatBox();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ const impl = struct {
|
|||||||
const spawn = @import("command/spawn.zig").spawn;
|
const spawn = @import("command/spawn.zig").spawn;
|
||||||
const toggleFloat = @import("command/toggle_float.zig").toggleFloat;
|
const toggleFloat = @import("command/toggle_float.zig").toggleFloat;
|
||||||
const toggleFocusedTags = @import("command/tags.zig").toggleFocusedTags;
|
const toggleFocusedTags = @import("command/tags.zig").toggleFocusedTags;
|
||||||
|
const toggleFullscreen = @import("command/toggle_fullscreen.zig").toggleFullscreen;
|
||||||
const toggleViewTags = @import("command/tags.zig").toggleViewTags;
|
const toggleViewTags = @import("command/tags.zig").toggleViewTags;
|
||||||
const zoom = @import("command/zoom.zig").zoom;
|
const zoom = @import("command/zoom.zig").zoom;
|
||||||
};
|
};
|
||||||
|
@ -29,14 +29,13 @@ pub fn toggleFloat(
|
|||||||
out: *?[]const u8,
|
out: *?[]const u8,
|
||||||
) Error!void {
|
) Error!void {
|
||||||
if (args.len > 1) return Error.TooManyArguments;
|
if (args.len > 1) return Error.TooManyArguments;
|
||||||
|
|
||||||
if (seat.focused_view) |view| {
|
if (seat.focused_view) |view| {
|
||||||
switch (view.current.mode) {
|
// Don't float fullscreen views
|
||||||
.layout => {
|
if (view.pending.fullscreen) return;
|
||||||
view.pending.mode = .float;
|
|
||||||
view.pending.box = view.getDefaultFloatBox();
|
if (!view.pending.float) view.pending.box = view.getDefaultFloatBox();
|
||||||
},
|
view.pending.float = !view.pending.float;
|
||||||
.float => view.pending.mode = .layout,
|
|
||||||
}
|
|
||||||
view.output.root.arrange();
|
view.output.root.arrange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,21 @@ pub fn zoom(
|
|||||||
const focused_node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus);
|
const focused_node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus);
|
||||||
|
|
||||||
// Only zoom views that are part of the layout
|
// 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);
|
var it = ViewStack(View).iterator(output.views.first, output.current_focused_tags);
|
||||||
const zoom_node = if (focused_node == it.next())
|
const layout_first = while (it.next()) |node| {
|
||||||
if (it.next()) |second| second else null
|
if (!node.view.pending.float and !node.view.pending.fullscreen) break node;
|
||||||
else
|
} else unreachable;
|
||||||
focused_node;
|
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| {
|
if (zoom_node) |to_bump| {
|
||||||
output.views.remove(to_bump);
|
output.views.remove(to_bump);
|
||||||
|
Loading…
Reference in New Issue
Block a user