summaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-19 21:29:21 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-22 23:10:19 +1000
commitdd337127d80ce93ba556691c4a4565a19babba0e (patch)
tree0689c4a0fcc7c640e498e6c9a7baf6bd2dbab6ab /sway/input/cursor.c
parentImprove resize performance by partially flushing the transaction queue (diff)
downloadsway-dd337127d80ce93ba556691c4a4565a19babba0e.tar.gz
sway-dd337127d80ce93ba556691c4a4565a19babba0e.tar.zst
sway-dd337127d80ce93ba556691c4a4565a19babba0e.zip
Use separate function for choosing edge cursor
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 7a06cf9c..dfb5603e 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -299,6 +299,31 @@ static void handle_resize_motion(struct sway_seat *seat,
299 transaction_commit_dirty(); 299 transaction_commit_dirty();
300} 300}
301 301
302static const char *edge_to_image_name(enum resize_edge edge) {
303 switch (edge) {
304 case RESIZE_EDGE_NONE:
305 return "left_ptr";
306 case RESIZE_EDGE_TOP:
307 return "top_side";
308 case RESIZE_EDGE_RIGHT:
309 return "right_side";
310 case RESIZE_EDGE_BOTTOM:
311 return "bottom_side";
312 case RESIZE_EDGE_LEFT:
313 return "left_side";
314 }
315 if (edge == (RESIZE_EDGE_TOP | RESIZE_EDGE_LEFT)) {
316 return "top_left_corner";
317 } else if (edge == (RESIZE_EDGE_TOP | RESIZE_EDGE_RIGHT)) {
318 return "top_right_corner";
319 } else if (edge == (RESIZE_EDGE_BOTTOM | RESIZE_EDGE_LEFT)) {
320 return "bottom_left_corner";
321 } else if (edge == (RESIZE_EDGE_BOTTOM | RESIZE_EDGE_RIGHT)) {
322 return "bottom_right_corner";
323 }
324 return "left_ptr";
325}
326
302void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, 327void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
303 bool allow_refocusing) { 328 bool allow_refocusing) {
304 if (time_msec == 0) { 329 if (time_msec == 0) {
@@ -378,37 +403,9 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
378 } else if (c && container_is_floating(c)) { 403 } else if (c && container_is_floating(c)) {
379 // Try a floating container's resize edge 404 // Try a floating container's resize edge
380 enum resize_edge edge = find_resize_edge(c, cursor); 405 enum resize_edge edge = find_resize_edge(c, cursor);
381 if (edge == RESIZE_EDGE_NONE) { 406 const char *image = edge_to_image_name(edge);
382 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, 407 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image,
383 "left_ptr", cursor->cursor); 408 cursor->cursor);
384 } else if (edge == RESIZE_EDGE_TOP) {
385 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
386 "top_side", cursor->cursor);
387 } else if (edge == RESIZE_EDGE_RIGHT) {
388 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
389 "right_side", cursor->cursor);
390 } else if (edge == RESIZE_EDGE_BOTTOM) {
391 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
392 "bottom_side", cursor->cursor);
393 } else if (edge == RESIZE_EDGE_LEFT) {
394 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
395 "left_side", cursor->cursor);
396 } else if (edge == (RESIZE_EDGE_TOP | RESIZE_EDGE_LEFT)) {
397 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
398 "top_left_corner", cursor->cursor);
399 } else if (edge == (RESIZE_EDGE_TOP | RESIZE_EDGE_RIGHT)) {
400 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
401 "top_right_corner", cursor->cursor);
402 } else if (edge == (RESIZE_EDGE_BOTTOM | RESIZE_EDGE_LEFT)) {
403 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
404 "bottom_left_corner", cursor->cursor);
405 } else if (edge == (RESIZE_EDGE_BOTTOM | RESIZE_EDGE_RIGHT)) {
406 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
407 "bottom_right_corner", cursor->cursor);
408 } else {
409 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
410 "left_ptr", cursor->cursor);
411 }
412 cursor->image_client = NULL; 409 cursor->image_client = NULL;
413 } else { 410 } else {
414 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, 411 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,