Track the focused output of seats
This commit is contained in:
@ -24,7 +24,7 @@ pub fn exitCompositor(seat: *Seat, arg: Arg) void {
|
||||
/// Focus either the next or the previous visible view, depending on the bool
|
||||
/// passed.
|
||||
fn focusNextPrevView(seat: *Seat, next: bool) void {
|
||||
const output = seat.input_manager.server.root.focusedOutput();
|
||||
const output = seat.focused_output;
|
||||
if (seat.focused_view) |current_focus| {
|
||||
// If there is a currently focused view, focus the next visible view in the stack.
|
||||
const focused_node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus);
|
||||
@ -66,27 +66,25 @@ pub fn focusPrevView(seat: *Seat, arg: Arg) void {
|
||||
/// Modify the number of master views
|
||||
pub fn modifyMasterCount(seat: *Seat, arg: Arg) void {
|
||||
const delta = arg.int;
|
||||
const root = &seat.input_manager.server.root;
|
||||
const output = root.focusedOutput();
|
||||
const output = seat.focused_output;
|
||||
output.master_count = @intCast(
|
||||
u32,
|
||||
std.math.max(0, @intCast(i32, output.master_count) + delta),
|
||||
);
|
||||
root.arrange();
|
||||
seat.input_manager.server.root.arrange();
|
||||
}
|
||||
|
||||
/// Modify the percent of the width of the screen that the master views occupy.
|
||||
pub fn modifyMasterFactor(seat: *Seat, arg: Arg) void {
|
||||
const delta = arg.float;
|
||||
const root = &seat.input_manager.server.root;
|
||||
const output = root.focusedOutput();
|
||||
const output = seat.focused_output;
|
||||
const new_master_factor = std.math.min(
|
||||
std.math.max(output.master_factor + delta, 0.05),
|
||||
0.95,
|
||||
);
|
||||
if (new_master_factor != output.master_factor) {
|
||||
output.master_factor = new_master_factor;
|
||||
root.arrange();
|
||||
seat.input_manager.server.root.arrange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,13 +92,12 @@ pub fn modifyMasterFactor(seat: *Seat, arg: Arg) void {
|
||||
/// TODO: if the top of the stack is focused, bump the next visible view.
|
||||
pub fn zoom(seat: *Seat, arg: Arg) void {
|
||||
if (seat.focused_view) |current_focus| {
|
||||
const root = &seat.input_manager.server.root;
|
||||
const output = root.focusedOutput();
|
||||
const output = seat.focused_output;
|
||||
const node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus);
|
||||
if (node != output.views.first) {
|
||||
output.views.remove(node);
|
||||
output.views.push(node);
|
||||
root.arrange();
|
||||
seat.input_manager.server.root.arrange();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,21 +105,18 @@ pub fn zoom(seat: *Seat, arg: Arg) void {
|
||||
/// Switch focus to the passed tags.
|
||||
pub fn focusTags(seat: *Seat, arg: Arg) void {
|
||||
const tags = arg.uint;
|
||||
const root = &seat.input_manager.server.root;
|
||||
const output = root.focusedOutput();
|
||||
output.pending_focused_tags = tags;
|
||||
root.arrange();
|
||||
seat.focused_output.pending_focused_tags = tags;
|
||||
seat.input_manager.server.root.arrange();
|
||||
}
|
||||
|
||||
/// Toggle focus of the passsed tags.
|
||||
pub fn toggleTags(seat: *Seat, arg: Arg) void {
|
||||
const tags = arg.uint;
|
||||
const root = &seat.input_manager.server.root;
|
||||
const output = root.focusedOutput();
|
||||
const output = seat.focused_output;
|
||||
const new_focused_tags = output.current_focused_tags ^ tags;
|
||||
if (new_focused_tags != 0) {
|
||||
output.pending_focused_tags = new_focused_tags;
|
||||
root.arrange();
|
||||
seat.input_manager.server.root.arrange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user