view: sidestep transaction for float/fullscreen

Transactions are only useful when multiple views need to atomically
change size together. Float/fullscreen views are independant of the
layout and should bypass the transaction system.
This commit is contained in:
Isaac Freund
2020-07-31 12:16:11 +02:00
parent ecef8c2dc4
commit 7a244092e5
5 changed files with 37 additions and 21 deletions

View File

@ -39,8 +39,14 @@ pub fn toggleFloat(
// Don't modify views which are the target of a cursor action
if (seat.input_manager.isCursorActionTarget(view)) return;
if (!view.pending.float) view.pending.box = view.float_box;
view.pending.float = !view.pending.float;
// If switching from layout to float, restore the previous floating dimensions
if (view.pending.float) {
view.pending.box = view.float_box;
view.configure();
}
view.output.root.arrange();
}
}

View File

@ -17,6 +17,9 @@
const std = @import("std");
const c = @import("../c.zig");
const Box = @import("../Box.zig");
const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig");
@ -35,7 +38,22 @@ pub fn toggleFullscreen(
// Don't modify views which are the target of a cursor action
if (seat.input_manager.isCursorActionTarget(view)) return;
view.setFullscreen(!seat.focused.view.pending.fullscreen);
view.output.root.arrange();
view.setFullscreen(!view.pending.fullscreen);
if (view.pending.fullscreen) {
const output = view.output;
view.pending.box = Box.fromWlrBox(
c.wlr_output_layout_get_box(output.root.wlr_output_layout, output.wlr_output).*,
);
view.configure();
} else if (view.pending.float) {
// If transitioning from fullscreen -> float, return to the saved
// floating dimensions.
view.pending.box = view.float_box;
view.configure();
} else {
// Transitioning to layout, arrange and start a transaction
view.output.root.arrange();
}
}
}