aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-21 11:23:48 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-22 23:10:19 +1000
commit9df660ee3188386c907d8feb999636ce8d61d095 (patch)
treeeb9343b66221d664ac995995d7bcceb45d25ee94 /sway
parentPrevent re-uploading the same cursor image multiple times (diff)
downloadsway-9df660ee3188386c907d8feb999636ce8d61d095.tar.gz
sway-9df660ee3188386c907d8feb999636ce8d61d095.tar.zst
sway-9df660ee3188386c907d8feb999636ce8d61d095.zip
Store last button and use it when views request to move or resize
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/xdg_shell.c13
-rw-r--r--sway/desktop/xdg_shell_v6.c13
-rw-r--r--sway/input/cursor.c18
-rw-r--r--sway/input/seat.c12
4 files changed, 29 insertions, 27 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index d6c3a9a7..c5d53d1d 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -1,9 +1,4 @@
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
7#include <stdbool.h> 2#include <stdbool.h>
8#include <stdlib.h> 3#include <stdlib.h>
9#include <wayland-server.h> 4#include <wayland-server.h>
@@ -259,7 +254,9 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
259 struct sway_view *view = &xdg_shell_view->view; 254 struct sway_view *view = &xdg_shell_view->view;
260 struct wlr_xdg_toplevel_move_event *e = data; 255 struct wlr_xdg_toplevel_move_event *e = data;
261 struct sway_seat *seat = e->seat->seat->data; 256 struct sway_seat *seat = e->seat->seat->data;
262 seat_begin_move(seat, view->swayc); 257 if (e->serial == seat->last_button_serial) {
258 seat_begin_move(seat, view->swayc, seat->last_button);
259 }
263} 260}
264 261
265static void handle_request_resize(struct wl_listener *listener, void *data) { 262static void handle_request_resize(struct wl_listener *listener, void *data) {
@@ -268,7 +265,9 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
268 struct sway_view *view = &xdg_shell_view->view; 265 struct sway_view *view = &xdg_shell_view->view;
269 struct wlr_xdg_toplevel_resize_event *e = data; 266 struct wlr_xdg_toplevel_resize_event *e = data;
270 struct sway_seat *seat = e->seat->seat->data; 267 struct sway_seat *seat = e->seat->seat->data;
271 seat_begin_resize(seat, view->swayc, BTN_LEFT, e->edges); 268 if (e->serial == seat->last_button_serial) {
269 seat_begin_resize(seat, view->swayc, seat->last_button, e->edges);
270 }
272} 271}
273 272
274static void handle_unmap(struct wl_listener *listener, void *data) { 273static void handle_unmap(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 241bd9b0..4bd6af5e 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -1,9 +1,4 @@
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
7#include <stdbool.h> 2#include <stdbool.h>
8#include <stdlib.h> 3#include <stdlib.h>
9#include <wayland-server.h> 4#include <wayland-server.h>
@@ -254,7 +249,9 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
254 struct sway_view *view = &xdg_shell_v6_view->view; 249 struct sway_view *view = &xdg_shell_v6_view->view;
255 struct wlr_xdg_toplevel_v6_move_event *e = data; 250 struct wlr_xdg_toplevel_v6_move_event *e = data;
256 struct sway_seat *seat = e->seat->seat->data; 251 struct sway_seat *seat = e->seat->seat->data;
257 seat_begin_move(seat, view->swayc); 252 if (e->serial == seat->last_button_serial) {
253 seat_begin_move(seat, view->swayc, seat->last_button);
254 }
258} 255}
259 256
260static void handle_request_resize(struct wl_listener *listener, void *data) { 257static void handle_request_resize(struct wl_listener *listener, void *data) {
@@ -263,7 +260,9 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
263 struct sway_view *view = &xdg_shell_v6_view->view; 260 struct sway_view *view = &xdg_shell_v6_view->view;
264 struct wlr_xdg_toplevel_v6_resize_event *e = data; 261 struct wlr_xdg_toplevel_v6_resize_event *e = data;
265 struct sway_seat *seat = e->seat->seat->data; 262 struct sway_seat *seat = e->seat->seat->data;
266 seat_begin_resize(seat, view->swayc, BTN_LEFT, e->edges); 263 if (e->serial == seat->last_button_serial) {
264 seat_begin_resize(seat, view->swayc, seat->last_button, e->edges);
265 }
267} 266}
268 267
269static void handle_unmap(struct wl_listener *listener, void *data) { 268static void handle_unmap(struct wl_listener *listener, void *data) {
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 43721d28..ad0ceb94 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -429,7 +429,7 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor,
429 429
430 // Deny moving or resizing a fullscreen view 430 // Deny moving or resizing a fullscreen view
431 if (cont->type == C_VIEW && cont->sway_view->is_fullscreen) { 431 if (cont->type == C_VIEW && cont->sway_view->is_fullscreen) {
432 wlr_seat_pointer_notify_button(seat->wlr_seat, time_msec, button, state); 432 seat_pointer_notify_button(seat, time_msec, button, state);
433 return; 433 return;
434 } 434 }
435 435
@@ -442,7 +442,7 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor,
442 // Check for beginning move 442 // Check for beginning move
443 if (button == BTN_LEFT && state == WLR_BUTTON_PRESSED && 443 if (button == BTN_LEFT && state == WLR_BUTTON_PRESSED &&
444 (mod_pressed || over_title)) { 444 (mod_pressed || over_title)) {
445 seat_begin_move(seat, cont); 445 seat_begin_move(seat, cont, BTN_LEFT);
446 return; 446 return;
447 } 447 }
448 448
@@ -456,7 +456,7 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor,
456 } 456 }
457 457
458 // Send event to surface 458 // Send event to surface
459 wlr_seat_pointer_notify_button(seat->wlr_seat, time_msec, button, state); 459 seat_pointer_notify_button(seat, time_msec, button, state);
460} 460}
461 461
462void dispatch_cursor_button(struct sway_cursor *cursor, 462void dispatch_cursor_button(struct sway_cursor *cursor,
@@ -480,8 +480,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
480 if (layer->current.keyboard_interactive) { 480 if (layer->current.keyboard_interactive) {
481 seat_set_focus_layer(cursor->seat, layer); 481 seat_set_focus_layer(cursor->seat, layer);
482 } 482 }
483 wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, 483 seat_pointer_notify_button(cursor->seat, time_msec, button, state);
484 time_msec, button, state);
485 } else if (cont && container_is_floating(cont)) { 484 } else if (cont && container_is_floating(cont)) {
486 dispatch_cursor_button_floating(cursor, time_msec, button, state, 485 dispatch_cursor_button_floating(cursor, time_msec, button, state,
487 surface, sx, sy, cont); 486 surface, sx, sy, cont);
@@ -501,15 +500,12 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
501 if (new_ws != old_ws) { 500 if (new_ws != old_ws) {
502 seat_set_focus(cursor->seat, cont); 501 seat_set_focus(cursor->seat, cont);
503 } 502 }
504 wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, 503 seat_pointer_notify_button(cursor->seat, time_msec, button, state);
505 time_msec, button, state);
506 } else if (cont) { 504 } else if (cont) {
507 seat_set_focus(cursor->seat, cont); 505 seat_set_focus(cursor->seat, cont);
508 wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, 506 seat_pointer_notify_button(cursor->seat, time_msec, button, state);
509 time_msec, button, state);
510 } else { 507 } else {
511 wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, 508 seat_pointer_notify_button(cursor->seat, time_msec, button, state);
512 time_msec, button, state);
513 } 509 }
514 510
515 transaction_commit_dirty(); 511 transaction_commit_dirty();
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 3a3350e1..4e803efd 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -901,14 +901,15 @@ struct seat_config *seat_get_config(struct sway_seat *seat) {
901 return NULL; 901 return NULL;
902} 902}
903 903
904void seat_begin_move(struct sway_seat *seat, struct sway_container *con) { 904void seat_begin_move(struct sway_seat *seat, struct sway_container *con,
905 uint32_t button) {
905 if (!seat->cursor) { 906 if (!seat->cursor) {
906 wlr_log(WLR_DEBUG, "Ignoring move request due to no cursor device"); 907 wlr_log(WLR_DEBUG, "Ignoring move request due to no cursor device");
907 return; 908 return;
908 } 909 }
909 seat->operation = OP_MOVE; 910 seat->operation = OP_MOVE;
910 seat->op_container = con; 911 seat->op_container = con;
911 seat->op_button = BTN_LEFT; 912 seat->op_button = button;
912} 913}
913 914
914void seat_begin_resize(struct sway_seat *seat, struct sway_container *con, 915void seat_begin_resize(struct sway_seat *seat, struct sway_container *con,
@@ -951,3 +952,10 @@ void seat_end_mouse_operation(struct sway_seat *seat) {
951 seat->operation = OP_NONE; 952 seat->operation = OP_NONE;
952 seat->op_container = NULL; 953 seat->op_container = NULL;
953} 954}
955
956void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec,
957 uint32_t button, enum wlr_button_state state) {
958 seat->last_button = button;
959 seat->last_button_serial = wlr_seat_pointer_notify_button(seat->wlr_seat,
960 time_msec, button, state);
961}