From e9d46ccbddf69e380d72b23d50d21988015ab60b Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 11 Aug 2018 00:08:18 +1000 Subject: [PATCH] Use col-resize and row-resize cursor images --- sway/input/cursor.c | 26 +++++++++++++++++++++++--- sway/input/seat.c | 3 --- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 12cca7fdb..8e7157a28 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -472,9 +472,17 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, } else if (c) { // Try a container's resize edge enum wlr_edges edge = find_resize_edge(c, cursor); - const char *image = edge == WLR_EDGE_NONE ? - "left_ptr" : wlr_xcursor_get_resize_name(edge); - cursor_set_image(cursor, image, NULL); + if (edge == WLR_EDGE_NONE) { + cursor_set_image(cursor, "left_ptr", NULL); + } else if (container_is_floating(c)) { + cursor_set_image(cursor, wlr_xcursor_get_resize_name(edge), NULL); + } else { + if (edge & (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)) { + cursor_set_image(cursor, "col-resize", NULL); + } else { + cursor_set_image(cursor, "row-resize", NULL); + } + } } else { cursor_set_image(cursor, "left_ptr", NULL); } @@ -676,6 +684,18 @@ void dispatch_cursor_button(struct sway_cursor *cursor, WLR_EDGE_RIGHT : WLR_EDGE_LEFT; edge |= cursor->cursor->y > cont->y + cont->height / 2 ? WLR_EDGE_BOTTOM : WLR_EDGE_TOP; + + const char *image = NULL; + if (edge == (WLR_EDGE_LEFT | WLR_EDGE_TOP)) { + image = "nw-resize"; + } else if (edge == (WLR_EDGE_TOP | WLR_EDGE_RIGHT)) { + image = "ne-resize"; + } else if (edge == (WLR_EDGE_RIGHT | WLR_EDGE_BOTTOM)) { + image = "se-resize"; + } else if (edge == (WLR_EDGE_BOTTOM | WLR_EDGE_LEFT)) { + image = "sw-resize"; + } + cursor_set_image(seat->cursor, image, NULL); seat_set_focus(seat, cont); seat_begin_resize_tiling(seat, cont, button, edge); return; diff --git a/sway/input/seat.c b/sway/input/seat.c index 6d9e85dc5..57cc65f62 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -980,9 +980,6 @@ void seat_begin_resize_tiling(struct sway_seat *seat, seat->op_ref_con_ly = con->y; seat->op_ref_width = con->width; seat->op_ref_height = con->height; - - const char *image = wlr_xcursor_get_resize_name(edge); - cursor_set_image(seat->cursor, image, NULL); } void seat_end_mouse_operation(struct sway_seat *seat) {