mirror of
https://github.com/swaywm/sway.git
synced 2025-11-08 13:29:50 -05:00
input config handler context
This commit is contained in:
parent
3dd915876d
commit
9e0595f26b
21 changed files with 69 additions and 25 deletions
|
|
@ -11,8 +11,12 @@ struct cmd_results *cmd_input(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (config->reading && strcmp("{", argv[1]) == 0) {
|
||||
current_input_config = new_input_config(argv[0]);
|
||||
wlr_log(L_DEBUG, "entering input block: %s", current_input_config->identifier);
|
||||
free_input_config(config->handler_context.input_config);
|
||||
config->handler_context.input_config = new_input_config(argv[0]);
|
||||
if (!config->handler_context.input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config");
|
||||
}
|
||||
wlr_log(L_DEBUG, "entering input block: %s", argv[0]);
|
||||
return cmd_results_new(CMD_BLOCK_INPUT, NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -20,15 +24,16 @@ struct cmd_results *cmd_input(int argc, char **argv) {
|
|||
return error;
|
||||
}
|
||||
|
||||
bool has_context = (config->handler_context.input_config != NULL);
|
||||
if (!has_context) {
|
||||
// caller did not give a context so create one just for this command
|
||||
config->handler_context.input_config = new_input_config(argv[0]);
|
||||
}
|
||||
|
||||
int argc_new = argc-2;
|
||||
char **argv_new = argv+2;
|
||||
|
||||
struct cmd_results *res;
|
||||
struct input_config *old_input_config = current_input_config;
|
||||
current_input_config = new_input_config(argv[0]);
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config");
|
||||
}
|
||||
if (strcasecmp("accel_profile", argv[1]) == 0) {
|
||||
res = input_cmd_accel_profile(argc_new, argv_new);
|
||||
} else if (strcasecmp("click_method", argv[1]) == 0) {
|
||||
|
|
@ -64,7 +69,12 @@ struct cmd_results *cmd_input(int argc, char **argv) {
|
|||
} else {
|
||||
res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]);
|
||||
}
|
||||
free_input_config(current_input_config);
|
||||
current_input_config = old_input_config;
|
||||
|
||||
if (!has_context) {
|
||||
// clean up the context we created earlier
|
||||
free_input_config(config->handler_context.input_config);
|
||||
config->handler_context.input_config = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
|
|||
if ((error = checkarg(argc, "accel_profile", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "accel_profile",
|
||||
"No input device defined.");
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
#include "log.h"
|
||||
|
||||
struct cmd_results *input_cmd_click_method(int argc, char **argv) {
|
||||
wlr_log(L_DEBUG, "click_method for device: %d %s",
|
||||
current_input_config==NULL, current_input_config->identifier);
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "click_method",
|
||||
"No input device defined.");
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
|
|||
if ((error = checkarg(argc, "drag_lock", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE,
|
||||
"drag_lock", "No input device defined.");
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
|
|||
if ((error = checkarg(argc, "dwt", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,16 +6,18 @@
|
|||
#include "log.h"
|
||||
|
||||
struct cmd_results *input_cmd_events(int argc, char **argv) {
|
||||
wlr_log(L_DEBUG, "events for device: %s",
|
||||
current_input_config->identifier);
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "events",
|
||||
"No input device defined.");
|
||||
}
|
||||
wlr_log(L_DEBUG, "events for device: %s",
|
||||
current_input_config->identifier);
|
||||
struct input_config *new_config =
|
||||
new_input_config(current_input_config->identifier);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
|
|||
if ((error = checkarg(argc, "left_handed", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "left_handed",
|
||||
"No input device defined.");
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
|
|||
if ((error = checkarg(argc, "middle_emulation", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "middle_emulation",
|
||||
"No input device defined.");
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
|
|||
if ((error = checkarg(argc, "natural_scroll", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "natural_scoll",
|
||||
"No input device defined.");
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
|
|||
if ((error = checkarg(argc, "pointer_accel", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE,
|
||||
"pointer_accel", "No input device defined.");
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
|
|||
if ((error = checkarg(argc, "scroll_method", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "scroll_method",
|
||||
"No input device defined.");
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@
|
|||
#include "log.h"
|
||||
|
||||
struct cmd_results *input_cmd_tap(int argc, char **argv) {
|
||||
wlr_log(L_DEBUG, "tap for device: %s", current_input_config->identifier);
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "tap", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "tap", "No input device defined.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@
|
|||
#include "log.h"
|
||||
|
||||
struct cmd_results *input_cmd_xkb_layout(int argc, char **argv) {
|
||||
wlr_log(L_DEBUG, "xkb layout for device: %s", current_input_config->identifier);
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "xkb_layout", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "xkb_layout", "No input device defined.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@
|
|||
#include "log.h"
|
||||
|
||||
struct cmd_results *input_cmd_xkb_model(int argc, char **argv) {
|
||||
wlr_log(L_DEBUG, "xkb model for device: %s", current_input_config->identifier);
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "xkb_model", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "xkb_model", "No input device defined.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@
|
|||
#include "log.h"
|
||||
|
||||
struct cmd_results *input_cmd_xkb_options(int argc, char **argv) {
|
||||
wlr_log(L_DEBUG, "xkb options for device: %s", current_input_config->identifier);
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "xkb_options", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "xkb_options", "No input device defined.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@
|
|||
#include "log.h"
|
||||
|
||||
struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) {
|
||||
wlr_log(L_DEBUG, "xkb rules for device: %s", current_input_config->identifier);
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "xkb_rules", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "xkb_rules", "No input device defined.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@
|
|||
#include "log.h"
|
||||
|
||||
struct cmd_results *input_cmd_xkb_variant(int argc, char **argv) {
|
||||
wlr_log(L_DEBUG, "xkb variant for device: %s", current_input_config->identifier);
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "xkb_variant", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct input_config *current_input_config =
|
||||
config->handler_context.input_config;
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "xkb_variant", "No input device defined.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue