aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/rootston/input.h8
-rw-r--r--rootston/cursor.c27
-rw-r--r--rootston/xdg_shell_v6.c12
3 files changed, 34 insertions, 13 deletions
diff --git a/include/rootston/input.h b/include/rootston/input.h
index cf4513e5..c2e0ff75 100644
--- a/include/rootston/input.h
+++ b/include/rootston/input.h
@@ -53,6 +53,13 @@ enum roots_cursor_mode {
ROOTS_CURSOR_ROTATE = 3,
};
+enum roots_cursor_resize_edge {
+ ROOTS_CURSOR_RESIZE_EDGE_TOP = 1,
+ ROOTS_CURSOR_RESIZE_EDGE_BOTTOM = 2,
+ ROOTS_CURSOR_RESIZE_EDGE_LEFT = 4,
+ ROOTS_CURSOR_RESIZE_EDGE_RIGHT = 8,
+};
+
struct roots_input_event {
uint32_t serial;
struct wlr_cursor *cursor;
@@ -71,6 +78,7 @@ struct roots_input {
enum roots_cursor_mode mode;
struct roots_view *active_view;
int offs_x, offs_y;
+ int view_width, view_height;
uint32_t resize_edges;
// Ring buffer of input events that could trigger move/resize/rotate
diff --git a/rootston/cursor.c b/rootston/cursor.c
index c57bff52..ac6b1dc3 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -33,8 +33,10 @@ void view_begin_resize(struct roots_input *input, struct wlr_cursor *cursor,
struct roots_view *view, uint32_t edges) {
input->mode = ROOTS_CURSOR_RESIZE;
wlr_log(L_DEBUG, "begin resize");
- input->offs_x = cursor->x - (double)view->wlr_surface->current.width - view->x;
- input->offs_y = cursor->y - (double)view->wlr_surface->current.height - view->y;
+ input->offs_x = cursor->x - view->x;
+ input->offs_y = cursor->y - view->y;
+ input->view_width = view->wlr_surface->current.width;
+ input->view_height = view->wlr_surface->current.height;
input->resize_edges = edges;
wlr_seat_pointer_clear_focus(input->wl_seat);
}
@@ -64,9 +66,24 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
break;
case ROOTS_CURSOR_RESIZE:
if (input->active_view) {
- // TODO: edges
- uint32_t width = input->cursor->x - input->offs_x;
- uint32_t height = input->cursor->y - input->offs_y;
+ int dx = input->cursor->x - input->offs_x;
+ int dy = input->cursor->y - input->offs_y;
+ int width = input->view_width;
+ int height = input->view_height;
+ if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) {
+ input->active_view->y = dy;
+ height -= dy;
+ }
+ if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) {
+ height += dy;
+ }
+ if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) {
+ input->active_view->x = dx;
+ width -= dx;
+ }
+ if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) {
+ width += dx;
+ }
view_resize(input->active_view, width, height);
}
break;
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index a18aa501..8f5b405c 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -10,16 +10,12 @@
#include "rootston/server.h"
#include "rootston/input.h"
-static void get_input_bounds(struct roots_view *view, struct wlr_box *box) {
+/*static void get_input_bounds(struct roots_view *view, struct wlr_box *box) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
+ // TODO: surf->geometry can be NULL
memcpy(box, surf->geometry, sizeof(struct wlr_box));
- // TODO: real input bounds
- box->x -= 10;
- box->y -= 10;
- box->width += 20;
- box->height += 20;
-}
+}*/
static void activate(struct roots_view *view, bool active) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
@@ -108,7 +104,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
view->xdg_surface_v6 = surface;
view->roots_xdg_surface_v6 = roots_surface;
view->wlr_surface = surface->surface;
- view->get_input_bounds = get_input_bounds;
+ //view->get_input_bounds = get_input_bounds;
view->activate = activate;
view->resize = resize;
view->desktop = desktop;