summaryrefslogtreecommitdiff
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorTony Crisci <[email protected]>2017-12-10 11:11:47 -0500
committerTony Crisci <[email protected]>2017-12-10 11:11:47 -0500
commit21626e8153490bf155e812644454fe9610491ffd (patch)
tree5b881dcc23dfdae692f58aaf1a9677b5d1395f61 /sway/input/cursor.c
parent0fdecb4d3a36d4c73a906bcc0465620293b6e6d2 (diff)
seat focus on button press
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 5f2d650e..217c2ddb 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -1,4 +1,9 @@
#define _XOPEN_SOURCE 700
+#ifdef __linux__
+#include <linux/input-event-codes.h>
+#elif __FreeBSD__
+#include <dev/evdev/input-event-codes.h>
+#endif
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include "sway/input/cursor.h"
@@ -57,6 +62,16 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor =
wl_container_of(listener, cursor, button);
struct wlr_event_pointer_button *event = data;
+
+ if (event->button == BTN_LEFT) {
+ struct wlr_surface *surface = NULL;
+ double sx, sy;
+ swayc_t *swayc =
+ swayc_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy);
+
+ sway_seat_set_focus(cursor->seat, swayc);
+ }
+
wlr_seat_pointer_notify_button(cursor->seat->seat, event->time_msec,
event->button, event->state);
}