conf->titlebar: Add multi mouse section for titlebar
This commit is contained in:
parent
56c380ea14
commit
1effeb8368
25
src/bar.c
25
src/bar.c
@ -86,7 +86,7 @@ bar_moveresize(BarWindow *bw, int x, int y, uint w, uint h)
|
||||
bw->y = y;
|
||||
}
|
||||
|
||||
XMoveResizeWindow(dpy, bw->win, x, y, w, h);
|
||||
XMoveResizeWindow(dpy, bw->win, bw->x, bw->y, bw->w, bw->h);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -232,8 +232,9 @@ uicb_togglebarpos(uicb_t cmd)
|
||||
void
|
||||
updatetitlebar(Client *c)
|
||||
{
|
||||
|
||||
int pos_y, pos_x;
|
||||
char *tmpcolor = NULL;
|
||||
|
||||
XFetchName(dpy, c->win, &(c->title));
|
||||
if(!c->title)
|
||||
c->title = strdup("WMFS");
|
||||
@ -247,18 +248,24 @@ updatetitlebar(Client *c)
|
||||
/* Set the text alignement */
|
||||
switch(conf.titlebar.text_align)
|
||||
{
|
||||
case Center: pos_x = (c->geo.width / 2) - (textw(c->title) / 2); break;
|
||||
case Right: pos_x = c->geo.width - textw(c->title) - 2; break;
|
||||
default: case Left: pos_x = 2; break;
|
||||
case Center:
|
||||
pos_x = (c->geo.width / 2) - (textw(c->title) / 2);
|
||||
break;
|
||||
case Right:
|
||||
pos_x = c->geo.width - textw(c->title) - 2;
|
||||
break;
|
||||
default:
|
||||
case Left:
|
||||
pos_x = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set y text position (always at the middle) */
|
||||
/* Set y text position (always at the middle) and fg color */
|
||||
pos_y = (fonth - (xftfont->descent - 1)) + ((conf.titlebar.height - fonth) / 2);
|
||||
tmpcolor = ((c == sel) ? conf.titlebar.fg_focus : conf.titlebar.fg_normal);
|
||||
|
||||
/* Draw title */
|
||||
draw_text(c->tbar->dr, pos_x, pos_y,
|
||||
((c == sel) ? conf.titlebar.fg_focus : conf.titlebar.fg_normal),
|
||||
conf.titlebar.bg, 0, c->title);
|
||||
draw_text(c->tbar->dr, pos_x, pos_y, tmpcolor, conf.titlebar.bg, 0, c->title);
|
||||
|
||||
bar_refresh(c->tbar);
|
||||
}
|
||||
|
||||
19
src/client.c
19
src/client.c
@ -454,6 +454,14 @@ client_raise(Client *c)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
uicb_client_raise(uicb_t cmd)
|
||||
{
|
||||
client_raise(sel);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
client_unhide(Client *c)
|
||||
{
|
||||
@ -473,12 +481,17 @@ client_unmanage(Client *c)
|
||||
sel = ((sel == c) ? ((c->next) ? c->next : NULL) : NULL);
|
||||
selbytag[seltag] = (sel && sel->tag == seltag) ? sel : NULL;
|
||||
client_detach(c);
|
||||
if(conf.titlebar.height)
|
||||
bar_delete(c->tbar);
|
||||
|
||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||
setwinstate(c->win, WithdrawnState);
|
||||
free(c);
|
||||
|
||||
XSync(dpy, False);
|
||||
XUngrabServer(dpy);
|
||||
|
||||
if(conf.titlebar.height)
|
||||
bar_delete(c->tbar);
|
||||
free(c);
|
||||
|
||||
arrange();
|
||||
|
||||
return;
|
||||
|
||||
68
src/config.c
68
src/config.c
@ -50,7 +50,11 @@ func_name_list_t func_list[] =
|
||||
{"set_mwfact", uicb_set_mwfact },
|
||||
{"set_nmaster", uicb_set_nmaster },
|
||||
{"quit", uicb_quit },
|
||||
{"togglebarpos", uicb_togglebarpos }
|
||||
{"togglebarpos", uicb_togglebarpos },
|
||||
{"mouse_move", uicb_mousemove },
|
||||
{"mouse_resize", uicb_resizemouse },
|
||||
{"client_raise", uicb_client_raise },
|
||||
{"tile_switch", uicb_tile_switch }
|
||||
};
|
||||
|
||||
func_name_list_t layout_list[] =
|
||||
@ -176,25 +180,34 @@ init_conf(void)
|
||||
|
||||
static cfg_opt_t colors_opts[] =
|
||||
{
|
||||
CFG_STR("border_normal", "#354B5C", CFGF_NONE),
|
||||
CFG_STR("border_focus", "#6286A1", CFGF_NONE),
|
||||
CFG_STR("bar_bg", "#090909", CFGF_NONE),
|
||||
CFG_STR("bar_fg", "#6289A1", CFGF_NONE),
|
||||
CFG_STR("tag_sel_fg", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("tag_sel_bg", "#354B5C", CFGF_NONE),
|
||||
CFG_STR("tag_border", "#090909", CFGF_NONE),
|
||||
CFG_STR("layout_fg", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("layout_bg", "#292929", CFGF_NONE),
|
||||
CFG_STR("border_normal", "#354B5C", CFGF_NONE),
|
||||
CFG_STR("border_focus", "#6286A1", CFGF_NONE),
|
||||
CFG_STR("bar_bg", "#090909", CFGF_NONE),
|
||||
CFG_STR("bar_fg", "#6289A1", CFGF_NONE),
|
||||
CFG_STR("tag_sel_fg", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("tag_sel_bg", "#354B5C", CFGF_NONE),
|
||||
CFG_STR("tag_border", "#090909", CFGF_NONE),
|
||||
CFG_STR("layout_fg", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("layout_bg", "#292929", CFGF_NONE),
|
||||
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 titlebar_opts[] =
|
||||
{
|
||||
CFG_INT("height", 0, CFGF_NONE),
|
||||
CFG_STR("bg", "#090909", CFGF_NONE),
|
||||
CFG_STR("fg_focus", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("fg_normal", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("text_align", "left", CFGF_NONE),
|
||||
CFG_INT("height", 0, CFGF_NONE),
|
||||
CFG_STR("bg", "#090909", CFGF_NONE),
|
||||
CFG_STR("fg_focus", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("fg_normal", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("text_align", "left", CFGF_NONE),
|
||||
CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI)
|
||||
};
|
||||
|
||||
static cfg_opt_t layout_opts[] =
|
||||
@ -241,14 +254,6 @@ init_conf(void)
|
||||
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[] =
|
||||
{
|
||||
CFG_STR("content", "", CFGF_NONE),
|
||||
@ -374,6 +379,17 @@ init_conf(void)
|
||||
else
|
||||
conf.titlebar.text_align = Left;
|
||||
|
||||
conf.titlebar.nmouse = cfg_size(cfg_titlebar, "mouse");
|
||||
conf.titlebar.mouse = emalloc(conf.titlebar.nmouse, sizeof(MouseBinding));
|
||||
|
||||
for(i = 0; i < conf.titlebar.nmouse; ++i)
|
||||
{
|
||||
cfgtmp = cfg_getnsec(cfg_titlebar, "mouse", i);
|
||||
conf.titlebar.mouse[i].button = char_to_button(cfg_getstr(cfgtmp, "button"));
|
||||
conf.titlebar.mouse[i].func = name_to_func(cfg_getstr(cfgtmp, "func"), func_list);
|
||||
conf.titlebar.mouse[i].cmd = strdup(var_to_str(cfg_getstr(cfgtmp, "cmd")));
|
||||
}
|
||||
|
||||
/* layout */
|
||||
if((conf.nlayout = cfg_size(cfg_layouts, "layout")) > MAXLAYOUT
|
||||
|| !(conf.nlayout = cfg_size(cfg_layouts, "layout")))
|
||||
@ -477,9 +493,9 @@ init_conf(void)
|
||||
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"), func_list);
|
||||
conf.barbutton[i].cmd[j] = strdup(var_to_str(cfg_getstr(cfgtmp3, "cmd")));
|
||||
conf.barbutton[i].mouse[j] = char_to_button(cfg_getstr(cfgtmp3, "button"));
|
||||
conf.barbutton[i].mouse[j].func = name_to_func(cfg_getstr(cfgtmp3, "func"), func_list);
|
||||
conf.barbutton[i].mouse[j].cmd = strdup(var_to_str(cfg_getstr(cfgtmp3, "cmd")));
|
||||
conf.barbutton[i].mouse[j].button = char_to_button(cfg_getstr(cfgtmp3, "button"));
|
||||
}
|
||||
conf.barbutton[i].nmousesec = cfg_size(cfgtmp2, "mouse");
|
||||
conf.barbutton[i].content = strdup(var_to_str(cfg_getstr(cfgtmp2, "content")));
|
||||
|
||||
68
src/event.c
68
src/event.c
@ -43,41 +43,21 @@ buttonpress(XEvent ev)
|
||||
int i, j;
|
||||
char s[6];
|
||||
|
||||
if(conf.titlebar.height)
|
||||
/* ******** */
|
||||
/* TITLEBAR */
|
||||
/* ******** */
|
||||
{
|
||||
/* ******** */
|
||||
/* TITLEBAR */
|
||||
/* ******** */
|
||||
if(conf.titlebar.height)
|
||||
{
|
||||
if((c = client_gettbar(ev.xbutton.window)))
|
||||
{
|
||||
client_raise(c);
|
||||
/* BUTTON 1 */
|
||||
{
|
||||
if(ev.xbutton.button == Button1)
|
||||
mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, False);
|
||||
}
|
||||
/* BUTTON 2 */
|
||||
{
|
||||
if(ev.xbutton.button == Button2)
|
||||
{
|
||||
if(tags[seltag].layout.func == tile)
|
||||
uicb_tile_switch(NULL);
|
||||
else
|
||||
uicb_togglemax(NULL);
|
||||
}
|
||||
}
|
||||
/* BUTTON 3 */
|
||||
{
|
||||
if(ev.xbutton.button == Button3)
|
||||
mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, True);
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < conf.titlebar.nmouse; ++i)
|
||||
if(ev.xbutton.button == conf.titlebar.mouse[i].button)
|
||||
if(conf.titlebar.mouse[i].func)
|
||||
conf.titlebar.mouse[i].func(conf.titlebar.mouse[i].cmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* ****** */
|
||||
/* CLIENT */
|
||||
/* ****** */
|
||||
@ -210,12 +190,12 @@ buttonpress(XEvent ev)
|
||||
/* BAR BUTTONS */
|
||||
/* *********** */
|
||||
{
|
||||
for(i=0; i<conf.nbutton ; ++i)
|
||||
for(j=0; j<conf.barbutton[i].nmousesec; ++j)
|
||||
for(i = 0; i < conf.nbutton ; ++i)
|
||||
for(j = 0; j < conf.barbutton[i].nmousesec; ++j)
|
||||
if(ev.xbutton.window == conf.barbutton[i].bw->win
|
||||
&& ev.xbutton.button == conf.barbutton[i].mouse[j])
|
||||
if(conf.barbutton[i].func[j])
|
||||
conf.barbutton[i].func[j](conf.barbutton[i].cmd[j]);
|
||||
&& ev.xbutton.button == conf.barbutton[i].mouse[j].button)
|
||||
if(conf.barbutton[i].mouse[j].func)
|
||||
conf.barbutton[i].mouse[j].func(conf.barbutton[i].mouse[j].cmd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -252,7 +232,6 @@ void
|
||||
destroynotify(XEvent ev)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
if((c = client_get(ev.xdestroywindow.window)))
|
||||
client_unmanage(c);
|
||||
|
||||
@ -453,6 +432,24 @@ mouseaction(Client *c, int x, int y, int type)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
uicb_mousemove(uicb_t cmd)
|
||||
{
|
||||
|
||||
mouseaction(sel, event.xbutton.x_root, event.xbutton.y_root, False);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
uicb_resizemouse(uicb_t cmd)
|
||||
{
|
||||
mouseaction(sel, event.xbutton.x_root, event.xbutton.y_root, True);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* PROPERTYNOTIFY */
|
||||
void
|
||||
propertynotify(XEvent ev)
|
||||
@ -492,6 +489,7 @@ unmapnotify(XEvent ev)
|
||||
|
||||
if((c = client_get(ev.xunmap.window)))
|
||||
if(ev.xunmap.send_event
|
||||
&& ev.xunmap.event == RootWindow(ev.xany.display, screen)
|
||||
&& getwinstate(c->win) == NormalState)
|
||||
client_unmanage(c);
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
#include "wmfs.h"
|
||||
|
||||
#define NBUTTON 5
|
||||
#define NBUTTON 8
|
||||
#define MAXTAG 36
|
||||
#define MAXLAYOUT 3
|
||||
|
||||
@ -100,9 +100,16 @@ typedef struct
|
||||
uint mod;
|
||||
KeySym keysym;
|
||||
void (*func)(uicb_t);
|
||||
char *cmd;
|
||||
uicb_t cmd;
|
||||
} Key;
|
||||
|
||||
/* Mouse Binding Struct */
|
||||
typedef struct
|
||||
{
|
||||
uint button;
|
||||
void (*func)(uicb_t);
|
||||
uicb_t cmd;
|
||||
} MouseBinding;
|
||||
|
||||
/* Bar Button */
|
||||
typedef struct
|
||||
@ -113,9 +120,7 @@ typedef struct
|
||||
int bg_color;
|
||||
uint x;
|
||||
int nmousesec;
|
||||
void (*func[NBUTTON])(uicb_t);
|
||||
char *cmd[NBUTTON];
|
||||
uint mouse[NBUTTON];
|
||||
MouseBinding mouse[NBUTTON];
|
||||
} BarButton;
|
||||
|
||||
/* Layout Structure */
|
||||
@ -166,6 +171,8 @@ typedef struct
|
||||
char *fg_focus;
|
||||
char *fg_normal;
|
||||
int text_align;
|
||||
MouseBinding *mouse;
|
||||
int nmouse;
|
||||
} titlebar;
|
||||
Tag tag[MAXTAG];
|
||||
Layout layout[MAXLAYOUT];
|
||||
|
||||
@ -99,6 +99,7 @@ void client_raise(Client *c);
|
||||
void client_unhide(Client *c);
|
||||
void client_unmanage(Client *c);
|
||||
void client_unmap(Client *c);
|
||||
void uicb_client_raise(uicb_t cmd);
|
||||
void uicb_client_prev(uicb_t);
|
||||
void uicb_client_next(uicb_t);
|
||||
void uicb_client_kill(uicb_t);
|
||||
@ -119,6 +120,8 @@ void keypress(XEvent ev);
|
||||
void mapnotify(XEvent ev);
|
||||
void maprequest(XEvent ev);
|
||||
void mouseaction(Client *c, int x, int y, int type);
|
||||
void uicb_mousemove(uicb_t cmd);
|
||||
void uicb_resizemouse(uicb_t cmd);
|
||||
void propertynotify(XEvent ev);
|
||||
void unmapnotify(XEvent ev);
|
||||
void getevent(void);
|
||||
|
||||
6
wmfsrc
6
wmfsrc
@ -42,6 +42,12 @@ titlebar
|
||||
fg_normal = "#D4D4D4"
|
||||
fg_focus = "#D4D4D4"
|
||||
text_align = "center"
|
||||
|
||||
mouse { button = "1" func = "client_raise" }
|
||||
mouse { button = "1" func = "mouse_move" }
|
||||
mouse { button = "2" func = "tile_switch" }
|
||||
mouse { button = "3" func = "client_raise" }
|
||||
mouse { button = "3" func = "mouse_resize" }
|
||||
}
|
||||
|
||||
layouts
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user