[ALL] New system for bar button (better), Fix some stuff, typo...
This commit is contained in:
62
config.c
62
config.c
@@ -6,11 +6,6 @@
|
|||||||
|
|
||||||
#define FILE_NAME ".wmfsrc"
|
#define FILE_NAME ".wmfsrc"
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char *name;
|
|
||||||
KeySym keysym;
|
|
||||||
} key_name_list_t;
|
|
||||||
|
|
||||||
func_name_list_t func_list[] = {
|
func_name_list_t func_list[] = {
|
||||||
{"spawn", spawn},
|
{"spawn", spawn},
|
||||||
{"killclient", killclient},
|
{"killclient", killclient},
|
||||||
@@ -38,6 +33,14 @@ key_name_list_t key_list[] = {
|
|||||||
{NULL, NoSymbol}
|
{NULL, NoSymbol}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mouse_button_list_t mouse_button_list[] = {
|
||||||
|
{"Button1", Button1},
|
||||||
|
{"Button2", Button2},
|
||||||
|
{"Button3", Button3},
|
||||||
|
{"Button4", Button4},
|
||||||
|
{"Button5", Button5}
|
||||||
|
};
|
||||||
|
|
||||||
void*
|
void*
|
||||||
name_to_func(char *name) {
|
name_to_func(char *name) {
|
||||||
int i;
|
int i;
|
||||||
@@ -54,11 +57,21 @@ char_to_modkey(char *name) {
|
|||||||
int i;
|
int i;
|
||||||
if(name)
|
if(name)
|
||||||
for(i=0; key_list[i].name; ++i)
|
for(i=0; key_list[i].name; ++i)
|
||||||
if(!strcmp(name,key_list[i].name))
|
if(!strcmp(name, key_list[i].name))
|
||||||
return key_list[i].keysym;
|
return key_list[i].keysym;
|
||||||
return NoSymbol;
|
return NoSymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
char_to_button(char *name) {
|
||||||
|
int i;
|
||||||
|
if(name)
|
||||||
|
for(i=0; mouse_button_list[i].name; ++i)
|
||||||
|
if(!strcmp(name, mouse_button_list[i].name))
|
||||||
|
return mouse_button_list[i].button;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init_conf(void) {
|
init_conf(void) {
|
||||||
|
|
||||||
@@ -103,7 +116,7 @@ init_conf(void) {
|
|||||||
CFG_STR_LIST("mod","{Control}", CFGF_NONE),
|
CFG_STR_LIST("mod","{Control}", CFGF_NONE),
|
||||||
CFG_STR("key", "None", CFGF_NONE),
|
CFG_STR("key", "None", CFGF_NONE),
|
||||||
CFG_STR("func", "", CFGF_NONE),
|
CFG_STR("func", "", CFGF_NONE),
|
||||||
CFG_STR("cmd", NULL, CFGF_NONE),
|
CFG_STR("cmd", "", CFGF_NONE),
|
||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,11 +126,18 @@ init_conf(void) {
|
|||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static cfg_opt_t mouse_button_opts[] = {
|
||||||
|
|
||||||
|
CFG_STR("button", "Button1", CFGF_NONE),
|
||||||
|
CFG_STR("func", "", CFGF_NONE),
|
||||||
|
CFG_STR("cmd", "", CFGF_NONE),
|
||||||
|
CFG_END()
|
||||||
|
};
|
||||||
|
|
||||||
static cfg_opt_t button_opts[] = {
|
static cfg_opt_t button_opts[] = {
|
||||||
|
|
||||||
CFG_STR("text", "", CFGF_NONE),
|
CFG_STR("text", "", CFGF_NONE),
|
||||||
CFG_STR("func", "", CFGF_NONE),
|
CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI),
|
||||||
CFG_STR("cmd", "", CFGF_NONE),
|
|
||||||
CFG_INT("fg_color", 0x000000, CFGF_NONE),
|
CFG_INT("fg_color", 0x000000, CFGF_NONE),
|
||||||
CFG_INT("bg_color", 0xFFFFFF, CFGF_NONE),
|
CFG_INT("bg_color", 0xFFFFFF, CFGF_NONE),
|
||||||
CFG_END()
|
CFG_END()
|
||||||
@@ -147,7 +167,7 @@ init_conf(void) {
|
|||||||
cfg_t *cfg_tag;
|
cfg_t *cfg_tag;
|
||||||
cfg_t *cfg_keys;
|
cfg_t *cfg_keys;
|
||||||
cfg_t *cfg_buttons;
|
cfg_t *cfg_buttons;
|
||||||
cfg_t *cfgtmp, *cfgtmp2;
|
cfg_t *cfgtmp, *cfgtmp2, *cfgtmp3;
|
||||||
char final_path[100];
|
char final_path[100];
|
||||||
int ret, i, j, l;
|
int ret, i, j, l;
|
||||||
|
|
||||||
@@ -190,9 +210,9 @@ init_conf(void) {
|
|||||||
conf.colors.tagselbg = cfg_getint(cfg_colors, "tag_sel_bg");
|
conf.colors.tagselbg = cfg_getint(cfg_colors, "tag_sel_bg");
|
||||||
|
|
||||||
/* layout */
|
/* layout */
|
||||||
conf.layouts.free = strdup(cfg_getstr(cfg_layout,"free"));
|
conf.layouts.free = strdup(cfg_getstr(cfg_layout, "free"));
|
||||||
conf.layouts.tile = strdup(cfg_getstr(cfg_layout,"tile"));
|
conf.layouts.tile = strdup(cfg_getstr(cfg_layout, "tile"));
|
||||||
conf.layouts.max = strdup(cfg_getstr(cfg_layout,"max"));
|
conf.layouts.max = strdup(cfg_getstr(cfg_layout, "max"));
|
||||||
|
|
||||||
/* tag */
|
/* tag */
|
||||||
conf.ntag = cfg_size(cfg_tag, "tag");
|
conf.ntag = cfg_size(cfg_tag, "tag");
|
||||||
@@ -210,19 +230,27 @@ init_conf(void) {
|
|||||||
keys[j].keysym = XStringToKeysym(cfg_getstr(cfgtmp, "key"));
|
keys[j].keysym = XStringToKeysym(cfg_getstr(cfgtmp, "key"));
|
||||||
keys[j].func = name_to_func(cfg_getstr(cfgtmp, "func"));
|
keys[j].func = name_to_func(cfg_getstr(cfgtmp, "func"));
|
||||||
if(!keys[j].func) {
|
if(!keys[j].func) {
|
||||||
printf("WMFS Configuration: Unknow Function %s",cfg_getstr(cfgtmp,"func"));
|
printf("WMFS Configuration: Unknow Function %s",cfg_getstr(cfgtmp, "func"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
keys[j].cmd = strdup(strdup(cfg_getstr(cfgtmp, "cmd")));
|
if(!strdup(strdup(cfg_getstr(cfgtmp, "cmd"))))
|
||||||
|
keys[j].cmd = NULL;
|
||||||
|
else
|
||||||
|
keys[j].cmd = strdup(strdup(cfg_getstr(cfgtmp, "cmd")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button */
|
/* button */
|
||||||
conf.nbutton = cfg_size(cfg_buttons, "button");
|
conf.nbutton = cfg_size(cfg_buttons, "button");
|
||||||
for(i = 0; i < conf.nbutton; ++i) {
|
for(i = 0; i < conf.nbutton; ++i) {
|
||||||
cfgtmp2 = cfg_getnsec(cfg_buttons, "button", i);
|
cfgtmp2 = cfg_getnsec(cfg_buttons, "button", i);
|
||||||
|
for(j = 0; j < cfg_size(cfgtmp2, "mouse"); ++j) {
|
||||||
|
cfgtmp3 = cfg_getnsec(cfgtmp2, "mouse", j);
|
||||||
|
conf.barbutton[i].func[j] = name_to_func(cfg_getstr(cfgtmp3, "func"));
|
||||||
|
conf.barbutton[i].cmd[j] = strdup(cfg_getstr(cfgtmp3, "cmd"));
|
||||||
|
conf.barbutton[i].mouse[j] = char_to_button(cfg_getstr(cfgtmp3, "button"));
|
||||||
|
}
|
||||||
|
conf.barbutton[i].nmousesec = cfg_size(cfgtmp2, "mouse");
|
||||||
conf.barbutton[i].text = strdup(cfg_getstr(cfgtmp2, "text"));
|
conf.barbutton[i].text = strdup(cfg_getstr(cfgtmp2, "text"));
|
||||||
conf.barbutton[i].func = name_to_func(cfg_getstr(cfgtmp2, "func"));
|
|
||||||
conf.barbutton[i].cmd = strdup(cfg_getstr(cfgtmp2, "cmd"));
|
|
||||||
conf.barbutton[i].fg_color = cfg_getint(cfgtmp2, "fg_color");
|
conf.barbutton[i].fg_color = cfg_getint(cfgtmp2, "fg_color");
|
||||||
conf.barbutton[i].bg_color = cfg_getint(cfgtmp2, "bg_color");
|
conf.barbutton[i].bg_color = cfg_getint(cfgtmp2, "bg_color");
|
||||||
}
|
}
|
||||||
|
|||||||
10
local.h
10
local.h
@@ -7,11 +7,8 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <confuse.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
@@ -72,12 +69,13 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
char *text;
|
char *text;
|
||||||
Window win;
|
Window win;
|
||||||
void (*func)(char *cmd);
|
void (*func[5])(char *cmd);
|
||||||
char *cmd;
|
char *cmd[5];
|
||||||
int fg_color;
|
int fg_color;
|
||||||
int bg_color;
|
int bg_color;
|
||||||
unsigned int x;
|
unsigned int x;
|
||||||
unsigned int button;
|
unsigned int mouse[5];
|
||||||
|
int nmousesec;
|
||||||
} BarButton;
|
} BarButton;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
34
wmfs.c
34
wmfs.c
@@ -41,7 +41,7 @@ attach(Client *c) {
|
|||||||
void
|
void
|
||||||
buttonpress(XEvent *event) {
|
buttonpress(XEvent *event) {
|
||||||
Client *c;
|
Client *c;
|
||||||
int i;
|
int i, j;
|
||||||
char s[6];
|
char s[6];
|
||||||
XButtonPressedEvent *ev = &event->xbutton;
|
XButtonPressedEvent *ev = &event->xbutton;
|
||||||
|
|
||||||
@@ -110,10 +110,12 @@ buttonpress(XEvent *event) {
|
|||||||
|
|
||||||
/* Bar Button */
|
/* Bar Button */
|
||||||
for(i=0; i<conf.nbutton ; ++i) {
|
for(i=0; i<conf.nbutton ; ++i) {
|
||||||
if(ev->window == conf.barbutton[i].win
|
for(j=0; j<conf.barbutton[i].nmousesec; ++j) {
|
||||||
&& ev->button == Button1) {
|
if(ev->window == conf.barbutton[i].win
|
||||||
if(conf.barbutton[i].func)
|
&& ev->button == conf.barbutton[i].mouse[j]) {
|
||||||
conf.barbutton[i].func(conf.barbutton[i].cmd);
|
if(conf.barbutton[i].func[j])
|
||||||
|
conf.barbutton[i].func[j](conf.barbutton[i].cmd[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -535,7 +537,11 @@ ishide(Client *c) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
keymovex(char *cmd) {
|
keymovex(char *cmd) {
|
||||||
if(sel && cmd && !ishide(sel) && !sel->max) {
|
if(sel
|
||||||
|
&& cmd
|
||||||
|
&& !ishide(sel)
|
||||||
|
&& !sel->max)
|
||||||
|
{
|
||||||
if((layout[seltag] == Tile && !sel->hint) || layout[seltag] == Max)
|
if((layout[seltag] == Tile && !sel->hint) || layout[seltag] == Max)
|
||||||
return;
|
return;
|
||||||
int tmp;
|
int tmp;
|
||||||
@@ -547,7 +553,11 @@ keymovex(char *cmd) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
keymovey(char *cmd) {
|
keymovey(char *cmd) {
|
||||||
if(sel && cmd && !ishide(sel) && !sel->max) {
|
if(sel
|
||||||
|
&& cmd
|
||||||
|
&& !ishide(sel)
|
||||||
|
&& !sel->max)
|
||||||
|
{
|
||||||
if((layout[seltag] == Tile && !sel->hint) || layout[seltag] == Max)
|
if((layout[seltag] == Tile && !sel->hint) || layout[seltag] == Max)
|
||||||
return;
|
return;
|
||||||
int tmp;
|
int tmp;
|
||||||
@@ -578,7 +588,11 @@ keypress(XEvent *e) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
keyresize(char *cmd) {
|
keyresize(char *cmd) {
|
||||||
if(sel && !ishide(sel) && !sel->max && layout[seltag] != Tile && layout[seltag] != Max) {
|
if(sel && !ishide(sel)
|
||||||
|
&& !sel->max
|
||||||
|
&& layout[seltag] != Tile
|
||||||
|
&& layout[seltag] != Max)
|
||||||
|
{
|
||||||
int temph = 0, tempw = 0, modh = 0, modw = 0, tmp = 0;
|
int temph = 0, tempw = 0, modh = 0, modw = 0, tmp = 0;
|
||||||
|
|
||||||
switch(cmd[1]) {
|
switch(cmd[1]) {
|
||||||
@@ -667,7 +681,7 @@ manage(Window w, XWindowAttributes *wa) {
|
|||||||
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
|
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
|
||||||
for(t = clients; t && t->win != trans; t = t->next);
|
for(t = clients; t && t->win != trans; t = t->next);
|
||||||
|
|
||||||
c->tbar = XCreateSimpleWindow(dpy,root,
|
c->tbar = XCreateSimpleWindow(dpy, root,
|
||||||
c->x,
|
c->x,
|
||||||
c->y - conf.ttbarheight,
|
c->y - conf.ttbarheight,
|
||||||
c->w,
|
c->w,
|
||||||
@@ -677,7 +691,7 @@ manage(Window w, XWindowAttributes *wa) {
|
|||||||
conf.colors.bar);
|
conf.colors.bar);
|
||||||
XSelectInput(dpy, c->tbar, ExposureMask | EnterWindowMask);
|
XSelectInput(dpy, c->tbar, ExposureMask | EnterWindowMask);
|
||||||
|
|
||||||
c->button = XCreateSimpleWindow(dpy,root,
|
c->button = XCreateSimpleWindow(dpy, root,
|
||||||
c->x + c->w - 10,
|
c->x + c->w - 10,
|
||||||
BUTY(c->y),
|
BUTY(c->y),
|
||||||
5,
|
5,
|
||||||
|
|||||||
18
wmfsrc
18
wmfsrc
@@ -22,9 +22,9 @@ colors
|
|||||||
|
|
||||||
layout
|
layout
|
||||||
{
|
{
|
||||||
free = "[Free]"
|
free = "[Free]"
|
||||||
tile = "[Tile]"
|
tile = "[Tile]"
|
||||||
max = "[Max]"
|
max = "[Max]"
|
||||||
}
|
}
|
||||||
|
|
||||||
tag
|
tag
|
||||||
@@ -34,7 +34,13 @@ tag
|
|||||||
|
|
||||||
buttons
|
buttons
|
||||||
{
|
{
|
||||||
button { text = "Terminal" func = "spawn" cmd = "urxvt" fg_color = 0xFFFFFF bg_color = 0x3E3E3E }
|
button
|
||||||
|
{
|
||||||
|
text = "Terminal"
|
||||||
|
mouse { button = "Button1" func = "spawn" cmd = "urxvt" }
|
||||||
|
mouse { button = "Button3" func = "spawn" cmd = "xterm" }
|
||||||
|
fg_color = 0xFFFFFF bg_color = 0x3E3E3E
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keys
|
keys
|
||||||
@@ -42,8 +48,8 @@ keys
|
|||||||
# general keybind
|
# general keybind
|
||||||
|
|
||||||
key { mod = {"Control"} key = "Return" func = "spawn" cmd = "urxvt" }
|
key { mod = {"Control"} key = "Return" func = "spawn" cmd = "urxvt" }
|
||||||
key { mod = {"Alt"} key = "q" func = "killclient" cmd = NULL }
|
key { mod = {"Alt"} key = "q" func = "killclient" }
|
||||||
key { mod = {"Control"} key = "m" func = "togglemax" cmd = NULL }
|
key { mod = {"Control"} key = "m" func = "togglemax" }
|
||||||
key { mod = {"Alt"} key = "Tab" func = "wswitch" cmd = "+" }
|
key { mod = {"Alt"} key = "Tab" func = "wswitch" cmd = "+" }
|
||||||
key { mod = {"Alt","Shift"} key = "Tab" func = "wswitch" cmd = "-" }
|
key { mod = {"Alt","Shift"} key = "Tab" func = "wswitch" cmd = "-" }
|
||||||
key { mod = {"Control"} key = "Right" func = "tagswitch" cmd = "+1" }
|
key { mod = {"Control"} key = "Right" func = "tagswitch" cmd = "+1" }
|
||||||
|
|||||||
Reference in New Issue
Block a user