common.h: cleanup, cont.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2019-05-06 02:23:15 +01:00
parent 16ea51bbc1
commit cdb24ec99c
6 changed files with 50 additions and 72 deletions

View File

@@ -211,6 +211,26 @@ static const c2_predef_t C2_PREDEFS[] = {
[C2_L_PROLE] = {"role", C2_L_TSTRING, 0},
};
/**
* Get the numeric property value from a win_prop_t.
*/
static inline long winprop_get_int(winprop_t prop) {
long tgt = 0;
if (!prop.nitems) {
return 0;
}
switch (prop.format) {
case 8: tgt = *(prop.p8); break;
case 16: tgt = *(prop.p16); break;
case 32: tgt = *(prop.p32); break;
default: assert(0); break;
}
return tgt;
}
/**
* Compare next word in a string with another string.
*/