From f86291169ee7eaa7fbab98544caba1ac30d248ff Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 23 Jul 2021 11:44:10 +0200 Subject: [PATCH] cursor: allow commands to override cursor operations Now that we properly handle state changes during cursor operations, blocking these commands if the target view is the target of a cursor operation is unnecessary complexity. It is also inconsistent as we don't block changing the tags of the view. --- river/Cursor.zig | 10 +++------- river/InputManager.zig | 7 ------- river/command/move.zig | 3 --- river/command/toggle_float.zig | 3 --- river/command/toggle_fullscreen.zig | 3 --- 5 files changed, 3 insertions(+), 23 deletions(-) diff --git a/river/Cursor.zig b/river/Cursor.zig index 803d8c0..24896c1 100644 --- a/river/Cursor.zig +++ b/river/Cursor.zig @@ -179,17 +179,13 @@ pub fn setTheme(self: *Self, theme: ?[*:0]const u8, _size: ?u32) !void { } } -pub fn isCursorActionTarget(self: Self, view: *const View) bool { - return switch (self.mode) { +pub fn handleViewUnmap(self: *Self, view: *View) void { + if (switch (self.mode) { .passthrough => false, .down => |target_view| target_view == view, .move => |target_view| target_view == view, .resize => |data| data.view == view, - }; -} - -pub fn handleViewUnmap(self: *Self, view: *View) void { - if (self.isCursorActionTarget(view)) { + }) { self.mode = .passthrough; self.clearFocus(); } diff --git a/river/InputManager.zig b/river/InputManager.zig index 8463c90..dd066c4 100644 --- a/river/InputManager.zig +++ b/river/InputManager.zig @@ -178,13 +178,6 @@ pub fn inputAllowed(self: Self, wlr_surface: *wlr.Surface) bool { true; } -pub fn isCursorActionTarget(self: Self, view: *View) bool { - var it = self.seats.first; - return while (it) |node| : (it = node.next) { - if (node.data.cursor.isCursorActionTarget(view)) break true; - } else false; -} - fn handleInhibitActivate( listener: *wl.Listener(*wlr.InputInhibitManager), input_inhibit_manager: *wlr.InputInhibitManager, diff --git a/river/command/move.zig b/river/command/move.zig index 5ed11f4..4df0977 100644 --- a/river/command/move.zig +++ b/river/command/move.zig @@ -155,8 +155,5 @@ fn getView(seat: *Seat) ?*View { // Do not touch fullscreen views if (view.pending.fullscreen) return null; - // Do not touch views which are the target of a cursor action - if (server.input_manager.isCursorActionTarget(view)) return null; - return view; } diff --git a/river/command/toggle_float.zig b/river/command/toggle_float.zig index bdcc20d..5f33c68 100644 --- a/river/command/toggle_float.zig +++ b/river/command/toggle_float.zig @@ -44,9 +44,6 @@ pub fn toggleFloat( // Don't float fullscreen views if (view.pending.fullscreen) return; - // Don't modify views which are the target of a cursor action - if (server.input_manager.isCursorActionTarget(view)) return; - view.pending.float = !view.pending.float; view.applyPending(); } diff --git a/river/command/toggle_fullscreen.zig b/river/command/toggle_fullscreen.zig index 8e5ec62..63c1c86 100644 --- a/river/command/toggle_fullscreen.zig +++ b/river/command/toggle_fullscreen.zig @@ -35,9 +35,6 @@ pub fn toggleFullscreen( if (seat.focused == .view) { const view = seat.focused.view; - // Don't modify views which are the target of a cursor action - if (server.input_manager.isCursorActionTarget(view)) return; - view.pending.fullscreen = !view.pending.fullscreen; view.applyPending(); }