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

@ -193,6 +193,7 @@ fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
// Make views with app_ids listed in the float filter float
for (root.server.config.float_filter.items) |filter_app_id| {
if (std.mem.eql(u8, std.mem.span(app_id), std.mem.span(filter_app_id))) {
view.current.float = true;
view.pending.float = true;
view.pending.box = view.float_box;
break;
@ -245,11 +246,11 @@ fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
view.surface_box = new_box;
if (s == self.wlr_xdg_surface.configure_serial) {
// If this commit is in response to our configure and the view is
// part of the layout, notify the transaction code. If floating or
// fullscreen apply the pending state immediately.
// If this commit is in response to our configure and the
// transaction code is tracking this configure, notify it.
// Otherwise, apply the pending state immediately.
view.pending_serial = null;
if (!view.pending.float and !view.pending.fullscreen)
if (view.shouldTrackConfigure())
view.output.root.notifyConfigured()
else
view.current = view.pending;
@ -286,5 +287,6 @@ fn handleNewPopup(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
fn handleRequestFullscreen(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const self = @fieldParentPtr(Self, "listen_request_fullscreen", listener.?);
const event = util.voidCast(c.wlr_xdg_toplevel_set_fullscreen_event, data.?);
self.view.setFullscreen(event.fullscreen);
self.view.pending.fullscreen = event.fullscreen;
self.view.applyPending();
}