commit 21ce20885a6a6e9e7178778513b09fea9354c603
parent 338a0399f8d7c0ebe9cbb989945d8fd646d8d407
Author: Tony Crisci <tony@dubstepdish.com>
Date: Thu, 7 Dec 2017 07:31:49 -0500
rename input to input-manager
Diffstat:
7 files changed, 102 insertions(+), 99 deletions(-)
diff --git a/include/sway/input-manager.h b/include/sway/input-manager.h
@@ -0,0 +1,19 @@
+#ifndef _SWAY_INPUT_H
+#define _SWAY_INPUT_H
+#include <libinput.h>
+#include "sway/server.h"
+#include "config.h"
+#include "list.h"
+
+struct sway_input_manager {
+ list_t *input_devices;
+};
+
+struct input_config *new_input_config(const char* identifier);
+
+char* libinput_dev_unique_id(struct libinput_device *dev);
+
+struct sway_input_manager *sway_input_manager_create(
+ struct sway_server *server);
+
+#endif
diff --git a/include/sway/input.h b/include/sway/input.h
@@ -1,18 +0,0 @@
-#ifndef _SWAY_INPUT_H
-#define _SWAY_INPUT_H
-#include <libinput.h>
-#include "sway/server.h"
-#include "config.h"
-#include "list.h"
-
-struct sway_input {
- list_t *input_devices;
-};
-
-struct input_config *new_input_config(const char* identifier);
-
-char* libinput_dev_unique_id(struct libinput_device *dev);
-
-struct sway_input *sway_input_create(struct sway_server *server);
-
-#endif
diff --git a/include/sway/server.h b/include/sway/server.h
@@ -22,7 +22,7 @@ struct sway_server {
struct wlr_compositor *compositor;
struct wlr_data_device_manager *data_device_manager;
- struct sway_input *input;
+ struct sway_input_manager *input;
struct wl_listener output_add;
struct wl_listener output_remove;
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
@@ -0,0 +1,79 @@
+#define _XOPEN_SOURCE 700
+#include <ctype.h>
+#include <float.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <libinput.h>
+#include "sway/config.h"
+#include "sway/input-manager.h"
+#include "sway/server.h"
+#include "list.h"
+#include "log.h"
+
+struct input_config *current_input_config = NULL;
+
+struct sway_input_manager *sway_input_manager_create(
+ struct sway_server *server) {
+ struct sway_input_manager *input =
+ calloc(1, sizeof(struct sway_input_manager));
+ if (!input) {
+ return NULL;
+ }
+ return input;
+}
+
+struct input_config *new_input_config(const char* identifier) {
+ struct input_config *input = calloc(1, sizeof(struct input_config));
+ if (!input) {
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
+ sway_log(L_DEBUG, "new_input_config(%s)", identifier);
+ if (!(input->identifier = strdup(identifier))) {
+ free(input);
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
+
+ input->tap = INT_MIN;
+ input->drag_lock = INT_MIN;
+ input->dwt = INT_MIN;
+ input->send_events = INT_MIN;
+ input->click_method = INT_MIN;
+ input->middle_emulation = INT_MIN;
+ input->natural_scroll = INT_MIN;
+ input->accel_profile = INT_MIN;
+ input->pointer_accel = FLT_MIN;
+ input->scroll_method = INT_MIN;
+ input->left_handed = INT_MIN;
+
+ return input;
+}
+
+char *libinput_dev_unique_id(struct libinput_device *device) {
+ int vendor = libinput_device_get_id_vendor(device);
+ int product = libinput_device_get_id_product(device);
+ char *name = strdup(libinput_device_get_name(device));
+
+ char *p = name;
+ for (; *p; ++p) {
+ if (*p == ' ') {
+ *p = '_';
+ }
+ }
+
+ sway_log(L_DEBUG, "rewritten name %s", name);
+
+ int len = strlen(name) + sizeof(char) * 6;
+ char *identifier = malloc(len);
+ if (!identifier) {
+ sway_log(L_ERROR, "Unable to allocate unique input device name");
+ return NULL;
+ }
+
+ const char *fmt = "%d:%d:%s";
+ snprintf(identifier, len, fmt, vendor, product, name);
+ free(name);
+ return identifier;
+}
diff --git a/sway/input/input.c b/sway/input/input.c
@@ -1,77 +0,0 @@
-#define _XOPEN_SOURCE 700
-#include <ctype.h>
-#include <float.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <libinput.h>
-#include "sway/config.h"
-#include "sway/input.h"
-#include "sway/server.h"
-#include "list.h"
-#include "log.h"
-
-struct input_config *current_input_config = NULL;
-
-struct sway_input *sway_input_create(struct sway_server *server) {
- struct sway_input *input = calloc(1, sizeof(struct sway_input));
- if (!input) {
- return NULL;
- }
- return input;
-}
-
-struct input_config *new_input_config(const char* identifier) {
- struct input_config *input = calloc(1, sizeof(struct input_config));
- if (!input) {
- sway_log(L_DEBUG, "Unable to allocate input config");
- return NULL;
- }
- sway_log(L_DEBUG, "new_input_config(%s)", identifier);
- if (!(input->identifier = strdup(identifier))) {
- free(input);
- sway_log(L_DEBUG, "Unable to allocate input config");
- return NULL;
- }
-
- input->tap = INT_MIN;
- input->drag_lock = INT_MIN;
- input->dwt = INT_MIN;
- input->send_events = INT_MIN;
- input->click_method = INT_MIN;
- input->middle_emulation = INT_MIN;
- input->natural_scroll = INT_MIN;
- input->accel_profile = INT_MIN;
- input->pointer_accel = FLT_MIN;
- input->scroll_method = INT_MIN;
- input->left_handed = INT_MIN;
-
- return input;
-}
-
-char *libinput_dev_unique_id(struct libinput_device *device) {
- int vendor = libinput_device_get_id_vendor(device);
- int product = libinput_device_get_id_product(device);
- char *name = strdup(libinput_device_get_name(device));
-
- char *p = name;
- for (; *p; ++p) {
- if (*p == ' ') {
- *p = '_';
- }
- }
-
- sway_log(L_DEBUG, "rewritten name %s", name);
-
- int len = strlen(name) + sizeof(char) * 6;
- char *identifier = malloc(len);
- if (!identifier) {
- sway_log(L_ERROR, "Unable to allocate unique input device name");
- return NULL;
- }
-
- const char *fmt = "%d:%d:%s";
- snprintf(identifier, len, fmt, vendor, product, name);
- free(name);
- return identifier;
-}
diff --git a/sway/meson.build b/sway/meson.build
@@ -2,7 +2,7 @@ sway_sources = files(
'main.c',
'server.c',
'commands.c',
- 'input/input.c',
+ 'input/input-manager.c',
'commands/exit.c',
'commands/exec.c',
'commands/exec_always.c',
diff --git a/sway/server.c b/sway/server.c
@@ -11,7 +11,7 @@
// TODO WLR: make Xwayland optional
#include <wlr/xwayland.h>
#include "sway/server.h"
-#include "sway/input.h"
+#include "sway/input-manager.h"
#include "log.h"
bool server_init(struct sway_server *server) {
@@ -60,7 +60,7 @@ bool server_init(struct sway_server *server) {
return false;
}
- server->input = sway_input_create(server);
+ server->input = sway_input_manager_create(server);
return true;
}