move things around

- rename parse_config to config_parse
- move KeyModList and ButtonList in their own functions
- move LayoutsList in layout.c
- move static fcts around in config.c
This commit is contained in:
Julien Danjou 2007-12-16 13:22:13 +01:00
parent 66d43ef0d9
commit f0f522bd47
4 changed files with 83 additions and 90 deletions

View File

@ -336,7 +336,7 @@ main(int argc, char *argv[])
focus_add_client(&globalconf.focus, NULL);
/* store display */
globalconf.display = dpy;
parse_config(confpath);
config_parse(confpath);
for(screen = 0; screen < get_screen_count(dpy); screen++)
{

147
config.c
View File

@ -26,26 +26,17 @@
#include <confuse.h>
#include <X11/keysym.h>
#include "awesome.h"
#include "layout.h"
#include "statusbar.h"
#include "util.h"
#include "rules.h"
#include "screen.h"
#include "widget.h"
#include "layouts/tile.h"
#include "layouts/floating.h"
#include "layouts/max.h"
#include "layouts/fibonacci.h"
#include "defconfig.h"
#define AWESOME_CONFIG_FILE ".awesomerc"
extern awesome_config globalconf;
static XColor initxcolor(Display *, int, const char *);
static unsigned int get_numlockmask(Display *);
/** Link a name to a key symbol */
typedef struct
{
@ -62,7 +53,47 @@ typedef struct
extern const NameFuncLink UicbList[];
extern const NameFuncLink WidgetList[];
extern const NameFuncLink LayoutsList[];
/** Initialize color from X side
* \param disp Display ref
* \param scr Screen number
* \param colorstr Color code
*/
static XColor
initxcolor(Display *disp, int scr, const char *colstr)
{
XColor color;
if(!XAllocNamedColor(disp, DefaultColormap(disp, scr), colstr, &color, &color))
die("awesome: error, cannot allocate color '%s'\n", colstr);
return color;
}
static unsigned int
get_numlockmask(Display *disp)
{
XModifierKeymap *modmap;
unsigned int mask = 0;
int i, j;
modmap = XGetModifierMapping(disp);
for(i = 0; i < 8; i++)
for(j = 0; j < modmap->max_keypermod; j++)
if(modmap->modifiermap[i * modmap->max_keypermod + j]
== XKeysymToKeycode(disp, XK_Num_Lock))
mask = (1 << i);
XFreeModifiermap(modmap);
return mask;
}
/** Lookup for a key mask from its name
* \param keyname Key name
* \return Key mask or 0 if not found
*/
static KeySym
key_mask_lookup(const char *keyname)
{
/** List of keyname and corresponding X11 mask codes */
static const KeyMod KeyModList[] =
{
@ -76,36 +107,6 @@ static const KeyMod KeyModList[] =
{"Mod5", Mod5Mask},
{NULL, NoSymbol}
};
/** List of button name and corresponding X11 mask codes */
static const MouseButton MouseButtonList[] =
{
{"1", Button1},
{"2", Button2},
{"3", Button3},
{"4", Button4},
{"5", Button5},
{NULL, 0}
};
/** List of available layouts and link between name and functions */
static const NameFuncLink LayoutsList[] =
{
{"tile", layout_tile},
{"tileleft", layout_tileleft},
{"max", layout_max},
{"spiral", layout_spiral},
{"dwindle", layout_dwindle},
{"floating", layout_floating},
{NULL, NULL}
};
/** Lookup for a key mask from its name
* \param keyname Key name
* \return Key mask or 0 if not found
*/
static KeySym
key_mask_lookup(const char *keyname)
{
int i;
if(keyname)
@ -123,6 +124,16 @@ key_mask_lookup(const char *keyname)
static unsigned int
mouse_button_lookup(const char *button)
{
/** List of button name and corresponding X11 mask codes */
static const MouseButton MouseButtonList[] =
{
{"1", Button1},
{"2", Button2},
{"3", Button3},
{"4", Button4},
{"5", Button5},
{NULL, 0}
};
int i;
if(button)
@ -243,21 +254,16 @@ static Key *section_keys(cfg_t *cfg_keys)
return head;
}
const char *widget_names[] = {
"focustitle",
"layoutinfo",
"taglist",
"textbox",
};
static int
cmp_widget_cfg(const void *a, const void *b){
cmp_widget_cfg(const void *a, const void *b)
{
if (((cfg_t*)a)->line < ((cfg_t*)b)->line)
return -1;
else if (((cfg_t*)a)->line > ((cfg_t*)b)->line)
if (((cfg_t*)a)->line > ((cfg_t*)b)->line)
return 1;
else
return 0;
}
@ -265,6 +271,13 @@ cmp_widget_cfg(const void *a, const void *b){
static void
create_widgets(cfg_t* cfg_statusbar, Statusbar *statusbar)
{
static const char *widget_names[] =
{
"focustitle",
"layoutinfo",
"taglist",
"textbox",
};
cfg_t* widgets, *wptr;
Widget *widget = NULL;
unsigned int i, j, numnames, numwidgets = 0;
@ -307,12 +320,11 @@ create_widgets(cfg_t* cfg_statusbar, Statusbar *statusbar)
}
}
/** Parse configuration file and initialize some stuff
* \param configpatharg Path to configuration file
*/
void
parse_config(const char *confpatharg)
config_parse(const char *confpatharg)
{
static cfg_opt_t general_opts[] =
{
@ -692,37 +704,4 @@ parse_config(const char *confpatharg)
p_delete(&confpath);
}
static unsigned int
get_numlockmask(Display *disp)
{
XModifierKeymap *modmap;
unsigned int mask = 0;
int i, j;
modmap = XGetModifierMapping(disp);
for(i = 0; i < 8; i++)
for(j = 0; j < modmap->max_keypermod; j++)
if(modmap->modifiermap[i * modmap->max_keypermod + j]
== XKeysymToKeycode(disp, XK_Num_Lock))
mask = (1 << i);
XFreeModifiermap(modmap);
return mask;
}
/** Initialize color from X side
* \param disp Display ref
* \param scr Screen number
* \param colorstr Color code
*/
static XColor
initxcolor(Display *disp, int scr, const char *colstr)
{
XColor color;
if(!XAllocNamedColor(disp, DefaultColormap(disp, scr), colstr, &color, &color))
die("awesome: error, cannot allocate color '%s'\n", colstr);
return color;
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -267,7 +267,7 @@ struct awesome_config
FocusList *focus;
};
void parse_config(const char *);
void config_parse(const char *);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -29,10 +29,24 @@
#include "xutil.h"
#include "focus.h"
#include "statusbar.h"
#include "layouts/tile.h"
#include "layouts/max.h"
#include "layouts/fibonacci.h"
#include "layouts/floating.h"
extern awesome_config globalconf;
const NameFuncLink LayoutsList[] =
{
{"tile", layout_tile},
{"tileleft", layout_tileleft},
{"max", layout_max},
{"spiral", layout_spiral},
{"dwindle", layout_dwindle},
{"floating", layout_floating},
{NULL, NULL}
};
/** Find the index of the first currently selected tag
* \param screen the screen to search
* \return tag