Clean up cursor handling code
This commit is contained in:
parent
b3bad0ca93
commit
45c7e27935
1 changed files with 11 additions and 8 deletions
|
@ -112,8 +112,11 @@ pub const Cursor = struct {
|
||||||
|
|
||||||
fn process_move(self: *@This(), time: u32) void {
|
fn process_move(self: *@This(), time: u32) void {
|
||||||
// Move the grabbed view to the new position.
|
// Move the grabbed view to the new position.
|
||||||
self.grabbed_view.?.x = @floatToInt(c_int, self.wlr_cursor.x - self.grab_x);
|
// TODO: log on null
|
||||||
self.grabbed_view.?.y = @floatToInt(c_int, self.wlr_cursor.y - self.grab_y);
|
if (self.grabbed_view) |view| {
|
||||||
|
view.x = @floatToInt(c_int, self.wlr_cursor.x - self.grab_x);
|
||||||
|
view.y = @floatToInt(c_int, self.wlr_cursor.y - self.grab_y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_resize(self: *@This(), time: u32) void {
|
fn process_resize(self: *@This(), time: u32) void {
|
||||||
|
@ -127,13 +130,13 @@ pub const Cursor = struct {
|
||||||
// commit any movement that was prepared.
|
// commit any movement that was prepared.
|
||||||
|
|
||||||
// TODO: Handle null view
|
// TODO: Handle null view
|
||||||
const view = self.grabbed_view;
|
const view = self.grabbed_view.?;
|
||||||
|
|
||||||
const dx: f64 = self.wlr_cursor.x - self.grab_x;
|
const dx: f64 = self.wlr_cursor.x - self.grab_x;
|
||||||
const dy: f64 = self.wlr_cursor.y - self.grab_y;
|
const dy: f64 = self.wlr_cursor.y - self.grab_y;
|
||||||
|
|
||||||
var x: f64 = @intToFloat(f64, view.?.x);
|
var x: f64 = @intToFloat(f64, view.x);
|
||||||
var y: f64 = @intToFloat(f64, view.?.y);
|
var y: f64 = @intToFloat(f64, view.y);
|
||||||
|
|
||||||
var width = @intToFloat(f64, self.grab_width);
|
var width = @intToFloat(f64, self.grab_width);
|
||||||
var height = @intToFloat(f64, self.grab_height);
|
var height = @intToFloat(f64, self.grab_height);
|
||||||
|
@ -156,10 +159,10 @@ pub const Cursor = struct {
|
||||||
} else if (self.resize_edges & @intCast(u32, c.WLR_EDGE_RIGHT) != 0) {
|
} else if (self.resize_edges & @intCast(u32, c.WLR_EDGE_RIGHT) != 0) {
|
||||||
width += dx;
|
width += dx;
|
||||||
}
|
}
|
||||||
view.?.x = @floatToInt(c_int, x);
|
view.x = @floatToInt(c_int, x);
|
||||||
view.?.y = @floatToInt(c_int, y);
|
view.y = @floatToInt(c_int, y);
|
||||||
_ = c.wlr_xdg_toplevel_set_size(
|
_ = c.wlr_xdg_toplevel_set_size(
|
||||||
view.?.wlr_xdg_surface,
|
view.wlr_xdg_surface,
|
||||||
@floatToInt(u32, width),
|
@floatToInt(u32, width),
|
||||||
@floatToInt(u32, height),
|
@floatToInt(u32, height),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue