root: refactor transaction initiation
- require the caller to use Root.startTransaction() directly - introduce View.applyPending() to unify logic - introduce View.shouldTrackConfigure() to unify more logic - update all callsites to intelligently rearrange only what is necessary
This commit is contained in:
@ -31,7 +31,8 @@ pub fn borderWidth(
|
||||
|
||||
const server = seat.input_manager.server;
|
||||
server.config.border_width = try std.fmt.parseInt(u32, args[1], 10);
|
||||
server.root.arrange();
|
||||
server.root.arrangeAll();
|
||||
server.root.startTransaction();
|
||||
}
|
||||
|
||||
pub fn viewPadding(
|
||||
@ -45,7 +46,8 @@ pub fn viewPadding(
|
||||
|
||||
const server = seat.input_manager.server;
|
||||
server.config.view_padding = try std.fmt.parseInt(u32, args[1], 10);
|
||||
server.root.arrange();
|
||||
server.root.arrangeAll();
|
||||
server.root.startTransaction();
|
||||
}
|
||||
|
||||
pub fn outerPadding(
|
||||
@ -59,7 +61,8 @@ pub fn outerPadding(
|
||||
|
||||
const server = seat.input_manager.server;
|
||||
server.config.outer_padding = try std.fmt.parseInt(u32, args[1], 10);
|
||||
server.root.arrange();
|
||||
server.root.arrangeAll();
|
||||
server.root.startTransaction();
|
||||
}
|
||||
|
||||
pub fn backgroundColor(
|
||||
|
@ -33,5 +33,6 @@ pub fn modMasterCount(
|
||||
const delta = try std.fmt.parseInt(i32, args[1], 10);
|
||||
const output = seat.focused_output;
|
||||
output.master_count = @intCast(u32, std.math.max(0, @intCast(i32, output.master_count) + delta));
|
||||
seat.input_manager.server.root.arrange();
|
||||
output.arrangeViews();
|
||||
output.root.startTransaction();
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ pub fn modMasterFactor(
|
||||
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;
|
||||
seat.input_manager.server.root.arrange();
|
||||
output.arrangeViews();
|
||||
output.root.startTransaction();
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,9 @@ pub fn sendToOutput(
|
||||
seat.focused.view.sendToOutput(destination_output);
|
||||
|
||||
// Handle the change and focus whatever's next in the focus stack
|
||||
root.arrange();
|
||||
seat.focus(null);
|
||||
seat.focused_output.arrangeViews();
|
||||
destination_output.arrangeViews();
|
||||
root.startTransaction();
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ pub fn setFocusedTags(
|
||||
const tags = try parseTags(allocator, args, out);
|
||||
if (seat.focused_output.pending.tags != tags) {
|
||||
seat.focused_output.pending.tags = tags;
|
||||
seat.input_manager.server.root.arrange();
|
||||
seat.focused_output.arrangeViews();
|
||||
seat.focused_output.root.startTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +45,7 @@ pub fn setViewTags(
|
||||
const tags = try parseTags(allocator, args, out);
|
||||
if (seat.focused == .view) {
|
||||
seat.focused.view.pending.tags = tags;
|
||||
seat.focused.view.output.root.arrange();
|
||||
seat.focused.view.applyPending();
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +61,8 @@ pub fn toggleFocusedTags(
|
||||
const new_focused_tags = output.pending.tags ^ tags;
|
||||
if (new_focused_tags != 0) {
|
||||
output.pending.tags = new_focused_tags;
|
||||
seat.input_manager.server.root.arrange();
|
||||
output.arrangeViews();
|
||||
output.root.startTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +78,7 @@ pub fn toggleViewTags(
|
||||
const new_tags = seat.focused.view.current.tags ^ tags;
|
||||
if (new_tags != 0) {
|
||||
seat.focused.view.pending.tags = new_tags;
|
||||
seat.focused.view.output.root.arrange();
|
||||
seat.focused.view.applyPending();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,18 +40,6 @@ pub fn toggleFloat(
|
||||
if (seat.input_manager.isCursorActionTarget(view)) return;
|
||||
|
||||
view.pending.float = !view.pending.float;
|
||||
|
||||
if (view.pending.float) {
|
||||
// If switching from layout to float, restore the previous floating
|
||||
// dimensions.
|
||||
view.pending.box = view.float_box;
|
||||
view.configure();
|
||||
} else {
|
||||
// If switching from float to layout save the floating dimensions
|
||||
// for next time.
|
||||
view.float_box = view.current.box;
|
||||
}
|
||||
|
||||
view.output.root.arrange();
|
||||
view.applyPending();
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ pub fn toggleFullscreen(
|
||||
// Don't modify views which are the target of a cursor action
|
||||
if (seat.input_manager.isCursorActionTarget(view)) return;
|
||||
|
||||
view.setFullscreen(!view.pending.fullscreen);
|
||||
view.pending.fullscreen = !view.pending.fullscreen;
|
||||
view.applyPending();
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +56,9 @@ pub fn zoom(
|
||||
if (zoom_node) |to_bump| {
|
||||
output.views.remove(to_bump);
|
||||
output.views.push(to_bump);
|
||||
seat.input_manager.server.root.arrange();
|
||||
seat.focus(&to_bump.view);
|
||||
output.arrangeViews();
|
||||
output.root.startTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user