session-lock: handle output unplugging better
This commit is contained in:
parent
33187e0b09
commit
49efbfe046
@ -72,7 +72,7 @@ fn handleMap(listener: *wl.Listener(*wlr.Drag.Icon), wlr_drag_icon: *wlr.Drag.Ic
|
|||||||
|
|
||||||
wlr_drag_icon.surface.events.commit.add(&drag_icon.commit);
|
wlr_drag_icon.surface.events.commit.add(&drag_icon.commit);
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.outputs.first;
|
||||||
while (it) |node| : (it = node.next) node.data.damage.addWhole();
|
while (it) |node| : (it = node.next) node.data.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleUnmap(listener: *wl.Listener(*wlr.Drag.Icon), _: *wlr.Drag.Icon) void {
|
fn handleUnmap(listener: *wl.Listener(*wlr.Drag.Icon), _: *wlr.Drag.Icon) void {
|
||||||
@ -80,12 +80,12 @@ fn handleUnmap(listener: *wl.Listener(*wlr.Drag.Icon), _: *wlr.Drag.Icon) void {
|
|||||||
|
|
||||||
drag_icon.commit.link.remove();
|
drag_icon.commit.link.remove();
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.outputs.first;
|
||||||
while (it) |node| : (it = node.next) node.data.damage.addWhole();
|
while (it) |node| : (it = node.next) node.data.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleCommit(_: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
fn handleCommit(_: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.outputs.first;
|
||||||
while (it) |node| : (it = node.next) node.data.damage.addWhole();
|
while (it) |node| : (it = node.next) node.data.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleNewSubsurface(listener: *wl.Listener(*wlr.Subsurface), wlr_subsurface: *wlr.Subsurface) void {
|
fn handleNewSubsurface(listener: *wl.Listener(*wlr.Subsurface), wlr_subsurface: *wlr.Subsurface) void {
|
||||||
|
@ -164,7 +164,7 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
|||||||
server.root.startTransaction();
|
server.root.startTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.output.damage.addWhole();
|
self.output.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), wlr_xdg_popup: *wlr.XdgPopup) void {
|
fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), wlr_xdg_popup: *wlr.XdgPopup) void {
|
||||||
|
@ -120,5 +120,5 @@ fn handleSurface(
|
|||||||
assert(manager.locked);
|
assert(manager.locked);
|
||||||
assert(manager.lock != null);
|
assert(manager.lock != null);
|
||||||
|
|
||||||
LockSurface.create(wlr_lock_surface);
|
LockSurface.create(wlr_lock_surface, manager.lock.?);
|
||||||
}
|
}
|
||||||
|
@ -24,17 +24,19 @@ const server = &@import("main.zig").server;
|
|||||||
const util = @import("util.zig");
|
const util = @import("util.zig");
|
||||||
|
|
||||||
const Output = @import("Output.zig");
|
const Output = @import("Output.zig");
|
||||||
|
const Seat = @import("Seat.zig");
|
||||||
const Subsurface = @import("Subsurface.zig");
|
const Subsurface = @import("Subsurface.zig");
|
||||||
|
|
||||||
wlr_lock_surface: *wlr.SessionLockSurfaceV1,
|
wlr_lock_surface: *wlr.SessionLockSurfaceV1,
|
||||||
|
lock: *wlr.SessionLockV1,
|
||||||
|
|
||||||
output_mode: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleOutputMode),
|
output_mode: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleOutputMode),
|
||||||
map: wl.Listener(void) = wl.Listener(void).init(handleMap),
|
map: wl.Listener(void) = wl.Listener(void).init(handleMap),
|
||||||
destroy: wl.Listener(void) = wl.Listener(void).init(handleDestroy),
|
surface_destroy: wl.Listener(void) = wl.Listener(void).init(handleDestroy),
|
||||||
commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit),
|
commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit),
|
||||||
new_subsurface: wl.Listener(*wlr.Subsurface) = wl.Listener(*wlr.Subsurface).init(handleSubsurface),
|
new_subsurface: wl.Listener(*wlr.Subsurface) = wl.Listener(*wlr.Subsurface).init(handleSubsurface),
|
||||||
|
|
||||||
pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1) void {
|
pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1, lock: *wlr.SessionLockV1) void {
|
||||||
const lock_surface = util.gpa.create(LockSurface) catch {
|
const lock_surface = util.gpa.create(LockSurface) catch {
|
||||||
wlr_lock_surface.resource.getClient().postNoMemory();
|
wlr_lock_surface.resource.getClient().postNoMemory();
|
||||||
return;
|
return;
|
||||||
@ -42,10 +44,13 @@ pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1) void {
|
|||||||
|
|
||||||
lock_surface.* = .{
|
lock_surface.* = .{
|
||||||
.wlr_lock_surface = wlr_lock_surface,
|
.wlr_lock_surface = wlr_lock_surface,
|
||||||
|
.lock = lock,
|
||||||
};
|
};
|
||||||
|
wlr_lock_surface.data = @ptrToInt(lock_surface);
|
||||||
|
|
||||||
wlr_lock_surface.output.events.mode.add(&lock_surface.output_mode);
|
wlr_lock_surface.output.events.mode.add(&lock_surface.output_mode);
|
||||||
wlr_lock_surface.events.map.add(&lock_surface.map);
|
wlr_lock_surface.events.map.add(&lock_surface.map);
|
||||||
wlr_lock_surface.events.destroy.add(&lock_surface.destroy);
|
wlr_lock_surface.events.destroy.add(&lock_surface.surface_destroy);
|
||||||
wlr_lock_surface.surface.events.commit.add(&lock_surface.commit);
|
wlr_lock_surface.surface.events.commit.add(&lock_surface.commit);
|
||||||
wlr_lock_surface.surface.events.new_subsurface.add(&lock_surface.new_subsurface);
|
wlr_lock_surface.surface.events.new_subsurface.add(&lock_surface.new_subsurface);
|
||||||
|
|
||||||
@ -54,6 +59,38 @@ pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1) void {
|
|||||||
Subsurface.handleExisting(wlr_lock_surface.surface, .{ .lock_surface = lock_surface });
|
Subsurface.handleExisting(wlr_lock_surface.surface, .{ .lock_surface = lock_surface });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn destroy(lock_surface: *LockSurface) void {
|
||||||
|
lock_surface.output().lock_surface = null;
|
||||||
|
if (lock_surface.output().damage) |damage| damage.addWhole();
|
||||||
|
|
||||||
|
{
|
||||||
|
var surface_it = lock_surface.lock.surfaces.iterator(.forward);
|
||||||
|
const new_focus: Seat.FocusTarget = while (surface_it.next()) |surface| {
|
||||||
|
if (surface != lock_surface.wlr_lock_surface)
|
||||||
|
break .{ .lock_surface = @intToPtr(*LockSurface, surface.data) };
|
||||||
|
} else .none;
|
||||||
|
|
||||||
|
var seat_it = server.input_manager.seats.first;
|
||||||
|
while (seat_it) |node| : (seat_it = node.next) {
|
||||||
|
const seat = &node.data;
|
||||||
|
if (seat.focused == .lock_surface and seat.focused.lock_surface == lock_surface) {
|
||||||
|
seat.setFocusRaw(new_focus);
|
||||||
|
}
|
||||||
|
seat.cursor.updateState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lock_surface.output_mode.link.remove();
|
||||||
|
lock_surface.map.link.remove();
|
||||||
|
lock_surface.surface_destroy.link.remove();
|
||||||
|
lock_surface.commit.link.remove();
|
||||||
|
lock_surface.new_subsurface.link.remove();
|
||||||
|
|
||||||
|
Subsurface.destroySubsurfaces(lock_surface.wlr_lock_surface.surface);
|
||||||
|
|
||||||
|
util.gpa.destroy(lock_surface);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn output(lock_surface: *LockSurface) *Output {
|
pub fn output(lock_surface: *LockSurface) *Output {
|
||||||
return @intToPtr(*Output, lock_surface.wlr_lock_surface.output.data);
|
return @intToPtr(*Output, lock_surface.wlr_lock_surface.output.data);
|
||||||
}
|
}
|
||||||
@ -84,37 +121,15 @@ fn handleMap(listener: *wl.Listener(void)) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handleDestroy(listener: *wl.Listener(void)) void {
|
fn handleDestroy(listener: *wl.Listener(void)) void {
|
||||||
const lock_surface = @fieldParentPtr(LockSurface, "destroy", listener);
|
const lock_surface = @fieldParentPtr(LockSurface, "surface_destroy", listener);
|
||||||
|
|
||||||
lock_surface.output().lock_surface = null;
|
lock_surface.destroy();
|
||||||
lock_surface.output().damage.addWhole();
|
|
||||||
|
|
||||||
{
|
|
||||||
var it = server.input_manager.seats.first;
|
|
||||||
while (it) |node| : (it = node.next) {
|
|
||||||
const seat = &node.data;
|
|
||||||
if (seat.focused == .lock_surface and seat.focused.lock_surface == lock_surface) {
|
|
||||||
seat.setFocusRaw(.none);
|
|
||||||
}
|
|
||||||
seat.cursor.updateState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lock_surface.output_mode.link.remove();
|
|
||||||
lock_surface.map.link.remove();
|
|
||||||
lock_surface.destroy.link.remove();
|
|
||||||
lock_surface.commit.link.remove();
|
|
||||||
lock_surface.new_subsurface.link.remove();
|
|
||||||
|
|
||||||
Subsurface.destroySubsurfaces(lock_surface.wlr_lock_surface.surface);
|
|
||||||
|
|
||||||
util.gpa.destroy(lock_surface);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
||||||
const lock_surface = @fieldParentPtr(LockSurface, "commit", listener);
|
const lock_surface = @fieldParentPtr(LockSurface, "commit", listener);
|
||||||
|
|
||||||
lock_surface.output().damage.addWhole();
|
lock_surface.output().damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleSubsurface(listener: *wl.Listener(*wlr.Subsurface), subsurface: *wlr.Subsurface) void {
|
fn handleSubsurface(listener: *wl.Listener(*wlr.Subsurface), subsurface: *wlr.Subsurface) void {
|
||||||
|
@ -55,7 +55,7 @@ const State = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
wlr_output: *wlr.Output,
|
wlr_output: *wlr.Output,
|
||||||
damage: *wlr.OutputDamage,
|
damage: ?*wlr.OutputDamage,
|
||||||
|
|
||||||
/// All layer surfaces on the output, indexed by the layer enum.
|
/// All layer surfaces on the output, indexed by the layer enum.
|
||||||
layers: [4]std.TailQueue(LayerSurface) = [1]std.TailQueue(LayerSurface){.{}} ** 4,
|
layers: [4]std.TailQueue(LayerSurface) = [1]std.TailQueue(LayerSurface){.{}} ** 4,
|
||||||
@ -136,8 +136,8 @@ pub fn init(self: *Self, wlr_output: *wlr.Output) !void {
|
|||||||
wlr_output.events.enable.add(&self.enable);
|
wlr_output.events.enable.add(&self.enable);
|
||||||
wlr_output.events.mode.add(&self.mode);
|
wlr_output.events.mode.add(&self.mode);
|
||||||
|
|
||||||
self.damage.events.frame.add(&self.frame);
|
self.damage.?.events.frame.add(&self.frame);
|
||||||
self.damage.events.destroy.add(&self.damage_destroy);
|
self.damage.?.events.destroy.add(&self.damage_destroy);
|
||||||
|
|
||||||
// Ensure that a cursor image at the output's scale factor is loaded
|
// Ensure that a cursor image at the output's scale factor is loaded
|
||||||
// for each seat.
|
// for each seat.
|
||||||
@ -431,6 +431,8 @@ fn handleDamageDestroy(listener: *wl.Listener(*wlr.OutputDamage), _: *wlr.Output
|
|||||||
self.frame.link.remove();
|
self.frame.link.remove();
|
||||||
// Ensure that it is safe to call remove() again in handleDestroy()
|
// Ensure that it is safe to call remove() again in handleDestroy()
|
||||||
self.frame.link = .{ .prev = &self.frame.link, .next = &self.frame.link };
|
self.frame.link = .{ .prev = &self.frame.link, .next = &self.frame.link };
|
||||||
|
|
||||||
|
self.damage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
|
fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
|
||||||
@ -452,6 +454,8 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.lock_surface) |surface| surface.destroy();
|
||||||
|
|
||||||
// Remove all listeners
|
// Remove all listeners
|
||||||
self.destroy.link.remove();
|
self.destroy.link.remove();
|
||||||
self.enable.link.remove();
|
self.enable.link.remove();
|
||||||
|
@ -392,7 +392,7 @@ fn commitTransaction(self: *Self) void {
|
|||||||
if (view_tags_changed) output.sendViewTags();
|
if (view_tags_changed) output.sendViewTags();
|
||||||
if (urgent_tags_dirty) output.sendUrgentTags();
|
if (urgent_tags_dirty) output.sendUrgentTags();
|
||||||
|
|
||||||
output.damage.addWhole();
|
output.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
server.input_manager.updateCursorState();
|
server.input_manager.updateCursorState();
|
||||||
server.idle_inhibitor_manager.idleInhibitCheckActive();
|
server.idle_inhibitor_manager.idleInhibitCheckActive();
|
||||||
|
@ -47,7 +47,7 @@ const XwaylandOverrideRedirect = @import("XwaylandOverrideRedirect.zig");
|
|||||||
const log = std.log.scoped(.seat);
|
const log = std.log.scoped(.seat);
|
||||||
const PointerConstraint = @import("PointerConstraint.zig");
|
const PointerConstraint = @import("PointerConstraint.zig");
|
||||||
|
|
||||||
const FocusTarget = union(enum) {
|
pub const FocusTarget = union(enum) {
|
||||||
view: *View,
|
view: *View,
|
||||||
xwayland_override_redirect: *XwaylandOverrideRedirect,
|
xwayland_override_redirect: *XwaylandOverrideRedirect,
|
||||||
layer: *LayerSurface,
|
layer: *LayerSurface,
|
||||||
|
@ -37,12 +37,12 @@ pub const Parent = union(enum) {
|
|||||||
|
|
||||||
pub fn damageWholeOutput(parent: Parent) void {
|
pub fn damageWholeOutput(parent: Parent) void {
|
||||||
switch (parent) {
|
switch (parent) {
|
||||||
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.view.output.damage.addWhole(),
|
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.view.output.damage.?.addWhole(),
|
||||||
.layer_surface => |layer_surface| layer_surface.output.damage.addWhole(),
|
.layer_surface => |layer_surface| layer_surface.output.damage.?.addWhole(),
|
||||||
.lock_surface => |lock_surface| lock_surface.output().damage.addWhole(),
|
.lock_surface => |lock_surface| lock_surface.output().damage.?.addWhole(),
|
||||||
.drag_icon => |_| {
|
.drag_icon => |_| {
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.outputs.first;
|
||||||
while (it) |node| : (it = node.next) node.data.damage.addWhole();
|
while (it) |node| : (it = node.next) node.data.damage.?.addWhole();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
|||||||
// before some change occured that caused shouldTrackConfigure() to return false.
|
// before some change occured that caused shouldTrackConfigure() to return false.
|
||||||
view.dropSavedBuffers();
|
view.dropSavedBuffers();
|
||||||
|
|
||||||
view.output.damage.addWhole();
|
view.output.damage.?.addWhole();
|
||||||
server.input_manager.updateCursorState();
|
server.input_manager.updateCursorState();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -309,7 +309,7 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
|||||||
view.sendFrameDone();
|
view.sendFrameDone();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
view.output.damage.addWhole();
|
view.output.damage.?.addWhole();
|
||||||
const size_changed = !std.meta.eql(view.surface_box, new_box);
|
const size_changed = !std.meta.eql(view.surface_box, new_box);
|
||||||
view.surface_box = new_box;
|
view.surface_box = new_box;
|
||||||
// If the client has decided to resize itself and the view is floating,
|
// If the client has decided to resize itself and the view is floating,
|
||||||
|
@ -130,7 +130,7 @@ fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSur
|
|||||||
|
|
||||||
fn handleCommit(_: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
fn handleCommit(_: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.outputs.first;
|
||||||
while (it) |node| : (it = node.next) node.data.damage.addWhole();
|
while (it) |node| : (it = node.next) node.data.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleSetOverrideRedirect(
|
fn handleSetOverrideRedirect(
|
||||||
|
@ -300,7 +300,7 @@ fn handleSetOverrideRedirect(
|
|||||||
fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void {
|
fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void {
|
||||||
const self = @fieldParentPtr(Self, "commit", listener);
|
const self = @fieldParentPtr(Self, "commit", listener);
|
||||||
|
|
||||||
self.view.output.damage.addWhole();
|
self.view.output.damage.?.addWhole();
|
||||||
|
|
||||||
self.view.surface_box = .{
|
self.view.surface_box = .{
|
||||||
.x = 0,
|
.x = 0,
|
||||||
|
@ -48,7 +48,7 @@ pub fn backgroundColor(
|
|||||||
server.config.background_color = try parseRgba(args[1]);
|
server.config.background_color = try parseRgba(args[1]);
|
||||||
|
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.outputs.first;
|
||||||
while (it) |node| : (it = node.next) node.data.damage.addWhole();
|
while (it) |node| : (it = node.next) node.data.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn borderColorFocused(
|
pub fn borderColorFocused(
|
||||||
@ -62,7 +62,7 @@ pub fn borderColorFocused(
|
|||||||
server.config.border_color_focused = try parseRgba(args[1]);
|
server.config.border_color_focused = try parseRgba(args[1]);
|
||||||
|
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.outputs.first;
|
||||||
while (it) |node| : (it = node.next) node.data.damage.addWhole();
|
while (it) |node| : (it = node.next) node.data.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn borderColorUnfocused(
|
pub fn borderColorUnfocused(
|
||||||
@ -76,7 +76,7 @@ pub fn borderColorUnfocused(
|
|||||||
server.config.border_color_unfocused = try parseRgba(args[1]);
|
server.config.border_color_unfocused = try parseRgba(args[1]);
|
||||||
|
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.outputs.first;
|
||||||
while (it) |node| : (it = node.next) node.data.damage.addWhole();
|
while (it) |node| : (it = node.next) node.data.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn borderColorUrgent(
|
pub fn borderColorUrgent(
|
||||||
@ -90,7 +90,7 @@ pub fn borderColorUrgent(
|
|||||||
server.config.border_color_urgent = try parseRgba(args[1]);
|
server.config.border_color_urgent = try parseRgba(args[1]);
|
||||||
|
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.outputs.first;
|
||||||
while (it) |node| : (it = node.next) node.data.damage.addWhole();
|
while (it) |node| : (it = node.next) node.data.damage.?.addWhole();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setCursorWarp(
|
pub fn setCursorWarp(
|
||||||
|
@ -51,7 +51,7 @@ pub fn renderOutput(output: *Output) void {
|
|||||||
var damage_region: pixman.Region32 = undefined;
|
var damage_region: pixman.Region32 = undefined;
|
||||||
damage_region.init();
|
damage_region.init();
|
||||||
defer damage_region.deinit();
|
defer damage_region.deinit();
|
||||||
output.damage.attachRender(&needs_frame, &damage_region) catch {
|
output.damage.?.attachRender(&needs_frame, &damage_region) catch {
|
||||||
log.err("failed to attach renderer", .{});
|
log.err("failed to attach renderer", .{});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user