Enable function calls on "eesh set ..." to do reconfiguration.

SVN revision: 13349
This commit is contained in:
Kim Woelders 2005-02-13 11:19:51 +00:00
parent f9c0359c5b
commit fad7f96620
4 changed files with 70 additions and 12 deletions

View File

@ -808,8 +808,8 @@ typedef struct
int num;
int dragdir;
int dragbar_width;
int dragbar_ordering;
int dragbar_length;
int dragbar_ordering;
char desks_wraparound;
char slidein;
int slidespeed;

View File

@ -69,6 +69,19 @@ DeskControlsCreate(Desk * d)
int x[3], y[3], w[3], h[3], m, n, o;
const char *t;
if (Conf.desks.dragdir < 0 || Conf.desks.dragdir > 3)
Conf.desks.dragdir = 2;
if (Conf.desks.dragbar_ordering < 0 || Conf.desks.dragbar_ordering > 5)
Conf.desks.dragbar_ordering = 1;
if (Conf.desks.dragbar_width < 0)
Conf.desks.dragbar_width = 0;
else if (Conf.desks.dragbar_width > 64)
Conf.desks.dragbar_width = 64;
if (Conf.desks.dragbar_length < 0)
Conf.desks.dragbar_length = 0;
else if (Conf.desks.dragbar_length > VRoot.w)
Conf.desks.dragbar_length = VRoot.w;
Esnprintf(s, sizeof(s), "DRAGBAR_DESKTOP_%i", d->num);
ac = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
@ -1524,7 +1537,7 @@ DeskDragdirSet(const char *params)
static void
DeskDragbarOrderSet(const char *params)
{
char pd;
int pd;
pd = Conf.desks.dragbar_ordering;
@ -2367,18 +2380,54 @@ IpcItem DesktopsIpcArray[] = {
};
#define N_IPC_FUNCS (sizeof(DesktopsIpcArray)/sizeof(IpcItem))
static void
DesksCfgFuncCount(void *item __UNUSED__, const char *value)
{
ChangeNumberOfDesktops(atoi(value));
}
static void
DesksCfgFuncDragdir(void *item __UNUSED__, const char *value)
{
DeskDragdirSet(value);
}
static void
DesksCfgFuncDragdbarOrder(void *item __UNUSED__, const char *value)
{
DeskDragbarOrderSet(value);
}
static void
AreasCfgFuncSizeX(void *item __UNUSED__, const char *value)
{
int ax, ay;
GetAreaSize(&ax, &ay);
SetNewAreaSize(atoi(value), ay);
}
static void
AreasCfgFuncSizeY(void *item __UNUSED__, const char *value)
{
int ax, ay;
GetAreaSize(&ax, &ay);
SetNewAreaSize(ax, atoi(value));
}
static const CfgItem DesktopsCfgItems[] = {
CFG_ITEM_INT(Conf.desks, num, 2),
CFG_ITEM_INT(Conf.desks, dragdir, 2),
CFG_FUNC_INT(Conf.desks, num, 2, DesksCfgFuncCount),
CFG_FUNC_INT(Conf.desks, dragdir, 2, DesksCfgFuncDragdir),
CFG_ITEM_INT(Conf.desks, dragbar_width, 16),
CFG_ITEM_INT(Conf.desks, dragbar_ordering, 1),
CFG_ITEM_INT(Conf.desks, dragbar_length, 0),
CFG_FUNC_INT(Conf.desks, dragbar_ordering, 1, DesksCfgFuncDragdbarOrder),
CFG_ITEM_BOOL(Conf.desks, desks_wraparound, 0),
CFG_ITEM_BOOL(Conf.desks, slidein, 1),
CFG_ITEM_INT(Conf.desks, slidespeed, 6000),
CFG_ITEM_INT(Conf.desks, areas_nx, 2),
CFG_ITEM_INT(Conf.desks, areas_ny, 1),
CFG_FUNC_INT(Conf.desks, areas_nx, 2, AreasCfgFuncSizeX),
CFG_FUNC_INT(Conf.desks, areas_ny, 1, AreasCfgFuncSizeY),
CFG_ITEM_BOOL(Conf.desks, areas_wraparound, 0),
};
#define N_CFG_ITEMS (sizeof(DesktopsCfgItems)/sizeof(CfgItem))

View File

@ -432,7 +432,11 @@ CfgItemListNamedItemSet(const CfgItem * pcl, int ncl, const char *item,
ci = CfgItemFind(pcl, ncl, item);
if (!ci)
return -1;
CfgItemSetFromString(ci, value);
if (ci->func)
ci->func(ci->ptr, value);
else
CfgItemSetFromString(ci, value);
return 0;
}

View File

@ -30,6 +30,7 @@ typedef struct
void *ptr;
char type;
long dflt;
void (*func) (void *item, const char *value);
} CfgItem;
typedef enum
@ -40,12 +41,16 @@ typedef enum
ITEM_TYPE_STRING
} cfg_item_type_e;
#define CFG_ITEM_BOOL(conf, name, dflt) { #name, &conf.name, ITEM_TYPE_BOOL, dflt }
#define CFG_ITEM_INT(conf, name, dflt) { #name, &conf.name, ITEM_TYPE_INT, dflt }
#define CFG_ITEM_STR(conf, name) { #name, &conf.name, ITEM_TYPE_STRING, 0 }
#define CFG_ITEM_BOOL(conf, name, dflt) { #name, &conf.name, ITEM_TYPE_BOOL, dflt, NULL }
#define CFG_ITEM_INT(conf, name, dflt) { #name, &conf.name, ITEM_TYPE_INT, dflt, NULL }
#define CFG_ITEM_STR(conf, name) { #name, &conf.name, ITEM_TYPE_STRING, 0, NULL }
#define CFG_FUNC_BOOL(conf, name, dflt, func) { #name, &conf.name, ITEM_TYPE_BOOL, dflt, func }
#define CFG_FUNC_INT(conf, name, dflt, func) { #name, &conf.name, ITEM_TYPE_INT, dflt, func }
#define CFG_FUNC_STR(conf, name, func) { #name, &conf.name, ITEM_TYPE_STRING, 0, func }
/* Change to this? */
#define CFR_ITEM_BOOL(conf, name, dflt) { #name, &conf, ITEM_TYPE_BOOL, dflt }
#define CFR_ITEM_BOOL(conf, name, dflt) { #name, &conf, ITEM_TYPE_BOOL, dflt, NULL }
const CfgItem *CfgItemFind(const CfgItem * pcl, int ncl, const char *name);
void CfgItemToString(const CfgItem * ci, char *buf, int len);