Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
view: forbid mode change if cursor target
Making a floating view tiled during a resize breaks things badly.
river/InputManager.zig | 13 +++++++++++++
river/command/toggle_float.zig | 3 +++
river/command/toggle_fullscreen.zig | 9 +++++++--
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/river/InputManager.zig b/river/InputManager.zig
index 1175b5d..dae5bb0 100644
--- a/river/InputManager.zig
+++ b/river/InputManager.zig
@@ -26,6 +26,7 @@ const util = @import("util.zig");
const Seat = @import("Seat.zig");
const Server = @import("Server.zig");
+const View = @import("View.zig");
const default_seat_name = "default";
@@ -101,6 +102,18 @@ pub fn inputAllowed(self: Self, wlr_surface: *c.wlr_surface) bool {
true;
}
+pub fn isCursorActionTarget(self: Self, view: *View) bool {
+ var it = self.seats.first;
+ return while (it) |node| : (it = node.next) {
+ const seat = &node.data;
+ switch (seat.cursor.mode) {
+ .passthrough => {},
+ .move => |data| if (data.view == view) break true,
+ .resize => |data| if (data.view == view) break true,
+ }
+ } else false;
+}
+
fn handleInhibitActivate(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const self = @fieldParentPtr(Self, "listen_inhibit_activate", listener.?);
diff --git a/river/command/toggle_float.zig b/river/command/toggle_float.zig
index 4238469..b392081 100644
--- a/river/command/toggle_float.zig
+++ b/river/command/toggle_float.zig
@@ -36,6 +36,9 @@ 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 (seat.input_manager.isCursorActionTarget(view)) return;
+
if (!view.pending.float) view.pending.box = view.float_box;
view.pending.float = !view.pending.float;
view.output.root.arrange();
diff --git a/river/command/toggle_fullscreen.zig b/river/command/toggle_fullscreen.zig
index 5699e8a..c5ffb12 100644
--- a/river/command/toggle_fullscreen.zig
+++ b/river/command/toggle_fullscreen.zig
@@ -30,7 +30,12 @@ pub fn toggleFullscreen(
if (args.len > 1) return Error.TooManyArguments;
if (seat.focused == .view) {
- seat.focused.view.setFullscreen(!seat.focused.view.pending.fullscreen);
- seat.focused.view.output.root.arrange();
+ const view = seat.focused.view;
+
+ // Don't modify views which are the target of a cursor action
+ if (seat.input_manager.isCursorActionTarget(view)) return;
+
+ view.setFullscreen(!seat.focused.view.pending.fullscreen);
+ view.output.root.arrange();
}
}