mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
cvsimport
This commit is contained in:
commit
b1d81b7eb6
1
calmwm.c
1
calmwm.c
@ -169,7 +169,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
conf_color(&Conf, sc);
|
||||
|
||||
group_init(sc);
|
||||
font_init(sc);
|
||||
conf_font(&Conf, sc);
|
||||
|
||||
TAILQ_INIT(&sc->mruq);
|
||||
|
34
calmwm.h
34
calmwm.h
@ -76,8 +76,9 @@ size_t strlcat(char *, const char *, size_t);
|
||||
#define CWM_EXEC_WM 0x0002
|
||||
|
||||
/* cycle */
|
||||
#define CWM_CYCLE 0
|
||||
#define CWM_RCYCLE 1
|
||||
#define CWM_CYCLE 0x0001
|
||||
#define CWM_RCYCLE 0x0002
|
||||
#define CWM_INGROUP 0x0004
|
||||
|
||||
#define KBTOGROUP(X) ((X) - 1)
|
||||
|
||||
@ -93,12 +94,13 @@ enum cwmcolor {
|
||||
CWM_COLOR_BORDER_UNGROUP,
|
||||
CWM_COLOR_FG_MENU,
|
||||
CWM_COLOR_BG_MENU,
|
||||
CWM_COLOR_FONT,
|
||||
CWM_COLOR_MAX
|
||||
};
|
||||
|
||||
struct color {
|
||||
unsigned long pixel;
|
||||
char *name;
|
||||
unsigned long pixel;
|
||||
};
|
||||
|
||||
struct gap {
|
||||
@ -128,6 +130,8 @@ struct client_ctx {
|
||||
int y; /* y position */
|
||||
int width; /* width */
|
||||
int height;/* height */
|
||||
} geom, savegeom;
|
||||
struct {
|
||||
int basew; /* desired width */
|
||||
int baseh; /* desired height */
|
||||
int minw; /* minimum width */
|
||||
@ -138,7 +142,7 @@ struct client_ctx {
|
||||
int inch; /* height increment progression */
|
||||
float mina; /* minimum aspect ratio */
|
||||
float maxa; /* maximum aspect ratio */
|
||||
} geom, savegeom;
|
||||
} hint;
|
||||
struct {
|
||||
int x; /* x position */
|
||||
int y; /* y position */
|
||||
@ -148,10 +152,12 @@ struct client_ctx {
|
||||
int xproto;
|
||||
#define CLIENT_HIDDEN 0x0001
|
||||
#define CLIENT_IGNORE 0x0002
|
||||
#define CLIENT_MAXIMIZED 0x0004
|
||||
#define CLIENT_VMAXIMIZED 0x0008
|
||||
#define CLIENT_HMAXIMIZED 0x0010
|
||||
#define CLIENT_FREEZE 0x0020
|
||||
#define CLIENT_VMAXIMIZED 0x0004
|
||||
#define CLIENT_HMAXIMIZED 0x0008
|
||||
#define CLIENT_FREEZE 0x0010
|
||||
|
||||
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
|
||||
#define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
|
||||
int flags;
|
||||
int state;
|
||||
int active;
|
||||
@ -284,17 +290,11 @@ struct conf {
|
||||
#define CONF_SNAPDIST 0
|
||||
int snapdist;
|
||||
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];
|
||||
char termpath[MAXPATHLEN];
|
||||
char lockpath[MAXPATHLEN];
|
||||
#define DEFAULTFONTNAME "sans-serif:pixelsize=14:bold"
|
||||
char *DefaultFontName;
|
||||
#define CONF_FONT "sans-serif:pixelsize=14:bold"
|
||||
char *font;
|
||||
};
|
||||
|
||||
/* MWM hints */
|
||||
@ -444,7 +444,7 @@ int font_descent(struct screen_ctx *);
|
||||
void font_draw(struct screen_ctx *, const char *, int,
|
||||
Drawable, int, int);
|
||||
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);
|
||||
XftFont *font_make(struct screen_ctx *, const char *);
|
||||
|
||||
|
245
client.c
245
client.c
@ -281,39 +281,49 @@ client_maximize(struct client_ctx *cc)
|
||||
if (cc->flags & CLIENT_FREEZE)
|
||||
return;
|
||||
|
||||
if (cc->flags & CLIENT_MAXIMIZED) {
|
||||
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) {
|
||||
cc->flags &= ~CLIENT_MAXIMIZED;
|
||||
cc->geom = cc->savegeom;
|
||||
cc->bwidth = Conf.bwidth;
|
||||
cc->flags &= ~CLIENT_MAXIMIZED;
|
||||
} else {
|
||||
if (!(cc->flags & (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)))
|
||||
cc->savegeom = cc->geom;
|
||||
if (HasXinerama) {
|
||||
XineramaScreenInfo *xine;
|
||||
/*
|
||||
* pick screen that the middle of the window is on.
|
||||
* that's probably more fair than if just the origin of
|
||||
* a window is poking over a boundary
|
||||
*/
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
x_org = xine->x_org;
|
||||
y_org = xine->y_org;
|
||||
xmax = xine->width;
|
||||
ymax = xine->height;
|
||||
}
|
||||
calc:
|
||||
cc->geom.x = x_org + sc->gap.left;
|
||||
cc->geom.y = y_org + sc->gap.top;
|
||||
cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom);
|
||||
cc->geom.width = xmax - (sc->gap.left + sc->gap.right);
|
||||
cc->bwidth = 0;
|
||||
cc->flags |= CLIENT_MAXIMIZED;
|
||||
goto resize;
|
||||
}
|
||||
|
||||
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) {
|
||||
XineramaScreenInfo *xine;
|
||||
/*
|
||||
* pick screen that the middle of the window is on.
|
||||
* that's probably more fair than if just the origin of
|
||||
* a window is poking over a boundary
|
||||
*/
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
x_org = xine->x_org;
|
||||
y_org = xine->y_org;
|
||||
xmax = xine->width;
|
||||
ymax = xine->height;
|
||||
}
|
||||
calc:
|
||||
cc->geom.x = x_org + sc->gap.left;
|
||||
cc->geom.y = y_org + sc->gap.top;
|
||||
cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom);
|
||||
cc->geom.width = xmax - (sc->gap.left + sc->gap.right);
|
||||
cc->bwidth = 0;
|
||||
cc->flags |= CLIENT_MAXIMIZED;
|
||||
|
||||
resize:
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
@ -330,27 +340,38 @@ client_vertmaximize(struct client_ctx *cc)
|
||||
cc->geom.y = cc->savegeom.y;
|
||||
cc->geom.height = cc->savegeom.height;
|
||||
cc->bwidth = Conf.bwidth;
|
||||
if (cc->flags & CLIENT_HMAXIMIZED)
|
||||
cc->geom.width -= cc->bwidth * 2;
|
||||
cc->flags &= ~CLIENT_VMAXIMIZED;
|
||||
} else {
|
||||
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_HMAXIMIZED)))
|
||||
cc->savegeom = cc->geom;
|
||||
if (HasXinerama) {
|
||||
XineramaScreenInfo *xine;
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
y_org = xine->y_org;
|
||||
ymax = xine->height;
|
||||
}
|
||||
calc:
|
||||
cc->geom.y = y_org + sc->gap.top;
|
||||
cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top +
|
||||
sc->gap.bottom);
|
||||
cc->flags |= CLIENT_VMAXIMIZED;
|
||||
goto resize;
|
||||
}
|
||||
|
||||
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) {
|
||||
XineramaScreenInfo *xine;
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
y_org = xine->y_org;
|
||||
ymax = xine->height;
|
||||
}
|
||||
calc:
|
||||
cc->geom.y = y_org + sc->gap.top;
|
||||
cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top +
|
||||
sc->gap.bottom);
|
||||
cc->flags |= CLIENT_VMAXIMIZED;
|
||||
|
||||
resize:
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
@ -367,27 +388,38 @@ client_horizmaximize(struct client_ctx *cc)
|
||||
cc->geom.x = cc->savegeom.x;
|
||||
cc->geom.width = cc->savegeom.width;
|
||||
cc->bwidth = Conf.bwidth;
|
||||
if (cc->flags & CLIENT_VMAXIMIZED)
|
||||
cc->geom.height -= cc->bwidth * 2;
|
||||
cc->flags &= ~CLIENT_HMAXIMIZED;
|
||||
} else {
|
||||
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED)))
|
||||
cc->savegeom = cc->geom;
|
||||
if (HasXinerama) {
|
||||
XineramaScreenInfo *xine;
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
x_org = xine->x_org;
|
||||
xmax = xine->width;
|
||||
}
|
||||
calc:
|
||||
cc->geom.x = x_org + sc->gap.left;
|
||||
cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left +
|
||||
sc->gap.right);
|
||||
cc->flags |= CLIENT_HMAXIMIZED;
|
||||
goto resize;
|
||||
}
|
||||
|
||||
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) {
|
||||
XineramaScreenInfo *xine;
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
x_org = xine->x_org;
|
||||
xmax = xine->width;
|
||||
}
|
||||
calc:
|
||||
cc->geom.x = x_org + sc->gap.left;
|
||||
cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left +
|
||||
sc->gap.right);
|
||||
cc->flags |= CLIENT_HMAXIMIZED;
|
||||
|
||||
resize:
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
@ -567,7 +599,7 @@ match:
|
||||
}
|
||||
|
||||
void
|
||||
client_cycle(struct screen_ctx *sc, int reverse)
|
||||
client_cycle(struct screen_ctx *sc, int flags)
|
||||
{
|
||||
struct client_ctx *oldcc, *newcc;
|
||||
int again = 1;
|
||||
@ -579,18 +611,19 @@ client_cycle(struct screen_ctx *sc, int reverse)
|
||||
return;
|
||||
|
||||
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));
|
||||
|
||||
newcc = oldcc;
|
||||
while (again) {
|
||||
again = 0;
|
||||
|
||||
newcc = (reverse ? client_mruprev(newcc) :
|
||||
newcc = (flags & CWM_RCYCLE ? client_mruprev(newcc) :
|
||||
client_mrunext(newcc));
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Is oldcc the only non-hidden window? */
|
||||
@ -724,36 +757,36 @@ client_getsizehints(struct client_ctx *cc)
|
||||
cc->size->flags = PSize;
|
||||
|
||||
if (cc->size->flags & PBaseSize) {
|
||||
cc->geom.basew = cc->size->base_width;
|
||||
cc->geom.baseh = cc->size->base_height;
|
||||
cc->hint.basew = cc->size->base_width;
|
||||
cc->hint.baseh = cc->size->base_height;
|
||||
} else if (cc->size->flags & PMinSize) {
|
||||
cc->geom.basew = cc->size->min_width;
|
||||
cc->geom.baseh = cc->size->min_height;
|
||||
cc->hint.basew = cc->size->min_width;
|
||||
cc->hint.baseh = cc->size->min_height;
|
||||
}
|
||||
if (cc->size->flags & PMinSize) {
|
||||
cc->geom.minw = cc->size->min_width;
|
||||
cc->geom.minh = cc->size->min_height;
|
||||
cc->hint.minw = cc->size->min_width;
|
||||
cc->hint.minh = cc->size->min_height;
|
||||
} else if (cc->size->flags & PBaseSize) {
|
||||
cc->geom.minw = cc->size->base_width;
|
||||
cc->geom.minh = cc->size->base_height;
|
||||
cc->hint.minw = cc->size->base_width;
|
||||
cc->hint.minh = cc->size->base_height;
|
||||
}
|
||||
if (cc->size->flags & PMaxSize) {
|
||||
cc->geom.maxw = cc->size->max_width;
|
||||
cc->geom.maxh = cc->size->max_height;
|
||||
cc->hint.maxw = cc->size->max_width;
|
||||
cc->hint.maxh = cc->size->max_height;
|
||||
}
|
||||
if (cc->size->flags & PResizeInc) {
|
||||
cc->geom.incw = cc->size->width_inc;
|
||||
cc->geom.inch = cc->size->height_inc;
|
||||
cc->hint.incw = cc->size->width_inc;
|
||||
cc->hint.inch = cc->size->height_inc;
|
||||
}
|
||||
cc->geom.incw = MAX(1, cc->geom.incw);
|
||||
cc->geom.inch = MAX(1, cc->geom.inch);
|
||||
cc->hint.incw = MAX(1, cc->hint.incw);
|
||||
cc->hint.inch = MAX(1, cc->hint.inch);
|
||||
|
||||
if (cc->size->flags & PAspect) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -762,48 +795,48 @@ client_applysizehints(struct client_ctx *cc)
|
||||
{
|
||||
Bool baseismin;
|
||||
|
||||
baseismin = (cc->geom.basew == cc->geom.minw) &&
|
||||
(cc->geom.baseh == cc->geom.minh);
|
||||
baseismin = (cc->hint.basew == cc->hint.minw) &&
|
||||
(cc->hint.baseh == cc->hint.minh);
|
||||
|
||||
/* temporarily remove base dimensions, ICCCM 4.1.2.3 */
|
||||
if (!baseismin) {
|
||||
cc->geom.width -= cc->geom.basew;
|
||||
cc->geom.height -= cc->geom.baseh;
|
||||
cc->geom.width -= cc->hint.basew;
|
||||
cc->geom.height -= cc->hint.baseh;
|
||||
}
|
||||
|
||||
/* adjust for aspect limits */
|
||||
if (cc->geom.mina > 0 && cc->geom.maxa > 0) {
|
||||
if (cc->geom.maxa <
|
||||
if (cc->hint.mina > 0 && cc->hint.maxa > 0) {
|
||||
if (cc->hint.maxa <
|
||||
(float)cc->geom.width / cc->geom.height)
|
||||
cc->geom.width = cc->geom.height * cc->geom.maxa;
|
||||
else if (cc->geom.mina <
|
||||
cc->geom.width = cc->geom.height * cc->hint.maxa;
|
||||
else if (cc->hint.mina <
|
||||
(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 */
|
||||
if (baseismin) {
|
||||
cc->geom.width -= cc->geom.basew;
|
||||
cc->geom.height -= cc->geom.baseh;
|
||||
cc->geom.width -= cc->hint.basew;
|
||||
cc->geom.height -= cc->hint.baseh;
|
||||
}
|
||||
|
||||
/* adjust for increment value */
|
||||
cc->geom.width -= cc->geom.width % cc->geom.incw;
|
||||
cc->geom.height -= cc->geom.height % cc->geom.inch;
|
||||
cc->geom.width -= cc->geom.width % cc->hint.incw;
|
||||
cc->geom.height -= cc->geom.height % cc->hint.inch;
|
||||
|
||||
/* restore base dimensions */
|
||||
cc->geom.width += cc->geom.basew;
|
||||
cc->geom.height += cc->geom.baseh;
|
||||
cc->geom.width += cc->hint.basew;
|
||||
cc->geom.height += cc->hint.baseh;
|
||||
|
||||
/* adjust for min width/height */
|
||||
cc->geom.width = MAX(cc->geom.width, cc->geom.minw);
|
||||
cc->geom.height = MAX(cc->geom.height, cc->geom.minh);
|
||||
cc->geom.width = MAX(cc->geom.width, cc->hint.minw);
|
||||
cc->geom.height = MAX(cc->geom.height, cc->hint.minh);
|
||||
|
||||
/* adjust for max width/height */
|
||||
if (cc->geom.maxw)
|
||||
cc->geom.width = MIN(cc->geom.width, cc->geom.maxw);
|
||||
if (cc->geom.maxh)
|
||||
cc->geom.height = MIN(cc->geom.height, cc->geom.maxh);
|
||||
if (cc->hint.maxw)
|
||||
cc->geom.width = MIN(cc->geom.width, cc->hint.maxw);
|
||||
if (cc->hint.maxh)
|
||||
cc->geom.height = MIN(cc->geom.height, cc->hint.maxh);
|
||||
}
|
||||
|
||||
static void
|
||||
|
65
conf.c
65
conf.c
@ -31,13 +31,6 @@
|
||||
|
||||
#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_unbind(struct conf *, struct keybinding *);
|
||||
|
||||
@ -69,9 +62,20 @@ conf_gap(struct conf *c, struct screen_ctx *sc)
|
||||
void
|
||||
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
|
||||
conf_color(struct conf *c, struct screen_ctx *sc)
|
||||
{
|
||||
@ -98,6 +102,7 @@ conf_reload(struct conf *c)
|
||||
conf_gap(c, sc);
|
||||
conf_color(c, sc);
|
||||
conf_font(c, sc);
|
||||
menu_init(sc);
|
||||
}
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
client_draw_border(cc);
|
||||
@ -198,24 +203,14 @@ conf_init(struct conf *c)
|
||||
for (i = 0; i < nitems(m_binds); i++)
|
||||
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 */
|
||||
(void)strlcpy(c->termpath, "xterm", sizeof(c->termpath));
|
||||
(void)strlcpy(c->lockpath, "xlock", sizeof(c->lockpath));
|
||||
|
||||
c->color[CWM_COLOR_BORDER_ACTIVE].name =
|
||||
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);
|
||||
c->font = xstrdup(CONF_FONT);
|
||||
}
|
||||
|
||||
void
|
||||
@ -259,32 +254,38 @@ conf_clear(struct conf *c)
|
||||
for (i = 0; i < CWM_COLOR_MAX; i++)
|
||||
xfree(c->color[i].name);
|
||||
|
||||
xfree(c->DefaultFontName);
|
||||
xfree(c->font);
|
||||
}
|
||||
|
||||
void
|
||||
conf_setup(struct conf *c, const char *conf_file)
|
||||
{
|
||||
char *home;
|
||||
struct stat sb;
|
||||
int parse = 0;
|
||||
|
||||
conf_init(c);
|
||||
|
||||
if (conf_file == NULL) {
|
||||
char *home = getenv("HOME");
|
||||
|
||||
if (home == NULL)
|
||||
if ((home = getenv("HOME")) == NULL)
|
||||
errx(1, "No HOME directory.");
|
||||
|
||||
(void)snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s",
|
||||
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))
|
||||
errx(1, "%s: %s", conf_file, strerror(errno));
|
||||
else
|
||||
else {
|
||||
(void)strlcpy(c->conf_path, conf_file,
|
||||
sizeof(c->conf_path));
|
||||
parse = 1;
|
||||
}
|
||||
}
|
||||
|
||||
conf_init(c);
|
||||
|
||||
if (parse_config(c->conf_path, c) == -1)
|
||||
if (parse && (parse_config(c->conf_path, c) == -1))
|
||||
warnx("config file %s has errors, not loading", c->conf_path);
|
||||
}
|
||||
|
||||
@ -360,6 +361,8 @@ static struct {
|
||||
{ "nogroup", kbfunc_client_nogroup, 0, {0} },
|
||||
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
|
||||
{ "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}},
|
||||
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} },
|
||||
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },
|
||||
|
15
cwmrc.5
15
cwmrc.5
@ -14,7 +14,7 @@
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.Dd $Mdocdate: June 24 2011 $
|
||||
.Dd $Mdocdate: September 8 2011 $
|
||||
.Dt CWMRC 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -99,12 +99,21 @@ Set the window border width to
|
||||
.It Ic color activeborder Ar color
|
||||
Set the color of the active border.
|
||||
.Pp
|
||||
.It Ic color font Ar color
|
||||
Set menu font color.
|
||||
.Pp
|
||||
.It Ic color groupborder Ar color
|
||||
Set the color of the border while grouping a window.
|
||||
.Pp
|
||||
.It Ic color inactiveborder Ar color
|
||||
Set the color of the inactive border.
|
||||
.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
|
||||
Set the color of the border while ungrouping a window.
|
||||
.Pp
|
||||
@ -289,6 +298,10 @@ Reverse cycle through groups.
|
||||
Forward cycle through windows.
|
||||
.It rcycle
|
||||
Reverse cycle through windows.
|
||||
.It cycleingroup
|
||||
Forward cycle through windows in current group.
|
||||
.It rcycleingroup
|
||||
Reverse cycle through windows in current group.
|
||||
.It snapdist
|
||||
Minimum distance to snap-to adjacent edge.
|
||||
.It delete
|
||||
|
9
font.c
9
font.c
@ -49,15 +49,20 @@ font_height(struct screen_ctx *sc)
|
||||
}
|
||||
|
||||
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,
|
||||
DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which));
|
||||
if (sc->xftdraw == NULL)
|
||||
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),
|
||||
DefaultColormap(X_Dpy, sc->which), "black", &sc->xftcolor))
|
||||
DefaultColormap(X_Dpy, sc->which), color, &sc->xftcolor))
|
||||
errx(1, "XftColorAllocName");
|
||||
}
|
||||
|
||||
|
9
kbfunc.c
9
kbfunc.c
@ -130,13 +130,8 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||
client_ptrwarp(cc);
|
||||
break;
|
||||
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_setpos(sc->rootwin, x + mx, y + my);
|
||||
}
|
||||
xu_ptr_getpos(sc->rootwin, &x, &y);
|
||||
xu_ptr_setpos(sc->rootwin, x + mx, y + my);
|
||||
break;
|
||||
default:
|
||||
warnx("invalid flags passed to kbfunc_client_moveresize");
|
||||
|
4
menu.c
4
menu.c
@ -76,6 +76,8 @@ menu_init(struct screen_ctx *sc)
|
||||
{
|
||||
XGCValues gv;
|
||||
|
||||
if (sc->menuwin)
|
||||
XDestroyWindow(X_Dpy, sc->menuwin);
|
||||
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1,
|
||||
Conf.bwidth,
|
||||
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.function = GXxor;
|
||||
|
||||
if (sc->gc)
|
||||
XFreeGC(X_Dpy, sc->gc);
|
||||
sc->gc = XCreateGC(X_Dpy, sc->menuwin,
|
||||
GCForeground|GCBackground|GCFunction, &gv);
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ mousefunc_sweep_draw(struct client_ctx *cc)
|
||||
int width, width_size, width_name;
|
||||
|
||||
(void)snprintf(asize, sizeof(asize), "%dx%d",
|
||||
(cc->geom.width - cc->geom.basew) / cc->geom.incw,
|
||||
(cc->geom.height - cc->geom.baseh) / cc->geom.inch);
|
||||
(cc->geom.width - cc->hint.basew) / cc->hint.incw,
|
||||
(cc->geom.height - cc->hint.baseh) / cc->hint.inch);
|
||||
width_size = font_width(sc, asize, strlen(asize)) + 4;
|
||||
width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
|
||||
width = MAX(width_size, width_name);
|
||||
|
24
parse.y
24
parse.y
@ -73,6 +73,7 @@ typedef struct {
|
||||
%token COLOR SNAPDIST
|
||||
%token ACTIVEBORDER INACTIVEBORDER
|
||||
%token GROUPBORDER UNGROUPBORDER
|
||||
%token MENUBG MENUFG FONTCOLOR
|
||||
%token ERROR
|
||||
%token <v.string> STRING
|
||||
%token <v.number> NUMBER
|
||||
@ -105,8 +106,8 @@ yesno : YES { $$ = 1; }
|
||||
;
|
||||
|
||||
main : FONTNAME STRING {
|
||||
free(conf->DefaultFontName);
|
||||
conf->DefaultFontName = $2;
|
||||
free(conf->font);
|
||||
conf->font = $2;
|
||||
}
|
||||
| STICKY yesno {
|
||||
if ($2 == 0)
|
||||
@ -184,6 +185,18 @@ colors : ACTIVEBORDER STRING {
|
||||
free(conf->color[CWM_COLOR_BORDER_UNGROUP].name);
|
||||
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},
|
||||
{ "color", COLOR},
|
||||
{ "command", COMMAND},
|
||||
{ "font", FONTCOLOR},
|
||||
{ "fontname", FONTNAME},
|
||||
{ "gap", GAP},
|
||||
{ "groupborder", GROUPBORDER},
|
||||
{ "ignore", IGNORE},
|
||||
{ "inactiveborder", INACTIVEBORDER},
|
||||
{ "menubg", MENUBG},
|
||||
{ "menufg", MENUFG},
|
||||
{ "mousebind", MOUSEBIND},
|
||||
{ "moveamount", MOVEAMOUNT},
|
||||
{ "no", NO},
|
||||
@ -462,8 +478,6 @@ pushfile(const char *name)
|
||||
nfile->name = xstrdup(name);
|
||||
|
||||
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
|
||||
if (errno != ENOENT)
|
||||
warn("%s", nfile->name);
|
||||
free(nfile->name);
|
||||
free(nfile);
|
||||
return (NULL);
|
||||
@ -563,7 +577,7 @@ parse_config(const char *filename, struct conf *xconf)
|
||||
for (i = 0; i < CWM_COLOR_MAX; i++)
|
||||
xconf->color[i].name = conf->color[i].name;
|
||||
|
||||
xconf->DefaultFontName = conf->DefaultFontName;
|
||||
xconf->font = conf->font;
|
||||
}
|
||||
|
||||
free(conf);
|
||||
|
@ -77,7 +77,6 @@ xev_handle_maprequest(XEvent *ee)
|
||||
XMapRequestEvent *e = &ee->xmaprequest;
|
||||
struct client_ctx *cc = NULL, *old_cc;
|
||||
XWindowAttributes xattr;
|
||||
struct winmatch *wm;
|
||||
|
||||
if ((old_cc = client_current()) != NULL)
|
||||
client_ptrsave(old_cc);
|
||||
@ -87,10 +86,6 @@ xev_handle_maprequest(XEvent *ee)
|
||||
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)
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user