Menu: Fix menulayout bug

This commit is contained in:
Martin Duquesnoy 2009-04-20 11:47:54 +02:00
parent 94905559de
commit 4a8db8d34b
6 changed files with 51 additions and 18 deletions

View File

@ -401,7 +401,8 @@ client_manage(Window w, XWindowAttributes *wa)
Window trans;
Status rettrans;
XSetWindowAttributes at;
int mx, my;
XClassHint xch;
int mx, my, i, j, k;
screen_get_sel();
@ -443,8 +444,8 @@ client_manage(Window w, XWindowAttributes *wa)
c->ogeo.y = c->geo.y = my;
c->ogeo.width = c->geo.width = wa->width;
c->ogeo.height = c->geo.height = wa->height;
c->tag = seltag[c->screen];
at.event_mask = PropertyChangeMask;
frame_create(c);
@ -452,12 +453,26 @@ client_manage(Window w, XWindowAttributes *wa)
XChangeWindowAttributes(dpy, c->win, CWEventMask, &at);
XSetWindowBorderWidth(dpy, c->win, 0); /* client win sould _not_ have borders */
mouse_grabbuttons(c, False);
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
for(t = clients; t && t->win != trans; t = t->next);
if(t) c->tag = t->tag;
if(!c->free) c->free = (rettrans == Success) || c->hint;
free(t);
XGetClassHint(dpy, c->win, &xch);
for(i = 0; i < screen_count(); ++i)
for(j = 1; j < conf.ntag[i] + 1; ++j)
if(tags[i][j].clients != NULL)
for(k = 0; k < tags[i][j].nclients; ++k)
if((xch.res_name && !strcmp(tags[i][j].clients[k], xch.res_name))
|| (xch.res_class && !strcmp(tags[i][j].clients[k], xch.res_class)))
{
printf("class: %s name: %s\n", xch.res_class, xch.res_name);
c->screen = i;
c->tag = j;
}
client_attach(c);
client_map(c);
client_get_name(c);

View File

@ -270,6 +270,8 @@ conf_layout_section(cfg_t *cfg_l)
conf.colors.bar,
conf.colors.text);
menulayout.special = True;
if(!conf.layout[0].symbol
&& !conf.layout[0].func)
{
@ -301,13 +303,13 @@ conf_layout_section(cfg_t *cfg_l)
void
conf_tag_section(cfg_t *cfg_t)
{
int i, j, k, l = 0;
int i, j, k, l = 0, m, n;
char *tmp;
/* If there is no tag in the conf or more than
* MAXTAG (32) print an error and create only one.
*/
Tag default_tag = { "WMFS",
Tag default_tag = { "WMFS", NULL, 0,
0.50, 1, False, IB_Top,
layout_name_to_struct(conf.layout, "tile_right", conf.nlayout, layout_list) };
@ -353,8 +355,18 @@ conf_tag_section(cfg_t *cfg_t)
else
tags[k][conf.ntag[k]].barpos = IB_Top;
tags[k][conf.ntag[k]].layout = layout_name_to_struct(conf.layout, cfg_getstr(cfgtmp, "layout"),
conf.nlayout, layout_list);
tags[k][conf.ntag[k]].layout = layout_name_to_struct(conf.layout, cfg_getstr(cfgtmp, "layout"),
conf.nlayout, layout_list);
/* Clients list */
if((n = cfg_size(cfgtmp, "clients")))
{
tags[k][conf.ntag[k]].nclients = n;
tags[k][conf.ntag[k]].clients = emalloc(n, sizeof(char *));
for(m = 0; m < n; ++m)
tags[k][conf.ntag[k]].clients[m] = _strdup(cfg_getnstr(cfgtmp, "clients", m));
}
}
l = 0;
}
@ -385,7 +397,9 @@ conf_menu_section(cfg_t *cfg_m)
conf.nmenu = cfg_size(cfg_m, "set_menu");
CHECK(conf.nmenu);
conf.menu = emalloc(conf.nmenu, sizeof(Menu));
conf.menu = emalloc(conf.nmenu + 1, sizeof(Menu));
conf.menu[conf.nmenu] = menulayout;
for(i = 0; i < conf.nmenu; ++i)
{
@ -399,10 +413,10 @@ conf_menu_section(cfg_t *cfg_m)
conf.menu[i].y = cfg_getint(cfgtmp, "y");
}
conf.menu[i].colors.focus.bg = getcolor(_strdup(cfg_getstr(cfgtmp, "bg_focus")));
conf.menu[i].colors.focus.fg = _strdup(cfg_getstr(cfgtmp, "fg_focus"));
conf.menu[i].colors.normal.bg = getcolor(_strdup(cfg_getstr(cfgtmp, "bg_normal")));
conf.menu[i].colors.normal.fg = _strdup(cfg_getstr(cfgtmp, "fg_normal"));
conf.menu[i].colors.focus.bg = getcolor(alias_to_str(_strdup(cfg_getstr(cfgtmp, "bg_focus"))));
conf.menu[i].colors.focus.fg = _strdup(alias_to_str(cfg_getstr(cfgtmp, "fg_focus")));
conf.menu[i].colors.normal.bg = getcolor(alias_to_str(_strdup(cfg_getstr(cfgtmp, "bg_normal"))));
conf.menu[i].colors.normal.fg = _strdup(alias_to_str(cfg_getstr(cfgtmp, "fg_normal")));
conf.menu[i].nitem = cfg_size(cfgtmp, "item");

View File

@ -146,6 +146,7 @@ cfg_opt_t tag_opts[] =
CFG_STR("layout", "tile_right", CFGF_NONE),
CFG_STR("infobar_position", "top", CFGF_NONE),
CFG_BOOL("resizehint", cfg_false, CFGF_NONE),
CFG_STR_LIST("clients", "{}", CFGF_NONE),
CFG_END()
};

View File

@ -114,13 +114,13 @@ buttonpress(XButtonEvent *ev)
{
if(conf.layout_system && (ev->button == Button1 || ev->button == Button3)) /* True -> menu */
{
y = spgeo[selscreen].y + infobar[selscreen].layout_button->geo.y + INFOBARH;
x = infobar[selscreen].layout_button->geo.x + (sgeo[selscreen].x - BORDH);
conf.menu[conf.nmenu].y = spgeo[selscreen].y + infobar[selscreen].layout_button->geo.y + INFOBARH;
conf.menu[conf.nmenu].x = infobar[selscreen].layout_button->geo.x + (sgeo[selscreen].x - BORDH);
if(infobar[selscreen].geo.y != spgeo[selscreen].y)
y = infobar[selscreen].geo.y - (INFOBARH * menulayout.nitem) - SHADH;
conf.menu[conf.nmenu].y = infobar[selscreen].geo.y - (INFOBARH * menulayout.nitem) - SHADH;
menu_draw(menulayout, x, y);
uicb_menu("menulayout");
}
else
{

View File

@ -234,7 +234,7 @@ uicb_menu(uicb_t cmd)
int i, d, u, x, y;
Window w;
for(i = 0; i < conf.nmenu; ++i)
for(i = 0; i < conf.nmenu + 1; ++i)
if(!strcmp(cmd, conf.menu[i].name))
{
if(conf.menu[i].place_at_mouse)
@ -242,8 +242,8 @@ uicb_menu(uicb_t cmd)
else
{
screen_get_sel();
x = sgeo[selscreen].x + conf.menu[i].x;
y = sgeo[selscreen].y + conf.menu[i].y;
x = conf.menu[i].x + ((conf.menu[i].special) ? 0 : spgeo[selscreen].x);
y = conf.menu[i].y + ((conf.menu[i].special) ? 0 : spgeo[selscreen].y);;
}
menu_draw(conf.menu[i], x, y);
}

View File

@ -200,6 +200,8 @@ typedef struct
typedef struct
{
char *name;
char **clients;
int nclients;
float mwfact;
int nmaster;
Bool resizehint;
@ -225,6 +227,7 @@ typedef struct
char *name;
/* Placement */
Bool place_at_mouse;
Bool special;
int x, y;
/* Color */
struct