transactions: revert c0d7e71

This commit is contained in:
Isaac Freund 2020-06-09 17:04:38 +02:00
parent 7c094420ed
commit 24b1a566de
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
6 changed files with 36 additions and 99 deletions

View file

@ -334,8 +334,8 @@ pub fn layoutMasterStack(self: *Self, visible_count: u32, output_tags: u32, posi
new_box.width -= delta_size; new_box.width -= delta_size;
new_box.height -= delta_size; new_box.height -= delta_size;
// Set the view's next box to the new dimensions // Set the view's pending box to the new dimensions
view.next_box = new_box; view.pending_box = new_box;
i += 1; i += 1;
} }
@ -391,7 +391,7 @@ pub fn layoutFull(self: *Self, visible_count: u32, output_tags: u32) void {
.height = layout_height, .height = layout_height,
}; };
view.next_box = new_box; view.pending_box = new_box;
i += 1; i += 1;
} }

View file

@ -132,63 +132,27 @@ fn startTransaction(self: *Self) void {
var view_it = ViewStack(View).iterator(output.views.first, std.math.maxInt(u32)); var view_it = ViewStack(View).iterator(output.views.first, std.math.maxInt(u32));
while (view_it.next()) |view_node| { while (view_it.next()) |view_node| {
const view = &view_node.view; const view = &view_node.view;
// Clear the serial in case this transaction is interrupting a prior one.
switch (view.configureAction()) {
.override => {
view.configure();
// Some clients do not ack a configure if the requested
// size is the same as their current size. Configures of
// this nature may be sent if a pending configure is
// interrupted by a configure returning to the original
// size.
if (view.pending_box.?.width == view.current_box.width and
view.pending_box.?.height == view.current_box.height)
{
view.pending_serial = null; view.pending_serial = null;
} else {
std.debug.assert(view.pending_serial != null); if (view.needsConfigure()) {
self.pending_configures += 1;
}
},
.new_configure => {
view.configure(); view.configure();
self.pending_configures += 1; self.pending_configures += 1;
std.debug.assert(view.pending_serial != null);
},
.old_configure => {
self.pending_configures += 1;
if (view.next_box) |next_box| {
view.pending_box.?.x = next_box.x;
view.pending_box.?.y = next_box.y;
view.next_box = null;
}
},
.noop => {
if (view.next_box) |next_box| {
view.pending_box = view.next_box;
view.next_box = null;
}
std.debug.assert(view.pending_serial == null);
},
}
// If there is a saved buffer present, then this transaction is
// interrupting a previous transaction and we should keep the old
// buffer.
if (view.stashed_buffer == null) {
view.stashBuffer();
// We save the current buffer, so we can send an early // We save the current buffer, so we can send an early
// frame done event to give the client a head start on // frame done event to give the client a head start on
// redrawing. // redrawing.
view.sendFrameDone(); view.sendFrameDone();
} }
// If there is a saved buffer present, then this transaction is interrupting
// a previous transaction and we should keep the old buffer.
if (view.stashed_buffer == null) {
view.stashBuffer();
}
} }
} }
// If there are views that need configures, start a timer and wait for
// configure events before committing.
if (self.pending_configures > 0) { if (self.pending_configures > 0) {
Log.Debug.log( Log.Debug.log(
"Started transaction with {} pending configures.", "Started transaction with {} pending configures.",
@ -201,10 +165,6 @@ fn startTransaction(self: *Self) void {
self.commitTransaction(); self.commitTransaction();
} }
} else { } else {
// No views need configures, clear the current timer in case we are
// interrupting another transaction and commit.
if (c.wl_event_source_timer_update(self.transaction_timer, 0) < 0)
Log.Error.log("Error disarming timer", .{});
self.commitTransaction(); self.commitTransaction();
} }
} }
@ -223,7 +183,7 @@ pub fn notifyConfigured(self: *Self) void {
self.pending_configures -= 1; self.pending_configures -= 1;
if (self.pending_configures == 0) { if (self.pending_configures == 0) {
// Disarm the timer, as we didn't timeout // Disarm the timer, as we didn't timeout
if (c.wl_event_source_timer_update(self.transaction_timer, 0) < 0) if (c.wl_event_source_timer_update(self.transaction_timer, 0) == -1)
Log.Error.log("Error disarming timer", .{}); Log.Error.log("Error disarming timer", .{});
self.commitTransaction(); self.commitTransaction();
} }
@ -263,7 +223,6 @@ fn commitTransaction(self: *Self) void {
const view = &view_node.view; const view = &view_node.view;
// Ensure that all pending state is cleared // Ensure that all pending state is cleared
view.pending_serial = null; view.pending_serial = null;
std.debug.assert(view.next_box == null);
if (view.pending_box) |state| { if (view.pending_box) |state| {
view.current_box = state; view.current_box = state;
view.pending_box = null; view.pending_box = null;

View file

@ -55,13 +55,8 @@ focused: bool,
/// The current output-relative coordinates and dimensions of the view /// The current output-relative coordinates and dimensions of the view
current_box: Box, current_box: Box,
/// The dimensions sent with the most recent configure
pending_box: ?Box, pending_box: ?Box,
/// The dimensions to be used for the next configure
next_box: ?Box,
/// The dimensions the view would have taken if we didn't force it to tile /// The dimensions the view would have taken if we didn't force it to tile
natural_width: u32, natural_width: u32,
natural_height: u32, natural_height: u32,
@ -116,40 +111,23 @@ pub fn deinit(self: Self) void {
} }
} }
/// Returns true if a configure needs to be sent to ensure the next_box is pub fn needsConfigure(self: Self) bool {
/// applied correctly. if (self.pending_box) |pending_box| {
pub fn configureAction(self: Self) enum { override, new_configure, old_configure, noop } { return pending_box.width != self.current_box.width or
// If we have a pending box, check if the next box is different from the pending_box.height != self.current_box.height;
// pending box. If we do not have a pending box, check if the next box is
// different from the current box.
if (self.pending_box) |pending_box|
if (self.next_box) |next_box| {
if (next_box.width != pending_box.width or next_box.height != pending_box.height) {
return .override;
} else { } else {
return .old_configure; return false;
} }
};
if (self.next_box) |next_box|
if (next_box.width != self.current_box.width or next_box.height != self.current_box.height)
return .new_configure;
return .noop;
} }
/// Tell the client to assume the size of next_box. Set pending_box to pub fn configure(self: Self) void {
/// next_box and next_box to null. if (self.pending_box) |pending_box| {
pub fn configure(self: *Self) void {
if (self.next_box) |next_box| {
switch (self.impl) { switch (self.impl) {
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.configure(next_box), .xdg_toplevel => |xdg_toplevel| xdg_toplevel.configure(pending_box),
.xwayland_view => |xwayland_view| xwayland_view.configure(next_box), .xwayland_view => |xwayland_view| xwayland_view.configure(pending_box),
} }
self.pending_box = next_box;
self.next_box = null;
} else { } else {
Log.Error.log("configure called on View with null next_box", .{}); Log.Error.log("Configure called on a View with no pending box", .{});
} }
} }

View file

@ -23,7 +23,7 @@ const c = @import("c.zig");
const Box = @import("Box.zig"); const Box = @import("Box.zig");
pub fn configure(self: Self, box: Box) void { pub fn configure(self: Self, pending_box: Box) void {
unreachable; unreachable;
} }

View file

@ -63,11 +63,11 @@ pub fn init(self: *Self, view: *View, wlr_xdg_surface: *c.wlr_xdg_surface) void
c.wl_signal_add(&self.wlr_xdg_surface.events.unmap, &self.listen_unmap); c.wl_signal_add(&self.wlr_xdg_surface.events.unmap, &self.listen_unmap);
} }
pub fn configure(self: Self, box: Box) void { pub fn configure(self: Self, pending_box: Box) void {
self.view.pending_serial = c.wlr_xdg_toplevel_set_size( self.view.pending_serial = c.wlr_xdg_toplevel_set_size(
self.wlr_xdg_surface, self.wlr_xdg_surface,
box.width, pending_box.width,
box.height, pending_box.height,
); );
} }

View file

@ -58,13 +58,13 @@ pub fn init(self: *Self, view: *View, wlr_xwayland_surface: *c.wlr_xwayland_surf
} }
/// Tell the client to take a new size /// Tell the client to take a new size
pub fn configure(self: Self, box: Box) void { pub fn configure(self: Self, pending_box: Box) void {
c.wlr_xwayland_surface_configure( c.wlr_xwayland_surface_configure(
self.wlr_xwayland_surface, self.wlr_xwayland_surface,
@intCast(i16, box.x), @intCast(i16, pending_box.x),
@intCast(i16, box.y), @intCast(i16, pending_box.y),
@intCast(u16, box.width), @intCast(u16, pending_box.width),
@intCast(u16, box.height), @intCast(u16, pending_box.height),
); );
// Xwayland surfaces don't use serials, so we will just assume they have // Xwayland surfaces don't use serials, so we will just assume they have
// configured the next time they commit. Set pending serial to a dummy // configured the next time they commit. Set pending serial to a dummy