ext-session-lock: implement protocol

This commit is contained in:
Isaac Freund
2021-12-30 04:27:50 +00:00
parent 78a46c316a
commit 33187e0b09
11 changed files with 332 additions and 20 deletions

View File

@ -32,6 +32,7 @@ const util = @import("util.zig");
const Config = @import("Config.zig");
const LayerSurface = @import("LayerSurface.zig");
const LockSurface = @import("LockSurface.zig");
const Output = @import("Output.zig");
const Seat = @import("Seat.zig");
const View = @import("View.zig");
@ -337,7 +338,6 @@ fn handleButton(listener: *wl.Listener(*wlr.Pointer.event.Button), event: *wlr.P
fn updateKeyboardFocus(self: Self, result: SurfaceAtResult) void {
switch (result.parent) {
.view => |view| {
// Otherwise focus the view
self.seat.focus(view);
},
.layer_surface => |layer_surface| {
@ -350,6 +350,10 @@ fn updateKeyboardFocus(self: Self, result: SurfaceAtResult) void {
self.seat.focus(null);
}
},
.lock_surface => |lock_surface| {
assert(server.lock_manager.locked);
self.seat.setFocusRaw(.{ .lock_surface = lock_surface });
},
.xwayland_override_redirect => |override_redirect| {
if (!build_options.xwayland) unreachable;
if (override_redirect.xwayland_surface.overrideRedirectWantsFocus() and
@ -628,6 +632,7 @@ const SurfaceAtResult = struct {
parent: union(enum) {
view: *View,
layer_surface: *LayerSurface,
lock_surface: *LockSurface,
xwayland_override_redirect: if (build_options.xwayland) *XwaylandOverrideRedirect else void,
},
};
@ -650,6 +655,22 @@ fn surfaceAtCoords(lx: f64, ly: f64) ?SurfaceAtResult {
var oy = ly;
server.root.output_layout.outputCoords(wlr_output, &ox, &oy);
if (server.lock_manager.locked) {
if (output.lock_surface) |lock_surface| {
var sx: f64 = undefined;
var sy: f64 = undefined;
if (lock_surface.wlr_lock_surface.surface.surfaceAt(ox, oy, &sx, &sy)) |found| {
return SurfaceAtResult{
.surface = found,
.sx = sx,
.sy = sy,
.parent = .{ .lock_surface = lock_surface },
};
}
}
return null;
}
// Find the first visible fullscreen view in the stack if there is one
var it = ViewStack(View).iter(output.views.first, .forward, output.current.tags, surfaceAtFilter);
const fullscreen_view = while (it.next()) |view| {
@ -1010,7 +1031,7 @@ pub fn checkFocusFollowsCursor(self: *Self) void {
server.root.startTransaction();
}
},
.layer_surface => {},
.layer_surface, .lock_surface => {},
.xwayland_override_redirect => assert(build_options.xwayland),
}
}
@ -1050,6 +1071,7 @@ fn shouldPassthrough(self: Self) bool {
return false;
},
.resize, .move => {
assert(!server.lock_manager.locked);
const target = if (self.mode == .resize) self.mode.resize.view else self.mode.move.view;
// The target view is no longer visible, is part of the layout, or is fullscreen.
return target.current.tags & target.output.current.tags == 0 or
@ -1064,6 +1086,7 @@ fn passthrough(self: *Self, time: u32) void {
assert(self.mode == .passthrough);
if (self.surfaceAt()) |result| {
assert((result.parent == .lock_surface) == server.lock_manager.locked);
self.seat.wlr_seat.pointerNotifyEnter(result.surface, result.sx, result.sy);
self.seat.wlr_seat.pointerNotifyMotion(time, result.sx, result.sy);
} else {