View: use last set fullscreen state in applyPending()
This avoids a race where the fullscreen set is e.g. set then unset before the transaction has been completed and the current state has been updated.
This commit is contained in:
parent
be870e058d
commit
147d9c2f90
@ -179,7 +179,7 @@ pub fn applyPending(self: *Self) void {
|
|||||||
self.pending.box = self.float_box;
|
self.pending.box = self.float_box;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self.current.fullscreen and self.pending.fullscreen) {
|
if (!self.lastSetFullscreenState() and self.pending.fullscreen) {
|
||||||
// If switching to fullscreen, set the dimensions to the full area of the output
|
// If switching to fullscreen, set the dimensions to the full area of the output
|
||||||
self.setFullscreen(true);
|
self.setFullscreen(true);
|
||||||
self.post_fullscreen_box = self.current.box;
|
self.post_fullscreen_box = self.current.box;
|
||||||
@ -190,7 +190,7 @@ pub fn applyPending(self: *Self) void {
|
|||||||
.width = dimensions.width,
|
.width = dimensions.width,
|
||||||
.height = dimensions.height,
|
.height = dimensions.height,
|
||||||
};
|
};
|
||||||
} else if (self.current.fullscreen and !self.pending.fullscreen) {
|
} else if (self.lastSetFullscreenState() and !self.pending.fullscreen) {
|
||||||
self.setFullscreen(false);
|
self.setFullscreen(false);
|
||||||
self.pending.box = self.post_fullscreen_box;
|
self.pending.box = self.post_fullscreen_box;
|
||||||
}
|
}
|
||||||
@ -219,6 +219,13 @@ pub fn configure(self: *Self) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn lastSetFullscreenState(self: Self) bool {
|
||||||
|
return switch (self.impl) {
|
||||||
|
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.lastSetFullscreenState(),
|
||||||
|
.xwayland_view => |xwayland_view| xwayland_view.lastSetFullscreenState(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn sendFrameDone(self: Self) void {
|
pub fn sendFrameDone(self: Self) void {
|
||||||
var now: os.timespec = undefined;
|
var now: os.timespec = undefined;
|
||||||
os.clock_gettime(os.CLOCK.MONOTONIC, &now) catch @panic("CLOCK_MONOTONIC not supported");
|
os.clock_gettime(os.CLOCK.MONOTONIC, &now) catch @panic("CLOCK_MONOTONIC not supported");
|
||||||
@ -330,11 +337,11 @@ pub fn setActivated(self: Self, activated: bool) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setFullscreen(self: Self, fullscreen: bool) void {
|
fn setFullscreen(self: *Self, fullscreen: bool) void {
|
||||||
if (self.foreign_toplevel_handle) |handle| handle.setFullscreen(fullscreen);
|
if (self.foreign_toplevel_handle) |handle| handle.setFullscreen(fullscreen);
|
||||||
switch (self.impl) {
|
switch (self.impl) {
|
||||||
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.setFullscreen(fullscreen),
|
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.setFullscreen(fullscreen),
|
||||||
.xwayland_view => |xwayland_view| xwayland_view.setFullscreen(fullscreen),
|
.xwayland_view => |*xwayland_view| xwayland_view.setFullscreen(fullscreen),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,10 @@ pub fn configure(_: Self) void {
|
|||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn lastSetFullscreenState(_: Self) bool {
|
||||||
|
unreachable;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn setActivated(_: Self, _: bool) void {
|
pub fn setActivated(_: Self, _: bool) void {
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,10 @@ pub fn configure(self: *Self) void {
|
|||||||
self.acked_pending_serial = false;
|
self.acked_pending_serial = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn lastSetFullscreenState(self: Self) bool {
|
||||||
|
return self.xdg_surface.role_data.toplevel.scheduled.fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
/// Close the view. This will lead to the unmap and destroy events being sent
|
/// Close the view. This will lead to the unmap and destroy events being sent
|
||||||
pub fn close(self: Self) void {
|
pub fn close(self: Self) void {
|
||||||
self.xdg_surface.role_data.toplevel.sendClose();
|
self.xdg_surface.role_data.toplevel.sendClose();
|
||||||
|
@ -34,6 +34,11 @@ view: *View,
|
|||||||
/// The corresponding wlroots object
|
/// The corresponding wlroots object
|
||||||
xwayland_surface: *wlr.XwaylandSurface,
|
xwayland_surface: *wlr.XwaylandSurface,
|
||||||
|
|
||||||
|
/// The wlroots Xwayland implementation overwrites xwayland_surface.fullscreen
|
||||||
|
/// immediately when the client requests it, so we track this state here to be
|
||||||
|
/// able to match the XdgToplevel API.
|
||||||
|
last_set_fullscreen_state: bool,
|
||||||
|
|
||||||
// Listeners that are always active over the view's lifetime
|
// Listeners that are always active over the view's lifetime
|
||||||
destroy: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleDestroy),
|
destroy: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleDestroy),
|
||||||
map: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleMap),
|
map: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleMap),
|
||||||
@ -51,7 +56,11 @@ request_minimize: wl.Listener(*wlr.XwaylandSurface.event.Minimize) =
|
|||||||
wl.Listener(*wlr.XwaylandSurface.event.Minimize).init(handleRequestMinimize),
|
wl.Listener(*wlr.XwaylandSurface.event.Minimize).init(handleRequestMinimize),
|
||||||
|
|
||||||
pub fn init(self: *Self, view: *View, xwayland_surface: *wlr.XwaylandSurface) void {
|
pub fn init(self: *Self, view: *View, xwayland_surface: *wlr.XwaylandSurface) void {
|
||||||
self.* = .{ .view = view, .xwayland_surface = xwayland_surface };
|
self.* = .{
|
||||||
|
.view = view,
|
||||||
|
.xwayland_surface = xwayland_surface,
|
||||||
|
.last_set_fullscreen_state = xwayland_surface.fullscreen,
|
||||||
|
};
|
||||||
xwayland_surface.data = @ptrToInt(self);
|
xwayland_surface.data = @ptrToInt(self);
|
||||||
|
|
||||||
// Add listeners that are active over the view's entire lifetime
|
// Add listeners that are active over the view's entire lifetime
|
||||||
@ -85,6 +94,10 @@ pub fn configure(self: Self) void {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn lastSetFullscreenState(self: Self) bool {
|
||||||
|
return self.last_set_fullscreen_state;
|
||||||
|
}
|
||||||
|
|
||||||
/// Close the view. This will lead to the unmap and destroy events being sent
|
/// Close the view. This will lead to the unmap and destroy events being sent
|
||||||
pub fn close(self: Self) void {
|
pub fn close(self: Self) void {
|
||||||
self.xwayland_surface.close();
|
self.xwayland_surface.close();
|
||||||
@ -99,7 +112,8 @@ pub fn setActivated(self: Self, activated: bool) void {
|
|||||||
self.xwayland_surface.restack(null, .above);
|
self.xwayland_surface.restack(null, .above);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setFullscreen(self: Self, fullscreen: bool) void {
|
pub fn setFullscreen(self: *Self, fullscreen: bool) void {
|
||||||
|
self.last_set_fullscreen_state = fullscreen;
|
||||||
self.xwayland_surface.setFullscreen(fullscreen);
|
self.xwayland_surface.setFullscreen(fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user