|
|
|
@ -150,6 +150,37 @@ void add_binding_config(struct wl_list *bindings, const char* combination,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void config_handle_cursor(struct roots_config *config,
|
|
|
|
|
const char *seat_name, const char *name, const char *value) {
|
|
|
|
|
struct roots_cursor_config *cc;
|
|
|
|
|
bool found = false;
|
|
|
|
|
wl_list_for_each(cc, &config->cursors, link) {
|
|
|
|
|
if (strcmp(cc->seat, seat_name) == 0) {
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
|
cc = calloc(1, sizeof(struct roots_cursor_config));
|
|
|
|
|
cc->seat = strdup(seat_name);
|
|
|
|
|
wl_list_insert(&config->cursors, &cc->link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(name, "map-to-output") == 0) {
|
|
|
|
|
free(cc->mapped_output);
|
|
|
|
|
cc->mapped_output = strdup(value);
|
|
|
|
|
} else if (strcmp(name, "geometry") == 0) {
|
|
|
|
|
free(cc->mapped_box);
|
|
|
|
|
cc->mapped_box = parse_geometry(value);
|
|
|
|
|
} else if (strcmp(name, "theme") == 0) {
|
|
|
|
|
free(cc->theme);
|
|
|
|
|
cc->theme = strdup(value);
|
|
|
|
|
} else {
|
|
|
|
|
wlr_log(L_ERROR, "got unknown cursor config: %s", name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void config_handle_keyboard(struct roots_config *config,
|
|
|
|
|
const char *device_name, const char *name, const char *value) {
|
|
|
|
|
struct roots_keyboard_config *kc;
|
|
|
|
@ -190,6 +221,7 @@ static void config_handle_keyboard(struct roots_config *config,
|
|
|
|
|
static const char *output_prefix = "output:";
|
|
|
|
|
static const char *device_prefix = "device:";
|
|
|
|
|
static const char *keyboard_prefix = "keyboard:";
|
|
|
|
|
static const char *cursor_prefix = "cursor:";
|
|
|
|
|
|
|
|
|
|
static int config_ini_handler(void *user, const char *section, const char *name,
|
|
|
|
|
const char *value) {
|
|
|
|
@ -269,16 +301,12 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
|
|
|
|
oc->name, oc->mode.width, oc->mode.height,
|
|
|
|
|
oc->mode.refresh_rate);
|
|
|
|
|
}
|
|
|
|
|
} else if (strncmp(cursor_prefix, section, strlen(cursor_prefix)) == 0) {
|
|
|
|
|
const char *seat_name = section + strlen(cursor_prefix);
|
|
|
|
|
config_handle_cursor(config, seat_name, name, value);
|
|
|
|
|
} else if (strcmp(section, "cursor") == 0) {
|
|
|
|
|
if (strcmp(name, "map-to-output") == 0) {
|
|
|
|
|
free(config->cursor.mapped_output);
|
|
|
|
|
config->cursor.mapped_output = strdup(value);
|
|
|
|
|
} else if (strcmp(name, "geometry") == 0) {
|
|
|
|
|
free(config->cursor.mapped_box);
|
|
|
|
|
config->cursor.mapped_box = parse_geometry(value);
|
|
|
|
|
} else {
|
|
|
|
|
wlr_log(L_ERROR, "got unknown cursor config: %s", name);
|
|
|
|
|
}
|
|
|
|
|
config_handle_cursor(config, ROOTS_CONFIG_DEFAULT_SEAT_NAME, name,
|
|
|
|
|
value);
|
|
|
|
|
} else if (strncmp(device_prefix, section, strlen(device_prefix)) == 0) {
|
|
|
|
|
const char *device_name = section + strlen(device_prefix);
|
|
|
|
|
|
|
|
|
@ -294,7 +322,7 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
|
|
|
|
if (!found) {
|
|
|
|
|
dc = calloc(1, sizeof(struct roots_device_config));
|
|
|
|
|
dc->name = strdup(device_name);
|
|
|
|
|
dc->seat = strdup("seat0");
|
|
|
|
|
dc->seat = strdup(ROOTS_CONFIG_DEFAULT_SEAT_NAME);
|
|
|
|
|
wl_list_insert(&config->devices, &dc->link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -335,6 +363,7 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
|
|
|
|
|
wl_list_init(&config->outputs);
|
|
|
|
|
wl_list_init(&config->devices);
|
|
|
|
|
wl_list_init(&config->keyboards);
|
|
|
|
|
wl_list_init(&config->cursors);
|
|
|
|
|
wl_list_init(&config->bindings);
|
|
|
|
|
|
|
|
|
|
int c;
|
|
|
|
@ -415,6 +444,15 @@ void roots_config_destroy(struct roots_config *config) {
|
|
|
|
|
free(kc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct roots_cursor_config *cc, *ctmp = NULL;
|
|
|
|
|
wl_list_for_each_safe(cc, ctmp, &config->cursors, link) {
|
|
|
|
|
free(cc->seat);
|
|
|
|
|
free(cc->mapped_output);
|
|
|
|
|
free(cc->mapped_box);
|
|
|
|
|
free(cc->theme);
|
|
|
|
|
free(cc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct roots_binding_config *bc, *btmp = NULL;
|
|
|
|
|
wl_list_for_each_safe(bc, btmp, &config->bindings, link) {
|
|
|
|
|
free(bc->keysyms);
|
|
|
|
@ -423,8 +461,6 @@ void roots_config_destroy(struct roots_config *config) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free(config->config_path);
|
|
|
|
|
free(config->cursor.mapped_output);
|
|
|
|
|
free(config->cursor.mapped_box);
|
|
|
|
|
free(config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -454,13 +490,33 @@ struct roots_device_config *roots_config_get_device(struct roots_config *config,
|
|
|
|
|
|
|
|
|
|
struct roots_keyboard_config *roots_config_get_keyboard(
|
|
|
|
|
struct roots_config *config, struct wlr_input_device *device) {
|
|
|
|
|
const char *device_name = "";
|
|
|
|
|
if (device != NULL) {
|
|
|
|
|
device_name = device->name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
|
if (strcmp(kc->name, device_name) == 0) {
|
|
|
|
|
return kc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct roots_cursor_config *roots_config_get_cursor(struct roots_config *config,
|
|
|
|
|
const char *seat_name) {
|
|
|
|
|
if (seat_name == NULL) {
|
|
|
|
|
seat_name = ROOTS_CONFIG_DEFAULT_SEAT_NAME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct roots_cursor_config *cc;
|
|
|
|
|
wl_list_for_each(cc, &config->cursors, link) {
|
|
|
|
|
if (strcmp(cc->seat, seat_name) == 0) {
|
|
|
|
|
return cc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|