some consistency tweaks
This commit is contained in:
parent
84d39a9acc
commit
901d5bd0f8
22
ipc.h
22
ipc.h
|
@ -9,15 +9,15 @@
|
||||||
|
|
||||||
static char *ipcsockpath = "/tmp/speedwm.sock"; /* May be a good idea to change this to 'dwm.sock' for compatibility reasons. */
|
static char *ipcsockpath = "/tmp/speedwm.sock"; /* May be a good idea to change this to 'dwm.sock' for compatibility reasons. */
|
||||||
static IPCCommand ipccommands[] = {
|
static IPCCommand ipccommands[] = {
|
||||||
ipccmd( view, 1, { ARG_TYPE_UINT } ),
|
ipccmd( view, 1, { arg_uint } ),
|
||||||
ipccmd( tagmon, 1, { ARG_TYPE_UINT } ),
|
ipccmd( tagmon, 1, { arg_uint } ),
|
||||||
ipccmd( focusmon, 1, { ARG_TYPE_SINT } ),
|
ipccmd( focusmon, 1, { arg_sint } ),
|
||||||
ipccmd( focusstackvis, 1, { ARG_TYPE_SINT } ),
|
ipccmd( focusstackvis, 1, { arg_sint } ),
|
||||||
ipccmd( zoom, 1, { ARG_TYPE_NONE } ),
|
ipccmd( zoom, 1, { arg_none } ),
|
||||||
ipccmd( incmastercount, 1, { ARG_TYPE_SINT } ),
|
ipccmd( incmastercount, 1, { arg_sint } ),
|
||||||
ipccmd( killclient, 1, { ARG_TYPE_SINT } ),
|
ipccmd( killclient, 1, { arg_sint } ),
|
||||||
ipccmd( togglefloating, 1, { ARG_TYPE_NONE } ),
|
ipccmd( togglefloating, 1, { arg_none } ),
|
||||||
ipccmd( setmfact, 1, { ARG_TYPE_FLOAT } ),
|
ipccmd( setmfact, 1, { arg_float } ),
|
||||||
ipccmd( setlayoutsafe, 1, { ARG_TYPE_PTR } ),
|
ipccmd( setlayoutsafe, 1, { arg_ptr } ),
|
||||||
ipccmd( quit, 1, { ARG_TYPE_NONE } )
|
ipccmd( quit, 1, { arg_none } )
|
||||||
};
|
};
|
||||||
|
|
12
toggle/ipc.c
12
toggle/ipc.c
|
@ -360,7 +360,7 @@ ipc_parse_run_command(char *msg, IPCParsedCommand *parsed_command)
|
||||||
if (*argc == 0) {
|
if (*argc == 0) {
|
||||||
*args = (Arg *)malloc(sizeof(Arg));
|
*args = (Arg *)malloc(sizeof(Arg));
|
||||||
*arg_types = (ArgType *)malloc(sizeof(ArgType));
|
*arg_types = (ArgType *)malloc(sizeof(ArgType));
|
||||||
(*arg_types)[0] = ARG_TYPE_NONE;
|
(*arg_types)[0] = arg_none;
|
||||||
(*args)[0].i = 0;
|
(*args)[0].i = 0;
|
||||||
(*argc)++;
|
(*argc)++;
|
||||||
} else if (*argc > 0) {
|
} else if (*argc > 0) {
|
||||||
|
@ -375,18 +375,18 @@ ipc_parse_run_command(char *msg, IPCParsedCommand *parsed_command)
|
||||||
// Any values below 0 must be a signed int
|
// Any values below 0 must be a signed int
|
||||||
if (YAJL_GET_INTEGER(arg_val) < 0) {
|
if (YAJL_GET_INTEGER(arg_val) < 0) {
|
||||||
(*args)[i].i = YAJL_GET_INTEGER(arg_val);
|
(*args)[i].i = YAJL_GET_INTEGER(arg_val);
|
||||||
(*arg_types)[i] = ARG_TYPE_SINT;
|
(*arg_types)[i] = arg_sint;
|
||||||
DEBUG("i=%ld\n", (*args)[i].i);
|
DEBUG("i=%ld\n", (*args)[i].i);
|
||||||
// Any values above 0 should be an unsigned int
|
// Any values above 0 should be an unsigned int
|
||||||
} else if (YAJL_GET_INTEGER(arg_val) >= 0) {
|
} else if (YAJL_GET_INTEGER(arg_val) >= 0) {
|
||||||
(*args)[i].ui = YAJL_GET_INTEGER(arg_val);
|
(*args)[i].ui = YAJL_GET_INTEGER(arg_val);
|
||||||
(*arg_types)[i] = ARG_TYPE_UINT;
|
(*arg_types)[i] = arg_uint;
|
||||||
DEBUG("ui=%ld\n", (*args)[i].i);
|
DEBUG("ui=%ld\n", (*args)[i].i);
|
||||||
}
|
}
|
||||||
// If the number is not an integer, it must be a float
|
// If the number is not an integer, it must be a float
|
||||||
} else {
|
} else {
|
||||||
(*args)[i].f = (float)YAJL_GET_DOUBLE(arg_val);
|
(*args)[i].f = (float)YAJL_GET_DOUBLE(arg_val);
|
||||||
(*arg_types)[i] = ARG_TYPE_FLOAT;
|
(*arg_types)[i] = arg_float;
|
||||||
DEBUG("f=%f\n", (*args)[i].f);
|
DEBUG("f=%f\n", (*args)[i].f);
|
||||||
// If argument is not a number, it must be a string
|
// If argument is not a number, it must be a string
|
||||||
}
|
}
|
||||||
|
@ -437,10 +437,10 @@ ipc_validate_run_command(IPCParsedCommand *parsed, const IPCCommand actual)
|
||||||
ArgType atype = actual.arg_types[i];
|
ArgType atype = actual.arg_types[i];
|
||||||
|
|
||||||
if (ptype != atype) {
|
if (ptype != atype) {
|
||||||
if (ptype == ARG_TYPE_UINT && atype == ARG_TYPE_PTR)
|
if (ptype == arg_uint && atype == arg_ptr)
|
||||||
// If this argument is supposed to be a void pointer, cast it
|
// If this argument is supposed to be a void pointer, cast it
|
||||||
parsed->args[i].v = (void *)parsed->args[i].ui;
|
parsed->args[i].v = (void *)parsed->args[i].ui;
|
||||||
else if (ptype == ARG_TYPE_UINT && atype == ARG_TYPE_SINT)
|
else if (ptype == arg_uint && atype == arg_sint)
|
||||||
// If this argument is supposed to be a signed int, cast it
|
// If this argument is supposed to be a signed int, cast it
|
||||||
parsed->args[i].i = parsed->args[i].ui;
|
parsed->args[i].i = parsed->args[i].ui;
|
||||||
else
|
else
|
||||||
|
|
10
toggle/ipc.h
10
toggle/ipc.h
|
@ -50,11 +50,11 @@ typedef struct speedwm_ipc_header {
|
||||||
} __attribute((packed)) speedwm_ipc_header_t;
|
} __attribute((packed)) speedwm_ipc_header_t;
|
||||||
|
|
||||||
typedef enum ArgType {
|
typedef enum ArgType {
|
||||||
ARG_TYPE_NONE = 0,
|
arg_none = 0,
|
||||||
ARG_TYPE_UINT = 1,
|
arg_uint = 1,
|
||||||
ARG_TYPE_SINT = 2,
|
arg_sint = 2,
|
||||||
ARG_TYPE_FLOAT = 3,
|
arg_float = 3,
|
||||||
ARG_TYPE_PTR = 4,
|
arg_ptr = 4,
|
||||||
ARG_TYPE_STR = 5
|
ARG_TYPE_STR = 5
|
||||||
} ArgType;
|
} ArgType;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue