view: introduce state struct to simplify code

The state struct holds all of the state that is double-buffered and
applied through transactions. This more explicit handling simplifies
much of the code, and will allow for easier implementation of new
feature such as fullscreen.
This commit is contained in:
Isaac Freund
2020-06-27 22:43:15 +02:00
parent 89d0fb012d
commit c04112b81a
12 changed files with 105 additions and 124 deletions

View File

@ -57,11 +57,8 @@ pub fn init(self: *Self, view: *View, wlr_xwayland_surface: *c.wlr_xwayland_surf
}
pub fn needsConfigure(self: Self) bool {
const view = self.view;
if (view.pending_box) |pending_box|
return view.current_box.width != pending_box.width or
view.current_box.height != pending_box.height;
return false;
return self.view.current.box.width != self.view.pending.box.width or
self.view.current.box.height != self.view.pending.box.height;
}
/// Tell the client to take a new size
@ -105,8 +102,8 @@ pub fn forEachSurface(
pub fn surfaceAt(self: Self, ox: f64, oy: f64, sx: *f64, sy: *f64) ?*c.wlr_surface {
return c.wlr_surface_surface_at(
self.wlr_xwayland_surface.surface,
ox - @intToFloat(f64, self.view.current_box.x),
oy - @intToFloat(f64, self.view.current_box.y),
ox - @intToFloat(f64, self.view.current.box.x),
oy - @intToFloat(f64, self.view.current.box.y),
sx,
sy,
);