cursor: fix logic in Cursor.updateState()

The previous commit re-introduced a bug fixed by a3c65713 which caused
the pointer enter event not to be sent until moving the pointer when
switching tag focus or otherwise manipulating the window manager caused
the cursor to end up over a new surface.
This commit is contained in:
Isaac Freund 2021-07-24 02:30:15 +02:00
parent 53dd3875b3
commit f371e00716
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11

View file

@ -775,7 +775,7 @@ fn processMotion(self: *Self, device: *wlr.InputDevice, time: u32, delta_x: f64,
/// the target view of a cursor operation potentially being moved to a non-visible tag,
/// becoming fullscreen, etc.
pub fn updateState(self: *Self) void {
if (self.shouldExitMode()) {
if (self.shouldPassthrough()) {
self.mode = .passthrough;
var now: os.timespec = undefined;
os.clock_gettime(os.CLOCK_MONOTONIC, &now) catch @panic("CLOCK_MONOTONIC not supported");
@ -785,9 +785,14 @@ pub fn updateState(self: *Self) void {
}
}
fn shouldExitMode(self: Self) bool {
fn shouldPassthrough(self: Self) bool {
switch (self.mode) {
.passthrough => return false,
.passthrough => {
// If we are not currently in down/resize/move mode, we *always* need to passthrough()
// as what is under the cursor may have changed and we are not locked to a single
// target view.
return true;
},
.down => |target| {
// The target view is no longer visible
return target.current.tags & target.output.current.tags == 0;