mirror of
https://github.com/swaywm/sway.git
synced 2026-05-03 06:46:26 -04:00
Merge branch 'wlroots' into multibackend
This commit is contained in:
commit
9a099d7533
7 changed files with 314 additions and 222 deletions
|
|
@ -397,7 +397,7 @@ struct seat_attachment_config *seat_config_get_attachment(
|
||||||
void apply_seat_config(struct seat_config *seat);
|
void apply_seat_config(struct seat_config *seat);
|
||||||
|
|
||||||
int output_name_cmp(const void *item, const void *data);
|
int output_name_cmp(const void *item, const void *data);
|
||||||
struct output_config *new_output_config();
|
struct output_config *new_output_config(const char *name);
|
||||||
void merge_output_config(struct output_config *dst, struct output_config *src);
|
void merge_output_config(struct output_config *dst, struct output_config *src);
|
||||||
void apply_output_config(struct output_config *oc, swayc_t *output);
|
void apply_output_config(struct output_config *oc, swayc_t *output);
|
||||||
void free_output_config(struct output_config *oc);
|
void free_output_config(struct output_config *oc);
|
||||||
|
|
|
||||||
|
|
@ -20,253 +20,260 @@ static char *bg_options[] = {
|
||||||
"tile",
|
"tile",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct cmd_results *cmd_output_mode(struct output_config *output,
|
||||||
|
int *i, int argc, char **argv) {
|
||||||
|
if (++*i >= argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output", "Missing mode argument.");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *end;
|
||||||
|
output->width = strtol(argv[*i], &end, 10);
|
||||||
|
if (*end) {
|
||||||
|
// Format is 1234x4321
|
||||||
|
if (*end != 'x') {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Invalid mode width.");
|
||||||
|
}
|
||||||
|
++end;
|
||||||
|
output->height = strtol(end, &end, 10);
|
||||||
|
if (*end) {
|
||||||
|
if (*end != '@') {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Invalid mode height.");
|
||||||
|
}
|
||||||
|
++end;
|
||||||
|
output->refresh_rate = strtof(end, &end);
|
||||||
|
if (strcasecmp("Hz", end) != 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Invalid mode refresh rate.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Format is 1234 4321
|
||||||
|
if (++*i >= argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Missing mode argument (height).");
|
||||||
|
}
|
||||||
|
output->height = strtol(argv[*i], &end, 10);
|
||||||
|
if (*end) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Invalid mode height.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *cmd_output_position(struct output_config *output,
|
||||||
|
int *i, int argc, char **argv) {
|
||||||
|
if (++*i >= argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Missing position argument.");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *end;
|
||||||
|
output->x = strtol(argv[*i], &end, 10);
|
||||||
|
if (*end) {
|
||||||
|
// Format is 1234,4321
|
||||||
|
if (*end != ',') {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Invalid position x.");
|
||||||
|
}
|
||||||
|
++end;
|
||||||
|
output->y = strtol(end, &end, 10);
|
||||||
|
if (*end) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Invalid position y.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Format is 1234 4321 (legacy)
|
||||||
|
if (++*i >= argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Missing position argument (y).");
|
||||||
|
}
|
||||||
|
output->y = strtol(argv[*i], &end, 10);
|
||||||
|
if (*end) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Invalid position y.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *cmd_output_scale(struct output_config *output,
|
||||||
|
int *i, int argc, char **argv) {
|
||||||
|
if (++*i >= argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Missing scale argument.");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *end;
|
||||||
|
output->scale = strtof(argv[*i], &end);
|
||||||
|
if (*end) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output", "Invalid scale.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *cmd_output_transform(struct output_config *output,
|
||||||
|
int *i, int argc, char **argv) {
|
||||||
|
if (++*i >= argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Missing transform argument.");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *value = argv[*i];
|
||||||
|
if (strcmp(value, "normal") == 0) {
|
||||||
|
output->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
} else if (strcmp(value, "90") == 0) {
|
||||||
|
output->transform = WL_OUTPUT_TRANSFORM_90;
|
||||||
|
} else if (strcmp(value, "180") == 0) {
|
||||||
|
output->transform = WL_OUTPUT_TRANSFORM_180;
|
||||||
|
} else if (strcmp(value, "270") == 0) {
|
||||||
|
output->transform = WL_OUTPUT_TRANSFORM_270;
|
||||||
|
} else if (strcmp(value, "flipped") == 0) {
|
||||||
|
output->transform = WL_OUTPUT_TRANSFORM_FLIPPED;
|
||||||
|
} else if (strcmp(value, "flipped-90") == 0) {
|
||||||
|
output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_90;
|
||||||
|
} else if (strcmp(value, "flipped-180") == 0) {
|
||||||
|
output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_180;
|
||||||
|
} else if (strcmp(value, "flipped-270") == 0) {
|
||||||
|
output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_270;
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Invalid output transform.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *cmd_output_background(struct output_config *output,
|
||||||
|
int *i, int argc, char **argv) {
|
||||||
|
if (++*i >= argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Missing background file or color specification.");
|
||||||
|
}
|
||||||
|
const char *background = argv[*i];
|
||||||
|
if (*i + 1 >= argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Missing background scaling mode or `solid_color`.");
|
||||||
|
}
|
||||||
|
const char *background_option = argv[*i];
|
||||||
|
|
||||||
|
if (strcasecmp(background_option, "solid_color") == 0) {
|
||||||
|
output->background = strdup(background);
|
||||||
|
output->background_option = strdup("solid_color");
|
||||||
|
} else {
|
||||||
|
bool valid = false;
|
||||||
|
char *mode;
|
||||||
|
size_t j;
|
||||||
|
for (j = 0; j < (size_t)(argc - *i); ++j) {
|
||||||
|
mode = argv[*i + j];
|
||||||
|
size_t n = sizeof(bg_options) / sizeof(char *);
|
||||||
|
for (size_t k = 0; k < n; ++k) {
|
||||||
|
if (strcasecmp(mode, bg_options[k]) == 0) {
|
||||||
|
valid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (valid) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Missing background scaling mode.");
|
||||||
|
}
|
||||||
|
|
||||||
|
wordexp_t p;
|
||||||
|
char *src = join_args(argv + *i - 1, j);
|
||||||
|
if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Invalid syntax (%s).", src);
|
||||||
|
}
|
||||||
|
free(src);
|
||||||
|
src = p.we_wordv[0];
|
||||||
|
if (config->reading && *src != '/') {
|
||||||
|
char *conf = strdup(config->current_config);
|
||||||
|
if (conf) {
|
||||||
|
char *conf_path = dirname(conf);
|
||||||
|
src = malloc(strlen(conf_path) + strlen(src) + 2);
|
||||||
|
if (src) {
|
||||||
|
sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
|
||||||
|
} else {
|
||||||
|
sway_log(L_ERROR,
|
||||||
|
"Unable to allocate background source");
|
||||||
|
}
|
||||||
|
free(conf);
|
||||||
|
} else {
|
||||||
|
sway_log(L_ERROR, "Unable to allocate background source");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!src || access(src, F_OK) == -1) {
|
||||||
|
wordfree(&p);
|
||||||
|
return cmd_results_new(CMD_INVALID, "output",
|
||||||
|
"Background file unreadable (%s).", src);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->background = strdup(src);
|
||||||
|
output->background_option = strdup(mode);
|
||||||
|
if (src != p.we_wordv[0]) {
|
||||||
|
free(src);
|
||||||
|
}
|
||||||
|
wordfree(&p);
|
||||||
|
|
||||||
|
*i += j;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_output(int argc, char **argv) {
|
struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if ((error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1))) {
|
if ((error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
const char *name = argv[0];
|
|
||||||
|
|
||||||
struct output_config *output = new_output_config();
|
struct output_config *output = new_output_config(argv[0]);
|
||||||
if (!output) {
|
if (!output) {
|
||||||
sway_log(L_ERROR, "Failed to allocate output config");
|
sway_log(L_ERROR, "Failed to allocate output config");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
output->name = strdup(name);
|
|
||||||
|
|
||||||
int i;
|
for (int i = 1; i < argc; ++i) {
|
||||||
for (i = 1; i < argc; ++i) {
|
|
||||||
const char *command = argv[i];
|
const char *command = argv[i];
|
||||||
|
|
||||||
if (strcasecmp(command, "disable") == 0) {
|
if (strcasecmp(command, "enable") == 0) {
|
||||||
|
output->enabled = 1;
|
||||||
|
} else if (strcasecmp(command, "disable") == 0) {
|
||||||
output->enabled = 0;
|
output->enabled = 0;
|
||||||
} else if (strcasecmp(command, "mode") == 0 ||
|
} else if (strcasecmp(command, "mode") == 0 ||
|
||||||
strcasecmp(command, "resolution") == 0 ||
|
strcasecmp(command, "resolution") == 0 ||
|
||||||
strcasecmp(command, "res") == 0) {
|
strcasecmp(command, "res") == 0) {
|
||||||
if (++i >= argc) {
|
error = cmd_output_mode(output, &i, argc, argv);
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Missing mode argument.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
int width = -1, height = -1;
|
|
||||||
float refresh_rate = -1;
|
|
||||||
|
|
||||||
char *end;
|
|
||||||
width = strtol(argv[i], &end, 10);
|
|
||||||
if (*end) {
|
|
||||||
// Format is 1234x4321
|
|
||||||
if (*end != 'x') {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid mode width.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
++end;
|
|
||||||
height = strtol(end, &end, 10);
|
|
||||||
if (*end) {
|
|
||||||
if (*end != '@') {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid mode height.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
++end;
|
|
||||||
refresh_rate = strtof(end, &end);
|
|
||||||
if (strcasecmp("Hz", end) != 0) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid mode refresh rate.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Format is 1234 4321
|
|
||||||
if (++i >= argc) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Missing mode argument (height).");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
height = strtol(argv[i], &end, 10);
|
|
||||||
if (*end) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid mode height.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output->width = width;
|
|
||||||
output->height = height;
|
|
||||||
output->refresh_rate = refresh_rate;
|
|
||||||
} else if (strcasecmp(command, "position") == 0 ||
|
} else if (strcasecmp(command, "position") == 0 ||
|
||||||
strcasecmp(command, "pos") == 0) {
|
strcasecmp(command, "pos") == 0) {
|
||||||
if (++i >= argc) {
|
error = cmd_output_position(output, &i, argc, argv);
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Missing position argument.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
int x = -1, y = -1;
|
|
||||||
|
|
||||||
char *end;
|
|
||||||
x = strtol(argv[i], &end, 10);
|
|
||||||
if (*end) {
|
|
||||||
// Format is 1234,4321
|
|
||||||
if (*end != ',') {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid position x.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
++end;
|
|
||||||
y = strtol(end, &end, 10);
|
|
||||||
if (*end) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid position y.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Format is 1234 4321 (legacy)
|
|
||||||
if (++i >= argc) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Missing position argument (y).");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
y = strtol(argv[i], &end, 10);
|
|
||||||
if (*end) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid position y.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
output->x = x;
|
|
||||||
output->y = y;
|
|
||||||
} else if (strcasecmp(command, "scale") == 0) {
|
} else if (strcasecmp(command, "scale") == 0) {
|
||||||
if (++i >= argc) {
|
error = cmd_output_scale(output, &i, argc, argv);
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Missing scale parameter.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
char *end;
|
|
||||||
output->scale = strtof(argv[i], &end);
|
|
||||||
if (*end) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid scale.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
} else if (strcasecmp(command, "transform") == 0) {
|
} else if (strcasecmp(command, "transform") == 0) {
|
||||||
if (++i >= argc) {
|
error = cmd_output_transform(output, &i, argc, argv);
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Missing transform parameter.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
char *value = argv[i];
|
|
||||||
if (strcmp(value, "normal") == 0) {
|
|
||||||
output->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
|
||||||
} else if (strcmp(value, "90") == 0) {
|
|
||||||
output->transform = WL_OUTPUT_TRANSFORM_90;
|
|
||||||
} else if (strcmp(value, "180") == 0) {
|
|
||||||
output->transform = WL_OUTPUT_TRANSFORM_180;
|
|
||||||
} else if (strcmp(value, "270") == 0) {
|
|
||||||
output->transform = WL_OUTPUT_TRANSFORM_270;
|
|
||||||
} else if (strcmp(value, "flipped") == 0) {
|
|
||||||
output->transform = WL_OUTPUT_TRANSFORM_FLIPPED;
|
|
||||||
} else if (strcmp(value, "flipped-90") == 0) {
|
|
||||||
output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_90;
|
|
||||||
} else if (strcmp(value, "flipped-180") == 0) {
|
|
||||||
output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_180;
|
|
||||||
} else if (strcmp(value, "flipped-270") == 0) {
|
|
||||||
output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_270;
|
|
||||||
} else {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid output transform.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
} else if (strcasecmp(command, "background") == 0 ||
|
} else if (strcasecmp(command, "background") == 0 ||
|
||||||
strcasecmp(command, "bg") == 0) {
|
strcasecmp(command, "bg") == 0) {
|
||||||
wordexp_t p;
|
error = cmd_output_background(output, &i, argc, argv);
|
||||||
if (++i >= argc) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Missing background file or color specification.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (i + 1 >= argc) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Missing background scaling mode or `solid_color`.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (strcasecmp(argv[i + 1], "solid_color") == 0) {
|
|
||||||
output->background = strdup(argv[argc - 2]);
|
|
||||||
output->background_option = strdup("solid_color");
|
|
||||||
} else {
|
|
||||||
// argv[i+j]=bg_option
|
|
||||||
bool valid = false;
|
|
||||||
char *mode;
|
|
||||||
size_t j;
|
|
||||||
for (j = 0; j < (size_t) (argc - i); ++j) {
|
|
||||||
mode = argv[i + j];
|
|
||||||
size_t n = sizeof(bg_options) / sizeof(char *);
|
|
||||||
for (size_t k = 0; k < n; ++k) {
|
|
||||||
if (strcasecmp(mode, bg_options[k]) == 0) {
|
|
||||||
valid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (valid) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!valid) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Missing background scaling mode.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *src = join_args(argv + i, j);
|
|
||||||
if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Invalid syntax (%s).", src);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
free(src);
|
|
||||||
src = p.we_wordv[0];
|
|
||||||
if (config->reading && *src != '/') {
|
|
||||||
char *conf = strdup(config->current_config);
|
|
||||||
if (conf) {
|
|
||||||
char *conf_path = dirname(conf);
|
|
||||||
src = malloc(strlen(conf_path) + strlen(src) + 2);
|
|
||||||
if (src) {
|
|
||||||
sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
|
|
||||||
} else {
|
|
||||||
sway_log(L_ERROR,
|
|
||||||
"Unable to allocate background source");
|
|
||||||
}
|
|
||||||
free(conf);
|
|
||||||
} else {
|
|
||||||
sway_log(L_ERROR,
|
|
||||||
"Unable to allocate background source");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!src || access(src, F_OK) == -1) {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
|
||||||
"Background file unreadable (%s).", src);
|
|
||||||
wordfree(&p);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
output->background = strdup(src);
|
|
||||||
output->background_option = strdup(mode);
|
|
||||||
if (src != p.we_wordv[0]) {
|
|
||||||
free(src);
|
|
||||||
}
|
|
||||||
wordfree(&p);
|
|
||||||
|
|
||||||
i += j;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
error = cmd_results_new(CMD_INVALID, "output",
|
||||||
"Invalid output subcommand: %s.", command);
|
"Invalid output subcommand: %s.", command);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error != NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i = list_seq_find(config->output_configs, output_name_cmp, name);
|
int i = list_seq_find(config->output_configs, output_name_cmp, output->name);
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
// merge existing config
|
// merge existing config
|
||||||
struct output_config *oc = config->output_configs->items[i];
|
struct output_config *oc = config->output_configs->items[i];
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,16 @@ int output_name_cmp(const void *item, const void *data) {
|
||||||
return strcmp(output->name, name);
|
return strcmp(output->name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct output_config *new_output_config() {
|
struct output_config *new_output_config(const char *name) {
|
||||||
struct output_config *oc = calloc(1, sizeof(struct output_config));
|
struct output_config *oc = calloc(1, sizeof(struct output_config));
|
||||||
if (oc == NULL) {
|
if (oc == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
oc->name = strdup(name);
|
||||||
|
if (oc->name == NULL) {
|
||||||
|
free(oc);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
oc->enabled = -1;
|
oc->enabled = -1;
|
||||||
oc->width = oc->height = -1;
|
oc->width = oc->height = -1;
|
||||||
oc->refresh_rate = -1;
|
oc->refresh_rate = -1;
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,9 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
// - Criteria
|
// - Criteria
|
||||||
|
|
||||||
sway_surface->commit.notify = handle_commit;
|
sway_surface->commit.notify = handle_commit;
|
||||||
wl_signal_add(&shell_surface->events.commit, &sway_surface->commit);
|
wl_signal_add(&shell_surface->surface->events.commit,
|
||||||
|
&sway_surface->commit);
|
||||||
|
|
||||||
sway_surface->destroy.notify = handle_destroy;
|
sway_surface->destroy.notify = handle_destroy;
|
||||||
wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy);
|
wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,8 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
// - Criteria
|
// - Criteria
|
||||||
|
|
||||||
sway_surface->commit.notify = handle_commit;
|
sway_surface->commit.notify = handle_commit;
|
||||||
wl_signal_add(&xdg_surface->events.commit, &sway_surface->commit);
|
wl_signal_add(&xdg_surface->surface->events.commit, &sway_surface->commit);
|
||||||
|
|
||||||
sway_surface->destroy.notify = handle_destroy;
|
sway_surface->destroy.notify = handle_destroy;
|
||||||
wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy);
|
wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libinput.h>
|
#include <libinput.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <wlr/backend/libinput.h>
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "sway/input/seat.h"
|
#include "sway/input/seat.h"
|
||||||
|
|
@ -82,6 +83,75 @@ static bool input_has_seat_configuration(struct sway_input_manager *input) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sway_input_manager_libinput_config_pointer(struct sway_input_device *input_device) {
|
||||||
|
struct wlr_input_device *wlr_device = input_device->wlr_device;
|
||||||
|
struct input_config *ic = input_device->config;
|
||||||
|
struct libinput_device *libinput_device;
|
||||||
|
|
||||||
|
if (!ic || !wlr_input_device_is_libinput(wlr_device)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
libinput_device = wlr_libinput_get_device_handle(wlr_device);
|
||||||
|
sway_log(L_DEBUG, "sway_input_manager_libinput_config_pointer(%s)", ic->identifier);
|
||||||
|
|
||||||
|
if (ic->accel_profile != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)",
|
||||||
|
ic->identifier, ic->accel_profile);
|
||||||
|
libinput_device_config_accel_set_profile(libinput_device, ic->accel_profile);
|
||||||
|
}
|
||||||
|
if (ic->click_method != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)",
|
||||||
|
ic->identifier, ic->click_method);
|
||||||
|
libinput_device_config_click_set_method(libinput_device, ic->click_method);
|
||||||
|
}
|
||||||
|
if (ic->drag_lock != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)",
|
||||||
|
ic->identifier, ic->click_method);
|
||||||
|
libinput_device_config_tap_set_drag_lock_enabled(libinput_device, ic->drag_lock);
|
||||||
|
}
|
||||||
|
if (ic->dwt != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)",
|
||||||
|
ic->identifier, ic->dwt);
|
||||||
|
libinput_device_config_dwt_set_enabled(libinput_device, ic->dwt);
|
||||||
|
}
|
||||||
|
if (ic->left_handed != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) left_handed_set_enabled(%d)",
|
||||||
|
ic->identifier, ic->left_handed);
|
||||||
|
libinput_device_config_left_handed_set(libinput_device, ic->left_handed);
|
||||||
|
}
|
||||||
|
if (ic->middle_emulation != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) middle_emulation_set_enabled(%d)",
|
||||||
|
ic->identifier, ic->middle_emulation);
|
||||||
|
libinput_device_config_middle_emulation_set_enabled(libinput_device, ic->middle_emulation);
|
||||||
|
}
|
||||||
|
if (ic->natural_scroll != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) natural_scroll_set_enabled(%d)",
|
||||||
|
ic->identifier, ic->natural_scroll);
|
||||||
|
libinput_device_config_scroll_set_natural_scroll_enabled(libinput_device, ic->natural_scroll);
|
||||||
|
}
|
||||||
|
if (ic->pointer_accel != FLT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)",
|
||||||
|
ic->identifier, ic->pointer_accel);
|
||||||
|
libinput_device_config_accel_set_speed(libinput_device, ic->pointer_accel);
|
||||||
|
}
|
||||||
|
if (ic->scroll_method != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)",
|
||||||
|
ic->identifier, ic->scroll_method);
|
||||||
|
libinput_device_config_scroll_set_method(libinput_device, ic->scroll_method);
|
||||||
|
}
|
||||||
|
if (ic->send_events != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)",
|
||||||
|
ic->identifier, ic->send_events);
|
||||||
|
libinput_device_config_send_events_set_mode(libinput_device, ic->send_events);
|
||||||
|
}
|
||||||
|
if (ic->tap != INT_MIN) {
|
||||||
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)",
|
||||||
|
ic->identifier, ic->tap);
|
||||||
|
libinput_device_config_tap_set_enabled(libinput_device, ic->tap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void input_add_notify(struct wl_listener *listener, void *data) {
|
static void input_add_notify(struct wl_listener *listener, void *data) {
|
||||||
struct sway_input_manager *input =
|
struct sway_input_manager *input =
|
||||||
wl_container_of(listener, input, input_add);
|
wl_container_of(listener, input, input_add);
|
||||||
|
|
@ -109,6 +179,10 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
|
||||||
|
sway_input_manager_libinput_config_pointer(input_device);
|
||||||
|
}
|
||||||
|
|
||||||
struct sway_seat *seat = NULL;
|
struct sway_seat *seat = NULL;
|
||||||
if (!input_has_seat_configuration(input)) {
|
if (!input_has_seat_configuration(input)) {
|
||||||
sway_log(L_DEBUG, "no seat configuration, using default seat");
|
sway_log(L_DEBUG, "no seat configuration, using default seat");
|
||||||
|
|
@ -221,6 +295,10 @@ void sway_input_manager_apply_input_config(struct sway_input_manager *input,
|
||||||
if (strcmp(input_device->identifier, input_config->identifier) == 0) {
|
if (strcmp(input_device->identifier, input_config->identifier) == 0) {
|
||||||
input_device->config = input_config;
|
input_device->config = input_config;
|
||||||
|
|
||||||
|
if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
|
||||||
|
sway_input_manager_libinput_config_pointer(input_device);
|
||||||
|
}
|
||||||
|
|
||||||
struct sway_seat *seat = NULL;
|
struct sway_seat *seat = NULL;
|
||||||
wl_list_for_each(seat, &input->seats, link) {
|
wl_list_for_each(seat, &input->seats, link) {
|
||||||
sway_seat_configure_device(seat, input_device);
|
sway_seat_configure_device(seat, input_device);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input,
|
||||||
|
|
||||||
static void seat_configure_pointer(struct sway_seat *seat,
|
static void seat_configure_pointer(struct sway_seat *seat,
|
||||||
struct sway_seat_device *sway_device) {
|
struct sway_seat_device *sway_device) {
|
||||||
// TODO pointer configuration
|
|
||||||
wlr_cursor_attach_input_device(seat->cursor->cursor,
|
wlr_cursor_attach_input_device(seat->cursor->cursor,
|
||||||
sway_device->input_device->wlr_device);
|
sway_device->input_device->wlr_device);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue