aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar John Chadwick <johnwchadwick@gmail.com>2019-09-17 21:46:29 -0700
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-09-25 23:10:33 -0400
commit7e420cb6e4a334dea7296060820de12a768b76da (patch)
tree143678e6ff0a4b4223e2dfe30086eb5e2d2ab174 /sway/input/seat.c
parentAdd support for fullscreen view direct scan-out (diff)
downloadsway-7e420cb6e4a334dea7296060820de12a768b76da.tar.gz
sway-7e420cb6e4a334dea7296060820de12a768b76da.tar.zst
sway-7e420cb6e4a334dea7296060820de12a768b76da.zip
input: Add support for tablet protocol.
Sway has basic support for drawing tablets, but does not expose properties such as pressure sensitivity. This implements the wlr tablet v2 protocol, providing tablet events to Wayland clients.
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index b2243fe3..ebd40343 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -8,6 +8,7 @@
8#include <wlr/types/wlr_data_device.h> 8#include <wlr/types/wlr_data_device.h>
9#include <wlr/types/wlr_output_layout.h> 9#include <wlr/types/wlr_output_layout.h>
10#include <wlr/types/wlr_primary_selection.h> 10#include <wlr/types/wlr_primary_selection.h>
11#include <wlr/types/wlr_tablet_v2.h>
11#include <wlr/types/wlr_xcursor_manager.h> 12#include <wlr/types/wlr_xcursor_manager.h>
12#include "config.h" 13#include "config.h"
13#include "list.h" 14#include "list.h"
@@ -18,6 +19,7 @@
18#include "sway/input/keyboard.h" 19#include "sway/input/keyboard.h"
19#include "sway/input/seat.h" 20#include "sway/input/seat.h"
20#include "sway/input/switch.h" 21#include "sway/input/switch.h"
22#include "sway/input/tablet.h"
21#include "sway/ipc-server.h" 23#include "sway/ipc-server.h"
22#include "sway/layers.h" 24#include "sway/layers.h"
23#include "sway/output.h" 25#include "sway/output.h"
@@ -34,6 +36,8 @@ static void seat_device_destroy(struct sway_seat_device *seat_device) {
34 } 36 }
35 37
36 sway_keyboard_destroy(seat_device->keyboard); 38 sway_keyboard_destroy(seat_device->keyboard);
39 sway_tablet_destroy(seat_device->tablet);
40 sway_tablet_pad_destroy(seat_device->tablet_pad);
37 wlr_cursor_detach_input_device(seat_device->sway_seat->cursor->cursor, 41 wlr_cursor_detach_input_device(seat_device->sway_seat->cursor->cursor,
38 seat_device->input_device->wlr_device); 42 seat_device->input_device->wlr_device);
39 wl_list_remove(&seat_device->link); 43 wl_list_remove(&seat_device->link);
@@ -118,6 +122,14 @@ static void seat_keyboard_notify_enter(struct sway_seat *seat,
118 state->pressed_keycodes, state->npressed, &keyboard->modifiers); 122 state->pressed_keycodes, state->npressed, &keyboard->modifiers);
119} 123}
120 124
125static void seat_tablet_pads_notify_enter(struct sway_seat *seat,
126 struct wlr_surface *surface) {
127 struct sway_seat_device *seat_device;
128 wl_list_for_each(seat_device, &seat->devices, link) {
129 sway_tablet_pad_notify_enter(seat_device->tablet_pad, surface);
130 }
131}
132
121/** 133/**
122 * If con is a view, set it as active and enable keyboard input. 134 * If con is a view, set it as active and enable keyboard input.
123 * If con is a container, set all child views as active and don't enable 135 * If con is a container, set all child views as active and don't enable
@@ -138,6 +150,7 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) {
138#endif 150#endif
139 151
140 seat_keyboard_notify_enter(seat, view->surface); 152 seat_keyboard_notify_enter(seat, view->surface);
153 seat_tablet_pads_notify_enter(seat, view->surface);
141 154
142 struct wlr_pointer_constraint_v1 *constraint = 155 struct wlr_pointer_constraint_v1 *constraint =
143 wlr_pointer_constraints_v1_constraint_for_surface( 156 wlr_pointer_constraints_v1_constraint_for_surface(
@@ -638,14 +651,23 @@ static void seat_configure_touch(struct sway_seat *seat,
638 651
639static void seat_configure_tablet_tool(struct sway_seat *seat, 652static void seat_configure_tablet_tool(struct sway_seat *seat,
640 struct sway_seat_device *sway_device) { 653 struct sway_seat_device *sway_device) {
641 if ((seat->wlr_seat->capabilities & WL_SEAT_CAPABILITY_POINTER) == 0) { 654 if (!sway_device->tablet) {
642 seat_configure_xcursor(seat); 655 sway_device->tablet = sway_tablet_create(seat, sway_device);
643 } 656 }
657 sway_configure_tablet(sway_device->tablet);
644 wlr_cursor_attach_input_device(seat->cursor->cursor, 658 wlr_cursor_attach_input_device(seat->cursor->cursor,
645 sway_device->input_device->wlr_device); 659 sway_device->input_device->wlr_device);
646 seat_apply_input_config(seat, sway_device); 660 seat_apply_input_config(seat, sway_device);
647} 661}
648 662
663static void seat_configure_tablet_pad(struct sway_seat *seat,
664 struct sway_seat_device *sway_device) {
665 if (!sway_device->tablet) {
666 sway_device->tablet_pad = sway_tablet_pad_create(seat, sway_device);
667 }
668 sway_configure_tablet_pad(sway_device->tablet_pad);
669}
670
649static struct sway_seat_device *seat_get_device(struct sway_seat *seat, 671static struct sway_seat_device *seat_get_device(struct sway_seat *seat,
650 struct sway_input_device *input_device) { 672 struct sway_input_device *input_device) {
651 struct sway_seat_device *seat_device = NULL; 673 struct sway_seat_device *seat_device = NULL;
@@ -682,7 +704,7 @@ void seat_configure_device(struct sway_seat *seat,
682 seat_configure_tablet_tool(seat, seat_device); 704 seat_configure_tablet_tool(seat, seat_device);
683 break; 705 break;
684 case WLR_INPUT_DEVICE_TABLET_PAD: 706 case WLR_INPUT_DEVICE_TABLET_PAD:
685 sway_log(SWAY_DEBUG, "TODO: configure tablet pad"); 707 seat_configure_tablet_pad(seat, seat_device);
686 break; 708 break;
687 } 709 }
688} 710}
@@ -1079,6 +1101,7 @@ void seat_set_focus_surface(struct sway_seat *seat,
1079 seat->has_focus = false; 1101 seat->has_focus = false;
1080 } 1102 }
1081 seat_keyboard_notify_enter(seat, surface); 1103 seat_keyboard_notify_enter(seat, surface);
1104 seat_tablet_pads_notify_enter(seat, surface);
1082} 1105}
1083 1106
1084void seat_set_focus_layer(struct sway_seat *seat, 1107void seat_set_focus_layer(struct sway_seat *seat,