add compute_new_value_from_arg() to do the +/- job in uicb fcts
This commit is contained in:
parent
fda58db5f6
commit
35defcc4e8
|
@ -42,23 +42,17 @@ uicb_setnmaster(Display *disp,
|
|||
awesome_config *awesomeconf,
|
||||
const char * arg)
|
||||
{
|
||||
int delta;
|
||||
int wah = get_windows_area_height(disp, awesomeconf->statusbar);
|
||||
|
||||
if(!IS_ARRANGE(tile) && !IS_ARRANGE(tileleft) && !IS_ARRANGE(bstack) && !IS_ARRANGE(bstackportrait))
|
||||
return;
|
||||
|
||||
if(!arg)
|
||||
nmaster = awesomeconf->nmaster;
|
||||
else if(sscanf(arg, "%d", &delta))
|
||||
{
|
||||
if((arg[0] == '+' || arg[0] == '-')
|
||||
&& !((nmaster + delta) < 1 || wah / (nmaster + delta) <= 2 * awesomeconf->borderpx))
|
||||
nmaster += delta;
|
||||
else if(delta >= 1 && wah / delta <= 2 * awesomeconf->borderpx)
|
||||
nmaster = delta;
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
nmaster = (int) compute_new_value_from_arg(arg, (double) nmaster);
|
||||
|
||||
if(nmaster < 1)
|
||||
nmaster = 1;
|
||||
|
||||
if(sel)
|
||||
arrange(disp, drawcontext, awesomeconf);
|
||||
else
|
||||
|
|
16
util.c
16
util.c
|
@ -102,3 +102,19 @@ xgettextprop(Display *disp, Window w, Atom atom, char *text, unsigned int size)
|
|||
|
||||
return True;
|
||||
}
|
||||
|
||||
double
|
||||
compute_new_value_from_arg(const char *arg, double current_value)
|
||||
{
|
||||
double delta;
|
||||
|
||||
if(arg && sscanf(arg, "%lf", &delta) == 1)
|
||||
{
|
||||
if(arg[0] == '+' || arg[0] == '-')
|
||||
current_value += delta;
|
||||
else
|
||||
current_value = delta;
|
||||
}
|
||||
|
||||
return current_value;
|
||||
}
|
||||
|
|
1
util.h
1
util.h
|
@ -121,5 +121,6 @@ static inline char *a_strdup(const char *s)
|
|||
void eprint(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
||||
void uicb_spawn(Display *, DC *, awesome_config *, const char *);
|
||||
Bool xgettextprop(Display *, Window, Atom, char *, unsigned int);
|
||||
double compute_new_value_from_arg(const char *, double);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue