[ALL] Improve layout system, fix some stuffs..
This commit is contained in:
parent
4c7af5e0e8
commit
91af47a8ff
33
config.c
33
config.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* config.c
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.con>
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -88,7 +88,7 @@ name_to_func(char *name)
|
||||
int i;
|
||||
|
||||
if(name)
|
||||
for(i=0; func_list[i].name ; ++i)
|
||||
for(i = 0; func_list[i].name ; ++i)
|
||||
if(!strcmp(name, func_list[i].name))
|
||||
return func_list[i].func;
|
||||
return NULL;
|
||||
@ -100,7 +100,7 @@ char_to_modkey(char *name)
|
||||
int i;
|
||||
|
||||
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))
|
||||
return key_list[i].keysym;
|
||||
return NoSymbol;
|
||||
@ -112,22 +112,27 @@ char_to_button(char *name)
|
||||
int i;
|
||||
|
||||
if(name)
|
||||
for(i=0; mouse_button_list[i].name; ++i)
|
||||
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*
|
||||
layout_name_to_layout(char *name)
|
||||
Layout
|
||||
layout_name_to_struct(Layout lt[], char *name)
|
||||
{
|
||||
int i;
|
||||
void *f;
|
||||
|
||||
if(name)
|
||||
for(i=0; layout_list[i].name; ++i)
|
||||
if(!strcmp(name, layout_list[i].name))
|
||||
return layout_list[i].func;
|
||||
return 0;
|
||||
f = layout_list[i].func;
|
||||
if(f)
|
||||
for(i = 0; i < NLAYOUT; ++i)
|
||||
if(lt[i].func == f)
|
||||
return lt[i];
|
||||
return lt[Tile];
|
||||
}
|
||||
|
||||
void
|
||||
@ -284,9 +289,13 @@ init_conf(void)
|
||||
conf.colors.layout_bg = cfg_getint(cfg_colors, "layout_bg");
|
||||
|
||||
/* layout */
|
||||
conf.layouts.free = strdup(cfg_getstr(cfg_layouts, "free"));
|
||||
conf.layouts.tile = strdup(cfg_getstr(cfg_layouts, "tile"));
|
||||
conf.layouts.max = strdup(cfg_getstr(cfg_layouts, "max"));
|
||||
/* lyt is the base structure for all layouts */
|
||||
lyt[Tile].symbol = strdup(cfg_getstr(cfg_layouts, "tile"));
|
||||
lyt[Tile].func = tile;
|
||||
lyt[Max].symbol = strdup(cfg_getstr(cfg_layouts, "max"));
|
||||
lyt[Max].func = maxlayout;
|
||||
lyt[Free].symbol = strdup(cfg_getstr(cfg_layouts, "free"));
|
||||
lyt[Free].func = freelayout;
|
||||
|
||||
/* tag */
|
||||
conf.ntag = cfg_size(cfg_tags, "tag");
|
||||
@ -296,7 +305,7 @@ init_conf(void)
|
||||
conf.tag[i].name = strdup(cfg_getstr(cfgtmp, "name"));
|
||||
conf.tag[i].mwfact = cfg_getfloat(cfgtmp, "mwfact");
|
||||
conf.tag[i].nmaster = cfg_getint(cfgtmp, "nmaster");
|
||||
conf.tag[i].layout.func = layout_name_to_layout(cfg_getstr(cfgtmp, "layout"));
|
||||
conf.tag[i].layout = layout_name_to_struct(lyt, cfg_getstr(cfgtmp, "layout"));
|
||||
}
|
||||
|
||||
/* keybind ('tention ça rigole plus) */
|
||||
|
||||
6
event.c
6
event.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* event.c
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.con>
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -81,7 +81,7 @@ buttonpress(XEvent ev)
|
||||
for(i = 0; i < conf.ntag + 1; ++i)
|
||||
{
|
||||
if(ev.xbutton.x > taglen[i-1] - 3
|
||||
&& ev.xbutton.x < taglen[i])
|
||||
&& ev.xbutton.x < (taglen[i] - 3))
|
||||
{
|
||||
ITOA(s, i);
|
||||
if(ev.xbutton.button == Button1)
|
||||
@ -101,7 +101,7 @@ buttonpress(XEvent ev)
|
||||
/* layout switch */
|
||||
if(ev.xbutton.x >= taglen[conf.ntag] - 3
|
||||
&& ev.xbutton.x < taglen[conf.ntag] +
|
||||
TEXTW(getlayoutsym(seltag)) - 3)
|
||||
TEXTW(tags[seltag].layout.symbol) - 3)
|
||||
{
|
||||
if(ev.xbutton.button == Button1
|
||||
|| ev.xbutton.button == Button4)
|
||||
|
||||
5
util.c
5
util.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* util.c
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.con>
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -58,8 +58,7 @@ spawn(char *cmd)
|
||||
execl(getenv("SHELL"), getenv("SHELL"), "-c", cmd, (char*)NULL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
exit(EXIT_SUCCESS);}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
67
wmfs.c
67
wmfs.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* wmfs.c
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.con>
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -77,13 +77,10 @@ clientpertag(int tag)
|
||||
void
|
||||
detach(Client *c)
|
||||
{
|
||||
if(c->prev)
|
||||
c->prev->next = c->next;
|
||||
if(c->next)
|
||||
c->next->prev = c->prev;
|
||||
if(c == clients)
|
||||
clients = c->next;
|
||||
c->next = c->prev = NULL;
|
||||
Client **cc;
|
||||
|
||||
for(cc = &clients; *cc && *cc != c; cc = &(*cc)->next);
|
||||
*cc = c->next;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -187,20 +184,6 @@ getnext(Client *c)
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Will be replace */
|
||||
char*
|
||||
getlayoutsym(int tag)
|
||||
{
|
||||
if(tags[tag].layout.func == freelayout)
|
||||
return conf.layouts.free;
|
||||
else if(tags[tag].layout.func == tile)
|
||||
return conf.layouts.tile;
|
||||
else if(tags[tag].layout.func == maxlayout)
|
||||
return conf.layouts.max;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Client*
|
||||
gettbar(Window w)
|
||||
{
|
||||
@ -467,27 +450,21 @@ killclient(char *cmd)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Will be improve... */
|
||||
void
|
||||
layoutswitch(char *cmd)
|
||||
{
|
||||
if(cmd[0] == '+')
|
||||
int i;
|
||||
|
||||
for(i = 0; i < NLAYOUT; ++i)
|
||||
{
|
||||
if(tags[seltag].layout.func == freelayout)
|
||||
tags[seltag].layout.func = tile;
|
||||
else if(tags[seltag].layout.func == tile)
|
||||
tags[seltag].layout.func = maxlayout;
|
||||
else if(tags[seltag].layout.func == maxlayout)
|
||||
tags[seltag].layout.func = freelayout;
|
||||
}
|
||||
else if(cmd[0] == '-')
|
||||
{
|
||||
if(tags[seltag].layout.func == freelayout)
|
||||
tags[seltag].layout.func = maxlayout;
|
||||
else if(tags[seltag].layout.func == tile)
|
||||
tags[seltag].layout.func = freelayout;
|
||||
else if(tags[seltag].layout.func == maxlayout)
|
||||
tags[seltag].layout.func = tile;
|
||||
if(!memcmp(&tags[seltag].layout, &lyt[i], sizeof(Layout)))
|
||||
{
|
||||
if(cmd[0] == '+')
|
||||
tags[seltag].layout = lyt[((i + 1 < NLAYOUT) ? i + 1 : 0)];
|
||||
else if(cmd[0] == '-')
|
||||
tags[seltag].layout = lyt[((i - 1 > -1) ? i - 1 : NLAYOUT-1)];
|
||||
break;
|
||||
}
|
||||
}
|
||||
arrange();
|
||||
|
||||
@ -945,7 +922,7 @@ setsizehints(Client *c)
|
||||
}
|
||||
else
|
||||
c->incw = c->inch = 0;
|
||||
/* nax */
|
||||
/* max */
|
||||
if(size.flags & PMaxSize)
|
||||
{
|
||||
c->maxw = size.max_width;
|
||||
@ -1250,12 +1227,14 @@ updatebar(void)
|
||||
|
||||
/* Draw layout symbol */
|
||||
XSetForeground(dpy, gc, conf.colors.layout_bg);
|
||||
XFillRectangle(dpy, dr, gc, taglen[conf.ntag] - 5, 0, TEXTW(getlayoutsym(seltag)), barheight);
|
||||
XFillRectangle(dpy, dr, gc, taglen[conf.ntag] - 5, 0,
|
||||
TEXTW(strdup(tags[seltag].layout.symbol)),
|
||||
barheight);
|
||||
XSetForeground(dpy, gc, conf.colors.layout_fg);
|
||||
XDrawString(dpy, dr, gc, taglen[conf.ntag] - 4,
|
||||
fonth,
|
||||
getlayoutsym(seltag),
|
||||
strlen(getlayoutsym(seltag)));
|
||||
tags[seltag].layout.symbol,
|
||||
strlen(tags[seltag].layout.symbol));
|
||||
|
||||
/* Draw status */
|
||||
k = TEXTW(bartext);
|
||||
@ -1287,7 +1266,7 @@ updatebutton(Bool c)
|
||||
at.background_pixmap = ParentRelative;
|
||||
at.event_mask = ButtonPressMask | ExposureMask;
|
||||
|
||||
j = taglen[conf.ntag] + TEXTW(getlayoutsym(seltag));
|
||||
j = taglen[conf.ntag] + TEXTW(tags[seltag].layout.symbol);
|
||||
|
||||
if(!conf.bartop)
|
||||
y = bary + 3;
|
||||
|
||||
12
wmfs.h
12
wmfs.h
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* wmfs.h
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.con>
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -152,12 +152,6 @@ typedef struct
|
||||
int layout_fg;
|
||||
int layout_bg;
|
||||
} colors;
|
||||
struct
|
||||
{
|
||||
char *free;
|
||||
char *tile;
|
||||
char *max;
|
||||
} layouts;
|
||||
Tag tag[MAXTAG];
|
||||
BarButton barbutton[64];
|
||||
int ntag;
|
||||
@ -189,6 +183,7 @@ typedef struct
|
||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||
enum { WMState, WMProtocols, WMName, WMDelete, WMLast };
|
||||
enum { NetSupported, NetWMName, NetLast };
|
||||
enum { Tile = 0, Max = 1, Free = 2};
|
||||
|
||||
/* Functions Prototypes */
|
||||
|
||||
@ -225,7 +220,6 @@ void freelayout(void);
|
||||
Client* getbutton(Window w);
|
||||
Client* getclient(Window w);
|
||||
Client* getnext(Client *c);
|
||||
char* getlayoutsym(int tag);
|
||||
Client* gettbar(Window w);
|
||||
void grabbuttons(Client *c, Bool focused);
|
||||
void grabkeys(void);
|
||||
@ -300,6 +294,7 @@ int seltag;
|
||||
int taglen[MAXTAG];
|
||||
Drawable dr;
|
||||
int bary;
|
||||
Layout lyt[NLAYOUT];
|
||||
|
||||
/* Important Client */
|
||||
Client *clients;
|
||||
@ -310,3 +305,4 @@ unsigned int numlockmask;
|
||||
fd_set fd;
|
||||
|
||||
#endif /* LOCAL_H */
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user