mirror of
https://github.com/swaywm/sway.git
synced 2024-11-28 10:51:28 +00:00
Added in command queue
This commit is contained in:
parent
8c1191d0e1
commit
698685ee72
|
@ -33,6 +33,7 @@ bool load_config() {
|
||||||
void config_defaults(struct sway_config *config) {
|
void config_defaults(struct sway_config *config) {
|
||||||
config->symbols = create_list();
|
config->symbols = create_list();
|
||||||
config->modes = create_list();
|
config->modes = create_list();
|
||||||
|
config->cmd_queue = create_list();
|
||||||
config->current_mode = malloc(sizeof(struct sway_mode));
|
config->current_mode = malloc(sizeof(struct sway_mode));
|
||||||
config->current_mode->name = NULL;
|
config->current_mode->name = NULL;
|
||||||
config->current_mode->bindings = create_list();
|
config->current_mode->bindings = create_list();
|
||||||
|
@ -68,9 +69,20 @@ struct sway_config *read_config(FILE *file, bool is_active) {
|
||||||
goto _continue;
|
goto _continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!temp_depth && handle_command(config, line) != true) {
|
// Any command which would require wlc to be initialized
|
||||||
|
// should be queue for later execution
|
||||||
|
list_t *args = split_string(line, " ");
|
||||||
|
sway_log(L_DEBUG, "Checking command %s", line);
|
||||||
|
if (strcmp("workspace", args->items[0]) == 0) {
|
||||||
|
sway_log(L_DEBUG, "Deferring command %s", line);
|
||||||
|
char *cmd = malloc(strlen(line) + 1);
|
||||||
|
strcpy(cmd, line);
|
||||||
|
list_add(config->cmd_queue, cmd);
|
||||||
|
}else if (!temp_depth && !handle_command(config, line)) {
|
||||||
|
sway_log(L_DEBUG, "Config load failed for line %s", line);
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
list_free(args);
|
||||||
|
|
||||||
_continue:
|
_continue:
|
||||||
if (line && line[strlen(line) - 1] == '{') {
|
if (line && line[strlen(line) - 1] == '{') {
|
||||||
|
@ -80,6 +92,7 @@ _continue:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success == false) {
|
if (success == false) {
|
||||||
|
sway_log(L_DEBUG, "Config load failed, exiting");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct sway_mode {
|
||||||
struct sway_config {
|
struct sway_config {
|
||||||
list_t *symbols;
|
list_t *symbols;
|
||||||
list_t *modes;
|
list_t *modes;
|
||||||
|
list_t *cmd_queue;
|
||||||
struct sway_mode *current_mode;
|
struct sway_mode *current_mode;
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
|
|
|
@ -163,6 +163,16 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_wlc_ready(void) {
|
||||||
|
sway_log(L_DEBUG, "Compositor is ready, executing cmds in queue");
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < config->cmd_queue->length; ++i) {
|
||||||
|
sway_log(L_DEBUG, "Handling command %s", config->cmd_queue->items[i]);
|
||||||
|
handle_command(config, config->cmd_queue->items[i]);
|
||||||
|
}
|
||||||
|
list_free(config->cmd_queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct wlc_interface interface = {
|
struct wlc_interface interface = {
|
||||||
.output = {
|
.output = {
|
||||||
|
@ -185,6 +195,9 @@ struct wlc_interface interface = {
|
||||||
.pointer = {
|
.pointer = {
|
||||||
.motion = handle_pointer_motion,
|
.motion = handle_pointer_motion,
|
||||||
.button = handle_pointer_button
|
.button = handle_pointer_button
|
||||||
|
},
|
||||||
|
.compositor = {
|
||||||
|
.ready = handle_wlc_ready
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ char *workspace_next_name(void) {
|
||||||
struct sway_binding *binding = mode->bindings->items[i];
|
struct sway_binding *binding = mode->bindings->items[i];
|
||||||
const char* command = binding->command;
|
const char* command = binding->command;
|
||||||
list_t *args = split_string(command, " ");
|
list_t *args = split_string(command, " ");
|
||||||
sway_log(L_DEBUG, "Workspace: Checking name '%s'", command);
|
|
||||||
|
|
||||||
if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) {
|
if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) {
|
||||||
sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[1]);
|
sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[1]);
|
||||||
|
@ -47,7 +46,11 @@ char *workspace_next_name(void) {
|
||||||
if (workspace_find_by_name(args->items[1]))
|
if (workspace_find_by_name(args->items[1]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return args->items[1]; }
|
list_free(args);
|
||||||
|
|
||||||
|
sway_log(L_DEBUG, "Workspace: Found free name %s", args->items[1]);
|
||||||
|
return args->items[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// As a fall back, get the current number of active workspaces
|
// As a fall back, get the current number of active workspaces
|
||||||
// and return that + 1 for the next workspace's name
|
// and return that + 1 for the next workspace's name
|
||||||
|
|
Loading…
Reference in a new issue