From a7446792a1a0fd9fe3391f041d7bbfe9e2b11255 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 22 Oct 2017 23:19:21 -0400 Subject: Consider scale factor when rendering views --- rootston/config.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'rootston/config.c') diff --git a/rootston/config.c b/rootston/config.c index 18138ab0..983117ba 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -220,6 +220,7 @@ static int config_ini_handler(void *user, const char *section, const char *name, oc = calloc(1, sizeof(struct output_config)); oc->name = strdup(output_name); oc->transform = WL_OUTPUT_TRANSFORM_NORMAL; + oc->scale = 1; wl_list_insert(&config->outputs, &oc->link); } @@ -227,6 +228,9 @@ static int config_ini_handler(void *user, const char *section, const char *name, oc->x = strtol(value, NULL, 10); } else if (strcmp(name, "y") == 0) { oc->y = strtol(value, NULL, 10); + } else if (strcmp(name, "scale") == 0) { + oc->scale = strtol(value, NULL, 10); + assert(oc->scale >= 1); } else if (strcmp(name, "rotate") == 0) { if (strcmp(value, "90") == 0) { oc->transform = WL_OUTPUT_TRANSFORM_90; -- cgit v1.2.3 From 53021f8ed428a1a023769339e6162bfebbe4c7a2 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 2 Nov 2017 20:13:10 -0400 Subject: rootston: break up input.h --- include/rootston/input.h | 52 ------------------------------------------ include/rootston/keyboard.h | 22 ++++++++++++++++++ include/rootston/pointer.h | 16 +++++++++++++ include/rootston/tablet_tool.h | 20 ++++++++++++++++ include/rootston/touch.h | 22 ++++++++++++++++++ rootston/config.c | 1 + rootston/cursor.c | 4 ++++ rootston/input.c | 4 ++++ rootston/keyboard.c | 1 + rootston/pointer.c | 1 + rootston/tablet_tool.c | 1 + rootston/touch.c | 1 + 12 files changed, 93 insertions(+), 52 deletions(-) create mode 100644 include/rootston/keyboard.h create mode 100644 include/rootston/pointer.h create mode 100644 include/rootston/tablet_tool.h create mode 100644 include/rootston/touch.h (limited to 'rootston/config.c') diff --git a/include/rootston/input.h b/include/rootston/input.h index 20b73c8a..6d07de43 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -1,6 +1,5 @@ #ifndef _ROOTSTON_INPUT_H #define _ROOTSTON_INPUT_H -#include #include #include #include @@ -10,41 +9,6 @@ #include "rootston/view.h" #include "rootston/server.h" -#define ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP 32 - -struct roots_keyboard { - struct roots_input *input; - struct wlr_input_device *device; - struct wl_listener key; - struct wl_listener modifiers; - struct wl_list link; - - xkb_keysym_t pressed_keysyms[ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP]; -}; - -struct roots_pointer { - struct roots_input *input; - struct wlr_input_device *device; - struct wl_list link; -}; - -struct roots_touch { - struct roots_input *input; - struct wlr_input_device *device; - struct wl_list link; -}; - -// TODO: tablet pad -struct roots_tablet_tool { - struct roots_input *input; - struct wlr_input_device *device; - struct wl_listener axis; - struct wl_listener proximity; - struct wl_listener tip; - struct wl_listener button; - struct wl_list link; -}; - enum roots_cursor_mode { ROOTS_CURSOR_PASSTHROUGH = 0, ROOTS_CURSOR_MOVE = 1, @@ -77,13 +41,6 @@ struct roots_drag_icon { struct wl_listener surface_commit; }; -struct roots_touch_point { - struct roots_touch *device; - int32_t slot; - double x, y; - struct wl_list link; -}; - struct roots_input { struct roots_config *config; struct roots_server *server; @@ -138,15 +95,6 @@ struct roots_input *input_create(struct roots_server *server, struct roots_config *config); void input_destroy(struct roots_input *input); -void pointer_add(struct wlr_input_device *device, struct roots_input *input); -void pointer_remove(struct wlr_input_device *device, struct roots_input *input); -void keyboard_add(struct wlr_input_device *device, struct roots_input *input); -void keyboard_remove(struct wlr_input_device *device, struct roots_input *input); -void touch_add(struct wlr_input_device *device, struct roots_input *input); -void touch_remove(struct wlr_input_device *device, struct roots_input *input); -void tablet_tool_add(struct wlr_input_device *device, struct roots_input *input); -void tablet_tool_remove(struct wlr_input_device *device, struct roots_input *input); - void cursor_initialize(struct roots_input *input); void cursor_load_config(struct roots_config *config, struct wlr_cursor *cursor, diff --git a/include/rootston/keyboard.h b/include/rootston/keyboard.h new file mode 100644 index 00000000..33017b56 --- /dev/null +++ b/include/rootston/keyboard.h @@ -0,0 +1,22 @@ +#ifndef _ROOTSTON_KEYBOARD_H +#define _ROOTSTON_KEYBOARD_H + +#include +#include "rootston/input.h" + +#define ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP 32 + +struct roots_keyboard { + struct roots_input *input; + struct wlr_input_device *device; + struct wl_listener key; + struct wl_listener modifiers; + struct wl_list link; + + xkb_keysym_t pressed_keysyms[ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP]; +}; + +void keyboard_add(struct wlr_input_device *device, struct roots_input *input); +void keyboard_remove(struct wlr_input_device *device, struct roots_input *input); + +#endif diff --git a/include/rootston/pointer.h b/include/rootston/pointer.h new file mode 100644 index 00000000..b3fc8c3a --- /dev/null +++ b/include/rootston/pointer.h @@ -0,0 +1,16 @@ +#ifndef _ROOTSTON_POINTER_H +#define _ROOTSTON_POINTER_H + +#include +#include + +struct roots_pointer { + struct roots_input *input; + struct wlr_input_device *device; + struct wl_list link; +}; + +void pointer_add(struct wlr_input_device *device, struct roots_input *input); +void pointer_remove(struct wlr_input_device *device, struct roots_input *input); + +#endif diff --git a/include/rootston/tablet_tool.h b/include/rootston/tablet_tool.h new file mode 100644 index 00000000..72ebf6d8 --- /dev/null +++ b/include/rootston/tablet_tool.h @@ -0,0 +1,20 @@ +#ifndef _ROOTSTON_TABLET_TOOL_H +#define _ROOTSTON_TABLET_TOOL_H + +#include +#include "rootston/input.h" + +struct roots_tablet_tool { + struct roots_input *input; + struct wlr_input_device *device; + struct wl_listener axis; + struct wl_listener proximity; + struct wl_listener tip; + struct wl_listener button; + struct wl_list link; +}; + +void tablet_tool_add(struct wlr_input_device *device, struct roots_input *input); +void tablet_tool_remove(struct wlr_input_device *device, struct roots_input *input); + +#endif diff --git a/include/rootston/touch.h b/include/rootston/touch.h new file mode 100644 index 00000000..1624c3ad --- /dev/null +++ b/include/rootston/touch.h @@ -0,0 +1,22 @@ +#ifndef _ROOTSTON_TOUCH_H +#define _ROOTSTON_TOUCH_H + +#include + +struct roots_touch { + struct roots_input *input; + struct wlr_input_device *device; + struct wl_list link; +}; + +struct roots_touch_point { + struct roots_touch *device; + int32_t slot; + double x, y; + struct wl_list link; +}; + +void touch_add(struct wlr_input_device *device, struct roots_input *input); +void touch_remove(struct wlr_input_device *device, struct roots_input *input); + +#endif diff --git a/rootston/config.c b/rootston/config.c index dc7a4b1d..a3ae78be 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -13,6 +13,7 @@ #include #include "rootston/config.h" #include "rootston/input.h" +#include "rootston/keyboard.h" #include "rootston/ini.h" static void usage(const char *name, int ret) { diff --git a/rootston/cursor.c b/rootston/cursor.c index 31001a9f..61dcae7a 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -18,6 +18,10 @@ #include "rootston/input.h" #include "rootston/desktop.h" #include "rootston/view.h" +#include "rootston/keyboard.h" +#include "rootston/pointer.h" +#include "rootston/tablet_tool.h" +#include "rootston/touch.h" const struct roots_input_event *get_input_event(struct roots_input *input, uint32_t serial) { diff --git a/rootston/input.c b/rootston/input.c index 5d367a5e..c8d46a69 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -8,6 +8,10 @@ #include "rootston/server.h" #include "rootston/config.h" #include "rootston/input.h" +#include "rootston/tablet_tool.h" +#include "rootston/keyboard.h" +#include "rootston/pointer.h" +#include "rootston/touch.h" static const char *device_type(enum wlr_input_device_type type) { switch (type) { diff --git a/rootston/keyboard.c b/rootston/keyboard.c index e174b731..9458a05c 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -10,6 +10,7 @@ #include #include #include "rootston/input.h" +#include "rootston/keyboard.h" static ssize_t keyboard_pressed_keysym_index(struct roots_keyboard *keyboard, xkb_keysym_t keysym) { diff --git a/rootston/pointer.c b/rootston/pointer.c index 299ecdfc..cb099264 100644 --- a/rootston/pointer.c +++ b/rootston/pointer.c @@ -3,6 +3,7 @@ #include #include #include "rootston/input.h" +#include "rootston/pointer.h" void pointer_add(struct wlr_input_device *device, struct roots_input *input) { struct roots_pointer *pointer = calloc(sizeof(struct roots_pointer), 1); diff --git a/rootston/tablet_tool.c b/rootston/tablet_tool.c index a612e683..3327115d 100644 --- a/rootston/tablet_tool.c +++ b/rootston/tablet_tool.c @@ -4,6 +4,7 @@ #include #include #include "rootston/input.h" +#include "rootston/tablet_tool.h" void tablet_tool_add(struct wlr_input_device *device, struct roots_input *input) { struct roots_tablet_tool *tool = calloc(sizeof(struct roots_tablet_tool), 1); diff --git a/rootston/touch.c b/rootston/touch.c index f6d9b11a..069853ab 100644 --- a/rootston/touch.c +++ b/rootston/touch.c @@ -3,6 +3,7 @@ #include #include #include "rootston/input.h" +#include "rootston/touch.h" // TODO: we'll likely want touch events to both control the cursor *and* be // submitted directly to the seat. -- cgit v1.2.3 From 447c561d1588226fd6aeb6668c7adb352cb77725 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Fri, 3 Nov 2017 06:08:37 -0400 Subject: rootston: seat config by device --- include/rootston/config.h | 1 + rootston/config.c | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'rootston/config.c') diff --git a/include/rootston/config.h b/include/rootston/config.h index 75c04619..58fb1a1c 100644 --- a/include/rootston/config.h +++ b/include/rootston/config.h @@ -19,6 +19,7 @@ struct device_config { char *name; char *mapped_output; struct wlr_box *mapped_box; + char *seat; struct wl_list link; }; diff --git a/rootston/config.c b/rootston/config.c index a3ae78be..815040bf 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -289,6 +289,7 @@ static int config_ini_handler(void *user, const char *section, const char *name, if (!found) { dc = calloc(1, sizeof(struct device_config)); dc->name = strdup(device_name); + dc->seat = strdup("seat0"); wl_list_insert(&config->devices, &dc->link); } @@ -298,6 +299,9 @@ static int config_ini_handler(void *user, const char *section, const char *name, } else if (strcmp(name, "geometry") == 0) { free(dc->mapped_box); dc->mapped_box = parse_geometry(value); + } else if (strcmp(name, "seat") == 0) { + free(dc->seat); + dc->seat = strdup(value); } else { wlr_log(L_ERROR, "got unknown device config: %s", name); } @@ -387,6 +391,7 @@ void roots_config_destroy(struct roots_config *config) { struct device_config *dc, *dtmp = NULL; wl_list_for_each_safe(dc, dtmp, &config->devices, link) { free(dc->name); + free(dc->seat); free(dc->mapped_output); free(dc->mapped_box); free(dc); -- cgit v1.2.3 From 4ccadf713b68a01540ec192981e167821d75294e Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 11 Nov 2017 10:40:56 -0500 Subject: rootston: fix formatting for xwayland config --- rootston/config.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'rootston/config.c') diff --git a/rootston/config.c b/rootston/config.c index 54f10fcd..73bb6eb0 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -194,17 +194,17 @@ static int config_ini_handler(void *user, const char *section, const char *name, const char *value) { struct roots_config *config = user; if (strcmp(section, "core") == 0) { - if (strcmp(name, "xwayland") == 0) { - if (strcasecmp(value, "true") == 0) { - config->xwayland = true; - } else if (strcasecmp(value, "false") == 0) { - config->xwayland = false; - } else { - wlr_log(L_ERROR, "got unknown xwayland value: %s", value); - } - } else { - wlr_log(L_ERROR, "got unknown core config: %s", name); - } + if (strcmp(name, "xwayland") == 0) { + if (strcasecmp(value, "true") == 0) { + config->xwayland = true; + } else if (strcasecmp(value, "false") == 0) { + config->xwayland = false; + } else { + wlr_log(L_ERROR, "got unknown xwayland value: %s", value); + } + } else { + wlr_log(L_ERROR, "got unknown core config: %s", name); + } } else if (strncmp(output_prefix, section, strlen(output_prefix)) == 0) { const char *output_name = section + strlen(output_prefix); struct output_config *oc; -- cgit v1.2.3 From 1db3b5512821b1d6f936897f598e0f4d12233e8e Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 11 Nov 2017 10:59:04 -0500 Subject: rootston: prefix config structs and functions --- include/rootston/config.h | 18 +++++++++--------- include/rootston/keyboard.h | 2 +- rootston/config.c | 42 ++++++++++++++++++++++-------------------- rootston/input.c | 3 ++- rootston/keyboard.c | 15 ++++++++------- rootston/main.c | 2 +- rootston/output.c | 6 ++++-- rootston/seat.c | 8 ++++---- 8 files changed, 51 insertions(+), 45 deletions(-) (limited to 'rootston/config.c') diff --git a/include/rootston/config.h b/include/rootston/config.h index d2a25b5b..71ee61c7 100644 --- a/include/rootston/config.h +++ b/include/rootston/config.h @@ -3,7 +3,7 @@ #include #include -struct output_config { +struct roots_output_config { char *name; enum wl_output_transform transform; int x, y; @@ -15,7 +15,7 @@ struct output_config { } mode; }; -struct device_config { +struct roots_device_config { char *name; char *mapped_output; struct wlr_box *mapped_box; @@ -23,7 +23,7 @@ struct device_config { struct wl_list link; }; -struct binding_config { +struct roots_binding_config { uint32_t modifiers; xkb_keysym_t *keysyms; size_t keysyms_len; @@ -31,7 +31,7 @@ struct binding_config { struct wl_list link; }; -struct keyboard_config { +struct roots_keyboard_config { char *name; uint32_t meta_key; char *rules; @@ -63,7 +63,7 @@ struct roots_config { * arguments can specify the location of the config file. If it is not * specified, the default location will be used. */ -struct roots_config *parse_args(int argc, char *argv[]); +struct roots_config *roots_config_create_from_args(int argc, char *argv[]); /** * Destroy the config and free its resources. @@ -74,21 +74,21 @@ void roots_config_destroy(struct roots_config *config); * Get configuration for the output. If the output is not configured, returns * NULL. */ -struct output_config *config_get_output(struct roots_config *config, +struct roots_output_config *roots_config_get_output(struct roots_config *config, struct wlr_output *output); /** * Get configuration for the device. If the device is not configured, returns * NULL. */ -struct device_config *config_get_device(struct roots_config *config, +struct roots_device_config *roots_config_get_device(struct roots_config *config, struct wlr_input_device *device); /** * Get configuration for the keyboard. If the keyboard is not configured, * returns NULL. A NULL device returns the default config for keyboards. */ -struct keyboard_config *config_get_keyboard(struct roots_config *config, - struct wlr_input_device *device); +struct roots_keyboard_config *roots_config_get_keyboard( + struct roots_config *config, struct wlr_input_device *device); #endif diff --git a/include/rootston/keyboard.h b/include/rootston/keyboard.h index 51977f08..15e7c9c4 100644 --- a/include/rootston/keyboard.h +++ b/include/rootston/keyboard.h @@ -10,7 +10,7 @@ struct roots_keyboard { struct roots_input *input; struct roots_seat *seat; struct wlr_input_device *device; - struct keyboard_config *config; + struct roots_keyboard_config *config; struct wl_list link; struct wl_listener keyboard_key; diff --git a/rootston/config.c b/rootston/config.c index 73bb6eb0..9530ba37 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -115,7 +115,8 @@ static uint32_t parse_modifier(const char *symname) { void add_binding_config(struct wl_list *bindings, const char* combination, const char* command) { - struct binding_config *bc = calloc(1, sizeof(struct binding_config)); + struct roots_binding_config *bc = + calloc(1, sizeof(struct roots_binding_config)); xkb_keysym_t keysyms[ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP]; char *symnames = strdup(combination); @@ -151,7 +152,7 @@ void add_binding_config(struct wl_list *bindings, const char* combination, static void config_handle_keyboard(struct roots_config *config, const char *device_name, const char *name, const char *value) { - struct keyboard_config *kc; + struct roots_keyboard_config *kc; bool found = false; wl_list_for_each(kc, &config->keyboards, link) { if (strcmp(kc->name, device_name) == 0) { @@ -161,7 +162,7 @@ static void config_handle_keyboard(struct roots_config *config, } if (!found) { - kc = calloc(1, sizeof(struct keyboard_config)); + kc = calloc(1, sizeof(struct roots_keyboard_config)); kc->name = strdup(device_name); wl_list_insert(&config->keyboards, &kc->link); } @@ -207,7 +208,7 @@ static int config_ini_handler(void *user, const char *section, const char *name, } } else if (strncmp(output_prefix, section, strlen(output_prefix)) == 0) { const char *output_name = section + strlen(output_prefix); - struct output_config *oc; + struct roots_output_config *oc; bool found = false; wl_list_for_each(oc, &config->outputs, link) { @@ -218,7 +219,7 @@ static int config_ini_handler(void *user, const char *section, const char *name, } if (!found) { - oc = calloc(1, sizeof(struct output_config)); + oc = calloc(1, sizeof(struct roots_output_config)); oc->name = strdup(output_name); oc->transform = WL_OUTPUT_TRANSFORM_NORMAL; oc->scale = 1; @@ -281,7 +282,7 @@ static int config_ini_handler(void *user, const char *section, const char *name, } else if (strncmp(device_prefix, section, strlen(device_prefix)) == 0) { const char *device_name = section + strlen(device_prefix); - struct device_config *dc; + struct roots_device_config *dc; bool found = false; wl_list_for_each(dc, &config->devices, link) { if (strcmp(dc->name, device_name) == 0) { @@ -291,7 +292,7 @@ static int config_ini_handler(void *user, const char *section, const char *name, } if (!found) { - dc = calloc(1, sizeof(struct device_config)); + dc = calloc(1, sizeof(struct roots_device_config)); dc->name = strdup(device_name); dc->seat = strdup("seat0"); wl_list_insert(&config->devices, &dc->link); @@ -323,7 +324,7 @@ static int config_ini_handler(void *user, const char *section, const char *name, return 1; } -struct roots_config *parse_args(int argc, char *argv[]) { +struct roots_config *roots_config_create_from_args(int argc, char *argv[]) { struct roots_config *config = calloc(1, sizeof(struct roots_config)); if (config == NULL) { return NULL; @@ -370,7 +371,8 @@ struct roots_config *parse_args(int argc, char *argv[]) { add_binding_config(&config->bindings, "Logo+Shift+E", "exit"); add_binding_config(&config->bindings, "Ctrl+q", "close"); add_binding_config(&config->bindings, "Alt+Tab", "next_window"); - struct keyboard_config *kc = calloc(1, sizeof(struct keyboard_config)); + struct roots_keyboard_config *kc = + calloc(1, sizeof(struct roots_keyboard_config)); kc->meta_key = WLR_MODIFIER_LOGO; kc->name = strdup(""); wl_list_insert(&config->keyboards, &kc->link); @@ -386,13 +388,13 @@ struct roots_config *parse_args(int argc, char *argv[]) { } void roots_config_destroy(struct roots_config *config) { - struct output_config *oc, *otmp = NULL; + struct roots_output_config *oc, *otmp = NULL; wl_list_for_each_safe(oc, otmp, &config->outputs, link) { free(oc->name); free(oc); } - struct device_config *dc, *dtmp = NULL; + struct roots_device_config *dc, *dtmp = NULL; wl_list_for_each_safe(dc, dtmp, &config->devices, link) { free(dc->name); free(dc->seat); @@ -401,7 +403,7 @@ void roots_config_destroy(struct roots_config *config) { free(dc); } - struct keyboard_config *kc, *ktmp = NULL; + struct roots_keyboard_config *kc, *ktmp = NULL; wl_list_for_each_safe(kc, ktmp, &config->bindings, link) { free(kc->name); free(kc->rules); @@ -412,7 +414,7 @@ void roots_config_destroy(struct roots_config *config) { free(kc); } - struct binding_config *bc, *btmp = NULL; + struct roots_binding_config *bc, *btmp = NULL; wl_list_for_each_safe(bc, btmp, &config->bindings, link) { free(bc->keysyms); free(bc->command); @@ -425,9 +427,9 @@ void roots_config_destroy(struct roots_config *config) { free(config); } -struct output_config *config_get_output(struct roots_config *config, +struct roots_output_config *roots_config_get_output(struct roots_config *config, struct wlr_output *output) { - struct output_config *o_config; + struct roots_output_config *o_config; wl_list_for_each(o_config, &config->outputs, link) { if (strcmp(o_config->name, output->name) == 0) { return o_config; @@ -437,9 +439,9 @@ struct output_config *config_get_output(struct roots_config *config, return NULL; } -struct device_config *config_get_device(struct roots_config *config, +struct roots_device_config *roots_config_get_device(struct roots_config *config, struct wlr_input_device *device) { - struct device_config *d_config; + struct roots_device_config *d_config; wl_list_for_each(d_config, &config->devices, link) { if (strcmp(d_config->name, device->name) == 0) { return d_config; @@ -449,9 +451,9 @@ struct device_config *config_get_device(struct roots_config *config, return NULL; } -struct keyboard_config *config_get_keyboard(struct roots_config *config, - struct wlr_input_device *device) { - struct keyboard_config *kc; +struct roots_keyboard_config *roots_config_get_keyboard( + struct roots_config *config, struct wlr_input_device *device) { + struct roots_keyboard_config *kc; wl_list_for_each(kc, &config->keyboards, link) { if ((device != NULL && strcmp(kc->name, device->name) == 0) || (device == NULL && strcmp(kc->name, "") == 0)) { diff --git a/rootston/input.c b/rootston/input.c index e96565e0..35a5af97 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -44,7 +44,8 @@ static void input_add_notify(struct wl_listener *listener, void *data) { struct roots_input *input = wl_container_of(listener, input, input_add); char *seat_name = "seat0"; - struct device_config *dc = config_get_device(input->config, device); + struct roots_device_config *dc = + roots_config_get_device(input->config, device); if (dc) { seat_name = dc->seat; } diff --git a/rootston/keyboard.c b/rootston/keyboard.c index bb748550..c118e55c 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -92,7 +92,7 @@ static bool keyboard_keysym_press(struct roots_keyboard *keyboard, uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard); struct wl_list *bindings = &keyboard->input->server->config->bindings; - struct binding_config *bc; + struct roots_binding_config *bc; wl_list_for_each(bc, bindings, link) { if (modifiers ^ bc->modifiers) { continue; @@ -210,8 +210,8 @@ void roots_keyboard_handle_modifiers(struct roots_keyboard *r_keyboard) { wlr_seat_keyboard_notify_modifiers(seat); } -static void keyboard_config_merge(struct keyboard_config *config, - struct keyboard_config *fallback) { +static void keyboard_config_merge(struct roots_keyboard_config *config, + struct roots_keyboard_config *fallback) { if (fallback == NULL) { return; } @@ -248,15 +248,16 @@ struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device, keyboard->device = device; keyboard->input = input; - struct keyboard_config *config = calloc(1, sizeof(struct keyboard_config)); + struct roots_keyboard_config *config = + calloc(1, sizeof(struct roots_keyboard_config)); if (config == NULL) { free(keyboard); return NULL; } - keyboard_config_merge(config, config_get_keyboard(input->config, device)); - keyboard_config_merge(config, config_get_keyboard(input->config, NULL)); + keyboard_config_merge(config, roots_config_get_keyboard(input->config, device)); + keyboard_config_merge(config, roots_config_get_keyboard(input->config, NULL)); - struct keyboard_config env_config = { + struct roots_keyboard_config env_config = { .rules = getenv("XKB_DEFAULT_RULES"), .model = getenv("XKB_DEFAULT_MODEL"), .layout = getenv("XKB_DEFAULT_LAYOUT"), diff --git a/rootston/main.c b/rootston/main.c index 2a054e6c..d55bc682 100644 --- a/rootston/main.c +++ b/rootston/main.c @@ -13,7 +13,7 @@ struct roots_server server = { 0 }; int main(int argc, char **argv) { - assert(server.config = parse_args(argc, argv)); + assert(server.config = roots_config_create_from_args(argc, argv)); assert(server.wl_display = wl_display_create()); assert(server.wl_event_loop = wl_display_get_event_loop(server.wl_display)); diff --git a/rootston/output.c b/rootston/output.c index f192cb48..d853c45f 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -181,7 +181,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { output->last_frame = desktop->last_frame = now; } -static void set_mode(struct wlr_output *output, struct output_config *oc) { +static void set_mode(struct wlr_output *output, + struct roots_output_config *oc) { struct wlr_output_mode *mode, *best = NULL; int mhz = (int)(oc->mode.refresh_rate * 1000); wl_list_for_each(mode, &output->modes, link) { @@ -225,7 +226,8 @@ void output_add_notify(struct wl_listener *listener, void *data) { wl_signal_add(&wlr_output->events.frame, &output->frame); wl_list_insert(&desktop->outputs, &output->link); - struct output_config *output_config = config_get_output(config, wlr_output); + struct roots_output_config *output_config = + roots_config_get_output(config, wlr_output); if (output_config) { if (output_config->mode.width) { set_mode(wlr_output, output_config); diff --git a/rootston/seat.c b/rootston/seat.c index 3530fb75..4602aad5 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -117,8 +117,8 @@ static void seat_reset_device_mappings(struct roots_seat *seat, struct wlr_input struct roots_config *config = seat->input->config; wlr_cursor_map_input_to_output(cursor, device, NULL); - struct device_config *dconfig; - if ((dconfig = config_get_device(config, device))) { + struct roots_device_config *dconfig; + if ((dconfig = roots_config_get_device(config, device))) { wlr_cursor_map_input_to_region(cursor, device, dconfig->mapped_box); } } @@ -127,8 +127,8 @@ static void seat_set_device_output_mappings(struct roots_seat *seat, struct wlr_input_device *device, struct wlr_output *output) { struct wlr_cursor *cursor = seat->cursor->cursor; struct roots_config *config = seat->input->config; - struct device_config *dconfig; - dconfig = config_get_device(config, device); + struct roots_device_config *dconfig; + dconfig = roots_config_get_device(config, device); if (dconfig && dconfig->mapped_output && strcmp(dconfig->mapped_output, output->name) == 0) { wlr_cursor_map_input_to_output(cursor, device, output); -- cgit v1.2.3 From 7072ac87fd1f92cfe6e88a075ff0e8ac2901e870 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 11 Nov 2017 10:59:50 -0500 Subject: rootston: config.c 80 col --- rootston/config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'rootston/config.c') diff --git a/rootston/config.c b/rootston/config.c index 9530ba37..7ffbb786 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -312,7 +312,8 @@ static int config_ini_handler(void *user, const char *section, const char *name, } } else if (strcmp(section, "keyboard") == 0) { config_handle_keyboard(config, "", name, value); - } else if (strncmp(keyboard_prefix, section, strlen(keyboard_prefix)) == 0) { + } else if (strncmp(keyboard_prefix, + section, strlen(keyboard_prefix)) == 0) { const char *device_name = section + strlen(keyboard_prefix); config_handle_keyboard(config, device_name, name, value); } else if (strcmp(section, "bindings") == 0) { -- cgit v1.2.3 From bb79ada49f43be5417bdd55fda3a7cf07c2a69df Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 16 Nov 2017 10:30:54 +0100 Subject: Fix a bunch of mistakes detected with scan-build --- backend/libinput/events.c | 5 +++-- backend/session/session.c | 2 +- rootston/config.c | 2 +- rootston/cursor.c | 2 +- rootston/keyboard.c | 1 + rootston/seat.c | 1 - types/wlr_data_device.c | 5 ++++- types/wlr_keyboard.c | 5 ++++- types/wlr_screenshooter.c | 3 +++ types/wlr_wl_shell.c | 2 +- 10 files changed, 19 insertions(+), 9 deletions(-) (limited to 'rootston/config.c') diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 5da45c67..3ca41124 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -66,10 +66,11 @@ static void handle_device_added(struct wlr_libinput_backend *backend, int product = libinput_device_get_id_product(libinput_dev); const char *name = libinput_device_get_name(libinput_dev); struct wl_list *wlr_devices = calloc(1, sizeof(struct wl_list)); - wl_list_init(wlr_devices); if (!wlr_devices) { - goto fail; + wlr_log(L_ERROR, "Allocation failed"); + return; } + wl_list_init(wlr_devices); wlr_log(L_DEBUG, "Added %s [%d:%d]", name, vendor, product); if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) { diff --git a/backend/session/session.c b/backend/session/session.c index 760830c3..657558fd 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -249,7 +249,7 @@ static size_t explicit_find_gpus(struct wlr_session *session, } } while ((ptr = strtok_r(NULL, ":", &save))); - free(ptr); + free(gpus); return i; } diff --git a/rootston/config.c b/rootston/config.c index 7ffbb786..727b52d0 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -405,7 +405,7 @@ void roots_config_destroy(struct roots_config *config) { } struct roots_keyboard_config *kc, *ktmp = NULL; - wl_list_for_each_safe(kc, ktmp, &config->bindings, link) { + wl_list_for_each_safe(kc, ktmp, &config->keyboards, link) { free(kc->name); free(kc->rules); free(kc->model); diff --git a/rootston/cursor.c b/rootston/cursor.c index ecd5e9a0..5949a364 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -18,9 +18,9 @@ struct roots_cursor *roots_cursor_create(struct roots_seat *seat) { } cursor->cursor = wlr_cursor_create(); if (!cursor->cursor) { + free(cursor); return NULL; } - return cursor; } diff --git a/rootston/keyboard.c b/rootston/keyboard.c index c118e55c..fb648ae5 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -141,6 +141,7 @@ static bool keyboard_keysyms_xkb(struct roots_keyboard *keyboard, uint32_t consumed = xkb_state_key_get_consumed_mods2( keyboard->device->keyboard->xkb_state, keycode, XKB_CONSUMED_MODE_XKB); + // TODO: actually use this value modifiers = modifiers & ~consumed; bool handled = false; diff --git a/rootston/seat.c b/rootston/seat.c index 6d8dc749..1fa37c44 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -252,7 +252,6 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) { seat->seat = wlr_seat_create(input->server->wl_display, name); if (!seat->seat) { free(seat); - roots_cursor_destroy(seat->cursor); return NULL; } diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c index df18317b..4d926236 100644 --- a/types/wlr_data_device.c +++ b/types/wlr_data_device.c @@ -636,7 +636,10 @@ static void data_device_start_drag(struct wl_client *client, if (!seat_client_start_drag(seat_client, source, icon)) { wl_resource_post_no_memory(device_resource); - } else { + return; + } + + if (source) { source->seat_client = seat_client; } } diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 98ebeed5..c4f2ed52 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -105,7 +105,10 @@ void wlr_keyboard_init(struct wlr_keyboard *kb, } void wlr_keyboard_destroy(struct wlr_keyboard *kb) { - if (kb && kb->impl && kb->impl->destroy) { + if (kb == NULL) { + return; + } + if (kb->impl && kb->impl->destroy) { kb->impl->destroy(kb); } else { wl_list_remove(&kb->events.key.listener_list); diff --git a/types/wlr_screenshooter.c b/types/wlr_screenshooter.c index a78c7ad7..94b45384 100644 --- a/types/wlr_screenshooter.c +++ b/types/wlr_screenshooter.c @@ -85,6 +85,7 @@ static void screenshooter_shoot(struct wl_client *client, struct wlr_screenshot *screenshot = calloc(1, sizeof(struct wlr_screenshot)); if (!screenshot) { + free(pixels); wl_resource_post_no_memory(screenshooter_resource); return; } @@ -96,6 +97,7 @@ static void screenshooter_shoot(struct wl_client *client, wl_resource_get_version(screenshooter_resource), id); if (screenshot->resource == NULL) { free(screenshot); + free(pixels); wl_resource_post_no_memory(screenshooter_resource); return; } @@ -109,6 +111,7 @@ static void screenshooter_shoot(struct wl_client *client, if (!state) { wl_resource_destroy(screenshot->resource); free(screenshot); + free(pixels); wl_resource_post_no_memory(screenshooter_resource); return; } diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 31032fef..abe967d7 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -347,7 +347,7 @@ static void shell_surface_protocol_set_popup(struct wl_client *client, transient_state->flags = flags; struct wlr_wl_shell_surface_popup_state *popup_state = - calloc(1, sizeof(struct wlr_wl_shell_surface_transient_state)); + calloc(1, sizeof(struct wlr_wl_shell_surface_popup_state)); if (popup_state == NULL) { free(transient_state); wl_client_post_no_memory(client); -- cgit v1.2.3