Zoom to second view in stack if top is focused
This commit is contained in:
parent
f0c4faf10b
commit
adc4e12971
@ -5,16 +5,23 @@ const Seat = @import("../seat.zig").Seat;
|
|||||||
const View = @import("../view.zig").View;
|
const View = @import("../view.zig").View;
|
||||||
const ViewStack = @import("../view_stack.zig").ViewStack;
|
const ViewStack = @import("../view_stack.zig").ViewStack;
|
||||||
|
|
||||||
/// Bump the focused view to the top of the stack.
|
/// Bump the focused view to the top of the stack. If the view on the top of
|
||||||
/// TODO: if the top of the stack is focused, bump the next visible view.
|
/// the stack is focused, bump the second view to the top.
|
||||||
pub fn zoom(seat: *Seat, arg: Arg) void {
|
pub fn zoom(seat: *Seat, arg: Arg) void {
|
||||||
if (seat.focused_view) |current_focus| {
|
if (seat.focused_view) |current_focus| {
|
||||||
const output = seat.focused_output;
|
const output = seat.focused_output;
|
||||||
const node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus);
|
const focused_node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus);
|
||||||
if (node != output.views.first) {
|
|
||||||
output.views.remove(node);
|
const zoom_node = if (focused_node == output.views.first)
|
||||||
output.views.push(node);
|
if (focused_node.next) |second| second else null
|
||||||
|
else
|
||||||
|
focused_node;
|
||||||
|
|
||||||
|
if (zoom_node) |to_bump| {
|
||||||
|
output.views.remove(to_bump);
|
||||||
|
output.views.push(to_bump);
|
||||||
seat.input_manager.server.root.arrange();
|
seat.input_manager.server.root.arrange();
|
||||||
|
seat.focus(&to_bump.view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user