cvsimport

This commit is contained in:
okan 2011-09-08 12:35:33 +00:00
commit b1d81b7eb6
11 changed files with 238 additions and 177 deletions

View File

@ -169,7 +169,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
conf_color(&Conf, sc); conf_color(&Conf, sc);
group_init(sc); group_init(sc);
font_init(sc);
conf_font(&Conf, sc); conf_font(&Conf, sc);
TAILQ_INIT(&sc->mruq); TAILQ_INIT(&sc->mruq);

View File

@ -76,8 +76,9 @@ size_t strlcat(char *, const char *, size_t);
#define CWM_EXEC_WM 0x0002 #define CWM_EXEC_WM 0x0002
/* cycle */ /* cycle */
#define CWM_CYCLE 0 #define CWM_CYCLE 0x0001
#define CWM_RCYCLE 1 #define CWM_RCYCLE 0x0002
#define CWM_INGROUP 0x0004
#define KBTOGROUP(X) ((X) - 1) #define KBTOGROUP(X) ((X) - 1)
@ -93,12 +94,13 @@ enum cwmcolor {
CWM_COLOR_BORDER_UNGROUP, CWM_COLOR_BORDER_UNGROUP,
CWM_COLOR_FG_MENU, CWM_COLOR_FG_MENU,
CWM_COLOR_BG_MENU, CWM_COLOR_BG_MENU,
CWM_COLOR_FONT,
CWM_COLOR_MAX CWM_COLOR_MAX
}; };
struct color { struct color {
unsigned long pixel;
char *name; char *name;
unsigned long pixel;
}; };
struct gap { struct gap {
@ -128,6 +130,8 @@ struct client_ctx {
int y; /* y position */ int y; /* y position */
int width; /* width */ int width; /* width */
int height;/* height */ int height;/* height */
} geom, savegeom;
struct {
int basew; /* desired width */ int basew; /* desired width */
int baseh; /* desired height */ int baseh; /* desired height */
int minw; /* minimum width */ int minw; /* minimum width */
@ -138,7 +142,7 @@ struct client_ctx {
int inch; /* height increment progression */ int inch; /* height increment progression */
float mina; /* minimum aspect ratio */ float mina; /* minimum aspect ratio */
float maxa; /* maximum aspect ratio */ float maxa; /* maximum aspect ratio */
} geom, savegeom; } hint;
struct { struct {
int x; /* x position */ int x; /* x position */
int y; /* y position */ int y; /* y position */
@ -148,10 +152,12 @@ struct client_ctx {
int xproto; int xproto;
#define CLIENT_HIDDEN 0x0001 #define CLIENT_HIDDEN 0x0001
#define CLIENT_IGNORE 0x0002 #define CLIENT_IGNORE 0x0002
#define CLIENT_MAXIMIZED 0x0004 #define CLIENT_VMAXIMIZED 0x0004
#define CLIENT_VMAXIMIZED 0x0008 #define CLIENT_HMAXIMIZED 0x0008
#define CLIENT_HMAXIMIZED 0x0010 #define CLIENT_FREEZE 0x0010
#define CLIENT_FREEZE 0x0020
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
#define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
int flags; int flags;
int state; int state;
int active; int active;
@ -284,17 +290,11 @@ struct conf {
#define CONF_SNAPDIST 0 #define CONF_SNAPDIST 0
int snapdist; int snapdist;
struct gap gap; struct gap gap;
#define CONF_COLOR_ACTIVEBORDER "#CCCCCC"
#define CONF_COLOR_INACTIVEBORDER "#666666"
#define CONF_COLOR_GROUPBORDER "blue"
#define CONF_COLOR_UNGROUPBORDER "red"
#define CONF_COLOR_MENUFG "black"
#define CONF_COLOR_MENUBG "white"
struct color color[CWM_COLOR_MAX]; struct color color[CWM_COLOR_MAX];
char termpath[MAXPATHLEN]; char termpath[MAXPATHLEN];
char lockpath[MAXPATHLEN]; char lockpath[MAXPATHLEN];
#define DEFAULTFONTNAME "sans-serif:pixelsize=14:bold" #define CONF_FONT "sans-serif:pixelsize=14:bold"
char *DefaultFontName; char *font;
}; };
/* MWM hints */ /* MWM hints */
@ -444,7 +444,7 @@ int font_descent(struct screen_ctx *);
void font_draw(struct screen_ctx *, const char *, int, void font_draw(struct screen_ctx *, const char *, int,
Drawable, int, int); Drawable, int, int);
u_int font_height(struct screen_ctx *); u_int font_height(struct screen_ctx *);
void font_init(struct screen_ctx *); void font_init(struct screen_ctx *, const char *);
int font_width(struct screen_ctx *, const char *, int); int font_width(struct screen_ctx *, const char *, int);
XftFont *font_make(struct screen_ctx *, const char *); XftFont *font_make(struct screen_ctx *, const char *);

143
client.c
View File

@ -281,13 +281,23 @@ client_maximize(struct client_ctx *cc)
if (cc->flags & CLIENT_FREEZE) if (cc->flags & CLIENT_FREEZE)
return; return;
if (cc->flags & CLIENT_MAXIMIZED) { if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) {
cc->flags &= ~CLIENT_MAXIMIZED;
cc->geom = cc->savegeom; cc->geom = cc->savegeom;
cc->bwidth = Conf.bwidth; cc->bwidth = Conf.bwidth;
cc->flags &= ~CLIENT_MAXIMIZED; goto resize;
} else { }
if (!(cc->flags & (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)))
cc->savegeom = cc->geom; if ((cc->flags & CLIENT_VMAXIMIZED) == 0) {
cc->savegeom.height = cc->geom.height;
cc->savegeom.y = cc->geom.y;
}
if ((cc->flags & CLIENT_HMAXIMIZED) == 0) {
cc->savegeom.width = cc->geom.width;
cc->savegeom.x = cc->geom.x;
}
if (HasXinerama) { if (HasXinerama) {
XineramaScreenInfo *xine; XineramaScreenInfo *xine;
/* /*
@ -312,8 +322,8 @@ calc:
cc->geom.width = xmax - (sc->gap.left + sc->gap.right); cc->geom.width = xmax - (sc->gap.left + sc->gap.right);
cc->bwidth = 0; cc->bwidth = 0;
cc->flags |= CLIENT_MAXIMIZED; cc->flags |= CLIENT_MAXIMIZED;
}
resize:
client_resize(cc); client_resize(cc);
} }
@ -330,10 +340,21 @@ client_vertmaximize(struct client_ctx *cc)
cc->geom.y = cc->savegeom.y; cc->geom.y = cc->savegeom.y;
cc->geom.height = cc->savegeom.height; cc->geom.height = cc->savegeom.height;
cc->bwidth = Conf.bwidth; cc->bwidth = Conf.bwidth;
if (cc->flags & CLIENT_HMAXIMIZED)
cc->geom.width -= cc->bwidth * 2;
cc->flags &= ~CLIENT_VMAXIMIZED; cc->flags &= ~CLIENT_VMAXIMIZED;
} else { goto resize;
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_HMAXIMIZED))) }
cc->savegeom = cc->geom;
cc->savegeom.y = cc->geom.y;
cc->savegeom.height = cc->geom.height;
/* if this will make us fully maximized then remove boundary */
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) {
cc->geom.width += Conf.bwidth * 2;
cc->bwidth = 0;
}
if (HasXinerama) { if (HasXinerama) {
XineramaScreenInfo *xine; XineramaScreenInfo *xine;
xine = screen_find_xinerama(sc, xine = screen_find_xinerama(sc,
@ -349,8 +370,8 @@ calc:
cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top + cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top +
sc->gap.bottom); sc->gap.bottom);
cc->flags |= CLIENT_VMAXIMIZED; cc->flags |= CLIENT_VMAXIMIZED;
}
resize:
client_resize(cc); client_resize(cc);
} }
@ -367,10 +388,21 @@ client_horizmaximize(struct client_ctx *cc)
cc->geom.x = cc->savegeom.x; cc->geom.x = cc->savegeom.x;
cc->geom.width = cc->savegeom.width; cc->geom.width = cc->savegeom.width;
cc->bwidth = Conf.bwidth; cc->bwidth = Conf.bwidth;
if (cc->flags & CLIENT_VMAXIMIZED)
cc->geom.height -= cc->bwidth * 2;
cc->flags &= ~CLIENT_HMAXIMIZED; cc->flags &= ~CLIENT_HMAXIMIZED;
} else { goto resize;
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED))) }
cc->savegeom = cc->geom;
cc->savegeom.x = cc->geom.x;
cc->savegeom.width = cc->geom.width;
/* if this will make us fully maximized then remove boundary */
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_VMAXIMIZED) {
cc->geom.height += cc->bwidth * 2;
cc->bwidth = 0;
}
if (HasXinerama) { if (HasXinerama) {
XineramaScreenInfo *xine; XineramaScreenInfo *xine;
xine = screen_find_xinerama(sc, xine = screen_find_xinerama(sc,
@ -386,8 +418,8 @@ calc:
cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left + cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left +
sc->gap.right); sc->gap.right);
cc->flags |= CLIENT_HMAXIMIZED; cc->flags |= CLIENT_HMAXIMIZED;
}
resize:
client_resize(cc); client_resize(cc);
} }
@ -567,7 +599,7 @@ match:
} }
void void
client_cycle(struct screen_ctx *sc, int reverse) client_cycle(struct screen_ctx *sc, int flags)
{ {
struct client_ctx *oldcc, *newcc; struct client_ctx *oldcc, *newcc;
int again = 1; int again = 1;
@ -579,18 +611,19 @@ client_cycle(struct screen_ctx *sc, int reverse)
return; return;
if (oldcc == NULL) if (oldcc == NULL)
oldcc = (reverse ? TAILQ_LAST(&sc->mruq, cycle_entry_q) : oldcc = (flags & CWM_RCYCLE ? TAILQ_LAST(&sc->mruq, cycle_entry_q) :
TAILQ_FIRST(&sc->mruq)); TAILQ_FIRST(&sc->mruq));
newcc = oldcc; newcc = oldcc;
while (again) { while (again) {
again = 0; again = 0;
newcc = (reverse ? client_mruprev(newcc) : newcc = (flags & CWM_RCYCLE ? client_mruprev(newcc) :
client_mrunext(newcc)); client_mrunext(newcc));
/* Only cycle visible and non-ignored windows. */ /* Only cycle visible and non-ignored windows. */
if (newcc->flags & (CLIENT_HIDDEN|CLIENT_IGNORE)) if ((newcc->flags & (CLIENT_HIDDEN|CLIENT_IGNORE))
|| ((flags & CWM_INGROUP) && (newcc->group != oldcc->group)))
again = 1; again = 1;
/* Is oldcc the only non-hidden window? */ /* Is oldcc the only non-hidden window? */
@ -724,36 +757,36 @@ client_getsizehints(struct client_ctx *cc)
cc->size->flags = PSize; cc->size->flags = PSize;
if (cc->size->flags & PBaseSize) { if (cc->size->flags & PBaseSize) {
cc->geom.basew = cc->size->base_width; cc->hint.basew = cc->size->base_width;
cc->geom.baseh = cc->size->base_height; cc->hint.baseh = cc->size->base_height;
} else if (cc->size->flags & PMinSize) { } else if (cc->size->flags & PMinSize) {
cc->geom.basew = cc->size->min_width; cc->hint.basew = cc->size->min_width;
cc->geom.baseh = cc->size->min_height; cc->hint.baseh = cc->size->min_height;
} }
if (cc->size->flags & PMinSize) { if (cc->size->flags & PMinSize) {
cc->geom.minw = cc->size->min_width; cc->hint.minw = cc->size->min_width;
cc->geom.minh = cc->size->min_height; cc->hint.minh = cc->size->min_height;
} else if (cc->size->flags & PBaseSize) { } else if (cc->size->flags & PBaseSize) {
cc->geom.minw = cc->size->base_width; cc->hint.minw = cc->size->base_width;
cc->geom.minh = cc->size->base_height; cc->hint.minh = cc->size->base_height;
} }
if (cc->size->flags & PMaxSize) { if (cc->size->flags & PMaxSize) {
cc->geom.maxw = cc->size->max_width; cc->hint.maxw = cc->size->max_width;
cc->geom.maxh = cc->size->max_height; cc->hint.maxh = cc->size->max_height;
} }
if (cc->size->flags & PResizeInc) { if (cc->size->flags & PResizeInc) {
cc->geom.incw = cc->size->width_inc; cc->hint.incw = cc->size->width_inc;
cc->geom.inch = cc->size->height_inc; cc->hint.inch = cc->size->height_inc;
} }
cc->geom.incw = MAX(1, cc->geom.incw); cc->hint.incw = MAX(1, cc->hint.incw);
cc->geom.inch = MAX(1, cc->geom.inch); cc->hint.inch = MAX(1, cc->hint.inch);
if (cc->size->flags & PAspect) { if (cc->size->flags & PAspect) {
if (cc->size->min_aspect.x > 0) if (cc->size->min_aspect.x > 0)
cc->geom.mina = (float)cc->size->min_aspect.y / cc->hint.mina = (float)cc->size->min_aspect.y /
cc->size->min_aspect.x; cc->size->min_aspect.x;
if (cc->size->max_aspect.y > 0) if (cc->size->max_aspect.y > 0)
cc->geom.maxa = (float)cc->size->max_aspect.x / cc->hint.maxa = (float)cc->size->max_aspect.x /
cc->size->max_aspect.y; cc->size->max_aspect.y;
} }
} }
@ -762,48 +795,48 @@ client_applysizehints(struct client_ctx *cc)
{ {
Bool baseismin; Bool baseismin;
baseismin = (cc->geom.basew == cc->geom.minw) && baseismin = (cc->hint.basew == cc->hint.minw) &&
(cc->geom.baseh == cc->geom.minh); (cc->hint.baseh == cc->hint.minh);
/* temporarily remove base dimensions, ICCCM 4.1.2.3 */ /* temporarily remove base dimensions, ICCCM 4.1.2.3 */
if (!baseismin) { if (!baseismin) {
cc->geom.width -= cc->geom.basew; cc->geom.width -= cc->hint.basew;
cc->geom.height -= cc->geom.baseh; cc->geom.height -= cc->hint.baseh;
} }
/* adjust for aspect limits */ /* adjust for aspect limits */
if (cc->geom.mina > 0 && cc->geom.maxa > 0) { if (cc->hint.mina > 0 && cc->hint.maxa > 0) {
if (cc->geom.maxa < if (cc->hint.maxa <
(float)cc->geom.width / cc->geom.height) (float)cc->geom.width / cc->geom.height)
cc->geom.width = cc->geom.height * cc->geom.maxa; cc->geom.width = cc->geom.height * cc->hint.maxa;
else if (cc->geom.mina < else if (cc->hint.mina <
(float)cc->geom.height / cc->geom.width) (float)cc->geom.height / cc->geom.width)
cc->geom.height = cc->geom.width * cc->geom.mina; cc->geom.height = cc->geom.width * cc->hint.mina;
} }
/* remove base dimensions for increment */ /* remove base dimensions for increment */
if (baseismin) { if (baseismin) {
cc->geom.width -= cc->geom.basew; cc->geom.width -= cc->hint.basew;
cc->geom.height -= cc->geom.baseh; cc->geom.height -= cc->hint.baseh;
} }
/* adjust for increment value */ /* adjust for increment value */
cc->geom.width -= cc->geom.width % cc->geom.incw; cc->geom.width -= cc->geom.width % cc->hint.incw;
cc->geom.height -= cc->geom.height % cc->geom.inch; cc->geom.height -= cc->geom.height % cc->hint.inch;
/* restore base dimensions */ /* restore base dimensions */
cc->geom.width += cc->geom.basew; cc->geom.width += cc->hint.basew;
cc->geom.height += cc->geom.baseh; cc->geom.height += cc->hint.baseh;
/* adjust for min width/height */ /* adjust for min width/height */
cc->geom.width = MAX(cc->geom.width, cc->geom.minw); cc->geom.width = MAX(cc->geom.width, cc->hint.minw);
cc->geom.height = MAX(cc->geom.height, cc->geom.minh); cc->geom.height = MAX(cc->geom.height, cc->hint.minh);
/* adjust for max width/height */ /* adjust for max width/height */
if (cc->geom.maxw) if (cc->hint.maxw)
cc->geom.width = MIN(cc->geom.width, cc->geom.maxw); cc->geom.width = MIN(cc->geom.width, cc->hint.maxw);
if (cc->geom.maxh) if (cc->hint.maxh)
cc->geom.height = MIN(cc->geom.height, cc->geom.maxh); cc->geom.height = MIN(cc->geom.height, cc->hint.maxh);
} }
static void static void

65
conf.c
View File

@ -31,13 +31,6 @@
#include "calmwm.h" #include "calmwm.h"
#ifndef timespeccmp
#define timespeccmp(tsp, usp, cmp) \
(((tsp)->tv_sec == (usp)->tv_sec) ? \
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
((tsp)->tv_sec cmp (usp)->tv_sec))
#endif
static void conf_mouseunbind(struct conf *, struct mousebinding *); static void conf_mouseunbind(struct conf *, struct mousebinding *);
static void conf_unbind(struct conf *, struct keybinding *); static void conf_unbind(struct conf *, struct keybinding *);
@ -69,9 +62,20 @@ conf_gap(struct conf *c, struct screen_ctx *sc)
void void
conf_font(struct conf *c, struct screen_ctx *sc) conf_font(struct conf *c, struct screen_ctx *sc)
{ {
sc->font = font_make(sc, c->DefaultFontName); font_init(sc, c->color[CWM_COLOR_FONT].name);
sc->font = font_make(sc, c->font);
} }
static struct color color_binds[] = {
{ "#CCCCCC", 0 }, /* CWM_COLOR_BORDOR_ACTIVE */
{ "#666666", 0 }, /* CWM_COLOR_BORDOR_INACTIVE */
{ "blue", 0 }, /* CWM_COLOR_BORDOR_GROUP */
{ "red", 0 }, /* CWM_COLOR_BORDOR_UNGROUP */
{ "black", 0 }, /* CWM_COLOR_FG_MENU */
{ "white", 0 }, /* CWM_COLOR_BG_MENU */
{ "black", 0 }, /* CWM_COLOR_FONT */
};
void void
conf_color(struct conf *c, struct screen_ctx *sc) conf_color(struct conf *c, struct screen_ctx *sc)
{ {
@ -98,6 +102,7 @@ conf_reload(struct conf *c)
conf_gap(c, sc); conf_gap(c, sc);
conf_color(c, sc); conf_color(c, sc);
conf_font(c, sc); conf_font(c, sc);
menu_init(sc);
} }
TAILQ_FOREACH(cc, &Clientq, entry) TAILQ_FOREACH(cc, &Clientq, entry)
client_draw_border(cc); client_draw_border(cc);
@ -198,24 +203,14 @@ conf_init(struct conf *c)
for (i = 0; i < nitems(m_binds); i++) for (i = 0; i < nitems(m_binds); i++)
conf_mousebind(c, m_binds[i].key, m_binds[i].func); conf_mousebind(c, m_binds[i].key, m_binds[i].func);
for (i = 0; i < nitems(color_binds); i++)
c->color[i].name = xstrdup(color_binds[i].name);
/* Default term/lock */ /* Default term/lock */
(void)strlcpy(c->termpath, "xterm", sizeof(c->termpath)); (void)strlcpy(c->termpath, "xterm", sizeof(c->termpath));
(void)strlcpy(c->lockpath, "xlock", sizeof(c->lockpath)); (void)strlcpy(c->lockpath, "xlock", sizeof(c->lockpath));
c->color[CWM_COLOR_BORDER_ACTIVE].name = c->font = xstrdup(CONF_FONT);
xstrdup(CONF_COLOR_ACTIVEBORDER);
c->color[CWM_COLOR_BORDER_INACTIVE].name =
xstrdup(CONF_COLOR_INACTIVEBORDER);
c->color[CWM_COLOR_BORDER_GROUP].name =
xstrdup(CONF_COLOR_GROUPBORDER);
c->color[CWM_COLOR_BORDER_UNGROUP].name =
xstrdup(CONF_COLOR_UNGROUPBORDER);
c->color[CWM_COLOR_FG_MENU].name =
xstrdup(CONF_COLOR_MENUFG);
c->color[CWM_COLOR_BG_MENU].name =
xstrdup(CONF_COLOR_MENUBG);
c->DefaultFontName = xstrdup(DEFAULTFONTNAME);
} }
void void
@ -259,32 +254,38 @@ conf_clear(struct conf *c)
for (i = 0; i < CWM_COLOR_MAX; i++) for (i = 0; i < CWM_COLOR_MAX; i++)
xfree(c->color[i].name); xfree(c->color[i].name);
xfree(c->DefaultFontName); xfree(c->font);
} }
void void
conf_setup(struct conf *c, const char *conf_file) conf_setup(struct conf *c, const char *conf_file)
{ {
char *home;
struct stat sb; struct stat sb;
int parse = 0;
conf_init(c);
if (conf_file == NULL) { if (conf_file == NULL) {
char *home = getenv("HOME"); if ((home = getenv("HOME")) == NULL)
if (home == NULL)
errx(1, "No HOME directory."); errx(1, "No HOME directory.");
(void)snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s", (void)snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s",
home, CONFFILE); home, CONFFILE);
} else
if (stat(c->conf_path, &sb) == 0 && (sb.st_mode & S_IFREG))
parse = 1;
} else {
if (stat(conf_file, &sb) == -1 || !(sb.st_mode & S_IFREG)) if (stat(conf_file, &sb) == -1 || !(sb.st_mode & S_IFREG))
errx(1, "%s: %s", conf_file, strerror(errno)); errx(1, "%s: %s", conf_file, strerror(errno));
else else {
(void)strlcpy(c->conf_path, conf_file, (void)strlcpy(c->conf_path, conf_file,
sizeof(c->conf_path)); sizeof(c->conf_path));
parse = 1;
}
}
conf_init(c); if (parse && (parse_config(c->conf_path, c) == -1))
if (parse_config(c->conf_path, c) == -1)
warnx("config file %s has errors, not loading", c->conf_path); warnx("config file %s has errors, not loading", c->conf_path);
} }
@ -360,6 +361,8 @@ static struct {
{ "nogroup", kbfunc_client_nogroup, 0, {0} }, { "nogroup", kbfunc_client_nogroup, 0, {0} },
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} }, { "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} }, { "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
{ "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_CYCLE|CWM_INGROUP} },
{ "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_RCYCLE|CWM_INGROUP} },
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}}, { "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}},
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} }, { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} },
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} }, { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },

15
cwmrc.5
View File

@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: June 24 2011 $ .Dd $Mdocdate: September 8 2011 $
.Dt CWMRC 5 .Dt CWMRC 5
.Os .Os
.Sh NAME .Sh NAME
@ -99,12 +99,21 @@ Set the window border width to
.It Ic color activeborder Ar color .It Ic color activeborder Ar color
Set the color of the active border. Set the color of the active border.
.Pp .Pp
.It Ic color font Ar color
Set menu font color.
.Pp
.It Ic color groupborder Ar color .It Ic color groupborder Ar color
Set the color of the border while grouping a window. Set the color of the border while grouping a window.
.Pp .Pp
.It Ic color inactiveborder Ar color .It Ic color inactiveborder Ar color
Set the color of the inactive border. Set the color of the inactive border.
.Pp .Pp
.It Ic color menubg Ar color
Set menu background color.
.Pp
.It Ic color menufg Ar color
Set menu foreground color.
.Pp
.It Ic color ungroupborder Ar color .It Ic color ungroupborder Ar color
Set the color of the border while ungrouping a window. Set the color of the border while ungrouping a window.
.Pp .Pp
@ -289,6 +298,10 @@ Reverse cycle through groups.
Forward cycle through windows. Forward cycle through windows.
.It rcycle .It rcycle
Reverse cycle through windows. Reverse cycle through windows.
.It cycleingroup
Forward cycle through windows in current group.
.It rcycleingroup
Reverse cycle through windows in current group.
.It snapdist .It snapdist
Minimum distance to snap-to adjacent edge. Minimum distance to snap-to adjacent edge.
.It delete .It delete

9
font.c
View File

@ -49,15 +49,20 @@ font_height(struct screen_ctx *sc)
} }
void void
font_init(struct screen_ctx *sc) font_init(struct screen_ctx *sc, const char *color)
{ {
if (sc->xftdraw)
XftDrawDestroy(sc->xftdraw);
sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin, sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin,
DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which)); DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which));
if (sc->xftdraw == NULL) if (sc->xftdraw == NULL)
errx(1, "XftDrawCreate"); errx(1, "XftDrawCreate");
if (sc->xftcolor.pixel)
XftColorFree(X_Dpy, DefaultVisual(X_Dpy, sc->which),
DefaultColormap(X_Dpy, sc->which), &sc->xftcolor);
if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which), if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which),
DefaultColormap(X_Dpy, sc->which), "black", &sc->xftcolor)) DefaultColormap(X_Dpy, sc->which), color, &sc->xftcolor))
errx(1, "XftColorAllocName"); errx(1, "XftColorAllocName");
} }

View File

@ -130,13 +130,8 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
client_ptrwarp(cc); client_ptrwarp(cc);
break; break;
case CWM_PTRMOVE: case CWM_PTRMOVE:
if (cc) {
xu_ptr_getpos(cc->win, &x, &y);
xu_ptr_setpos(cc->win, x + mx, y + my);
} else {
xu_ptr_getpos(sc->rootwin, &x, &y); xu_ptr_getpos(sc->rootwin, &x, &y);
xu_ptr_setpos(sc->rootwin, x + mx, y + my); xu_ptr_setpos(sc->rootwin, x + mx, y + my);
}
break; break;
default: default:
warnx("invalid flags passed to kbfunc_client_moveresize"); warnx("invalid flags passed to kbfunc_client_moveresize");

4
menu.c
View File

@ -76,6 +76,8 @@ menu_init(struct screen_ctx *sc)
{ {
XGCValues gv; XGCValues gv;
if (sc->menuwin)
XDestroyWindow(X_Dpy, sc->menuwin);
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1,
Conf.bwidth, Conf.bwidth,
sc->color[CWM_COLOR_FG_MENU].pixel, sc->color[CWM_COLOR_FG_MENU].pixel,
@ -86,6 +88,8 @@ menu_init(struct screen_ctx *sc)
gv.background = sc->color[CWM_COLOR_BG_MENU].pixel; gv.background = sc->color[CWM_COLOR_BG_MENU].pixel;
gv.function = GXxor; gv.function = GXxor;
if (sc->gc)
XFreeGC(X_Dpy, sc->gc);
sc->gc = XCreateGC(X_Dpy, sc->menuwin, sc->gc = XCreateGC(X_Dpy, sc->menuwin,
GCForeground|GCBackground|GCFunction, &gv); GCForeground|GCBackground|GCFunction, &gv);
} }

View File

@ -58,8 +58,8 @@ mousefunc_sweep_draw(struct client_ctx *cc)
int width, width_size, width_name; int width, width_size, width_name;
(void)snprintf(asize, sizeof(asize), "%dx%d", (void)snprintf(asize, sizeof(asize), "%dx%d",
(cc->geom.width - cc->geom.basew) / cc->geom.incw, (cc->geom.width - cc->hint.basew) / cc->hint.incw,
(cc->geom.height - cc->geom.baseh) / cc->geom.inch); (cc->geom.height - cc->hint.baseh) / cc->hint.inch);
width_size = font_width(sc, asize, strlen(asize)) + 4; width_size = font_width(sc, asize, strlen(asize)) + 4;
width_name = font_width(sc, cc->name, strlen(cc->name)) + 4; width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
width = MAX(width_size, width_name); width = MAX(width_size, width_name);

24
parse.y
View File

@ -73,6 +73,7 @@ typedef struct {
%token COLOR SNAPDIST %token COLOR SNAPDIST
%token ACTIVEBORDER INACTIVEBORDER %token ACTIVEBORDER INACTIVEBORDER
%token GROUPBORDER UNGROUPBORDER %token GROUPBORDER UNGROUPBORDER
%token MENUBG MENUFG FONTCOLOR
%token ERROR %token ERROR
%token <v.string> STRING %token <v.string> STRING
%token <v.number> NUMBER %token <v.number> NUMBER
@ -105,8 +106,8 @@ yesno : YES { $$ = 1; }
; ;
main : FONTNAME STRING { main : FONTNAME STRING {
free(conf->DefaultFontName); free(conf->font);
conf->DefaultFontName = $2; conf->font = $2;
} }
| STICKY yesno { | STICKY yesno {
if ($2 == 0) if ($2 == 0)
@ -184,6 +185,18 @@ colors : ACTIVEBORDER STRING {
free(conf->color[CWM_COLOR_BORDER_UNGROUP].name); free(conf->color[CWM_COLOR_BORDER_UNGROUP].name);
conf->color[CWM_COLOR_BORDER_UNGROUP].name = $2; conf->color[CWM_COLOR_BORDER_UNGROUP].name = $2;
} }
| MENUBG STRING {
free(conf->color[CWM_COLOR_BG_MENU].name);
conf->color[CWM_COLOR_BG_MENU].name = $2;
}
| MENUFG STRING {
free(conf->color[CWM_COLOR_FG_MENU].name);
conf->color[CWM_COLOR_FG_MENU].name = $2;
}
| FONTCOLOR STRING {
free(conf->color[CWM_COLOR_FONT].name);
conf->color[CWM_COLOR_FONT].name = $2;
}
; ;
%% %%
@ -223,11 +236,14 @@ lookup(char *s)
{ "borderwidth", BORDERWIDTH}, { "borderwidth", BORDERWIDTH},
{ "color", COLOR}, { "color", COLOR},
{ "command", COMMAND}, { "command", COMMAND},
{ "font", FONTCOLOR},
{ "fontname", FONTNAME}, { "fontname", FONTNAME},
{ "gap", GAP}, { "gap", GAP},
{ "groupborder", GROUPBORDER}, { "groupborder", GROUPBORDER},
{ "ignore", IGNORE}, { "ignore", IGNORE},
{ "inactiveborder", INACTIVEBORDER}, { "inactiveborder", INACTIVEBORDER},
{ "menubg", MENUBG},
{ "menufg", MENUFG},
{ "mousebind", MOUSEBIND}, { "mousebind", MOUSEBIND},
{ "moveamount", MOVEAMOUNT}, { "moveamount", MOVEAMOUNT},
{ "no", NO}, { "no", NO},
@ -462,8 +478,6 @@ pushfile(const char *name)
nfile->name = xstrdup(name); nfile->name = xstrdup(name);
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) { if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
if (errno != ENOENT)
warn("%s", nfile->name);
free(nfile->name); free(nfile->name);
free(nfile); free(nfile);
return (NULL); return (NULL);
@ -563,7 +577,7 @@ parse_config(const char *filename, struct conf *xconf)
for (i = 0; i < CWM_COLOR_MAX; i++) for (i = 0; i < CWM_COLOR_MAX; i++)
xconf->color[i].name = conf->color[i].name; xconf->color[i].name = conf->color[i].name;
xconf->DefaultFontName = conf->DefaultFontName; xconf->font = conf->font;
} }
free(conf); free(conf);

View File

@ -77,7 +77,6 @@ xev_handle_maprequest(XEvent *ee)
XMapRequestEvent *e = &ee->xmaprequest; XMapRequestEvent *e = &ee->xmaprequest;
struct client_ctx *cc = NULL, *old_cc; struct client_ctx *cc = NULL, *old_cc;
XWindowAttributes xattr; XWindowAttributes xattr;
struct winmatch *wm;
if ((old_cc = client_current()) != NULL) if ((old_cc = client_current()) != NULL)
client_ptrsave(old_cc); client_ptrsave(old_cc);
@ -87,10 +86,6 @@ xev_handle_maprequest(XEvent *ee)
cc = client_new(e->window, screen_fromroot(xattr.root), 1); cc = client_new(e->window, screen_fromroot(xattr.root), 1);
} }
TAILQ_FOREACH(wm, &Conf.ignoreq, entry) {
if (strncasecmp(wm->title, cc->name, strlen(wm->title)) == 0)
return;
}
if ((cc->flags & CLIENT_IGNORE) == 0) if ((cc->flags & CLIENT_IGNORE) == 0)
client_ptrwarp(cc); client_ptrwarp(cc);
} }