summaryrefslogtreecommitdiffstats
path: root/sway/handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 60bfac87..b1c0e26a 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -1,6 +1,7 @@
1#include <xkbcommon/xkbcommon.h> 1#include <xkbcommon/xkbcommon.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <stdbool.h> 3#include <stdbool.h>
4#include <libinput.h>
4#include <math.h> 5#include <math.h>
5#include <wlc/wlc.h> 6#include <wlc/wlc.h>
6#include <wlc/wlc-wayland.h> 7#include <wlc/wlc-wayland.h>
@@ -21,6 +22,8 @@
21#include "extensions.h" 22#include "extensions.h"
22#include "criteria.h" 23#include "criteria.h"
23#include "ipc-server.h" 24#include "ipc-server.h"
25#include "list.h"
26#include "input.h"
24 27
25// Event should be sent to client 28// Event should be sent to client
26#define EVENT_PASSTHROUGH false 29#define EVENT_PASSTHROUGH false
@@ -30,6 +33,37 @@
30 33
31/* Handles */ 34/* Handles */
32 35
36static bool handle_input_created(struct libinput_device *device) {
37 const char *identifier = libinput_dev_unique_id(device);
38 sway_log(L_INFO, "Found input device (%s)", identifier);
39
40 list_add(input_devices, device);
41
42 struct input_config *ic = NULL;
43 int i;
44 for (i = 0; i < config->input_configs->length; ++i) {
45 struct input_config *cur = config->input_configs->items[i];
46 if (strcasecmp(identifier, cur->identifier) == 0) {
47 ic = cur;
48 break;
49 }
50 }
51
52 apply_input_config(ic, device);
53 return true;
54}
55
56static void handle_input_destroyed(struct libinput_device *device) {
57 int i;
58 list_t *list = input_devices;
59 for (i = 0; i < list->length; ++i) {
60 if(((struct libinput_device *)list->items[i]) == device) {
61 list_del(list, i);
62 break;
63 }
64 }
65}
66
33static bool handle_output_created(wlc_handle output) { 67static bool handle_output_created(wlc_handle output) {
34 swayc_t *op = new_output(output); 68 swayc_t *op = new_output(output);
35 69
@@ -660,5 +694,9 @@ struct wlc_interface interface = {
660 }, 694 },
661 .compositor = { 695 .compositor = {
662 .ready = handle_wlc_ready 696 .ready = handle_wlc_ready
697 },
698 .input = {
699 .created = handle_input_created,
700 .destroyed = handle_input_destroyed
663 } 701 }
664}; 702};