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:
parent
66d43ef0d9
commit
f0f522bd47
|
@ -336,7 +336,7 @@ main(int argc, char *argv[])
|
||||||
focus_add_client(&globalconf.focus, NULL);
|
focus_add_client(&globalconf.focus, NULL);
|
||||||
/* store display */
|
/* store display */
|
||||||
globalconf.display = dpy;
|
globalconf.display = dpy;
|
||||||
parse_config(confpath);
|
config_parse(confpath);
|
||||||
|
|
||||||
for(screen = 0; screen < get_screen_count(dpy); screen++)
|
for(screen = 0; screen < get_screen_count(dpy); screen++)
|
||||||
{
|
{
|
||||||
|
|
147
config.c
147
config.c
|
@ -26,26 +26,17 @@
|
||||||
#include <confuse.h>
|
#include <confuse.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
|
||||||
#include "awesome.h"
|
|
||||||
#include "layout.h"
|
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "rules.h"
|
#include "rules.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "layouts/tile.h"
|
|
||||||
#include "layouts/floating.h"
|
|
||||||
#include "layouts/max.h"
|
|
||||||
#include "layouts/fibonacci.h"
|
|
||||||
#include "defconfig.h"
|
#include "defconfig.h"
|
||||||
|
|
||||||
#define AWESOME_CONFIG_FILE ".awesomerc"
|
#define AWESOME_CONFIG_FILE ".awesomerc"
|
||||||
|
|
||||||
extern awesome_config globalconf;
|
extern awesome_config globalconf;
|
||||||
|
|
||||||
static XColor initxcolor(Display *, int, const char *);
|
|
||||||
static unsigned int get_numlockmask(Display *);
|
|
||||||
|
|
||||||
/** Link a name to a key symbol */
|
/** Link a name to a key symbol */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -62,7 +53,47 @@ typedef struct
|
||||||
|
|
||||||
extern const NameFuncLink UicbList[];
|
extern const NameFuncLink UicbList[];
|
||||||
extern const NameFuncLink WidgetList[];
|
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 */
|
/** List of keyname and corresponding X11 mask codes */
|
||||||
static const KeyMod KeyModList[] =
|
static const KeyMod KeyModList[] =
|
||||||
{
|
{
|
||||||
|
@ -76,36 +107,6 @@ static const KeyMod KeyModList[] =
|
||||||
{"Mod5", Mod5Mask},
|
{"Mod5", Mod5Mask},
|
||||||
{NULL, NoSymbol}
|
{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;
|
int i;
|
||||||
|
|
||||||
if(keyname)
|
if(keyname)
|
||||||
|
@ -123,6 +124,16 @@ key_mask_lookup(const char *keyname)
|
||||||
static unsigned int
|
static unsigned int
|
||||||
mouse_button_lookup(const char *button)
|
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;
|
int i;
|
||||||
|
|
||||||
if(button)
|
if(button)
|
||||||
|
@ -243,21 +254,16 @@ static Key *section_keys(cfg_t *cfg_keys)
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *widget_names[] = {
|
|
||||||
"focustitle",
|
|
||||||
"layoutinfo",
|
|
||||||
"taglist",
|
|
||||||
"textbox",
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
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)
|
if (((cfg_t*)a)->line < ((cfg_t*)b)->line)
|
||||||
return -1;
|
return -1;
|
||||||
else if (((cfg_t*)a)->line > ((cfg_t*)b)->line)
|
|
||||||
|
if (((cfg_t*)a)->line > ((cfg_t*)b)->line)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,6 +271,13 @@ cmp_widget_cfg(const void *a, const void *b){
|
||||||
static void
|
static void
|
||||||
create_widgets(cfg_t* cfg_statusbar, Statusbar *statusbar)
|
create_widgets(cfg_t* cfg_statusbar, Statusbar *statusbar)
|
||||||
{
|
{
|
||||||
|
static const char *widget_names[] =
|
||||||
|
{
|
||||||
|
"focustitle",
|
||||||
|
"layoutinfo",
|
||||||
|
"taglist",
|
||||||
|
"textbox",
|
||||||
|
};
|
||||||
cfg_t* widgets, *wptr;
|
cfg_t* widgets, *wptr;
|
||||||
Widget *widget = NULL;
|
Widget *widget = NULL;
|
||||||
unsigned int i, j, numnames, numwidgets = 0;
|
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
|
/** Parse configuration file and initialize some stuff
|
||||||
* \param configpatharg Path to configuration file
|
* \param configpatharg Path to configuration file
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
parse_config(const char *confpatharg)
|
config_parse(const char *confpatharg)
|
||||||
{
|
{
|
||||||
static cfg_opt_t general_opts[] =
|
static cfg_opt_t general_opts[] =
|
||||||
{
|
{
|
||||||
|
@ -692,37 +704,4 @@ parse_config(const char *confpatharg)
|
||||||
p_delete(&confpath);
|
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
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|
||||||
|
|
2
config.h
2
config.h
|
@ -267,7 +267,7 @@ struct awesome_config
|
||||||
FocusList *focus;
|
FocusList *focus;
|
||||||
};
|
};
|
||||||
|
|
||||||
void parse_config(const char *);
|
void config_parse(const char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|
||||||
|
|
14
layout.c
14
layout.c
|
@ -29,10 +29,24 @@
|
||||||
#include "xutil.h"
|
#include "xutil.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
#include "layouts/tile.h"
|
||||||
|
#include "layouts/max.h"
|
||||||
|
#include "layouts/fibonacci.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
|
|
||||||
extern awesome_config globalconf;
|
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
|
/** Find the index of the first currently selected tag
|
||||||
* \param screen the screen to search
|
* \param screen the screen to search
|
||||||
* \return tag
|
* \return tag
|
||||||
|
|
Loading…
Reference in New Issue