DragIcon: set position on creation

Currently if a drag icon is created but the cursor/touch point is not
moved river will render the drag icon at 0,0 instead of the cursor/touch
point location. This fixes that.
This commit is contained in:
Isaac Freund
2023-10-25 22:01:05 +02:00
parent 3fb229a71d
commit 4cb65f9e2e
3 changed files with 27 additions and 20 deletions

View File

@ -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);
}
}
}