mirror of
https://github.com/swaywm/sway.git
synced 2024-11-24 17:01:29 +00:00
Error case implemented and merged with master
This commit is contained in:
commit
d2669f1bc9
|
@ -2,6 +2,7 @@ add_library(sway-common
|
||||||
ipc-client.c
|
ipc-client.c
|
||||||
list.c
|
list.c
|
||||||
log.c
|
log.c
|
||||||
|
util.c
|
||||||
readline.c
|
readline.c
|
||||||
stringop.c
|
stringop.c
|
||||||
)
|
)
|
||||||
|
|
15
common/util.c
Normal file
15
common/util.c
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
int wrap(int i, int max) {
|
||||||
|
return ((i % max) + max) % max;
|
||||||
|
}
|
||||||
|
|
||||||
|
int numlen(int n) {
|
||||||
|
if (n >= 1000000) return 7;
|
||||||
|
if (n >= 100000) return 6;
|
||||||
|
if (n >= 10000) return 5;
|
||||||
|
if (n >= 1000) return 4;
|
||||||
|
if (n >= 100) return 3;
|
||||||
|
if (n >= 10) return 2;
|
||||||
|
return 1;
|
||||||
|
}
|
|
@ -80,12 +80,20 @@ struct bar_config {
|
||||||
* In "show" mode, it will always be shown on top of the active workspace.
|
* In "show" mode, it will always be shown on top of the active workspace.
|
||||||
*/
|
*/
|
||||||
char *hidden_state;
|
char *hidden_state;
|
||||||
|
/**
|
||||||
|
* Id name used to identify the bar through IPC.
|
||||||
|
*
|
||||||
|
* Defaults to bar-x, where x corresponds to the position of the
|
||||||
|
* embedding bar block in the config file (bar-0, bar-1, ...).
|
||||||
|
*/
|
||||||
|
char *id;
|
||||||
uint32_t modifier;
|
uint32_t modifier;
|
||||||
list_t *bindings;
|
list_t *bindings;
|
||||||
enum desktop_shell_panel_position position;
|
enum desktop_shell_panel_position position;
|
||||||
char *status_command;
|
char *status_command;
|
||||||
char *font;
|
char *font;
|
||||||
int bar_height;
|
int bar_height;
|
||||||
|
int tray_padding;
|
||||||
bool workspace_buttons;
|
bool workspace_buttons;
|
||||||
bool strip_workspace_numbers;
|
bool strip_workspace_numbers;
|
||||||
bool binding_mode_indicator;
|
bool binding_mode_indicator;
|
||||||
|
@ -111,15 +119,15 @@ struct bar_config {
|
||||||
struct sway_config {
|
struct sway_config {
|
||||||
list_t *symbols;
|
list_t *symbols;
|
||||||
list_t *modes;
|
list_t *modes;
|
||||||
|
list_t *bars;
|
||||||
list_t *cmd_queue;
|
list_t *cmd_queue;
|
||||||
list_t *workspace_outputs;
|
list_t *workspace_outputs;
|
||||||
list_t *output_configs;
|
list_t *output_configs;
|
||||||
list_t *criteria;
|
list_t *criteria;
|
||||||
struct sway_mode *current_mode;
|
struct sway_mode *current_mode;
|
||||||
struct bar_config bar;
|
struct bar_config bar;
|
||||||
|
struct bar_config *current_bar;
|
||||||
uint32_t floating_mod;
|
uint32_t floating_mod;
|
||||||
uint32_t dragging_key;
|
|
||||||
uint32_t resizing_key;
|
|
||||||
enum swayc_layouts default_orientation;
|
enum swayc_layouts default_orientation;
|
||||||
enum swayc_layouts default_layout;
|
enum swayc_layouts default_layout;
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,9 @@
|
||||||
*/
|
*/
|
||||||
int wrap(int i, int max);
|
int wrap(int i, int max);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count number of digits in int
|
||||||
|
*/
|
||||||
|
int numlen(int n);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,7 +21,6 @@ add_executable(sway
|
||||||
main.c
|
main.c
|
||||||
output.c
|
output.c
|
||||||
resize.c
|
resize.c
|
||||||
util.c
|
|
||||||
workspace.c
|
workspace.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
299
sway/commands.c
299
sway/commands.c
|
@ -15,6 +15,7 @@
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "util.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
|
@ -32,6 +33,7 @@ struct cmd_handler {
|
||||||
sway_cmd *handle;
|
sway_cmd *handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static sway_cmd cmd_bar;
|
||||||
static sway_cmd cmd_bindsym;
|
static sway_cmd cmd_bindsym;
|
||||||
static sway_cmd cmd_debuglog;
|
static sway_cmd cmd_debuglog;
|
||||||
static sway_cmd cmd_exec;
|
static sway_cmd cmd_exec;
|
||||||
|
@ -64,6 +66,14 @@ static sway_cmd cmd_workspace;
|
||||||
static sway_cmd cmd_ws_auto_back_and_forth;
|
static sway_cmd cmd_ws_auto_back_and_forth;
|
||||||
|
|
||||||
static sway_cmd bar_cmd_bindsym;
|
static sway_cmd bar_cmd_bindsym;
|
||||||
|
static sway_cmd bar_cmd_mode;
|
||||||
|
static sway_cmd bar_cmd_hidden_state;
|
||||||
|
static sway_cmd bar_cmd_id;
|
||||||
|
static sway_cmd bar_cmd_position;
|
||||||
|
static sway_cmd bar_cmd_strip_workspace_numbers;
|
||||||
|
static sway_cmd bar_cmd_tray_output;
|
||||||
|
static sway_cmd bar_cmd_tray_padding;
|
||||||
|
static sway_cmd bar_cmd_workspace_buttons;
|
||||||
|
|
||||||
swayc_t *sp_view;
|
swayc_t *sp_view;
|
||||||
int sp_index = 0;
|
int sp_index = 0;
|
||||||
|
@ -377,14 +387,14 @@ static struct cmd_results *cmd_floating(int argc, char **argv) {
|
||||||
|
|
||||||
static struct cmd_results *cmd_floating_mod(int argc, char **argv) {
|
static struct cmd_results *cmd_floating_mod(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) {
|
if ((error = checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
int i, j;
|
int i, j;
|
||||||
list_t *split = split_string(argv[0], "+");
|
list_t *split = split_string(argv[0], "+");
|
||||||
config->floating_mod = 0;
|
config->floating_mod = 0;
|
||||||
|
|
||||||
// set modifier keys
|
// set modifer keys
|
||||||
for (i = 0; i < split->length; ++i) {
|
for (i = 0; i < split->length; ++i) {
|
||||||
for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) {
|
for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) {
|
||||||
if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
|
if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
|
||||||
|
@ -397,19 +407,6 @@ static struct cmd_results *cmd_floating_mod(int argc, char **argv) {
|
||||||
error = cmd_results_new(CMD_INVALID, "floating_modifier", "Unknown keys %s", argv[0]);
|
error = cmd_results_new(CMD_INVALID, "floating_modifier", "Unknown keys %s", argv[0]);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc >= 2) {
|
|
||||||
if (strcasecmp("inverse", argv[1]) == 0) {
|
|
||||||
config->dragging_key = M_RIGHT_CLICK;
|
|
||||||
config->resizing_key = M_LEFT_CLICK;
|
|
||||||
} else if (strcasecmp("normal", argv[1]) == 0) {
|
|
||||||
config->dragging_key = M_LEFT_CLICK;
|
|
||||||
config->resizing_key = M_RIGHT_CLICK;
|
|
||||||
} else {
|
|
||||||
error = cmd_results_new(CMD_INVALID, "floating_modifier", "Invalid definition %s", argv[1]);
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,6 +1098,54 @@ static struct cmd_results *cmd_resize(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *cmd_bar(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "bar", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp("{", argv[0]) != 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "bar",
|
||||||
|
"Expected '{' at start of bar config definition.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config->reading) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "bar", "Can only be used in config file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new bar from default bar config
|
||||||
|
struct bar_config *bar = NULL;
|
||||||
|
bar = malloc(sizeof*bar);
|
||||||
|
bar->mode = strdup(config->bar.mode);
|
||||||
|
bar->hidden_state = strdup(config->bar.hidden_state);
|
||||||
|
bar->modifier = config->bar.modifier;
|
||||||
|
bar->position = config->bar.position;
|
||||||
|
bar->status_command = strdup(config->bar.status_command);
|
||||||
|
bar->font = strdup(config->bar.font);
|
||||||
|
bar->bar_height = config->bar.bar_height;
|
||||||
|
bar->workspace_buttons = config->bar.workspace_buttons;
|
||||||
|
bar->strip_workspace_numbers = config->bar.strip_workspace_numbers;
|
||||||
|
bar->binding_mode_indicator = config->bar.binding_mode_indicator;
|
||||||
|
bar->tray_padding = config->bar.tray_padding;
|
||||||
|
list_add(config->bars, bar);
|
||||||
|
|
||||||
|
// set bar id
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < config->bars->length; ++i) {
|
||||||
|
if (bar == config->bars->items[i]) {
|
||||||
|
const int len = 5 + numlen(i); // "bar-" + i + \0
|
||||||
|
bar->id = malloc(len * sizeof(char));
|
||||||
|
snprintf(bar->id, len, "bar-%d", i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set current bar
|
||||||
|
config->current_bar = bar;
|
||||||
|
sway_log(L_DEBUG, "Configuring bar %s", bar->id);
|
||||||
|
return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static swayc_t *fetch_view_from_scratchpad() {
|
static swayc_t *fetch_view_from_scratchpad() {
|
||||||
if (sp_index >= scratchpad->length) {
|
if (sp_index >= scratchpad->length) {
|
||||||
sp_index = 0;
|
sp_index = 0;
|
||||||
|
@ -1448,6 +1493,7 @@ static struct cmd_results *cmd_ws_auto_back_and_forth(int argc, char **argv) {
|
||||||
|
|
||||||
/* Keep alphabetized */
|
/* Keep alphabetized */
|
||||||
static struct cmd_handler handlers[] = {
|
static struct cmd_handler handlers[] = {
|
||||||
|
{ "bar", cmd_bar },
|
||||||
{ "bindsym", cmd_bindsym },
|
{ "bindsym", cmd_bindsym },
|
||||||
{ "debuglog", cmd_debuglog },
|
{ "debuglog", cmd_debuglog },
|
||||||
{ "default_orientation", cmd_orientation },
|
{ "default_orientation", cmd_orientation },
|
||||||
|
@ -1489,13 +1535,15 @@ static struct cmd_results *bar_cmd_bindsym(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_FAILURE, "bindsym", "Can only be used in config file.");
|
return cmd_results_new(CMD_FAILURE, "bindsym", "Can only be used in config file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: The bit that requires to be checked */
|
|
||||||
if (strlen(argv[1]) != 7) {
|
if (strlen(argv[1]) != 7) {
|
||||||
return ; //TODO: error case
|
return cmd_results_new(CMD_INVALID, "bindsym", "Invalid mouse binding %s", state);
|
||||||
}
|
}
|
||||||
uint32_t numbutton = (uint32_t) strtol(argv[1] + 6, NULL, 10);
|
uint32_t numbutton = (uint32_t) strtol(argv[1] + 6, NULL, 10);
|
||||||
if (numbutton < 1 || numbutton > 5) {
|
if (numbutton < 1 || numbutton > 5) {
|
||||||
return ; //TODO: error case
|
return cmd_results_new(CMD_INVALID, "bindsym", "Invalid mouse binding %s", state);
|
||||||
|
}
|
||||||
|
if (strncmp(argv[1], "button", 6) != 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "bindsym", "Invalid mouse binding %s", state);
|
||||||
}
|
}
|
||||||
struct sway_mouse_binding *binding = malloc(sizeof(struct sway_mouse_binding));
|
struct sway_mouse_binding *binding = malloc(sizeof(struct sway_mouse_binding));
|
||||||
binding->button = numbutton;
|
binding->button = numbutton;
|
||||||
|
@ -1513,6 +1561,186 @@ static struct cmd_results *bar_cmd_bindsym(int argc, char **argv) {
|
||||||
list_sort(bar.bindings, sway_mouse_binding_cmp);
|
list_sort(bar.bindings, sway_mouse_binding_cmp);
|
||||||
|
|
||||||
sway_log(L_DEBUG, "bindsym - Bound %s to command %s when clicking swaybar", argv[0], binding->command);
|
sway_log(L_DEBUG, "bindsym - Bound %s to command %s when clicking swaybar", argv[0], binding->command);
|
||||||
|
|
||||||
|
static struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "hidden_state", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *state = argv[0];
|
||||||
|
char *old_state = config->current_bar->hidden_state;
|
||||||
|
|
||||||
|
if (strcasecmp("hide", state) == 0) {
|
||||||
|
config->current_bar->hidden_state = strdup(state);
|
||||||
|
} else if(strcmp("show", state) == 0) {
|
||||||
|
config->current_bar->hidden_state = strdup(state);
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_INVALID, "hidden_state", "Invalid value %s", state);
|
||||||
|
}
|
||||||
|
|
||||||
|
sway_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s", state, config->current_bar->id);
|
||||||
|
|
||||||
|
// free old state
|
||||||
|
free(old_state);
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *bar_cmd_mode(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "mode", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *mode = argv[0];
|
||||||
|
char *old_mode = config->current_bar->mode;
|
||||||
|
|
||||||
|
if (strcasecmp("dock", mode) == 0) {
|
||||||
|
config->current_bar->mode = strdup(mode);
|
||||||
|
} else if(strcmp("hide", mode) == 0) {
|
||||||
|
config->current_bar->mode = strdup(mode);
|
||||||
|
} else if(strcmp("invisible", mode) == 0) {
|
||||||
|
config->current_bar->mode = strdup(mode);
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_INVALID, "mode", "Invalid value %s", mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
sway_log(L_DEBUG, "Setting mode: '%s' for bar: %s", mode, config->current_bar->id);
|
||||||
|
|
||||||
|
// free old mode
|
||||||
|
free(old_mode);
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *bar_cmd_id(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "id", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *name = argv[0];
|
||||||
|
const char *oldname = config->current_bar->id;
|
||||||
|
|
||||||
|
// check if id is used by a previously defined bar
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < config->bars->length; ++i) {
|
||||||
|
struct bar_config *find = config->bars->items[i];
|
||||||
|
if (strcmp(name, find->id) == 0 && config->current_bar != find) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "id",
|
||||||
|
"Id '%s' already defined for another bar. Id unchanged (%s).",
|
||||||
|
name, oldname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sway_log(L_DEBUG, "Renaming bar: '%s' to '%s'", oldname, name);
|
||||||
|
|
||||||
|
// free old bar id
|
||||||
|
free(config->current_bar->id);
|
||||||
|
|
||||||
|
config->current_bar->id = strdup(name);
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *bar_cmd_position(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config->current_bar) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "position", "No bar defined.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcasecmp("top", argv[0]) == 0) {
|
||||||
|
config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_TOP;
|
||||||
|
} else if (strcasecmp("bottom", argv[0]) == 0) {
|
||||||
|
config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
|
||||||
|
} else if (strcasecmp("left", argv[0]) == 0) {
|
||||||
|
config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_LEFT;
|
||||||
|
} else if (strcasecmp("right", argv[0]) == 0) {
|
||||||
|
config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_RIGHT;
|
||||||
|
} else {
|
||||||
|
error = cmd_results_new(CMD_INVALID, "position", "Invalid value %s", argv[0]);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
sway_log(L_DEBUG, "Setting bar position '%s' for bar: %s", argv[0], config->current_bar->id);
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config->current_bar) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "strip_workspace_numbers", "No bar defined.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
|
config->current_bar->strip_workspace_numbers = true;
|
||||||
|
sway_log(L_DEBUG, "Stripping workspace numbers on bar: %s", config->current_bar->id);
|
||||||
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
|
config->current_bar->strip_workspace_numbers = false;
|
||||||
|
sway_log(L_DEBUG, "Enabling workspace numbers on bar: %s", config->current_bar->id);
|
||||||
|
} else {
|
||||||
|
error = cmd_results_new(CMD_INVALID, "strip_workspace_numbers", "Invalid value %s", argv[0]);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *bar_cmd_tray_output(int argc, char **argv) {
|
||||||
|
sway_log(L_ERROR, "warning: tray_output is not supported on wayland");
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "tray_padding", EXPECTED_AT_LEAST, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config->current_bar) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "tray_padding", "No bar defined.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int padding = atoi(argv[0]);
|
||||||
|
if (padding < 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "tray_padding",
|
||||||
|
"Invalid padding value %s, minimum is 0", argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 1 && strcasecmp("px", argv[1]) != 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "tray_padding",
|
||||||
|
"Unknown unit %s", argv[1]);
|
||||||
|
}
|
||||||
|
config->current_bar->tray_padding = padding;
|
||||||
|
sway_log(L_DEBUG, "Enabling tray padding of %d px on bar: %s", padding, config->current_bar->id);
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config->current_bar) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "workspace_buttons", "No bar defined.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
|
config->current_bar->workspace_buttons = true;
|
||||||
|
sway_log(L_DEBUG, "Enabling workspace buttons on bar: %s", config->current_bar->id);
|
||||||
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
|
config->current_bar->workspace_buttons = false;
|
||||||
|
sway_log(L_DEBUG, "Disabling workspace buttons on bar: %s", config->current_bar->id);
|
||||||
|
} else {
|
||||||
|
error = cmd_results_new(CMD_INVALID, "workspace_buttons", "Invalid value %s", argv[0]);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1521,18 +1749,18 @@ static struct cmd_handler bar_handlers[] = {
|
||||||
{ "bindsym", bar_cmd_bindsym },
|
{ "bindsym", bar_cmd_bindsym },
|
||||||
{ "colors", NULL },
|
{ "colors", NULL },
|
||||||
{ "font", NULL },
|
{ "font", NULL },
|
||||||
{ "hidden_state", NULL },
|
{ "hidden_state", bar_cmd_hidden_state },
|
||||||
{ "id", NULL },
|
{ "id", bar_cmd_id },
|
||||||
{ "mode", NULL },
|
{ "mode", bar_cmd_mode },
|
||||||
{ "modifier", NULL },
|
{ "modifier", NULL },
|
||||||
{ "output", NULL },
|
{ "output", NULL },
|
||||||
{ "position", NULL },
|
{ "position", bar_cmd_position },
|
||||||
{ "seperator_symbol", NULL },
|
{ "seperator_symbol", NULL },
|
||||||
{ "status_command", NULL },
|
{ "status_command", NULL },
|
||||||
{ "strip_workspace_numbers", NULL },
|
{ "strip_workspace_numbers", bar_cmd_strip_workspace_numbers },
|
||||||
{ "tray_output", NULL },
|
{ "tray_output", bar_cmd_tray_output },
|
||||||
{ "tray_padding", NULL },
|
{ "tray_padding", bar_cmd_tray_padding },
|
||||||
{ "workspace_buttons", NULL },
|
{ "workspace_buttons", bar_cmd_workspace_buttons },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1544,14 +1772,17 @@ static int handler_compare(const void *_a, const void *_b) {
|
||||||
|
|
||||||
|
|
||||||
static struct cmd_handler *find_handler(char *line, enum cmd_status block) {
|
static struct cmd_handler *find_handler(char *line, enum cmd_status block) {
|
||||||
struct cmd_handler *h = handlers;
|
|
||||||
if (block == CMD_BLOCK_BAR) {
|
|
||||||
h = bar_handlers;
|
|
||||||
}
|
|
||||||
struct cmd_handler d = { .command=line };
|
struct cmd_handler d = { .command=line };
|
||||||
struct cmd_handler *res = bsearch(&d, h,
|
struct cmd_handler *res = NULL;
|
||||||
|
if (block == CMD_BLOCK_BAR) {
|
||||||
|
res = bsearch(&d, bar_handlers,
|
||||||
|
sizeof(bar_handlers) / sizeof(struct cmd_handler),
|
||||||
|
sizeof(struct cmd_handler), handler_compare);
|
||||||
|
} else {
|
||||||
|
res = bsearch(&d, handlers,
|
||||||
sizeof(handlers) / sizeof(struct cmd_handler),
|
sizeof(handlers) / sizeof(struct cmd_handler),
|
||||||
sizeof(struct cmd_handler), handler_compare);
|
sizeof(struct cmd_handler), handler_compare);
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1683,7 +1914,11 @@ struct cmd_results *config_command(char *exec, enum cmd_status block) {
|
||||||
if (argc>1 && (*argv[1] == '\"' || *argv[1] == '\'')) {
|
if (argc>1 && (*argv[1] == '\"' || *argv[1] == '\'')) {
|
||||||
strip_quotes(argv[1]);
|
strip_quotes(argv[1]);
|
||||||
}
|
}
|
||||||
results = handler->handle(argc-1, argv+1);
|
if (handler->handle) {
|
||||||
|
results = handler->handle(argc-1, argv+1);
|
||||||
|
} else {
|
||||||
|
results = cmd_results_new(CMD_INVALID, argv[0], "This command is shimmed, but unimplemented");
|
||||||
|
}
|
||||||
cleanup:
|
cleanup:
|
||||||
free_argv(argc, argv);
|
free_argv(argc, argv);
|
||||||
return results;
|
return results;
|
||||||
|
|
|
@ -38,6 +38,14 @@ static void free_mode(struct sway_mode *mode) {
|
||||||
free(mode);
|
free(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_bar(struct bar_config *bar) {
|
||||||
|
free(bar->mode);
|
||||||
|
free(bar->hidden_state);
|
||||||
|
free(bar->status_command);
|
||||||
|
free(bar->font);
|
||||||
|
free(bar);
|
||||||
|
}
|
||||||
|
|
||||||
void free_output_config(struct output_config *oc) {
|
void free_output_config(struct output_config *oc) {
|
||||||
free(oc->name);
|
free(oc->name);
|
||||||
free(oc);
|
free(oc);
|
||||||
|
@ -61,6 +69,11 @@ static void free_config(struct sway_config *config) {
|
||||||
}
|
}
|
||||||
list_free(config->modes);
|
list_free(config->modes);
|
||||||
|
|
||||||
|
for (i = 0; i < config->bars->length; ++i) {
|
||||||
|
free_bar(config->bars->items[i]);
|
||||||
|
}
|
||||||
|
list_free(config->bars);
|
||||||
|
|
||||||
free_flat_list(config->cmd_queue);
|
free_flat_list(config->cmd_queue);
|
||||||
|
|
||||||
for (i = 0; i < config->workspace_outputs->length; ++i) {
|
for (i = 0; i < config->workspace_outputs->length; ++i) {
|
||||||
|
@ -88,6 +101,7 @@ static bool file_exists(const char *path) {
|
||||||
static void config_defaults(struct sway_config *config) {
|
static void config_defaults(struct sway_config *config) {
|
||||||
config->symbols = create_list();
|
config->symbols = create_list();
|
||||||
config->modes = create_list();
|
config->modes = create_list();
|
||||||
|
config->bars = create_list();
|
||||||
config->workspace_outputs = create_list();
|
config->workspace_outputs = create_list();
|
||||||
config->criteria = create_list();
|
config->criteria = create_list();
|
||||||
config->output_configs = create_list();
|
config->output_configs = create_list();
|
||||||
|
@ -101,8 +115,6 @@ static void config_defaults(struct sway_config *config) {
|
||||||
list_add(config->modes, config->current_mode);
|
list_add(config->modes, config->current_mode);
|
||||||
|
|
||||||
config->floating_mod = 0;
|
config->floating_mod = 0;
|
||||||
config->dragging_key = M_LEFT_CLICK;
|
|
||||||
config->resizing_key = M_RIGHT_CLICK;
|
|
||||||
config->default_layout = L_NONE;
|
config->default_layout = L_NONE;
|
||||||
config->default_orientation = L_NONE;
|
config->default_orientation = L_NONE;
|
||||||
// Flags
|
// Flags
|
||||||
|
@ -130,6 +142,7 @@ static void config_defaults(struct sway_config *config) {
|
||||||
config->bar.workspace_buttons = true;
|
config->bar.workspace_buttons = true;
|
||||||
config->bar.strip_workspace_numbers = false;
|
config->bar.strip_workspace_numbers = false;
|
||||||
config->bar.binding_mode_indicator = true;
|
config->bar.binding_mode_indicator = true;
|
||||||
|
config->bar.tray_padding = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_config_path(void) {
|
static char *get_config_path(void) {
|
||||||
|
@ -138,7 +151,7 @@ static char *get_config_path(void) {
|
||||||
"$XDG_CONFIG_HOME/sway/config",
|
"$XDG_CONFIG_HOME/sway/config",
|
||||||
"$HOME/.i3/config",
|
"$HOME/.i3/config",
|
||||||
"$XDG_CONFIG_HOME/i3/config",
|
"$XDG_CONFIG_HOME/i3/config",
|
||||||
FALLBACK_CONFIG_DIR "/config",
|
FALLBACK_CONFIG_DIR "/config",
|
||||||
"/etc/i3/config",
|
"/etc/i3/config",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,11 +261,26 @@ bool read_config(FILE *file, bool is_active) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CMD_BLOCK_BAR:
|
||||||
|
if (block == CMD_BLOCK_END) {
|
||||||
|
block = CMD_BLOCK_BAR;
|
||||||
|
} else {
|
||||||
|
sway_log(L_ERROR, "Invalid block '%s'", line);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_END:
|
case CMD_BLOCK_END:
|
||||||
switch(block) {
|
switch(block) {
|
||||||
case CMD_BLOCK_MODE:
|
case CMD_BLOCK_MODE:
|
||||||
sway_log(L_DEBUG, "End of mode block");
|
sway_log(L_DEBUG, "End of mode block");
|
||||||
config->current_mode = config->modes->items[0];
|
config->current_mode = config->modes->items[0];
|
||||||
|
block = CMD_BLOCK_END;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_BLOCK_BAR:
|
||||||
|
sway_log(L_DEBUG, "End of bar block");
|
||||||
|
config->current_bar = NULL;
|
||||||
|
block = CMD_BLOCK_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_END:
|
case CMD_BLOCK_END:
|
||||||
|
|
|
@ -96,6 +96,7 @@ bool set_focused_container(swayc_t *c) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
swayc_t *active_ws = swayc_active_workspace();
|
swayc_t *active_ws = swayc_active_workspace();
|
||||||
|
int active_ws_child_count = active_ws->children->length + active_ws->floating->length;
|
||||||
|
|
||||||
swayc_log(L_DEBUG, c, "Setting focus to %p:%ld", c, c->handle);
|
swayc_log(L_DEBUG, c, "Setting focus to %p:%ld", c, c->handle);
|
||||||
|
|
||||||
|
@ -118,6 +119,11 @@ bool set_focused_container(swayc_t *c) {
|
||||||
p = p->parent;
|
p = p->parent;
|
||||||
p->is_focused = false;
|
p->is_focused = false;
|
||||||
}
|
}
|
||||||
|
// active_ws might have been destroyed by now
|
||||||
|
// (focus swap away from empty ws = destroy ws)
|
||||||
|
if (active_ws_child_count == 0) {
|
||||||
|
active_ws = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// get new focused view and set focus to it.
|
// get new focused view and set focus to it.
|
||||||
p = get_focused_view(c);
|
p = get_focused_view(c);
|
||||||
|
|
|
@ -194,16 +194,8 @@ void center_pointer_on(swayc_t *view) {
|
||||||
|
|
||||||
// Mode set left/right click
|
// Mode set left/right click
|
||||||
|
|
||||||
static void pointer_mode_set_dragging(void) {
|
static void pointer_mode_set_left(void) {
|
||||||
switch (config->dragging_key) {
|
set_initial_view(pointer_state.left.view);
|
||||||
case M_LEFT_CLICK:
|
|
||||||
set_initial_view(pointer_state.left.view);
|
|
||||||
break;
|
|
||||||
case M_RIGHT_CLICK:
|
|
||||||
set_initial_view(pointer_state.right.view);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (initial.ptr->is_floating) {
|
if (initial.ptr->is_floating) {
|
||||||
pointer_state.mode = M_DRAGGING | M_FLOATING;
|
pointer_state.mode = M_DRAGGING | M_FLOATING;
|
||||||
} else {
|
} else {
|
||||||
|
@ -216,15 +208,8 @@ static void pointer_mode_set_dragging(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointer_mode_set_resizing(void) {
|
static void pointer_mode_set_right(void) {
|
||||||
switch (config->resizing_key) {
|
set_initial_view(pointer_state.right.view);
|
||||||
case M_LEFT_CLICK:
|
|
||||||
set_initial_view(pointer_state.left.view);
|
|
||||||
break;
|
|
||||||
case M_RIGHT_CLICK:
|
|
||||||
set_initial_view(pointer_state.right.view);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Setup locking information
|
// Setup locking information
|
||||||
int midway_x = initial.ptr->x + initial.ptr->width/2;
|
int midway_x = initial.ptr->x + initial.ptr->width/2;
|
||||||
int midway_y = initial.ptr->y + initial.ptr->height/2;
|
int midway_y = initial.ptr->y + initial.ptr->height/2;
|
||||||
|
@ -248,19 +233,15 @@ void pointer_mode_set(uint32_t button, bool condition) {
|
||||||
// switch on drag/resize mode
|
// switch on drag/resize mode
|
||||||
switch (pointer_state.mode & (M_DRAGGING | M_RESIZING)) {
|
switch (pointer_state.mode & (M_DRAGGING | M_RESIZING)) {
|
||||||
case M_DRAGGING:
|
case M_DRAGGING:
|
||||||
// end drag mode when 'dragging' click is unpressed
|
// end drag mode when left click is unpressed
|
||||||
if (config->dragging_key == M_LEFT_CLICK && !pointer_state.left.held) {
|
if (!pointer_state.left.held) {
|
||||||
pointer_state.mode = 0;
|
|
||||||
} else if (config->dragging_key == M_RIGHT_CLICK && !pointer_state.right.held) {
|
|
||||||
pointer_state.mode = 0;
|
pointer_state.mode = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_RESIZING:
|
case M_RESIZING:
|
||||||
// end resize mode when 'resizing' click is unpressed
|
// end resize mode when right click is unpressed
|
||||||
if (config->resizing_key == M_LEFT_CLICK && !pointer_state.left.held) {
|
if (!pointer_state.right.held) {
|
||||||
pointer_state.mode = 0;
|
|
||||||
} else if (config->resizing_key == M_RIGHT_CLICK && !pointer_state.right.held) {
|
|
||||||
pointer_state.mode = 0;
|
pointer_state.mode = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -274,27 +255,19 @@ void pointer_mode_set(uint32_t button, bool condition) {
|
||||||
|
|
||||||
// Set mode depending on current button press
|
// Set mode depending on current button press
|
||||||
switch (button) {
|
switch (button) {
|
||||||
// Start left-click mode
|
// Start dragging mode
|
||||||
case M_LEFT_CLICK:
|
case M_LEFT_CLICK:
|
||||||
// if button release dont do anything
|
// if button release dont do anything
|
||||||
if (pointer_state.left.held) {
|
if (pointer_state.left.held) {
|
||||||
if (config->dragging_key == M_LEFT_CLICK) {
|
pointer_mode_set_left();
|
||||||
pointer_mode_set_dragging();
|
|
||||||
} else if (config->resizing_key == M_LEFT_CLICK) {
|
|
||||||
pointer_mode_set_resizing();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Start right-click mode
|
// Start resize mode
|
||||||
case M_RIGHT_CLICK:
|
case M_RIGHT_CLICK:
|
||||||
// if button release dont do anyhting
|
// if button release dont do anyhting
|
||||||
if (pointer_state.right.held) {
|
if (pointer_state.right.held) {
|
||||||
if (config->dragging_key == M_RIGHT_CLICK) {
|
pointer_mode_set_right();
|
||||||
pointer_mode_set_dragging();
|
|
||||||
} else if (config->resizing_key == M_RIGHT_CLICK) {
|
|
||||||
pointer_mode_set_resizing();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -314,17 +287,8 @@ void pointer_mode_update(void) {
|
||||||
switch (pointer_state.mode) {
|
switch (pointer_state.mode) {
|
||||||
case M_FLOATING | M_DRAGGING:
|
case M_FLOATING | M_DRAGGING:
|
||||||
// Update position
|
// Update position
|
||||||
switch (config->resizing_key) {
|
dx -= pointer_state.left.x;
|
||||||
case M_LEFT_CLICK:
|
dy -= pointer_state.left.y;
|
||||||
dx -= pointer_state.left.x;
|
|
||||||
dy -= pointer_state.left.y;
|
|
||||||
break;
|
|
||||||
case M_RIGHT_CLICK:
|
|
||||||
dx -= pointer_state.right.x;
|
|
||||||
dy -= pointer_state.right.y;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (initial.x + dx != initial.ptr->x) {
|
if (initial.x + dx != initial.ptr->x) {
|
||||||
initial.ptr->x = initial.x + dx;
|
initial.ptr->x = initial.x + dx;
|
||||||
}
|
}
|
||||||
|
@ -335,19 +299,9 @@ void pointer_mode_update(void) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_FLOATING | M_RESIZING:
|
case M_FLOATING | M_RESIZING:
|
||||||
switch (config->resizing_key) {
|
dx -= pointer_state.right.x;
|
||||||
case M_LEFT_CLICK:
|
dy -= pointer_state.right.y;
|
||||||
dx -= pointer_state.left.x;
|
initial.ptr = pointer_state.right.view;
|
||||||
dy -= pointer_state.left.y;
|
|
||||||
initial.ptr = pointer_state.left.view;
|
|
||||||
break;
|
|
||||||
case M_RIGHT_CLICK:
|
|
||||||
dx -= pointer_state.right.x;
|
|
||||||
dy -= pointer_state.right.y;
|
|
||||||
initial.ptr = pointer_state.right.view;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lock.left) {
|
if (lock.left) {
|
||||||
if (initial.w + dx > min_sane_w) {
|
if (initial.w + dx > min_sane_w) {
|
||||||
initial.ptr->width = initial.w + dx;
|
initial.ptr->width = initial.w + dx;
|
||||||
|
@ -387,17 +341,8 @@ void pointer_mode_update(void) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_TILING | M_RESIZING:
|
case M_TILING | M_RESIZING:
|
||||||
switch (config->resizing_key) {
|
dx -= pointer_state.right.x;
|
||||||
case M_LEFT_CLICK:
|
dy -= pointer_state.right.y;
|
||||||
dx -= pointer_state.left.x;
|
|
||||||
dy -= pointer_state.left.y;
|
|
||||||
break;
|
|
||||||
case M_RIGHT_CLICK:
|
|
||||||
dx -= pointer_state.right.x;
|
|
||||||
dy -= pointer_state.right.y;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// resize if we can
|
// resize if we can
|
||||||
if (initial.horiz.ptr) {
|
if (initial.horiz.ptr) {
|
||||||
if (lock.left) {
|
if (lock.left) {
|
||||||
|
|
|
@ -455,7 +455,11 @@ void ipc_get_outputs_callback(swayc_t *container, void *data) {
|
||||||
void ipc_event_workspace(swayc_t *old, swayc_t *new) {
|
void ipc_event_workspace(swayc_t *old, swayc_t *new) {
|
||||||
json_object *obj = json_object_new_object();
|
json_object *obj = json_object_new_object();
|
||||||
json_object_object_add(obj, "change", json_object_new_string("focus"));
|
json_object_object_add(obj, "change", json_object_new_string("focus"));
|
||||||
json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
|
if (old) {
|
||||||
|
json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
|
||||||
|
} else {
|
||||||
|
json_object_object_add(obj, "old", NULL);
|
||||||
|
}
|
||||||
json_object_object_add(obj, "current", ipc_json_describe_workspace(new));
|
json_object_object_add(obj, "current", ipc_json_describe_workspace(new));
|
||||||
const char *json_string = json_object_to_json_string(obj);
|
const char *json_string = json_object_to_json_string(obj);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ static void wlc_log_handler(enum wlc_log_type type, const char *str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void detect_nvidia() {
|
void detect_proprietary() {
|
||||||
FILE *f = fopen("/proc/modules", "r");
|
FILE *f = fopen("/proc/modules", "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
return;
|
return;
|
||||||
|
@ -48,6 +48,11 @@ void detect_nvidia() {
|
||||||
free(line);
|
free(line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (strstr(line, "fglrx")) {
|
||||||
|
fprintf(stderr, "\x1B[1;31mWarning: Proprietary AMD drivers do NOT support Wayland. Use radeon.\x1B[0m\n");
|
||||||
|
free(line);
|
||||||
|
break;
|
||||||
|
}
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -161,7 +166,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
setenv("WLC_DIM", "0", 0);
|
setenv("WLC_DIM", "0", 0);
|
||||||
wlc_log_set_handler(wlc_log_handler);
|
wlc_log_set_handler(wlc_log_handler);
|
||||||
detect_nvidia();
|
detect_proprietary();
|
||||||
|
|
||||||
/* Changing code earlier than this point requires detailed review */
|
/* Changing code earlier than this point requires detailed review */
|
||||||
/* (That code runs as root on systems without logind, and wlc_init drops to
|
/* (That code runs as root on systems without logind, and wlc_init drops to
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
int wrap(int i, int max) {
|
|
||||||
return ((i % max) + max) % max;
|
|
||||||
}
|
|
|
@ -8,21 +8,12 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "ipc-client.h"
|
#include "ipc-client.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
void sway_terminate(void) {
|
void sway_terminate(void) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int numlen(int n) {
|
|
||||||
if (n >= 1000000) return 7;
|
|
||||||
if (n >= 100000) return 6;
|
|
||||||
if (n >= 10000) return 5;
|
|
||||||
if (n >= 1000) return 4;
|
|
||||||
if (n >= 100) return 3;
|
|
||||||
if (n >= 10) return 2;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void grab_and_apply_magick(const char *file, const char *output,
|
void grab_and_apply_magick(const char *file, const char *output,
|
||||||
int socketfd, int raw) {
|
int socketfd, int raw) {
|
||||||
uint32_t len = strlen(output);
|
uint32_t len = strlen(output);
|
||||||
|
|
Loading…
Reference in a new issue