aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--river/Cursor.zig20
-rw-r--r--river/DragIcon.zig25
-rw-r--r--river/Seat.zig2
3 files changed, 27 insertions, 20 deletions
diff --git a/river/Cursor.zig b/river/Cursor.zig
index 4b097af..cfb418b 100644
--- a/river/Cursor.zig
+++ b/river/Cursor.zig
@@ -1104,24 +1104,8 @@ fn updateDragIcons(self: *Self) void {
while (it.next()) |node| {
const icon = @as(*DragIcon, @ptrFromInt(node.data));
- if (icon.wlr_drag_icon.drag.seat != self.seat.wlr_seat) continue;
-
- switch (icon.wlr_drag_icon.drag.grab_type) {
- .keyboard => unreachable,
- .keyboard_pointer => {
- icon.tree.node.setPosition(
- @intFromFloat(self.wlr_cursor.x),
- @intFromFloat(self.wlr_cursor.y),
- );
- },
- .keyboard_touch => {
- const touch_id = icon.wlr_drag_icon.drag.touch_id;
- const point = self.touch_points.get(touch_id) orelse continue;
- icon.tree.node.setPosition(
- @intFromFloat(point.lx),
- @intFromFloat(point.ly),
- );
- },
+ if (icon.wlr_drag_icon.drag.seat == self.seat.wlr_seat) {
+ icon.updatePosition(self);
}
}
}
diff --git a/river/DragIcon.zig b/river/DragIcon.zig
index 55dc00b..a7f15ba 100644
--- a/river/DragIcon.zig
+++ b/river/DragIcon.zig
@@ -23,6 +23,7 @@ const wl = @import("wayland").server.wl;
const server = &@import("main.zig").server;
const util = @import("util.zig");
+const Cursor = @import("Cursor.zig");
const SceneNodeData = @import("SceneNodeData.zig");
wlr_drag_icon: *wlr.Drag.Icon,
@@ -35,7 +36,7 @@ map: wl.Listener(*wlr.Drag.Icon) = wl.Listener(*wlr.Drag.Icon).init(handleMap),
unmap: wl.Listener(*wlr.Drag.Icon) = wl.Listener(*wlr.Drag.Icon).init(handleUnmap),
commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit),
-pub fn create(wlr_drag_icon: *wlr.Drag.Icon) error{OutOfMemory}!void {
+pub fn create(wlr_drag_icon: *wlr.Drag.Icon, cursor: *Cursor) error{OutOfMemory}!void {
const tree = try server.root.drag_icons.createSceneTree();
errdefer tree.node.destroy();
@@ -49,6 +50,7 @@ pub fn create(wlr_drag_icon: *wlr.Drag.Icon) error{OutOfMemory}!void {
};
tree.node.data = @intFromPtr(drag_icon);
+ drag_icon.updatePosition(cursor);
tree.node.setEnabled(wlr_drag_icon.mapped);
wlr_drag_icon.events.destroy.add(&drag_icon.destroy);
@@ -57,6 +59,27 @@ pub fn create(wlr_drag_icon: *wlr.Drag.Icon) error{OutOfMemory}!void {
wlr_drag_icon.surface.events.commit.add(&drag_icon.commit);
}
+pub fn updatePosition(drag_icon: *DragIcon, cursor: *Cursor) void {
+ switch (drag_icon.wlr_drag_icon.drag.grab_type) {
+ .keyboard => unreachable,
+ .keyboard_pointer => {
+ drag_icon.tree.node.setPosition(
+ @intFromFloat(cursor.wlr_cursor.x),
+ @intFromFloat(cursor.wlr_cursor.y),
+ );
+ },
+ .keyboard_touch => {
+ const touch_id = drag_icon.wlr_drag_icon.drag.touch_id;
+ if (cursor.touch_points.get(touch_id)) |point| {
+ drag_icon.tree.node.setPosition(
+ @intFromFloat(point.lx),
+ @intFromFloat(point.ly),
+ );
+ }
+ },
+ }
+}
+
fn handleDestroy(listener: *wl.Listener(*wlr.Drag.Icon), _: *wlr.Drag.Icon) void {
const drag_icon = @fieldParentPtr(DragIcon, "destroy", listener);
diff --git a/river/Seat.zig b/river/Seat.zig
index bae0f23..4984363 100644
--- a/river/Seat.zig
+++ b/river/Seat.zig
@@ -555,7 +555,7 @@ fn handleStartDrag(listener: *wl.Listener(*wlr.Drag), wlr_drag: *wlr.Drag) void
wlr_drag.events.destroy.add(&self.drag_destroy);
if (wlr_drag.icon) |wlr_drag_icon| {
- DragIcon.create(wlr_drag_icon) catch {
+ DragIcon.create(wlr_drag_icon, &self.cursor) catch {
log.err("out of memory", .{});
wlr_drag.seat_client.client.postNoMemory();
return;