input-inhibit: remove support for protocol

The only valid use-case for this as far as I'm concerned is lockscreens,
which will now be supported through ext-session-lock-v1.
This commit is contained in:
Isaac Freund 2021-12-29 21:13:32 +00:00
parent ba823ef96e
commit 78a46c316a
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
4 changed files with 42 additions and 110 deletions

View File

@ -157,8 +157,8 @@ are ignored by river.
Mappings are modal in river. Each mapping is associated with a mode and is Mappings are modal in river. Each mapping is associated with a mode and is
only active while in that mode. There are two special modes: "normal" and only active while in that mode. There are two special modes: "normal" and
"locked". The normal mode is the initial mode on startup. The locked mode "locked". The normal mode is the initial mode on startup. The locked mode
is automatically entered while an input inhibitor (such as a lockscreen) is automatically entered while a lock screen is active. It cannot be entered
is active. It cannot be entered or exited manually. or exited manually.
The following modifiers are available for use in mappings: The following modifiers are available for use in mappings:

View File

@ -1064,13 +1064,8 @@ fn passthrough(self: *Self, time: u32) void {
assert(self.mode == .passthrough); assert(self.mode == .passthrough);
if (self.surfaceAt()) |result| { if (self.surfaceAt()) |result| {
// If input is allowed on the surface, send pointer enter and motion self.seat.wlr_seat.pointerNotifyEnter(result.surface, result.sx, result.sy);
// events. Note that wlroots won't actually send an enter event if self.seat.wlr_seat.pointerNotifyMotion(time, result.sx, result.sy);
// the surface has already been entered.
if (server.input_manager.inputAllowed(result.surface)) {
self.seat.wlr_seat.pointerNotifyEnter(result.surface, result.sx, result.sy);
self.seat.wlr_seat.pointerNotifyMotion(time, result.sx, result.sy);
}
} else { } else {
// There is either no surface under the cursor or input is disallowed // There is either no surface under the cursor or input is disallowed
// Reset the cursor image to the default and clear focus. // Reset the cursor image to the default and clear focus.

View File

@ -40,7 +40,6 @@ const log = std.log.scoped(.input_manager);
new_input: wl.Listener(*wlr.InputDevice) = wl.Listener(*wlr.InputDevice).init(handleNewInput), new_input: wl.Listener(*wlr.InputDevice) = wl.Listener(*wlr.InputDevice).init(handleNewInput),
idle: *wlr.Idle, idle: *wlr.Idle,
input_inhibit_manager: *wlr.InputInhibitManager,
pointer_constraints: *wlr.PointerConstraintsV1, pointer_constraints: *wlr.PointerConstraintsV1,
relative_pointer_manager: *wlr.RelativePointerManagerV1, relative_pointer_manager: *wlr.RelativePointerManagerV1,
virtual_pointer_manager: *wlr.VirtualPointerManagerV1, virtual_pointer_manager: *wlr.VirtualPointerManagerV1,
@ -52,10 +51,6 @@ seats: std.TailQueue(Seat) = .{},
exclusive_client: ?*wl.Client = null, exclusive_client: ?*wl.Client = null,
inhibit_activate: wl.Listener(*wlr.InputInhibitManager) =
wl.Listener(*wlr.InputInhibitManager).init(handleInhibitActivate),
inhibit_deactivate: wl.Listener(*wlr.InputInhibitManager) =
wl.Listener(*wlr.InputInhibitManager).init(handleInhibitDeactivate),
new_pointer_constraint: wl.Listener(*wlr.PointerConstraintV1) = new_pointer_constraint: wl.Listener(*wlr.PointerConstraintV1) =
wl.Listener(*wlr.PointerConstraintV1).init(handleNewPointerConstraint), wl.Listener(*wlr.PointerConstraintV1).init(handleNewPointerConstraint),
new_virtual_pointer: wl.Listener(*wlr.VirtualPointerManagerV1.event.NewPointer) = new_virtual_pointer: wl.Listener(*wlr.VirtualPointerManagerV1.event.NewPointer) =
@ -70,7 +65,6 @@ pub fn init(self: *Self) !void {
self.* = .{ self.* = .{
// These are automatically freed when the display is destroyed // These are automatically freed when the display is destroyed
.idle = try wlr.Idle.create(server.wl_server), .idle = try wlr.Idle.create(server.wl_server),
.input_inhibit_manager = try wlr.InputInhibitManager.create(server.wl_server),
.pointer_constraints = try wlr.PointerConstraintsV1.create(server.wl_server), .pointer_constraints = try wlr.PointerConstraintsV1.create(server.wl_server),
.relative_pointer_manager = try wlr.RelativePointerManagerV1.create(server.wl_server), .relative_pointer_manager = try wlr.RelativePointerManagerV1.create(server.wl_server),
.virtual_pointer_manager = try wlr.VirtualPointerManagerV1.create(server.wl_server), .virtual_pointer_manager = try wlr.VirtualPointerManagerV1.create(server.wl_server),
@ -87,8 +81,6 @@ pub fn init(self: *Self) !void {
if (build_options.xwayland) server.xwayland.setSeat(self.defaultSeat().wlr_seat); if (build_options.xwayland) server.xwayland.setSeat(self.defaultSeat().wlr_seat);
server.backend.events.new_input.add(&self.new_input); server.backend.events.new_input.add(&self.new_input);
self.input_inhibit_manager.events.activate.add(&self.inhibit_activate);
self.input_inhibit_manager.events.deactivate.add(&self.inhibit_deactivate);
self.pointer_constraints.events.new_constraint.add(&self.new_pointer_constraint); self.pointer_constraints.events.new_constraint.add(&self.new_pointer_constraint);
self.virtual_pointer_manager.events.new_virtual_pointer.add(&self.new_virtual_pointer); self.virtual_pointer_manager.events.new_virtual_pointer.add(&self.new_virtual_pointer);
self.virtual_keyboard_manager.events.new_virtual_keyboard.add(&self.new_virtual_keyboard); self.virtual_keyboard_manager.events.new_virtual_keyboard.add(&self.new_virtual_keyboard);
@ -126,56 +118,6 @@ pub fn updateCursorState(self: Self) void {
while (it) |node| : (it = node.next) node.data.cursor.updateState(); while (it) |node| : (it = node.next) node.data.cursor.updateState();
} }
fn handleInhibitActivate(
listener: *wl.Listener(*wlr.InputInhibitManager),
_: *wlr.InputInhibitManager,
) void {
const self = @fieldParentPtr(Self, "inhibit_activate", listener);
log.debug("input inhibitor activated", .{});
var seat_it = self.seats.first;
while (seat_it) |seat_node| : (seat_it = seat_node.next) {
// Clear focus of all seats
seat_node.data.setFocusRaw(.{ .none = {} });
// Enter locked mode
seat_node.data.prev_mode_id = seat_node.data.mode_id;
seat_node.data.enterMode(1);
}
self.exclusive_client = self.input_inhibit_manager.active_client;
}
fn handleInhibitDeactivate(
listener: *wl.Listener(*wlr.InputInhibitManager),
_: *wlr.InputInhibitManager,
) void {
const self = @fieldParentPtr(Self, "inhibit_deactivate", listener);
log.debug("input inhibitor deactivated", .{});
self.exclusive_client = null;
// Calling arrangeLayers() like this ensures that any top or overlay,
// keyboard-interactive surfaces will re-grab focus.
var output_it = server.root.outputs.first;
while (output_it) |output_node| : (output_it = output_node.next) {
output_node.data.arrangeLayers(.mapped);
}
// After ensuring that any possible layer surface focus grab has occured,
// have each Seat handle focus and enter their previous mode.
var seat_it = self.seats.first;
while (seat_it) |seat_node| : (seat_it = seat_node.next) {
const seat = &seat_node.data;
seat.enterMode(seat.prev_mode_id);
seat.focus(null);
}
server.root.startTransaction();
}
fn handleNewInput(listener: *wl.Listener(*wlr.InputDevice), wlr_device: *wlr.InputDevice) void { fn handleNewInput(listener: *wl.Listener(*wlr.InputDevice), wlr_device: *wlr.InputDevice) void {
const self = @fieldParentPtr(Self, "new_input", listener); const self = @fieldParentPtr(Self, "new_input", listener);

View File

@ -223,51 +223,46 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void {
.none => null, .none => null,
}; };
// If input is not allowed on the target surface (e.g. due to an active // First clear the current focus
// input inhibitor) do not set focus. If there is no target surface we switch (self.focused) {
// still clear the focus. .view => |view| {
if (if (target_surface) |wlr_surface| server.input_manager.inputAllowed(wlr_surface) else true) { view.pending.focus -= 1;
// First clear the current focus if (view.pending.focus == 0) view.setActivated(false);
switch (self.focused) { },
.view => |view| { .xwayland_override_redirect, .layer, .none => {},
view.pending.focus -= 1; }
if (view.pending.focus == 0) view.setActivated(false);
}, // Set the new focus
.xwayland_override_redirect, .layer, .none => {}, switch (new_focus) {
.view => |target_view| {
assert(self.focused_output == target_view.output);
if (target_view.pending.focus == 0) target_view.setActivated(true);
target_view.pending.focus += 1;
target_view.pending.urgent = false;
},
.layer => |target_layer| assert(self.focused_output == target_layer.output),
.xwayland_override_redirect, .none => {},
}
self.focused = new_focus;
// Send keyboard enter/leave events and handle pointer constraints
if (target_surface) |wlr_surface| {
self.keyboardNotifyEnter(wlr_surface);
if (server.input_manager.pointer_constraints.constraintForSurface(wlr_surface, self.wlr_seat)) |constraint| {
@intToPtr(*PointerConstraint, constraint.data).setAsActive();
} else if (self.cursor.constraint) |constraint| {
PointerConstraint.warpToHint(&self.cursor);
constraint.sendDeactivated();
self.cursor.constraint = null;
} }
} else {
self.wlr_seat.keyboardClearFocus();
// Set the new focus if (self.cursor.constraint) |constraint| {
switch (new_focus) { PointerConstraint.warpToHint(&self.cursor);
.view => |target_view| { constraint.sendDeactivated();
assert(self.focused_output == target_view.output); self.cursor.constraint = null;
if (target_view.pending.focus == 0) target_view.setActivated(true);
target_view.pending.focus += 1;
target_view.pending.urgent = false;
},
.layer => |target_layer| assert(self.focused_output == target_layer.output),
.xwayland_override_redirect, .none => {},
}
self.focused = new_focus;
// Send keyboard enter/leave events and handle pointer constraints
if (target_surface) |wlr_surface| {
self.keyboardNotifyEnter(wlr_surface);
if (server.input_manager.pointer_constraints.constraintForSurface(wlr_surface, self.wlr_seat)) |constraint| {
@intToPtr(*PointerConstraint, constraint.data).setAsActive();
} else if (self.cursor.constraint) |constraint| {
PointerConstraint.warpToHint(&self.cursor);
constraint.sendDeactivated();
self.cursor.constraint = null;
}
} else {
self.wlr_seat.keyboardClearFocus();
if (self.cursor.constraint) |constraint| {
PointerConstraint.warpToHint(&self.cursor);
constraint.sendDeactivated();
self.cursor.constraint = null;
}
} }
} }