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:
Isaac Freund
2020-08-11 19:04:37 +02:00
parent 50d008adbb
commit 2669a615b6
13 changed files with 130 additions and 102 deletions

View File

@ -68,9 +68,8 @@ const Mode = union(enum) {
// Automatically float all views being moved by the pointer
if (!view.current.float) {
view.pending.float = true;
// Start a transaction to apply the pending state of the grabbed
// view and rearrange the layout to fill the hole.
view.output.root.arrange();
view.float_box = view.current.box;
view.applyPending();
}
// Clear cursor focus, so that the surface does not receive events
@ -145,8 +144,7 @@ const Mode = union(enum) {
@intToFloat(f64, view.pending.box.y - view.current.box.y),
);
// Apply new pending state (no need for a configure as size didn't change)
view.current = view.pending;
view.applyPending();
},
.resize => |data| {
var output_width: c_int = undefined;
@ -163,7 +161,7 @@ const Mode = union(enum) {
box.width = std.math.min(box.width, @intCast(u32, output_width - box.x - @intCast(i32, border_width)));
box.height = std.math.min(box.height, @intCast(u32, output_height - box.y - @intCast(i32, border_width)));
if (data.view.needsConfigure()) data.view.configure();
data.view.applyPending();
// Keep cursor locked to the original offset from the bottom right corner
c.wlr_cursor_warp_closest(