XdgToplevel: eliminate "self" naming convention

This commit is contained in:
Isaac Freund 2024-03-14 12:19:36 +01:00
parent 2eb2a13284
commit 0e2cac08df
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
3 changed files with 149 additions and 149 deletions

View File

@ -44,12 +44,12 @@ pub const Constraints = struct {
};
const Impl = union(enum) {
xdg_toplevel: XdgToplevel,
toplevel: XdgToplevel,
xwayland_view: if (build_options.xwayland) XwaylandView else noreturn,
/// This state is assigned during destruction after the xdg toplevel
/// has been destroyed but while the transaction system is still rendering
/// saved surfaces of the view.
/// The xdg_toplevel could simply be set to undefined instead, but using a
/// The toplevel could simply be set to undefined instead, but using a
/// tag like this gives us better safety checks.
none,
};
@ -132,7 +132,7 @@ saved_surface_tree: *wlr.SceneTree,
borders: [4]*wlr.SceneRect,
popup_tree: *wlr.SceneTree,
/// Bounds on the width/height of the view, set by the xdg_toplevel/xwayland_view implementation.
/// Bounds on the width/height of the view, set by the toplevel/xwayland_view implementation.
constraints: Constraints = .{},
mapped: bool = false,
@ -293,12 +293,12 @@ pub fn commitTransaction(view: *View) void {
view.dropSavedSurfaceTree();
switch (view.impl) {
.xdg_toplevel => |*xdg_toplevel| {
switch (xdg_toplevel.configure_state) {
.toplevel => |*toplevel| {
switch (toplevel.configure_state) {
.inflight, .acked => {
switch (xdg_toplevel.configure_state) {
.inflight => |serial| xdg_toplevel.configure_state = .{ .timed_out = serial },
.acked => xdg_toplevel.configure_state = .timed_out_acked,
switch (toplevel.configure_state) {
.inflight => |serial| toplevel.configure_state = .{ .timed_out = serial },
.acked => toplevel.configure_state = .timed_out_acked,
else => unreachable,
}
@ -321,15 +321,15 @@ pub fn commitTransaction(view: *View) void {
// we would be rendering the SSD border at initial size X but the surface
// would be rendered at size Y.
if (view.inflight.resizing) {
view.resizeUpdatePosition(xdg_toplevel.geometry.width, xdg_toplevel.geometry.height);
view.resizeUpdatePosition(toplevel.geometry.width, toplevel.geometry.height);
}
view.current = view.inflight;
view.current.box.width = xdg_toplevel.geometry.width;
view.current.box.height = xdg_toplevel.geometry.height;
view.current.box.width = toplevel.geometry.width;
view.current.box.height = toplevel.geometry.height;
},
.idle, .committed => {
xdg_toplevel.configure_state = .idle;
toplevel.configure_state = .idle;
view.current = view.inflight;
},
.timed_out, .timed_out_acked => unreachable,
@ -374,9 +374,9 @@ pub fn updateSceneState(view: *View) void {
surface_clip.y -= box.y;
switch (view.impl) {
.xdg_toplevel => |xdg_toplevel| {
surface_clip.x += xdg_toplevel.geometry.x;
surface_clip.y += xdg_toplevel.geometry.y;
.toplevel => |toplevel| {
surface_clip.x += toplevel.geometry.x;
surface_clip.y += toplevel.geometry.y;
},
.xwayland_view, .none => {},
}
@ -443,7 +443,7 @@ pub fn updateSceneState(view: *View) void {
pub fn configure(view: *View) bool {
assert(view.mapped and !view.destroying);
switch (view.impl) {
.xdg_toplevel => |*xdg_toplevel| return xdg_toplevel.configure(),
.toplevel => |*toplevel| return toplevel.configure(),
.xwayland_view => |*xwayland_view| return xwayland_view.configure(),
.none => unreachable,
}
@ -452,7 +452,7 @@ pub fn configure(view: *View) bool {
pub fn rootSurface(view: View) *wlr.Surface {
assert(view.mapped and !view.destroying);
return switch (view.impl) {
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.rootSurface(),
.toplevel => |toplevel| toplevel.rootSurface(),
.xwayland_view => |xwayland_view| xwayland_view.rootSurface(),
.none => unreachable,
};
@ -526,7 +526,7 @@ pub fn setPendingOutput(view: *View, output: *Output) void {
pub fn close(view: View) void {
assert(!view.destroying);
switch (view.impl) {
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.close(),
.toplevel => |toplevel| toplevel.close(),
.xwayland_view => |xwayland_view| xwayland_view.close(),
.none => unreachable,
}
@ -535,7 +535,7 @@ pub fn close(view: View) void {
pub fn destroyPopups(view: View) void {
assert(!view.destroying);
switch (view.impl) {
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.destroyPopups(),
.toplevel => |toplevel| toplevel.destroyPopups(),
.xwayland_view => {},
.none => unreachable,
}
@ -545,7 +545,7 @@ pub fn destroyPopups(view: View) void {
pub fn getTitle(view: View) ?[*:0]const u8 {
assert(!view.destroying);
return switch (view.impl) {
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.getTitle(),
.toplevel => |toplevel| toplevel.getTitle(),
.xwayland_view => |xwayland_view| xwayland_view.getTitle(),
.none => unreachable,
};
@ -555,7 +555,7 @@ pub fn getTitle(view: View) ?[*:0]const u8 {
pub fn getAppId(view: View) ?[*:0]const u8 {
assert(!view.destroying);
return switch (view.impl) {
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.getAppId(),
.toplevel => |toplevel| toplevel.getAppId(),
.xwayland_view => |xwayland_view| xwayland_view.getAppId(),
.none => unreachable,
};

View File

@ -34,32 +34,32 @@ request_mode: wl.Listener(*wlr.XdgToplevelDecorationV1) =
wl.Listener(*wlr.XdgToplevelDecorationV1).init(handleRequestMode),
pub fn init(wlr_decoration: *wlr.XdgToplevelDecorationV1) void {
const xdg_toplevel: *XdgToplevel = @ptrFromInt(wlr_decoration.toplevel.base.data);
const toplevel: *XdgToplevel = @ptrFromInt(wlr_decoration.toplevel.base.data);
xdg_toplevel.decoration = .{ .wlr_decoration = wlr_decoration };
const decoration = &xdg_toplevel.decoration.?;
toplevel.decoration = .{ .wlr_decoration = wlr_decoration };
const decoration = &toplevel.decoration.?;
wlr_decoration.events.destroy.add(&decoration.destroy);
wlr_decoration.events.request_mode.add(&decoration.request_mode);
const ssd = server.config.rules.ssd.match(xdg_toplevel.view) orelse
const ssd = server.config.rules.ssd.match(toplevel.view) orelse
(decoration.wlr_decoration.requested_mode != .client_side);
// TODO(wlroots): make sure this is properly batched in a single configure
// with all other initial state when wlroots makes this possible.
_ = wlr_decoration.setMode(if (ssd) .server_side else .client_side);
xdg_toplevel.view.pending.ssd = ssd;
toplevel.view.pending.ssd = ssd;
}
pub fn deinit(decoration: *XdgDecoration) void {
const xdg_toplevel: *XdgToplevel = @ptrFromInt(decoration.wlr_decoration.toplevel.base.data);
const toplevel: *XdgToplevel = @ptrFromInt(decoration.wlr_decoration.toplevel.base.data);
decoration.destroy.link.remove();
decoration.request_mode.link.remove();
assert(xdg_toplevel.decoration != null);
xdg_toplevel.decoration = null;
assert(toplevel.decoration != null);
toplevel.decoration = null;
}
fn handleDestroy(
@ -77,10 +77,10 @@ fn handleRequestMode(
) void {
const decoration = @fieldParentPtr(XdgDecoration, "request_mode", listener);
const xdg_toplevel: *XdgToplevel = @ptrFromInt(decoration.wlr_decoration.toplevel.base.data);
const view = xdg_toplevel.view;
const toplevel: *XdgToplevel = @ptrFromInt(decoration.wlr_decoration.toplevel.base.data);
const view = toplevel.view;
const ssd = server.config.rules.ssd.match(xdg_toplevel.view) orelse
const ssd = server.config.rules.ssd.match(toplevel.view) orelse
(decoration.wlr_decoration.requested_mode != .client_side);
if (view.pending.ssd != ssd) {

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const Self = @This();
const XdgToplevel = @This();
const std = @import("std");
const assert = std.debug.assert;
@ -36,7 +36,7 @@ const log = std.log.scoped(.xdg_shell);
/// TODO(zig): get rid of this and use @fieldParentPtr(), https://github.com/ziglang/zig/issues/6611
view: *View,
xdg_toplevel: *wlr.XdgToplevel,
wlr_toplevel: *wlr.XdgToplevel,
decoration: ?XdgDecoration = null,
@ -76,14 +76,14 @@ request_resize: wl.Listener(*wlr.XdgToplevel.event.Resize) =
set_title: wl.Listener(void) = wl.Listener(void).init(handleSetTitle),
set_app_id: wl.Listener(void) = wl.Listener(void).init(handleSetAppId),
pub fn create(xdg_toplevel: *wlr.XdgToplevel) error{OutOfMemory}!void {
const view = try View.create(.{ .xdg_toplevel = .{
pub fn create(wlr_toplevel: *wlr.XdgToplevel) error{OutOfMemory}!void {
const view = try View.create(.{ .toplevel = .{
.view = undefined,
.xdg_toplevel = xdg_toplevel,
.wlr_toplevel = wlr_toplevel,
} });
errdefer view.destroy();
const self = &view.impl.xdg_toplevel;
const toplevel = &view.impl.toplevel;
// This listener must be added before the scene xdg surface is created.
// Otherwise, the scene surface nodes will already be disabled by the unmap
@ -93,38 +93,38 @@ pub fn create(xdg_toplevel: *wlr.XdgToplevel) error{OutOfMemory}!void {
// so that we can save the buffers for frame perfection.
// TODO(wlroots) This is fragile, it would be good if wlroots gave us a
// better alternative here.
xdg_toplevel.base.surface.events.unmap.add(&self.unmap);
errdefer self.unmap.link.remove();
wlr_toplevel.base.surface.events.unmap.add(&toplevel.unmap);
errdefer toplevel.unmap.link.remove();
_ = try view.surface_tree.createSceneXdgSurface(xdg_toplevel.base);
_ = try view.surface_tree.createSceneXdgSurface(wlr_toplevel.base);
self.view = view;
toplevel.view = view;
xdg_toplevel.base.data = @intFromPtr(self);
xdg_toplevel.base.surface.data = @intFromPtr(&view.tree.node);
wlr_toplevel.base.data = @intFromPtr(toplevel);
wlr_toplevel.base.surface.data = @intFromPtr(&view.tree.node);
// Add listeners that are active over the toplevel's entire lifetime
xdg_toplevel.base.events.destroy.add(&self.destroy);
xdg_toplevel.base.surface.events.map.add(&self.map);
xdg_toplevel.base.events.new_popup.add(&self.new_popup);
wlr_toplevel.base.events.destroy.add(&toplevel.destroy);
wlr_toplevel.base.surface.events.map.add(&toplevel.map);
wlr_toplevel.base.events.new_popup.add(&toplevel.new_popup);
_ = xdg_toplevel.setWmCapabilities(.{ .fullscreen = true });
_ = wlr_toplevel.setWmCapabilities(.{ .fullscreen = true });
}
/// Send a configure event, applying the inflight state of the view.
pub fn configure(self: *Self) bool {
switch (self.configure_state) {
pub fn configure(toplevel: *XdgToplevel) bool {
switch (toplevel.configure_state) {
.idle, .timed_out, .timed_out_acked => {},
.inflight, .acked, .committed => unreachable,
}
defer switch (self.configure_state) {
defer switch (toplevel.configure_state) {
.idle, .inflight, .acked => {},
.timed_out, .timed_out_acked, .committed => unreachable,
};
const inflight = &self.view.inflight;
const current = &self.view.current;
const inflight = &toplevel.view.inflight;
const current = &toplevel.view.current;
const inflight_float = inflight.float or (inflight.output != null and inflight.output.?.layout == null);
const current_float = current.float or (current.output != null and current.output.?.layout == null);
@ -142,167 +142,167 @@ pub fn configure(self: *Self) bool {
{
// If no new configure is required, continue to track a timed out configure
// from the previous transaction if any.
switch (self.configure_state) {
switch (toplevel.configure_state) {
.idle => return false,
.timed_out => |serial| {
self.configure_state = .{ .inflight = serial };
toplevel.configure_state = .{ .inflight = serial };
return true;
},
.timed_out_acked => {
self.configure_state = .acked;
toplevel.configure_state = .acked;
return true;
},
.inflight, .acked, .committed => unreachable,
}
}
_ = self.xdg_toplevel.setActivated(inflight.focus != 0);
const wlr_toplevel = toplevel.wlr_toplevel;
_ = self.xdg_toplevel.setFullscreen(inflight.fullscreen);
_ = wlr_toplevel.setActivated(inflight.focus != 0);
_ = wlr_toplevel.setFullscreen(inflight.fullscreen);
_ = wlr_toplevel.setResizing(inflight.resizing);
if (inflight_float) {
_ = self.xdg_toplevel.setTiled(.{ .top = false, .bottom = false, .left = false, .right = false });
_ = wlr_toplevel.setTiled(.{ .top = false, .bottom = false, .left = false, .right = false });
} else {
_ = self.xdg_toplevel.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true });
_ = wlr_toplevel.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true });
}
if (self.decoration) |decoration| {
if (toplevel.decoration) |decoration| {
_ = decoration.wlr_decoration.setMode(if (inflight.ssd) .server_side else .client_side);
}
_ = self.xdg_toplevel.setResizing(inflight.resizing);
// We need to call this wlroots function even if the inflight dimensions
// match the current dimensions in order to prevent wlroots internal state
// from getting out of sync in the case where a client has resized itself.
const configure_serial = self.xdg_toplevel.setSize(inflight.box.width, inflight.box.height);
// from getting out of sync in the case where a client has resized ittoplevel.
const configure_serial = wlr_toplevel.setSize(inflight.box.width, inflight.box.height);
// Only track configures with the transaction system if they affect the dimensions of the view.
// If the configure state is not idle this means we are currently tracking a timed out
// configure from a previous transaction and should instead track the newly sent configure.
if (inflight.box.width == current.box.width and
inflight.box.height == current.box.height and
self.configure_state == .idle)
toplevel.configure_state == .idle)
{
return false;
}
self.configure_state = .{
toplevel.configure_state = .{
.inflight = configure_serial,
};
return true;
}
pub fn rootSurface(self: Self) *wlr.Surface {
return self.xdg_toplevel.base.surface;
pub fn rootSurface(toplevel: XdgToplevel) *wlr.Surface {
return toplevel.wlr_toplevel.base.surface;
}
/// Close the view. This will lead to the unmap and destroy events being sent
pub fn close(self: Self) void {
self.xdg_toplevel.sendClose();
pub fn close(toplevel: XdgToplevel) void {
toplevel.wlr_toplevel.sendClose();
}
/// Return the current title of the toplevel if any.
pub fn getTitle(self: Self) ?[*:0]const u8 {
return self.xdg_toplevel.title;
pub fn getTitle(toplevel: XdgToplevel) ?[*:0]const u8 {
return toplevel.wlr_toplevel.title;
}
/// Return the current app_id of the toplevel if any .
pub fn getAppId(self: Self) ?[*:0]const u8 {
return self.xdg_toplevel.app_id;
pub fn getAppId(toplevel: XdgToplevel) ?[*:0]const u8 {
return toplevel.wlr_toplevel.app_id;
}
pub fn destroyPopups(self: Self) void {
var it = self.xdg_toplevel.base.popups.safeIterator(.forward);
pub fn destroyPopups(toplevel: XdgToplevel) void {
var it = toplevel.wlr_toplevel.base.popups.safeIterator(.forward);
while (it.next()) |wlr_xdg_popup| wlr_xdg_popup.destroy();
}
fn handleDestroy(listener: *wl.Listener(void)) void {
const self = @fieldParentPtr(Self, "destroy", listener);
const toplevel = @fieldParentPtr(XdgToplevel, "destroy", listener);
// This can be be non-null here if the client commits a protocol error or
// if it exits without destroying its wayland objects.
if (self.decoration) |*decoration| {
if (toplevel.decoration) |*decoration| {
decoration.deinit();
}
assert(self.decoration == null);
assert(toplevel.decoration == null);
// Remove listeners that are active for the entire lifetime of the view
self.destroy.link.remove();
self.map.link.remove();
self.unmap.link.remove();
toplevel.destroy.link.remove();
toplevel.map.link.remove();
toplevel.unmap.link.remove();
// The wlr_surface may outlive the wlr_xdg_surface so we must clean up the user data.
self.xdg_toplevel.base.surface.data = 0;
toplevel.wlr_toplevel.base.surface.data = 0;
const view = self.view;
const view = toplevel.view;
view.impl = .none;
view.destroy();
}
fn handleMap(listener: *wl.Listener(void)) void {
const self = @fieldParentPtr(Self, "map", listener);
const view = self.view;
const toplevel = @fieldParentPtr(XdgToplevel, "map", listener);
const view = toplevel.view;
// Add listeners that are only active while mapped
self.xdg_toplevel.base.events.ack_configure.add(&self.ack_configure);
self.xdg_toplevel.base.surface.events.commit.add(&self.commit);
self.xdg_toplevel.events.request_fullscreen.add(&self.request_fullscreen);
self.xdg_toplevel.events.request_move.add(&self.request_move);
self.xdg_toplevel.events.request_resize.add(&self.request_resize);
self.xdg_toplevel.events.set_title.add(&self.set_title);
self.xdg_toplevel.events.set_app_id.add(&self.set_app_id);
toplevel.wlr_toplevel.base.events.ack_configure.add(&toplevel.ack_configure);
toplevel.wlr_toplevel.base.surface.events.commit.add(&toplevel.commit);
toplevel.wlr_toplevel.events.request_fullscreen.add(&toplevel.request_fullscreen);
toplevel.wlr_toplevel.events.request_move.add(&toplevel.request_move);
toplevel.wlr_toplevel.events.request_resize.add(&toplevel.request_resize);
toplevel.wlr_toplevel.events.set_title.add(&toplevel.set_title);
toplevel.wlr_toplevel.events.set_app_id.add(&toplevel.set_app_id);
self.xdg_toplevel.base.getGeometry(&self.geometry);
toplevel.wlr_toplevel.base.getGeometry(&toplevel.geometry);
view.pending.box = .{
.x = 0,
.y = 0,
.width = self.geometry.width,
.height = self.geometry.height,
.width = toplevel.geometry.width,
.height = toplevel.geometry.height,
};
view.inflight.box = view.pending.box;
view.current.box = view.pending.box;
const state = &self.xdg_toplevel.current;
const state = &toplevel.wlr_toplevel.current;
const has_fixed_size = state.min_width != 0 and state.min_height != 0 and
(state.min_width == state.max_width or state.min_height == state.max_height);
if (self.xdg_toplevel.parent != null or has_fixed_size) {
// If the self.xdg_toplevel has a parent or has a fixed size make it float.
if (toplevel.wlr_toplevel.parent != null or has_fixed_size) {
// If the toplevel.wlr_toplevel has a parent or has a fixed size make it float.
// This will be overwritten in View.map() if the view is matched by a rule.
view.pending.float = true;
}
self.view.pending.fullscreen = self.xdg_toplevel.requested.fullscreen;
toplevel.view.pending.fullscreen = toplevel.wlr_toplevel.requested.fullscreen;
view.map() catch {
log.err("out of memory", .{});
self.xdg_toplevel.resource.getClient().postNoMemory();
toplevel.wlr_toplevel.resource.getClient().postNoMemory();
};
}
/// Called when the surface is unmapped and will no longer be displayed.
fn handleUnmap(listener: *wl.Listener(void)) void {
const self = @fieldParentPtr(Self, "unmap", listener);
const toplevel = @fieldParentPtr(XdgToplevel, "unmap", listener);
// Remove listeners that are only active while mapped
self.ack_configure.link.remove();
self.commit.link.remove();
self.request_fullscreen.link.remove();
self.request_move.link.remove();
self.request_resize.link.remove();
self.set_title.link.remove();
self.set_app_id.link.remove();
toplevel.ack_configure.link.remove();
toplevel.commit.link.remove();
toplevel.request_fullscreen.link.remove();
toplevel.request_move.link.remove();
toplevel.request_resize.link.remove();
toplevel.set_title.link.remove();
toplevel.set_app_id.link.remove();
self.view.unmap();
toplevel.view.unmap();
}
fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), wlr_xdg_popup: *wlr.XdgPopup) void {
const self = @fieldParentPtr(Self, "new_popup", listener);
const toplevel = @fieldParentPtr(XdgToplevel, "new_popup", listener);
XdgPopup.create(wlr_xdg_popup, self.view.popup_tree, self.view.popup_tree) catch {
XdgPopup.create(wlr_xdg_popup, toplevel.view.popup_tree, toplevel.view.popup_tree) catch {
wlr_xdg_popup.resource.postNoMemory();
return;
};
@ -312,24 +312,24 @@ fn handleAckConfigure(
listener: *wl.Listener(*wlr.XdgSurface.Configure),
acked_configure: *wlr.XdgSurface.Configure,
) void {
const self = @fieldParentPtr(Self, "ack_configure", listener);
switch (self.configure_state) {
const toplevel = @fieldParentPtr(XdgToplevel, "ack_configure", listener);
switch (toplevel.configure_state) {
.inflight => |serial| if (acked_configure.serial == serial) {
self.configure_state = .acked;
toplevel.configure_state = .acked;
},
.timed_out => |serial| if (acked_configure.serial == serial) {
self.configure_state = .timed_out_acked;
toplevel.configure_state = .timed_out_acked;
},
.acked, .idle, .committed, .timed_out_acked => {},
}
}
fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
const self = @fieldParentPtr(Self, "commit", listener);
const view = self.view;
const toplevel = @fieldParentPtr(XdgToplevel, "commit", listener);
const view = toplevel.view;
{
const state = &self.xdg_toplevel.current;
const state = &toplevel.wlr_toplevel.current;
view.constraints = .{
.min_width = @max(state.min_width, 1),
.max_width = if (state.max_width > 0) @intCast(state.max_width) else math.maxInt(u31),
@ -338,19 +338,19 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
};
}
const old_geometry = self.geometry;
self.xdg_toplevel.base.getGeometry(&self.geometry);
const old_geometry = toplevel.geometry;
toplevel.wlr_toplevel.base.getGeometry(&toplevel.geometry);
switch (self.configure_state) {
switch (toplevel.configure_state) {
.idle, .committed, .timed_out => {
const size_changed = self.geometry.width != old_geometry.width or
self.geometry.height != old_geometry.height;
const size_changed = toplevel.geometry.width != old_geometry.width or
toplevel.geometry.height != old_geometry.height;
const no_layout = view.current.output != null and view.current.output.?.layout == null;
if (size_changed) {
log.debug(
"client initiated size change: {}x{} -> {}x{}",
.{ old_geometry.width, old_geometry.height, self.geometry.width, self.geometry.height },
.{ old_geometry.width, old_geometry.height, toplevel.geometry.width, toplevel.geometry.height },
);
if (!(view.current.float or no_layout) and !view.current.fullscreen) {
// It seems that a disappointingly high number of clients have a buggy
@ -365,10 +365,10 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
});
}
view.inflight.box.width = self.geometry.width;
view.inflight.box.height = self.geometry.height;
view.pending.box.width = self.geometry.width;
view.pending.box.height = self.geometry.height;
view.inflight.box.width = toplevel.geometry.width;
view.inflight.box.height = toplevel.geometry.height;
view.pending.box.width = toplevel.geometry.width;
view.pending.box.height = toplevel.geometry.height;
view.current = view.inflight;
view.updateSceneState();
}
@ -380,21 +380,21 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
.inflight => view.sendFrameDone(),
.acked, .timed_out_acked => {
if (view.inflight.resizing) {
view.resizeUpdatePosition(self.geometry.width, self.geometry.height);
view.resizeUpdatePosition(toplevel.geometry.width, toplevel.geometry.height);
}
view.inflight.box.width = self.geometry.width;
view.inflight.box.height = self.geometry.height;
view.pending.box.width = self.geometry.width;
view.pending.box.height = self.geometry.height;
view.inflight.box.width = toplevel.geometry.width;
view.inflight.box.height = toplevel.geometry.height;
view.pending.box.width = toplevel.geometry.width;
view.pending.box.height = toplevel.geometry.height;
switch (self.configure_state) {
switch (toplevel.configure_state) {
.acked => {
self.configure_state = .committed;
toplevel.configure_state = .committed;
server.root.notifyConfigured();
},
.timed_out_acked => {
self.configure_state = .idle;
toplevel.configure_state = .idle;
view.current = view.inflight;
view.updateSceneState();
},
@ -407,9 +407,9 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
/// Called when the client asks to be fullscreened. We always honor the request
/// for now, perhaps it should be denied in some cases in the future.
fn handleRequestFullscreen(listener: *wl.Listener(void)) void {
const self = @fieldParentPtr(Self, "request_fullscreen", listener);
if (self.view.pending.fullscreen != self.xdg_toplevel.requested.fullscreen) {
self.view.pending.fullscreen = self.xdg_toplevel.requested.fullscreen;
const toplevel = @fieldParentPtr(XdgToplevel, "request_fullscreen", listener);
if (toplevel.view.pending.fullscreen != toplevel.wlr_toplevel.requested.fullscreen) {
toplevel.view.pending.fullscreen = toplevel.wlr_toplevel.requested.fullscreen;
server.root.applyPending();
}
}
@ -418,9 +418,9 @@ fn handleRequestMove(
listener: *wl.Listener(*wlr.XdgToplevel.event.Move),
event: *wlr.XdgToplevel.event.Move,
) void {
const self = @fieldParentPtr(Self, "request_move", listener);
const toplevel = @fieldParentPtr(XdgToplevel, "request_move", listener);
const seat: *Seat = @ptrFromInt(event.seat.seat.data);
const view = self.view;
const view = toplevel.view;
if (view.current.output == null or view.pending.output == null) return;
if (view.current.tags & view.current.output.?.current.tags == 0) return;
@ -434,9 +434,9 @@ fn handleRequestMove(
}
fn handleRequestResize(listener: *wl.Listener(*wlr.XdgToplevel.event.Resize), event: *wlr.XdgToplevel.event.Resize) void {
const self = @fieldParentPtr(Self, "request_resize", listener);
const toplevel = @fieldParentPtr(XdgToplevel, "request_resize", listener);
const seat: *Seat = @ptrFromInt(event.seat.seat.data);
const view = self.view;
const view = toplevel.view;
if (view.current.output == null or view.pending.output == null) return;
if (view.current.tags & view.current.output.?.current.tags == 0) return;
@ -451,12 +451,12 @@ fn handleRequestResize(listener: *wl.Listener(*wlr.XdgToplevel.event.Resize), ev
/// Called when the client sets / updates its title
fn handleSetTitle(listener: *wl.Listener(void)) void {
const self = @fieldParentPtr(Self, "set_title", listener);
self.view.notifyTitle();
const toplevel = @fieldParentPtr(XdgToplevel, "set_title", listener);
toplevel.view.notifyTitle();
}
/// Called when the client sets / updates its app_id
fn handleSetAppId(listener: *wl.Listener(void)) void {
const self = @fieldParentPtr(Self, "set_app_id", listener);
self.view.notifyAppId();
const toplevel = @fieldParentPtr(XdgToplevel, "set_app_id", listener);
toplevel.view.notifyAppId();
}