aboutsummaryrefslogtreecommitdiff
path: root/sway/handlers.c
diff options
context:
space:
mode:
authorCole Mickens <cole.mickens@gmail.com>2016-01-17 02:53:37 -0800
committerCole Mickens <cole.mickens@gmail.com>2016-01-19 06:51:36 -0800
commit28081b76891ddbbb825dee6c202037d78aa8f164 (patch)
tree6b7412f626f5d9f10dba8920a2543dfd3c5a662e /sway/handlers.c
parentfe241126bb8d696d45dd30fc975da022f79c9928 (diff)
libinput
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 @@
#include <xkbcommon/xkbcommon.h>
#include <stdlib.h>
#include <stdbool.h>
+#include <libinput.h>
#include <math.h>
#include <wlc/wlc.h>
#include <wlc/wlc-wayland.h>
@@ -21,6 +22,8 @@
#include "extensions.h"
#include "criteria.h"
#include "ipc-server.h"
+#include "list.h"
+#include "input.h"
// Event should be sent to client
#define EVENT_PASSTHROUGH false
@@ -30,6 +33,37 @@
/* Handles */
+static bool handle_input_created(struct libinput_device *device) {
+ const char *identifier = libinput_dev_unique_id(device);
+ sway_log(L_INFO, "Found input device (%s)", identifier);
+
+ list_add(input_devices, device);
+
+ struct input_config *ic = NULL;
+ int i;
+ for (i = 0; i < config->input_configs->length; ++i) {
+ struct input_config *cur = config->input_configs->items[i];
+ if (strcasecmp(identifier, cur->identifier) == 0) {
+ ic = cur;
+ break;
+ }
+ }
+
+ apply_input_config(ic, device);
+ return true;
+}
+
+static void handle_input_destroyed(struct libinput_device *device) {
+ int i;
+ list_t *list = input_devices;
+ for (i = 0; i < list->length; ++i) {
+ if(((struct libinput_device *)list->items[i]) == device) {
+ list_del(list, i);
+ break;
+ }
+ }
+}
+
static bool handle_output_created(wlc_handle output) {
swayc_t *op = new_output(output);
@@ -660,5 +694,9 @@ struct wlc_interface interface = {
},
.compositor = {
.ready = handle_wlc_ready
+ },
+ .input = {
+ .created = handle_input_created,
+ .destroyed = handle_input_destroyed
}
};