diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/xdg_shell.c | 33 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 33 | ||||
-rw-r--r-- | sway/input/cursor.c | 100 | ||||
-rw-r--r-- | sway/input/seat.c | 38 |
4 files changed, 135 insertions, 69 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 98c16faf..d6c3a9a7 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -1,4 +1,9 @@ | |||
1 | #define _POSIX_C_SOURCE 199309L | 1 | #define _POSIX_C_SOURCE 199309L |
2 | #ifdef __linux__ | ||
3 | #include <linux/input-event-codes.h> | ||
4 | #elif __FreeBSD__ | ||
5 | #include <dev/evdev/input-event-codes.h> | ||
6 | #endif | ||
2 | #include <stdbool.h> | 7 | #include <stdbool.h> |
3 | #include <stdlib.h> | 8 | #include <stdlib.h> |
4 | #include <wayland-server.h> | 9 | #include <wayland-server.h> |
@@ -248,6 +253,24 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) | |||
248 | transaction_commit_dirty(); | 253 | transaction_commit_dirty(); |
249 | } | 254 | } |
250 | 255 | ||
256 | static void handle_request_move(struct wl_listener *listener, void *data) { | ||
257 | struct sway_xdg_shell_view *xdg_shell_view = | ||
258 | wl_container_of(listener, xdg_shell_view, request_move); | ||
259 | struct sway_view *view = &xdg_shell_view->view; | ||
260 | struct wlr_xdg_toplevel_move_event *e = data; | ||
261 | struct sway_seat *seat = e->seat->seat->data; | ||
262 | seat_begin_move(seat, view->swayc); | ||
263 | } | ||
264 | |||
265 | static void handle_request_resize(struct wl_listener *listener, void *data) { | ||
266 | struct sway_xdg_shell_view *xdg_shell_view = | ||
267 | wl_container_of(listener, xdg_shell_view, request_resize); | ||
268 | struct sway_view *view = &xdg_shell_view->view; | ||
269 | struct wlr_xdg_toplevel_resize_event *e = data; | ||
270 | struct sway_seat *seat = e->seat->seat->data; | ||
271 | seat_begin_resize(seat, view->swayc, BTN_LEFT, e->edges); | ||
272 | } | ||
273 | |||
251 | static void handle_unmap(struct wl_listener *listener, void *data) { | 274 | static void handle_unmap(struct wl_listener *listener, void *data) { |
252 | struct sway_xdg_shell_view *xdg_shell_view = | 275 | struct sway_xdg_shell_view *xdg_shell_view = |
253 | wl_container_of(listener, xdg_shell_view, unmap); | 276 | wl_container_of(listener, xdg_shell_view, unmap); |
@@ -262,6 +285,8 @@ static void handle_unmap(struct wl_listener *listener, void *data) { | |||
262 | wl_list_remove(&xdg_shell_view->commit.link); | 285 | wl_list_remove(&xdg_shell_view->commit.link); |
263 | wl_list_remove(&xdg_shell_view->new_popup.link); | 286 | wl_list_remove(&xdg_shell_view->new_popup.link); |
264 | wl_list_remove(&xdg_shell_view->request_fullscreen.link); | 287 | wl_list_remove(&xdg_shell_view->request_fullscreen.link); |
288 | wl_list_remove(&xdg_shell_view->request_move.link); | ||
289 | wl_list_remove(&xdg_shell_view->request_resize.link); | ||
265 | } | 290 | } |
266 | 291 | ||
267 | static void handle_map(struct wl_listener *listener, void *data) { | 292 | static void handle_map(struct wl_listener *listener, void *data) { |
@@ -299,6 +324,14 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
299 | xdg_shell_view->request_fullscreen.notify = handle_request_fullscreen; | 324 | xdg_shell_view->request_fullscreen.notify = handle_request_fullscreen; |
300 | wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, | 325 | wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, |
301 | &xdg_shell_view->request_fullscreen); | 326 | &xdg_shell_view->request_fullscreen); |
327 | |||
328 | xdg_shell_view->request_move.notify = handle_request_move; | ||
329 | wl_signal_add(&xdg_surface->toplevel->events.request_move, | ||
330 | &xdg_shell_view->request_move); | ||
331 | |||
332 | xdg_shell_view->request_resize.notify = handle_request_resize; | ||
333 | wl_signal_add(&xdg_surface->toplevel->events.request_resize, | ||
334 | &xdg_shell_view->request_resize); | ||
302 | } | 335 | } |
303 | 336 | ||
304 | static void handle_destroy(struct wl_listener *listener, void *data) { | 337 | static void handle_destroy(struct wl_listener *listener, void *data) { |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 4d76f0a7..241bd9b0 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -1,4 +1,9 @@ | |||
1 | #define _POSIX_C_SOURCE 199309L | 1 | #define _POSIX_C_SOURCE 199309L |
2 | #ifdef __linux__ | ||
3 | #include <linux/input-event-codes.h> | ||
4 | #elif __FreeBSD__ | ||
5 | #include <dev/evdev/input-event-codes.h> | ||
6 | #endif | ||
2 | #include <stdbool.h> | 7 | #include <stdbool.h> |
3 | #include <stdlib.h> | 8 | #include <stdlib.h> |
4 | #include <wayland-server.h> | 9 | #include <wayland-server.h> |
@@ -243,6 +248,24 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) | |||
243 | transaction_commit_dirty(); | 248 | transaction_commit_dirty(); |
244 | } | 249 | } |
245 | 250 | ||
251 | static void handle_request_move(struct wl_listener *listener, void *data) { | ||
252 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | ||
253 | wl_container_of(listener, xdg_shell_v6_view, request_move); | ||
254 | struct sway_view *view = &xdg_shell_v6_view->view; | ||
255 | struct wlr_xdg_toplevel_v6_move_event *e = data; | ||
256 | struct sway_seat *seat = e->seat->seat->data; | ||
257 | seat_begin_move(seat, view->swayc); | ||
258 | } | ||
259 | |||
260 | static void handle_request_resize(struct wl_listener *listener, void *data) { | ||
261 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | ||
262 | wl_container_of(listener, xdg_shell_v6_view, request_resize); | ||
263 | struct sway_view *view = &xdg_shell_v6_view->view; | ||
264 | struct wlr_xdg_toplevel_v6_resize_event *e = data; | ||
265 | struct sway_seat *seat = e->seat->seat->data; | ||
266 | seat_begin_resize(seat, view->swayc, BTN_LEFT, e->edges); | ||
267 | } | ||
268 | |||
246 | static void handle_unmap(struct wl_listener *listener, void *data) { | 269 | static void handle_unmap(struct wl_listener *listener, void *data) { |
247 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | 270 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = |
248 | wl_container_of(listener, xdg_shell_v6_view, unmap); | 271 | wl_container_of(listener, xdg_shell_v6_view, unmap); |
@@ -257,6 +280,8 @@ static void handle_unmap(struct wl_listener *listener, void *data) { | |||
257 | wl_list_remove(&xdg_shell_v6_view->commit.link); | 280 | wl_list_remove(&xdg_shell_v6_view->commit.link); |
258 | wl_list_remove(&xdg_shell_v6_view->new_popup.link); | 281 | wl_list_remove(&xdg_shell_v6_view->new_popup.link); |
259 | wl_list_remove(&xdg_shell_v6_view->request_fullscreen.link); | 282 | wl_list_remove(&xdg_shell_v6_view->request_fullscreen.link); |
283 | wl_list_remove(&xdg_shell_v6_view->request_move.link); | ||
284 | wl_list_remove(&xdg_shell_v6_view->request_resize.link); | ||
260 | } | 285 | } |
261 | 286 | ||
262 | static void handle_map(struct wl_listener *listener, void *data) { | 287 | static void handle_map(struct wl_listener *listener, void *data) { |
@@ -294,6 +319,14 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
294 | xdg_shell_v6_view->request_fullscreen.notify = handle_request_fullscreen; | 319 | xdg_shell_v6_view->request_fullscreen.notify = handle_request_fullscreen; |
295 | wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, | 320 | wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, |
296 | &xdg_shell_v6_view->request_fullscreen); | 321 | &xdg_shell_v6_view->request_fullscreen); |
322 | |||
323 | xdg_shell_v6_view->request_move.notify = handle_request_move; | ||
324 | wl_signal_add(&xdg_surface->toplevel->events.request_move, | ||
325 | &xdg_shell_v6_view->request_move); | ||
326 | |||
327 | xdg_shell_v6_view->request_resize.notify = handle_request_resize; | ||
328 | wl_signal_add(&xdg_surface->toplevel->events.request_resize, | ||
329 | &xdg_shell_v6_view->request_resize); | ||
297 | } | 330 | } |
298 | 331 | ||
299 | static void handle_destroy(struct wl_listener *listener, void *data) { | 332 | static void handle_destroy(struct wl_listener *listener, void *data) { |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 8723e2b4..8b9208c6 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -143,33 +143,33 @@ static struct sway_container *container_at_coords( | |||
143 | return output->swayc; | 143 | return output->swayc; |
144 | } | 144 | } |
145 | 145 | ||
146 | static enum resize_edge find_resize_edge(struct sway_container *cont, | 146 | static enum wlr_edges find_resize_edge(struct sway_container *cont, |
147 | struct sway_cursor *cursor) { | 147 | struct sway_cursor *cursor) { |
148 | if (cont->type != C_VIEW) { | 148 | if (cont->type != C_VIEW) { |
149 | return RESIZE_EDGE_NONE; | 149 | return WLR_EDGE_NONE; |
150 | } | 150 | } |
151 | struct sway_view *view = cont->sway_view; | 151 | struct sway_view *view = cont->sway_view; |
152 | if (view->border == B_NONE || !view->border_thickness || view->using_csd) { | 152 | if (view->border == B_NONE || !view->border_thickness || view->using_csd) { |
153 | return RESIZE_EDGE_NONE; | 153 | return WLR_EDGE_NONE; |
154 | } | 154 | } |
155 | 155 | ||
156 | enum resize_edge edge = 0; | 156 | enum wlr_edges edge = 0; |
157 | if (cursor->cursor->x < cont->x + view->border_thickness) { | 157 | if (cursor->cursor->x < cont->x + view->border_thickness) { |
158 | edge |= RESIZE_EDGE_LEFT; | 158 | edge |= WLR_EDGE_LEFT; |
159 | } | 159 | } |
160 | if (cursor->cursor->y < cont->y + view->border_thickness) { | 160 | if (cursor->cursor->y < cont->y + view->border_thickness) { |
161 | edge |= RESIZE_EDGE_TOP; | 161 | edge |= WLR_EDGE_TOP; |
162 | } | 162 | } |
163 | if (cursor->cursor->x >= cont->x + cont->width - view->border_thickness) { | 163 | if (cursor->cursor->x >= cont->x + cont->width - view->border_thickness) { |
164 | edge |= RESIZE_EDGE_RIGHT; | 164 | edge |= WLR_EDGE_RIGHT; |
165 | } | 165 | } |
166 | if (cursor->cursor->y >= cont->y + cont->height - view->border_thickness) { | 166 | if (cursor->cursor->y >= cont->y + cont->height - view->border_thickness) { |
167 | edge |= RESIZE_EDGE_BOTTOM; | 167 | edge |= WLR_EDGE_BOTTOM; |
168 | } | 168 | } |
169 | return edge; | 169 | return edge; |
170 | } | 170 | } |
171 | 171 | ||
172 | static void handle_drag_motion(struct sway_seat *seat, | 172 | static void handle_move_motion(struct sway_seat *seat, |
173 | struct sway_cursor *cursor) { | 173 | struct sway_cursor *cursor) { |
174 | struct sway_container *con = seat->op_container; | 174 | struct sway_container *con = seat->op_container; |
175 | desktop_damage_whole_container(con); | 175 | desktop_damage_whole_container(con); |
@@ -218,22 +218,22 @@ static void calculate_floating_constraints(struct sway_container *con, | |||
218 | static void handle_resize_motion(struct sway_seat *seat, | 218 | static void handle_resize_motion(struct sway_seat *seat, |
219 | struct sway_cursor *cursor) { | 219 | struct sway_cursor *cursor) { |
220 | struct sway_container *con = seat->op_container; | 220 | struct sway_container *con = seat->op_container; |
221 | enum resize_edge edge = seat->op_resize_edge; | 221 | enum wlr_edges edge = seat->op_resize_edge; |
222 | 222 | ||
223 | // The amount the mouse has moved since the start of the resize operation | 223 | // The amount the mouse has moved since the start of the resize operation |
224 | // Positive is down/right | 224 | // Positive is down/right |
225 | double mouse_move_x = cursor->cursor->x - seat->op_ref_lx; | 225 | double mouse_move_x = cursor->cursor->x - seat->op_ref_lx; |
226 | double mouse_move_y = cursor->cursor->y - seat->op_ref_ly; | 226 | double mouse_move_y = cursor->cursor->y - seat->op_ref_ly; |
227 | 227 | ||
228 | if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) { | 228 | if (edge == WLR_EDGE_TOP || edge == WLR_EDGE_BOTTOM) { |
229 | mouse_move_x = 0; | 229 | mouse_move_x = 0; |
230 | } | 230 | } |
231 | if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) { | 231 | if (edge == WLR_EDGE_LEFT || edge == WLR_EDGE_RIGHT) { |
232 | mouse_move_y = 0; | 232 | mouse_move_y = 0; |
233 | } | 233 | } |
234 | 234 | ||
235 | double grow_width = edge & RESIZE_EDGE_LEFT ? -mouse_move_x : mouse_move_x; | 235 | double grow_width = edge & WLR_EDGE_LEFT ? -mouse_move_x : mouse_move_x; |
236 | double grow_height = edge & RESIZE_EDGE_TOP ? -mouse_move_y : mouse_move_y; | 236 | double grow_height = edge & WLR_EDGE_TOP ? -mouse_move_y : mouse_move_y; |
237 | 237 | ||
238 | if (seat->op_resize_preserve_ratio) { | 238 | if (seat->op_resize_preserve_ratio) { |
239 | double x_multiplier = grow_width / seat->op_ref_width; | 239 | double x_multiplier = grow_width / seat->op_ref_width; |
@@ -259,16 +259,16 @@ static void handle_resize_motion(struct sway_seat *seat, | |||
259 | // Determine grow x/y values - these are relative to the container's x/y at | 259 | // Determine grow x/y values - these are relative to the container's x/y at |
260 | // the start of the resize operation. | 260 | // the start of the resize operation. |
261 | double grow_x = 0, grow_y = 0; | 261 | double grow_x = 0, grow_y = 0; |
262 | if (edge & RESIZE_EDGE_LEFT) { | 262 | if (edge & WLR_EDGE_LEFT) { |
263 | grow_x = -grow_width; | 263 | grow_x = -grow_width; |
264 | } else if (edge & RESIZE_EDGE_RIGHT) { | 264 | } else if (edge & WLR_EDGE_RIGHT) { |
265 | grow_x = 0; | 265 | grow_x = 0; |
266 | } else { | 266 | } else { |
267 | grow_x = -grow_width / 2; | 267 | grow_x = -grow_width / 2; |
268 | } | 268 | } |
269 | if (edge & RESIZE_EDGE_TOP) { | 269 | if (edge & WLR_EDGE_TOP) { |
270 | grow_y = -grow_height; | 270 | grow_y = -grow_height; |
271 | } else if (edge & RESIZE_EDGE_BOTTOM) { | 271 | } else if (edge & WLR_EDGE_BOTTOM) { |
272 | grow_y = 0; | 272 | grow_y = 0; |
273 | } else { | 273 | } else { |
274 | grow_y = -grow_height / 2; | 274 | grow_y = -grow_height / 2; |
@@ -299,31 +299,6 @@ static void handle_resize_motion(struct sway_seat *seat, | |||
299 | transaction_commit_dirty(); | 299 | transaction_commit_dirty(); |
300 | } | 300 | } |
301 | 301 | ||
302 | static 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 | |||
327 | void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | 302 | void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, |
328 | bool allow_refocusing) { | 303 | bool allow_refocusing) { |
329 | if (time_msec == 0) { | 304 | if (time_msec == 0) { |
@@ -333,8 +308,8 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
333 | struct sway_seat *seat = cursor->seat; | 308 | struct sway_seat *seat = cursor->seat; |
334 | 309 | ||
335 | if (seat->operation != OP_NONE) { | 310 | if (seat->operation != OP_NONE) { |
336 | if (seat->operation == OP_DRAG) { | 311 | if (seat->operation == OP_MOVE) { |
337 | handle_drag_motion(seat, cursor); | 312 | handle_move_motion(seat, cursor); |
338 | } else { | 313 | } else { |
339 | handle_resize_motion(seat, cursor); | 314 | handle_resize_motion(seat, cursor); |
340 | } | 315 | } |
@@ -402,8 +377,9 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
402 | } | 377 | } |
403 | } else if (c && container_is_floating(c)) { | 378 | } else if (c && container_is_floating(c)) { |
404 | // Try a floating container's resize edge | 379 | // Try a floating container's resize edge |
405 | enum resize_edge edge = find_resize_edge(c, cursor); | 380 | enum wlr_edges edge = find_resize_edge(c, cursor); |
406 | const char *image = edge_to_image_name(edge); | 381 | const char *image = edge == WLR_EDGE_NONE ? |
382 | "left_ptr" : wlr_xcursor_get_resize_name(edge); | ||
407 | wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image, | 383 | wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image, |
408 | cursor->cursor); | 384 | cursor->cursor); |
409 | cursor->image_client = NULL; | 385 | cursor->image_client = NULL; |
@@ -452,7 +428,7 @@ static void handle_cursor_motion_absolute( | |||
452 | } | 428 | } |
453 | 429 | ||
454 | static void handle_end_operation(struct sway_seat *seat) { | 430 | static void handle_end_operation(struct sway_seat *seat) { |
455 | if (seat->operation == OP_DRAG) { | 431 | if (seat->operation == OP_MOVE) { |
456 | // We "move" the container to its own location so it discovers its | 432 | // We "move" the container to its own location so it discovers its |
457 | // output again. | 433 | // output again. |
458 | struct sway_container *con = seat->op_container; | 434 | struct sway_container *con = seat->op_container; |
@@ -472,7 +448,7 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor, | |||
472 | struct sway_container *cont) { | 448 | struct sway_container *cont) { |
473 | struct sway_seat *seat = cursor->seat; | 449 | struct sway_seat *seat = cursor->seat; |
474 | 450 | ||
475 | // Deny dragging or resizing a fullscreen view | 451 | // Deny moving or resizing a fullscreen view |
476 | if (cont->type == C_VIEW && cont->sway_view->is_fullscreen) { | 452 | if (cont->type == C_VIEW && cont->sway_view->is_fullscreen) { |
477 | wlr_seat_pointer_notify_button(seat->wlr_seat, time_msec, button, state); | 453 | wlr_seat_pointer_notify_button(seat->wlr_seat, time_msec, button, state); |
478 | return; | 454 | return; |
@@ -481,36 +457,22 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor, | |||
481 | struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); | 457 | struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); |
482 | bool mod_pressed = keyboard && | 458 | bool mod_pressed = keyboard && |
483 | (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod); | 459 | (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod); |
484 | enum resize_edge edge = find_resize_edge(cont, cursor); | 460 | enum wlr_edges edge = find_resize_edge(cont, cursor); |
485 | bool over_title = edge == RESIZE_EDGE_NONE && !surface; | 461 | bool over_title = edge == WLR_EDGE_NONE && !surface; |
486 | 462 | ||
487 | // Check for beginning drag | 463 | // Check for beginning move |
488 | if (button == BTN_LEFT && state == WLR_BUTTON_PRESSED && | 464 | if (button == BTN_LEFT && state == WLR_BUTTON_PRESSED && |
489 | (mod_pressed || over_title)) { | 465 | (mod_pressed || over_title)) { |
490 | seat->operation = OP_DRAG; | 466 | seat_begin_move(seat, cont); |
491 | seat->op_container = cont; | ||
492 | seat->op_button = button; | ||
493 | return; | 467 | return; |
494 | } | 468 | } |
495 | 469 | ||
496 | // Check for beginning resize | 470 | // Check for beginning resize |
497 | bool resizing_via_border = button == BTN_LEFT && edge != RESIZE_EDGE_NONE; | 471 | bool resizing_via_border = button == BTN_LEFT && edge != WLR_EDGE_NONE; |
498 | bool resizing_via_mod = button == BTN_RIGHT && mod_pressed; | 472 | bool resizing_via_mod = button == BTN_RIGHT && mod_pressed; |
499 | if ((resizing_via_border || resizing_via_mod) && | 473 | if ((resizing_via_border || resizing_via_mod) && |
500 | state == WLR_BUTTON_PRESSED) { | 474 | state == WLR_BUTTON_PRESSED) { |
501 | seat->operation = OP_RESIZE; | 475 | seat_begin_resize(seat, cont, button, edge); |
502 | seat->op_container = cont; | ||
503 | seat->op_resize_preserve_ratio = keyboard && | ||
504 | (wlr_keyboard_get_modifiers(keyboard) & WLR_MODIFIER_SHIFT); | ||
505 | seat->op_resize_edge = resizing_via_mod ? | ||
506 | RESIZE_EDGE_BOTTOM | RESIZE_EDGE_RIGHT : edge; | ||
507 | seat->op_button = button; | ||
508 | seat->op_ref_lx = cursor->cursor->x; | ||
509 | seat->op_ref_ly = cursor->cursor->y; | ||
510 | seat->op_ref_con_lx = cont->x; | ||
511 | seat->op_ref_con_ly = cont->y; | ||
512 | seat->op_ref_width = cont->width; | ||
513 | seat->op_ref_height = cont->height; | ||
514 | return; | 476 | return; |
515 | } | 477 | } |
516 | 478 | ||
diff --git a/sway/input/seat.c b/sway/input/seat.c index e77d88a8..cc5b2e0f 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1,6 +1,11 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _XOPEN_SOURCE 700 |
2 | #define _POSIX_C_SOURCE 199309L | 2 | #define _POSIX_C_SOURCE 199309L |
3 | #include <assert.h> | 3 | #include <assert.h> |
4 | #ifdef __linux__ | ||
5 | #include <linux/input-event-codes.h> | ||
6 | #elif __FreeBSD__ | ||
7 | #include <dev/evdev/input-event-codes.h> | ||
8 | #endif | ||
4 | #include <strings.h> | 9 | #include <strings.h> |
5 | #include <time.h> | 10 | #include <time.h> |
6 | #include <wlr/types/wlr_cursor.h> | 11 | #include <wlr/types/wlr_cursor.h> |
@@ -348,6 +353,7 @@ struct sway_seat *seat_create(struct sway_input_manager *input, | |||
348 | free(seat); | 353 | free(seat); |
349 | return NULL; | 354 | return NULL; |
350 | } | 355 | } |
356 | seat->wlr_seat->data = seat; | ||
351 | 357 | ||
352 | seat->cursor = sway_cursor_create(seat); | 358 | seat->cursor = sway_cursor_create(seat); |
353 | if (!seat->cursor) { | 359 | if (!seat->cursor) { |
@@ -894,3 +900,35 @@ struct seat_config *seat_get_config(struct sway_seat *seat) { | |||
894 | 900 | ||
895 | return NULL; | 901 | return NULL; |
896 | } | 902 | } |
903 | |||
904 | void seat_begin_move(struct sway_seat *seat, struct sway_container *con) { | ||
905 | if (!seat->cursor) { | ||
906 | wlr_log(WLR_DEBUG, "Ignoring move request due to no cursor device"); | ||
907 | return; | ||
908 | } | ||
909 | seat->operation = OP_MOVE; | ||
910 | seat->op_container = con; | ||
911 | seat->op_button = BTN_LEFT; | ||
912 | } | ||
913 | |||
914 | void seat_begin_resize(struct sway_seat *seat, struct sway_container *con, | ||
915 | uint32_t button, enum wlr_edges edge) { | ||
916 | if (!seat->cursor) { | ||
917 | wlr_log(WLR_DEBUG, "Ignoring resize request due to no cursor device"); | ||
918 | return; | ||
919 | } | ||
920 | struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); | ||
921 | seat->operation = OP_RESIZE; | ||
922 | seat->op_container = con; | ||
923 | seat->op_resize_preserve_ratio = keyboard && | ||
924 | (wlr_keyboard_get_modifiers(keyboard) & WLR_MODIFIER_SHIFT); | ||
925 | seat->op_resize_edge = edge == WLR_EDGE_NONE ? | ||
926 | RESIZE_EDGE_BOTTOM | RESIZE_EDGE_RIGHT : edge; | ||
927 | seat->op_button = button; | ||
928 | seat->op_ref_lx = seat->cursor->cursor->x; | ||
929 | seat->op_ref_ly = seat->cursor->cursor->y; | ||
930 | seat->op_ref_con_lx = con->x; | ||
931 | seat->op_ref_con_ly = con->y; | ||
932 | seat->op_ref_width = con->width; | ||
933 | seat->op_ref_height = con->height; | ||
934 | } | ||