From d74ac69f7b932a8833527a41351e3310ad391d7c Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 7 Dec 2017 11:19:43 -0500 Subject: bring edges into wlr --- rootston/cursor.c | 17 +++++++++-------- rootston/meson.build | 1 - rootston/seat.c | 3 ++- rootston/xcursor.c | 28 ---------------------------- 4 files changed, 11 insertions(+), 38 deletions(-) delete mode 100644 rootston/xcursor.c (limited to 'rootston') diff --git a/rootston/cursor.c b/rootston/cursor.c index f0e3d70d..d38e40a1 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -8,6 +8,7 @@ #endif #include #include +#include #include "rootston/xcursor.h" #include "rootston/cursor.h" @@ -75,22 +76,22 @@ static void roots_cursor_update_position(struct roots_cursor *cursor, double y = view->y; int width = cursor->view_width; int height = cursor->view_height; - if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { + if (cursor->resize_edges & WLR_EDGE_TOP) { y = cursor->view_y + dy; height -= dy; if (height < 1) { y += height; } - } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) { + } else if (cursor->resize_edges & WLR_EDGE_BOTTOM) { height += dy; } - if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { + if (cursor->resize_edges & WLR_EDGE_LEFT) { x = cursor->view_x + dx; width -= dx; if (width < 1) { x += width; } - } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { + } else if (cursor->resize_edges & WLR_EDGE_RIGHT) { width += dx; } @@ -147,14 +148,14 @@ static void roots_cursor_press_button(struct roots_cursor *cursor, case BTN_RIGHT: edges = 0; if (sx < view->wlr_surface->current->width/2) { - edges |= ROOTS_CURSOR_RESIZE_EDGE_LEFT; + edges |= WLR_EDGE_LEFT; } else { - edges |= ROOTS_CURSOR_RESIZE_EDGE_RIGHT; + edges |= WLR_EDGE_RIGHT; } if (sy < view->wlr_surface->current->height/2) { - edges |= ROOTS_CURSOR_RESIZE_EDGE_TOP; + edges |= WLR_EDGE_TOP; } else { - edges |= ROOTS_CURSOR_RESIZE_EDGE_BOTTOM; + edges |= WLR_EDGE_BOTTOM; } roots_seat_begin_resize(seat, view, edges); break; diff --git a/rootston/meson.build b/rootston/meson.build index 9c543c4f..36b6241a 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -8,7 +8,6 @@ sources = [ 'main.c', 'output.c', 'seat.c', - 'xcursor.c', 'xdg_shell_v6.c', 'wl_shell.c', ] diff --git a/rootston/seat.c b/rootston/seat.c index 737bbd67..f6473581 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -661,8 +661,9 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view, view_maximize(view, false); wlr_seat_pointer_clear_focus(seat->seat); + const char *resize_name = wlr_xcursor_manager_get_resize_name(edges); wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, - roots_xcursor_get_resize_name(edges), seat->cursor->cursor); + resize_name, seat->cursor->cursor); } void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view) { diff --git a/rootston/xcursor.c b/rootston/xcursor.c deleted file mode 100644 index 74e732c9..00000000 --- a/rootston/xcursor.c +++ /dev/null @@ -1,28 +0,0 @@ -#define _POSIX_C_SOURCE 200809L -#include -#include -#include "rootston/xcursor.h" -#include "rootston/input.h" - -const char *roots_xcursor_get_resize_name(uint32_t edges) { - if (edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { - if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { - return "ne-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - return "nw-resize"; - } - return "n-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) { - if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { - return "se-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - return "sw-resize"; - } - return "s-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { - return "e-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - return "w-resize"; - } - return "se-resize"; // fallback -} -- cgit v1.2.3 From 4c60072be584a7ed5b97de325994217a9e96bbd4 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Fri, 8 Dec 2017 06:08:06 -0500 Subject: move get_resize_name to xcursor --- include/wlr/types/wlr_xcursor_manager.h | 7 ------- include/wlr/xcursor.h | 6 ++++++ rootston/seat.c | 2 +- types/wlr_xcursor_manager.c | 23 ----------------------- xcursor/wlr_xcursor.c | 23 +++++++++++++++++++++++ 5 files changed, 30 insertions(+), 31 deletions(-) (limited to 'rootston') diff --git a/include/wlr/types/wlr_xcursor_manager.h b/include/wlr/types/wlr_xcursor_manager.h index 63eb5386..c78a6e8d 100644 --- a/include/wlr/types/wlr_xcursor_manager.h +++ b/include/wlr/types/wlr_xcursor_manager.h @@ -4,7 +4,6 @@ #include #include #include -#include /** * A scaled XCursor theme. @@ -51,10 +50,4 @@ struct wlr_xcursor *wlr_xcursor_manager_get_xcursor( void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, const char *name, struct wlr_cursor *cursor); -/** - * Get the name of the cursor image for the given edges. - */ -const char *wlr_xcursor_manager_get_resize_name(enum wlr_edges edges); - - #endif diff --git a/include/wlr/xcursor.h b/include/wlr/xcursor.h index b6362b06..42fcedb9 100644 --- a/include/wlr/xcursor.h +++ b/include/wlr/xcursor.h @@ -32,6 +32,7 @@ #define WLR_XCURSOR_H #include +#include struct wlr_xcursor_image { uint32_t width; /* actual width */ @@ -65,4 +66,9 @@ struct wlr_xcursor *wlr_xcursor_theme_get_cursor( int wlr_xcursor_frame(struct wlr_xcursor *cursor, uint32_t time); +/** + * Get the name of the resize cursor image for the given edges. + */ +const char *wlr_xcursor_get_resize_name(enum wlr_edges edges); + #endif diff --git a/rootston/seat.c b/rootston/seat.c index f6473581..1fa09ad6 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -661,7 +661,7 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view, view_maximize(view, false); wlr_seat_pointer_clear_focus(seat->seat); - const char *resize_name = wlr_xcursor_manager_get_resize_name(edges); + const char *resize_name = wlr_xcursor_get_resize_name(edges); wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, resize_name, seat->cursor->cursor); } diff --git a/types/wlr_xcursor_manager.c b/types/wlr_xcursor_manager.c index 9350d721..f32a96bc 100644 --- a/types/wlr_xcursor_manager.c +++ b/types/wlr_xcursor_manager.c @@ -82,26 +82,3 @@ void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, theme->scale); } } - -const char *wlr_xcursor_manager_get_resize_name(enum wlr_edges edges) { - if (edges & WLR_EDGE_TOP) { - if (edges & WLR_EDGE_RIGHT) { - return "ne-resize"; - } else if (edges & WLR_EDGE_LEFT) { - return "nw-resize"; - } - return "n-resize"; - } else if (edges & WLR_EDGE_BOTTOM) { - if (edges & WLR_EDGE_RIGHT) { - return "se-resize"; - } else if (edges & WLR_EDGE_LEFT) { - return "sw-resize"; - } - return "s-resize"; - } else if (edges & WLR_EDGE_RIGHT) { - return "e-resize"; - } else if (edges & WLR_EDGE_LEFT) { - return "w-resize"; - } - return "se-resize"; // fallback -} diff --git a/xcursor/wlr_xcursor.c b/xcursor/wlr_xcursor.c index fdebe1af..b1678223 100644 --- a/xcursor/wlr_xcursor.c +++ b/xcursor/wlr_xcursor.c @@ -326,3 +326,26 @@ static int wlr_xcursor_frame_and_duration(struct wlr_xcursor *cursor, int wlr_xcursor_frame(struct wlr_xcursor *_cursor, uint32_t time) { return wlr_xcursor_frame_and_duration(_cursor, time, NULL); } + +const char *wlr_xcursor_get_resize_name(enum wlr_edges edges) { + if (edges & WLR_EDGE_TOP) { + if (edges & WLR_EDGE_RIGHT) { + return "ne-resize"; + } else if (edges & WLR_EDGE_LEFT) { + return "nw-resize"; + } + return "n-resize"; + } else if (edges & WLR_EDGE_BOTTOM) { + if (edges & WLR_EDGE_RIGHT) { + return "se-resize"; + } else if (edges & WLR_EDGE_LEFT) { + return "sw-resize"; + } + return "s-resize"; + } else if (edges & WLR_EDGE_RIGHT) { + return "e-resize"; + } else if (edges & WLR_EDGE_LEFT) { + return "w-resize"; + } + return "se-resize"; // fallback +} -- cgit v1.2.3