cvsimport

This commit is contained in:
okan 2013-01-06 01:01:26 +00:00
commit 104c7d5de3
10 changed files with 140 additions and 202 deletions

View File

@ -86,8 +86,8 @@ size_t strlcat(char *, const char *, size_t);
#define CWM_MENU_DUMMY 0x0001 #define CWM_MENU_DUMMY 0x0001
#define CWM_MENU_FILE 0x0002 #define CWM_MENU_FILE 0x0002
#define KBTOGROUP(X) ((X) - 1) #define ARG_CHAR 0x0001
#define ARG_INT 0x0002
union arg { union arg {
char *c; char *c;
int i; int i;
@ -101,17 +101,12 @@ enum menucolor {
CWM_COLOR_MENU_MAX CWM_COLOR_MENU_MAX
}; };
enum cwmcolor { enum bordercolor {
CWM_COLOR_BORDER_ACTIVE, CWM_COLOR_BORDER_ACTIVE,
CWM_COLOR_BORDER_INACTIVE, CWM_COLOR_BORDER_INACTIVE,
CWM_COLOR_BORDER_GROUP, CWM_COLOR_BORDER_GROUP,
CWM_COLOR_BORDER_UNGROUP, CWM_COLOR_BORDER_UNGROUP,
CWM_COLOR_MAX CWM_COLOR_BORDER_MAX
};
struct color {
char *name;
unsigned long pixel;
}; };
struct geom { struct geom {
@ -223,7 +218,7 @@ struct screen_ctx {
Colormap colormap; Colormap colormap;
Window rootwin; Window rootwin;
Window menuwin; Window menuwin;
struct color color[CWM_COLOR_MAX]; unsigned long color[CWM_COLOR_BORDER_MAX];
int cycling; int cycling;
struct geom view; /* viewable area */ struct geom view; /* viewable area */
struct geom work; /* workable area, gap-applied */ struct geom work; /* workable area, gap-applied */
@ -234,7 +229,7 @@ struct screen_ctx {
XftFont *xftfont; XftFont *xftfont;
int xinerama_no; int xinerama_no;
XineramaScreenInfo *xinerama; XineramaScreenInfo *xinerama;
#define CALMWM_NGROUPS 9 #define CALMWM_NGROUPS 10
struct group_ctx groups[CALMWM_NGROUPS]; struct group_ctx groups[CALMWM_NGROUPS];
struct group_ctx_q groupq; struct group_ctx_q groupq;
int group_hideall; int group_hideall;
@ -253,6 +248,7 @@ struct keybinding {
int keycode; int keycode;
#define KBFLAG_NEEDCLIENT 0x0001 #define KBFLAG_NEEDCLIENT 0x0001
int flags; int flags;
int argtype;
}; };
TAILQ_HEAD(keybinding_q, keybinding); TAILQ_HEAD(keybinding_q, keybinding);
@ -302,7 +298,7 @@ struct conf {
#define CONF_SNAPDIST 0 #define CONF_SNAPDIST 0
int snapdist; int snapdist;
struct gap gap; struct gap gap;
struct color color[CWM_COLOR_MAX]; char *color[CWM_COLOR_BORDER_MAX];
char *menucolor[CWM_COLOR_MENU_MAX]; char *menucolor[CWM_COLOR_MENU_MAX];
char termpath[MAXPATHLEN]; char termpath[MAXPATHLEN];
char lockpath[MAXPATHLEN]; char lockpath[MAXPATHLEN];
@ -336,7 +332,7 @@ struct client_ctx *client_find(Window);
void client_freeze(struct client_ctx *); void client_freeze(struct client_ctx *);
void client_getsizehints(struct client_ctx *); void client_getsizehints(struct client_ctx *);
void client_hide(struct client_ctx *); void client_hide(struct client_ctx *);
void client_horizmaximize(struct client_ctx *); void client_hmaximize(struct client_ctx *);
void client_leave(struct client_ctx *); void client_leave(struct client_ctx *);
void client_lower(struct client_ctx *); void client_lower(struct client_ctx *);
void client_map(struct client_ctx *); void client_map(struct client_ctx *);
@ -353,7 +349,7 @@ void client_setname(struct client_ctx *);
int client_snapcalc(int, int, int, int, int); int client_snapcalc(int, int, int, int, int);
void client_transient(struct client_ctx *); void client_transient(struct client_ctx *);
void client_unhide(struct client_ctx *); void client_unhide(struct client_ctx *);
void client_vertmaximize(struct client_ctx *); void client_vmaximize(struct client_ctx *);
void client_warp(struct client_ctx *); void client_warp(struct client_ctx *);
void group_alltoggle(struct screen_ctx *); void group_alltoggle(struct screen_ctx *);
@ -383,7 +379,7 @@ void search_match_text(struct menu_q *, struct menu_q *,
char *); char *);
void search_print_client(struct menu *, int); void search_print_client(struct menu *, int);
XineramaScreenInfo *screen_find_xinerama(struct screen_ctx *, int, int); struct geom screen_find_xinerama(struct screen_ctx *, int, int);
struct screen_ctx *screen_fromroot(Window); struct screen_ctx *screen_fromroot(Window);
void screen_init(struct screen_ctx *, u_int); void screen_init(struct screen_ctx *, u_int);
void screen_update_geometry(struct screen_ctx *); void screen_update_geometry(struct screen_ctx *);

133
client.c
View File

@ -41,7 +41,6 @@ static void client_gethints(struct client_ctx *);
static void client_freehints(struct client_ctx *); static void client_freehints(struct client_ctx *);
static int client_inbound(struct client_ctx *, int, int); static int client_inbound(struct client_ctx *, int, int);
static char emptystring[] = "";
struct client_ctx *_curcc = NULL; struct client_ctx *_curcc = NULL;
struct client_ctx * struct client_ctx *
@ -166,8 +165,7 @@ client_delete(struct client_ctx *cc)
while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) { while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) {
TAILQ_REMOVE(&cc->nameq, wn, entry); TAILQ_REMOVE(&cc->nameq, wn, entry);
if (wn->name != emptystring) free(wn->name);
free(wn->name);
free(wn); free(wn);
} }
@ -257,8 +255,7 @@ void
client_maximize(struct client_ctx *cc) client_maximize(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
int x_org, y_org, xmax, ymax; struct geom xine;
XineramaScreenInfo *xine;
if (cc->flags & CLIENT_FREEZE) if (cc->flags & CLIENT_FREEZE)
return; return;
@ -288,21 +285,11 @@ client_maximize(struct client_ctx *cc)
xine = screen_find_xinerama(sc, xine = screen_find_xinerama(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2); cc->geom.y + cc->geom.h / 2);
if (xine) {
x_org = xine->x_org;
y_org = xine->y_org;
xmax = xine->width;
ymax = xine->height;
} else {
x_org = y_org = 0;
xmax = sc->view.w;
ymax = sc->view.h;
}
cc->geom.x = x_org + sc->gap.left; cc->geom.x = xine.x + sc->gap.left;
cc->geom.y = y_org + sc->gap.top; cc->geom.y = xine.y + sc->gap.top;
cc->geom.h = ymax - (sc->gap.top + sc->gap.bottom); cc->geom.h = xine.h - (sc->gap.top + sc->gap.bottom);
cc->geom.w = xmax - (sc->gap.left + sc->gap.right); cc->geom.w = xine.w - (sc->gap.left + sc->gap.right);
cc->bwidth = 0; cc->bwidth = 0;
cc->flags |= CLIENT_MAXIMIZED; cc->flags |= CLIENT_MAXIMIZED;
@ -311,11 +298,10 @@ resize:
} }
void void
client_vertmaximize(struct client_ctx *cc) client_vmaximize(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
int y_org, ymax; struct geom xine;
XineramaScreenInfo *xine;
if (cc->flags & CLIENT_FREEZE) if (cc->flags & CLIENT_FREEZE)
return; return;
@ -335,23 +321,16 @@ client_vertmaximize(struct client_ctx *cc)
/* if this will make us fully maximized then remove boundary */ /* if this will make us fully maximized then remove boundary */
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) { if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) {
cc->geom.w += Conf.bwidth * 2; cc->geom.w += cc->bwidth * 2;
cc->bwidth = 0; cc->bwidth = 0;
} }
xine = screen_find_xinerama(sc, xine = screen_find_xinerama(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2); cc->geom.y + cc->geom.h / 2);
if (xine) {
y_org = xine->y_org;
ymax = xine->height;
} else {
y_org = 0;
ymax = sc->view.h;
}
cc->geom.y = y_org + sc->gap.top; cc->geom.y = xine.y + sc->gap.top;
cc->geom.h = ymax - (cc->bwidth * 2) - (sc->gap.top + cc->geom.h = xine.h - (cc->bwidth * 2) - (sc->gap.top +
sc->gap.bottom); sc->gap.bottom);
cc->flags |= CLIENT_VMAXIMIZED; cc->flags |= CLIENT_VMAXIMIZED;
@ -360,11 +339,10 @@ resize:
} }
void void
client_horizmaximize(struct client_ctx *cc) client_hmaximize(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
int x_org, xmax; struct geom xine;
XineramaScreenInfo *xine;
if (cc->flags & CLIENT_FREEZE) if (cc->flags & CLIENT_FREEZE)
return; return;
@ -391,16 +369,9 @@ client_horizmaximize(struct client_ctx *cc)
xine = screen_find_xinerama(sc, xine = screen_find_xinerama(sc,
cc->geom.x + cc->geom.w / 2, cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2); cc->geom.y + cc->geom.h / 2);
if (xine) {
x_org = xine->x_org;
xmax = xine->width;
} else {
x_org = 0;
xmax = sc->view.w;
}
cc->geom.x = x_org + sc->gap.left; cc->geom.x = xine.x + sc->gap.left;
cc->geom.w = xmax - (cc->bwidth * 2) - (sc->gap.left + cc->geom.w = xine.w - (cc->bwidth * 2) - (sc->gap.left +
sc->gap.right); sc->gap.right);
cc->flags |= CLIENT_HMAXIMIZED; cc->flags |= CLIENT_HMAXIMIZED;
@ -504,17 +475,17 @@ client_draw_border(struct client_ctx *cc)
if (cc->active) if (cc->active)
switch (cc->flags & CLIENT_HIGHLIGHT) { switch (cc->flags & CLIENT_HIGHLIGHT) {
case CLIENT_GROUP: case CLIENT_GROUP:
pixel = sc->color[CWM_COLOR_BORDER_GROUP].pixel; pixel = sc->color[CWM_COLOR_BORDER_GROUP];
break; break;
case CLIENT_UNGROUP: case CLIENT_UNGROUP:
pixel = sc->color[CWM_COLOR_BORDER_UNGROUP].pixel; pixel = sc->color[CWM_COLOR_BORDER_UNGROUP];
break; break;
default: default:
pixel = sc->color[CWM_COLOR_BORDER_ACTIVE].pixel; pixel = sc->color[CWM_COLOR_BORDER_ACTIVE];
break; break;
} }
else else
pixel = sc->color[CWM_COLOR_BORDER_INACTIVE].pixel; pixel = sc->color[CWM_COLOR_BORDER_INACTIVE];
XSetWindowBorderWidth(X_Dpy, cc->win, cc->bwidth); XSetWindowBorderWidth(X_Dpy, cc->win, cc->bwidth);
XSetWindowBorder(X_Dpy, cc->win, pixel); XSetWindowBorder(X_Dpy, cc->win, pixel);
@ -558,7 +529,7 @@ client_setname(struct client_ctx *cc)
if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME].atom, &newname)) if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME].atom, &newname))
if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname)) if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname))
newname = emptystring; newname = xstrdup("");
TAILQ_FOREACH(wn, &cc->nameq, entry) TAILQ_FOREACH(wn, &cc->nameq, entry)
if (strcmp(wn->name, newname) == 0) { if (strcmp(wn->name, newname) == 0) {
@ -581,8 +552,7 @@ match:
wn = TAILQ_FIRST(&cc->nameq); wn = TAILQ_FIRST(&cc->nameq);
assert(wn != NULL); assert(wn != NULL);
TAILQ_REMOVE(&cc->nameq, wn, entry); TAILQ_REMOVE(&cc->nameq, wn, entry);
if (wn->name != emptystring) free(wn->name);
free(wn->name);
free(wn); free(wn);
cc->nameqlen--; cc->nameqlen--;
} }
@ -685,48 +655,37 @@ client_placecalc(struct client_ctx *cc)
if (cc->size->y > 0) if (cc->size->y > 0)
cc->geom.y = MIN(cc->size->y, yslack); cc->geom.y = MIN(cc->size->y, yslack);
} else { } else {
XineramaScreenInfo *info; struct geom xine;
int xmouse, ymouse, xorig, yorig; int xmouse, ymouse;
int xmax, ymax;
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse); xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
info = screen_find_xinerama(sc, xmouse, ymouse); xine = screen_find_xinerama(sc, xmouse, ymouse);
if (info) { xmouse = MAX(xmouse, xine.x) - cc->geom.w / 2;
xorig = info->x_org; ymouse = MAX(ymouse, xine.y) - cc->geom.h / 2;
yorig = info->y_org;
xmax = xorig + info->width;
ymax = yorig + info->height;
} else {
xorig = yorig = 0;
xmax = sc->view.w;
ymax = sc->view.h;
}
xmouse = MAX(xmouse, xorig) - cc->geom.w / 2;
ymouse = MAX(ymouse, yorig) - cc->geom.h / 2;
xmouse = MAX(xmouse, xorig); xmouse = MAX(xmouse, xine.x);
ymouse = MAX(ymouse, yorig); ymouse = MAX(ymouse, xine.y);
xslack = xmax - cc->geom.w - cc->bwidth * 2; xslack = xine.w - cc->geom.w - cc->bwidth * 2;
yslack = ymax - cc->geom.h - cc->bwidth * 2; yslack = xine.h - cc->geom.h - cc->bwidth * 2;
if (xslack >= xorig) { if (xslack >= xine.x) {
cc->geom.x = MAX(MIN(xmouse, xslack), cc->geom.x = MAX(MIN(xmouse, xslack),
xorig + sc->gap.left); xine.x + sc->gap.left);
if (cc->geom.x > (xslack - sc->gap.right)) if (cc->geom.x > (xslack - sc->gap.right))
cc->geom.x -= sc->gap.right; cc->geom.x -= sc->gap.right;
} else { } else {
cc->geom.x = xorig + sc->gap.left; cc->geom.x = xine.x + sc->gap.left;
cc->geom.w = xmax - sc->gap.left; cc->geom.w = xine.w - sc->gap.left;
} }
if (yslack >= yorig) { if (yslack >= xine.y) {
cc->geom.y = MAX(MIN(ymouse, yslack), cc->geom.y = MAX(MIN(ymouse, yslack),
yorig + sc->gap.top); xine.y + sc->gap.top);
if (cc->geom.y > (yslack - sc->gap.bottom)) if (cc->geom.y > (yslack - sc->gap.bottom))
cc->geom.y -= sc->gap.bottom; cc->geom.y -= sc->gap.bottom;
} else { } else {
cc->geom.y = yorig + sc->gap.top; cc->geom.y = xine.y + sc->gap.top;
cc->geom.h = ymax - sc->gap.top; cc->geom.h = xine.h - sc->gap.top;
} }
} }
} }
@ -876,7 +835,7 @@ client_transient(struct client_ctx *cc)
if (XGetTransientForHint(X_Dpy, cc->win, &trans)) { if (XGetTransientForHint(X_Dpy, cc->win, &trans)) {
if ((tc = client_find(trans)) && tc->group) { if ((tc = client_find(trans)) && tc->group) {
group_movetogroup(cc, tc->group->shortcut - 1); group_movetogroup(cc, tc->group->shortcut);
if (tc->flags & CLIENT_IGNORE) if (tc->flags & CLIENT_IGNORE)
cc->flags |= CLIENT_IGNORE; cc->flags |= CLIENT_IGNORE;
} }
@ -891,19 +850,17 @@ client_inbound(struct client_ctx *cc, int x, int y)
} }
int int
client_snapcalc(int n, int dn, int nmax, int bwidth, int snapdist) client_snapcalc(int n0, int n1, int e0, int e1, int snapdist)
{ {
int n0, n1, s0, s1; int s0, s1;
s0 = s1 = 0; s0 = s1 = 0;
n0 = n;
n1 = n + dn + (bwidth * 2);
if (abs(n0) <= snapdist) if (abs(e0 - n0) <= snapdist)
s0 = -n0; s0 = e0 - n0;
if (nmax - snapdist <= n1 && n1 <= nmax + snapdist) if (abs(e1 - n1) <= snapdist)
s1 = nmax - n1; s1 = e1 - n1;
/* possible to snap in both directions */ /* possible to snap in both directions */
if (s0 != 0 && s1 != 0) if (s0 != 0 && s1 != 0)

34
conf.c
View File

@ -65,17 +65,17 @@ conf_font(struct conf *c, struct screen_ctx *sc)
} }
static char *menu_color_binds[CWM_COLOR_MENU_MAX] = { static char *menu_color_binds[CWM_COLOR_MENU_MAX] = {
"black", /* CWM_COLOR_MENU_FG */ "black", /* CWM_COLOR_MENU_FG */
"white", /* CWM_COLOR_MENU_BG */ "white", /* CWM_COLOR_MENU_BG */
"black", /* CWM_COLOR_MENU_FONT */ "black", /* CWM_COLOR_MENU_FONT */
"", /* CWM_COLOR_MENU_FONT_SEL */ "", /* CWM_COLOR_MENU_FONT_SEL */
}; };
static struct color color_binds[CWM_COLOR_MAX] = { static char *color_binds[CWM_COLOR_BORDER_MAX] = {
{ "#CCCCCC", 0 }, /* CWM_COLOR_BORDER_ACTIVE */ "#CCCCCC", /* CWM_COLOR_BORDER_ACTIVE */
{ "#666666", 0 }, /* CWM_COLOR_BORDER_INACTIVE */ "#666666", /* CWM_COLOR_BORDER_INACTIVE */
{ "blue", 0 }, /* CWM_COLOR_BORDER_GROUP */ "blue", /* CWM_COLOR_BORDER_GROUP */
{ "red", 0 }, /* CWM_COLOR_BORDER_UNGROUP */ "red", /* CWM_COLOR_BORDER_UNGROUP */
}; };
void void
@ -83,8 +83,8 @@ conf_color(struct conf *c, struct screen_ctx *sc)
{ {
int i; int i;
for (i = 0; i < CWM_COLOR_MAX; i++) for (i = 0; i < CWM_COLOR_BORDER_MAX; i++)
sc->color[i].pixel = xu_getcolor(sc, c->color[i].name); sc->color[i] = xu_getcolor(sc, c->color[i]);
} }
static struct { static struct {
@ -184,7 +184,7 @@ conf_init(struct conf *c)
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++) for (i = 0; i < nitems(color_binds); i++)
c->color[i].name = xstrdup(color_binds[i].name); c->color[i] = xstrdup(color_binds[i]);
for (i = 0; i < nitems(menu_color_binds); i++) for (i = 0; i < nitems(menu_color_binds); i++)
c->menucolor[i] = xstrdup(menu_color_binds[i]); c->menucolor[i] = xstrdup(menu_color_binds[i]);
@ -236,8 +236,8 @@ conf_clear(struct conf *c)
free(mb); free(mb);
} }
for (i = 0; i < CWM_COLOR_MAX; i++) for (i = 0; i < CWM_COLOR_BORDER_MAX; i++)
free(c->color[i].name); free(c->color[i]);
free(c->font); free(c->font);
} }
@ -470,14 +470,16 @@ conf_bindname(struct conf *c, char *name, char *binding)
current_binding->callback = name_to_kbfunc[i].handler; current_binding->callback = name_to_kbfunc[i].handler;
current_binding->flags = name_to_kbfunc[i].flags; current_binding->flags = name_to_kbfunc[i].flags;
current_binding->argument = name_to_kbfunc[i].argument; current_binding->argument = name_to_kbfunc[i].argument;
current_binding->argtype |= ARG_INT;
conf_grab(c, current_binding); conf_grab(c, current_binding);
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry); TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
return; return;
} }
current_binding->callback = kbfunc_cmdexec; current_binding->callback = kbfunc_cmdexec;
current_binding->argument.c = xstrdup(binding);
current_binding->flags = 0; current_binding->flags = 0;
current_binding->argument.c = xstrdup(binding);
current_binding->argtype |= ARG_CHAR;
conf_grab(c, current_binding); conf_grab(c, current_binding);
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry); TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
} }
@ -496,6 +498,8 @@ conf_unbind(struct conf *c, struct keybinding *unbind)
key->keysym == unbind->keysym) { key->keysym == unbind->keysym) {
conf_ungrab(c, key); conf_ungrab(c, key);
TAILQ_REMOVE(&c->keybindingq, key, entry); TAILQ_REMOVE(&c->keybindingq, key, entry);
if (key->argtype & ARG_CHAR)
free(key->argument.c);
free(key); free(key);
} }
} }

16
group.c
View File

@ -132,7 +132,7 @@ group_show(struct screen_ctx *sc, struct group_ctx *gc)
free(winlist); free(winlist);
gc->hidden = 0; gc->hidden = 0;
group_setactive(sc, gc->shortcut - 1); group_setactive(sc, gc->shortcut);
} }
void void
@ -151,7 +151,7 @@ group_init(struct screen_ctx *sc)
for (i = 0; i < CALMWM_NGROUPS; i++) { for (i = 0; i < CALMWM_NGROUPS; i++) {
TAILQ_INIT(&sc->groups[i].clients); TAILQ_INIT(&sc->groups[i].clients);
sc->groups[i].hidden = 0; sc->groups[i].hidden = 0;
sc->groups[i].shortcut = i + 1; sc->groups[i].shortcut = i;
TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], entry); TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], entry);
} }
@ -269,12 +269,8 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
if (gc->hidden) if (gc->hidden)
group_show(sc, gc); group_show(sc, gc);
else { else
group_hide(sc, gc); group_hide(sc, gc);
/* XXX wtf? */
if (TAILQ_EMPTY(&gc->clients))
group_setactive(sc, idx);
}
} }
void void
@ -327,7 +323,7 @@ group_cycle(struct screen_ctx *sc, int flags)
if (showgroup->hidden) if (showgroup->hidden)
group_show(sc, showgroup); group_show(sc, showgroup);
else else
group_setactive(sc, showgroup->shortcut - 1); group_setactive(sc, showgroup->shortcut);
} }
/* called when a client is deleted */ /* called when a client is deleted */
@ -420,7 +416,7 @@ group_autogroup(struct client_ctx *cc)
else if (*grpno > CALMWM_NGROUPS || *grpno < 0) else if (*grpno > CALMWM_NGROUPS || *grpno < 0)
no = CALMWM_NGROUPS - 1; no = CALMWM_NGROUPS - 1;
else else
no = *grpno + 1; no = *grpno;
XFree(grpno); XFree(grpno);
} else { } else {
TAILQ_FOREACH(aw, &Conf.autogroupq, entry) { TAILQ_FOREACH(aw, &Conf.autogroupq, entry) {
@ -480,7 +476,7 @@ group_update_names(struct screen_ctx *sc)
*/ */
if (n < CALMWM_NGROUPS) { if (n < CALMWM_NGROUPS) {
setnames = 1; setnames = 1;
i = 1; i = 0;
while (n < CALMWM_NGROUPS) while (n < CALMWM_NGROUPS)
strings[n++] = xstrdup(shortcut_to_name[i++]); strings[n++] = xstrdup(shortcut_to_name[i++]);
} }

View File

@ -101,11 +101,11 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
cc->geom.x = sc->view.w - 1; cc->geom.x = sc->view.w - 1;
cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x += client_snapcalc(cc->geom.x,
cc->geom.w, sc->view.w, cc->geom.x + cc->geom.w + (cc->bwidth * 2),
cc->bwidth, Conf.snapdist); sc->work.x, sc->work.w, Conf.snapdist);
cc->geom.y += client_snapcalc(cc->geom.y, cc->geom.y += client_snapcalc(cc->geom.y,
cc->geom.h, sc->view.h, cc->geom.y + cc->geom.h + (cc->bwidth * 2),
cc->bwidth, Conf.snapdist); sc->work.y, sc->work.h, Conf.snapdist);
client_move(cc); client_move(cc);
xu_ptr_getpos(cc->win, &x, &y); xu_ptr_getpos(cc->win, &x, &y);
@ -406,13 +406,13 @@ kbfunc_client_delete(struct client_ctx *cc, union arg *arg)
void void
kbfunc_client_group(struct client_ctx *cc, union arg *arg) kbfunc_client_group(struct client_ctx *cc, union arg *arg)
{ {
group_hidetoggle(cc->sc, KBTOGROUP(arg->i)); group_hidetoggle(cc->sc, arg->i);
} }
void void
kbfunc_client_grouponly(struct client_ctx *cc, union arg *arg) kbfunc_client_grouponly(struct client_ctx *cc, union arg *arg)
{ {
group_only(cc->sc, KBTOGROUP(arg->i)); group_only(cc->sc, arg->i);
} }
void void
@ -440,7 +440,7 @@ kbfunc_client_grouptoggle(struct client_ctx *cc, union arg *arg)
void void
kbfunc_client_movetogroup(struct client_ctx *cc, union arg *arg) kbfunc_client_movetogroup(struct client_ctx *cc, union arg *arg)
{ {
group_movetogroup(cc, KBTOGROUP(arg->i)); group_movetogroup(cc, arg->i);
} }
void void
@ -452,13 +452,13 @@ kbfunc_client_maximize(struct client_ctx *cc, union arg *arg)
void void
kbfunc_client_vmaximize(struct client_ctx *cc, union arg *arg) kbfunc_client_vmaximize(struct client_ctx *cc, union arg *arg)
{ {
client_vertmaximize(cc); client_vmaximize(cc);
} }
void void
kbfunc_client_hmaximize(struct client_ctx *cc, union arg *arg) kbfunc_client_hmaximize(struct client_ctx *cc, union arg *arg)
{ {
client_horizmaximize(cc); client_hmaximize(cc);
} }
void void

35
menu.c
View File

@ -350,8 +350,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
struct menu_q *resultq) struct menu_q *resultq)
{ {
struct menu *mi; struct menu *mi;
XineramaScreenInfo *xine; struct geom xine;
int xmin, xmax, ymin, ymax;
int n, xsave, ysave; int n, xsave, ysave;
if (mc->list) { if (mc->list) {
@ -395,32 +394,22 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
} }
xine = screen_find_xinerama(sc, mc->x, mc->y); xine = screen_find_xinerama(sc, mc->x, mc->y);
if (xine) {
xmin = xine->x_org;
xmax = xine->x_org + xine->width;
ymin = xine->y_org;
ymax = xine->y_org + xine->height;
} else {
xmin = ymin = 0;
xmax = sc->view.w;
ymax = sc->view.h;
}
xsave = mc->x; xsave = mc->x;
ysave = mc->y; ysave = mc->y;
/* Never hide the top, or left side, of the menu. */ /* Never hide the top, or left side, of the menu. */
if (mc->x + mc->width >= xmax) if (mc->x + mc->width >= xine.w)
mc->x = xmax - mc->width; mc->x = xine.w - mc->width;
if (mc->x < xmin) { if (mc->x < xine.x) {
mc->x = xmin; mc->x = xine.x;
mc->width = xmax - xmin; mc->width = xine.w - xine.x;
} }
if (mc->y + mc->height >= ymax) if (mc->y + mc->height >= xine.h)
mc->y = ymax - mc->height; mc->y = xine.h - mc->height;
if (mc->y < ymin) { if (mc->y < xine.y) {
mc->y = ymin; mc->y = xine.y;
mc->height = ymax - ymin; mc->height = xine.h - xine.y;
} }
if (mc->x != xsave || mc->y != ysave) if (mc->x != xsave || mc->y != ysave)
@ -443,7 +432,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
int y = n * font_height(sc) + font_ascent(sc) + 1; int y = n * font_height(sc) + font_ascent(sc) + 1;
/* Stop drawing when menu doesn't fit inside the screen. */ /* Stop drawing when menu doesn't fit inside the screen. */
if (mc->y + y > ymax) if (mc->y + y > xine.h)
break; break;
font_draw(sc, text, MIN(strlen(text), MENU_MAXENTRY), font_draw(sc, text, MIN(strlen(text), MENU_MAXENTRY),

View File

@ -162,11 +162,11 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth; cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x += client_snapcalc(cc->geom.x,
cc->geom.w, sc->view.w, cc->geom.x + cc->geom.w + (cc->bwidth * 2),
cc->bwidth, Conf.snapdist); sc->work.x, sc->work.w, Conf.snapdist);
cc->geom.y += client_snapcalc(cc->geom.y, cc->geom.y += client_snapcalc(cc->geom.y,
cc->geom.h, sc->view.h, cc->geom.y + cc->geom.h + (cc->bwidth * 2),
cc->bwidth, Conf.snapdist); sc->work.y, sc->work.h, Conf.snapdist);
/* don't move more than 60 times / second */ /* don't move more than 60 times / second */
if ((ev.xmotion.time - ltime) > (1000 / 60)) { if ((ev.xmotion.time - ltime) > (1000 / 60)) {

20
parse.y
View File

@ -173,20 +173,20 @@ color : COLOR colors
; ;
colors : ACTIVEBORDER STRING { colors : ACTIVEBORDER STRING {
free(conf->color[CWM_COLOR_BORDER_ACTIVE].name); free(conf->color[CWM_COLOR_BORDER_ACTIVE]);
conf->color[CWM_COLOR_BORDER_ACTIVE].name = $2; conf->color[CWM_COLOR_BORDER_ACTIVE] = $2;
} }
| INACTIVEBORDER STRING { | INACTIVEBORDER STRING {
free(conf->color[CWM_COLOR_BORDER_INACTIVE].name); free(conf->color[CWM_COLOR_BORDER_INACTIVE]);
conf->color[CWM_COLOR_BORDER_INACTIVE].name = $2; conf->color[CWM_COLOR_BORDER_INACTIVE] = $2;
} }
| GROUPBORDER STRING { | GROUPBORDER STRING {
free(conf->color[CWM_COLOR_BORDER_GROUP].name); free(conf->color[CWM_COLOR_BORDER_GROUP]);
conf->color[CWM_COLOR_BORDER_GROUP].name = $2; conf->color[CWM_COLOR_BORDER_GROUP] = $2;
} }
| UNGROUPBORDER STRING { | UNGROUPBORDER STRING {
free(conf->color[CWM_COLOR_BORDER_UNGROUP].name); free(conf->color[CWM_COLOR_BORDER_UNGROUP]);
conf->color[CWM_COLOR_BORDER_UNGROUP].name = $2; conf->color[CWM_COLOR_BORDER_UNGROUP] = $2;
} }
| MENUBG STRING { | MENUBG STRING {
free(conf->menucolor[CWM_COLOR_MENU_BG]); free(conf->menucolor[CWM_COLOR_MENU_BG]);
@ -580,8 +580,8 @@ parse_config(const char *filename, struct conf *xconf)
(void)strlcpy(xconf->lockpath, conf->lockpath, (void)strlcpy(xconf->lockpath, conf->lockpath,
sizeof(xconf->lockpath)); sizeof(xconf->lockpath));
for (i = 0; i < CWM_COLOR_MAX; i++) for (i = 0; i < CWM_COLOR_BORDER_MAX; i++)
xconf->color[i].name = conf->color[i].name; xconf->color[i] = conf->color[i];
for (i = 0; i < CWM_COLOR_MENU_MAX; i++) for (i = 0; i < CWM_COLOR_MENU_MAX; i++)
xconf->menucolor[i] = conf->menucolor[i]; xconf->menucolor[i] = conf->menucolor[i];

View File

@ -30,8 +30,6 @@
#include "calmwm.h" #include "calmwm.h"
static void screen_init_xinerama(struct screen_ctx *);
void void
screen_init(struct screen_ctx *sc, u_int which) screen_init(struct screen_ctx *sc, u_int which)
{ {
@ -124,49 +122,41 @@ screen_updatestackingorder(struct screen_ctx *sc)
XFree(wins); XFree(wins);
} }
/*
* If we're using RandR then we'll redo this whenever the screen
* changes since a CTRC may have been added or removed
*/
void
screen_init_xinerama(struct screen_ctx *sc)
{
XineramaScreenInfo *info = NULL;
int no = 0;
if (XineramaIsActive(X_Dpy))
info = XineramaQueryScreens(X_Dpy, &no);
if (sc->xinerama != NULL)
XFree(sc->xinerama);
sc->xinerama = info;
sc->xinerama_no = no;
}
/* /*
* Find which xinerama screen the coordinates (x,y) is on. * Find which xinerama screen the coordinates (x,y) is on.
*/ */
XineramaScreenInfo * struct geom
screen_find_xinerama(struct screen_ctx *sc, int x, int y) screen_find_xinerama(struct screen_ctx *sc, int x, int y)
{ {
XineramaScreenInfo *info; XineramaScreenInfo *info;
struct geom geom;
int i; int i;
geom = sc->view;
if (sc->xinerama == NULL) if (sc->xinerama == NULL)
return (NULL); return (geom);
for (i = 0; i < sc->xinerama_no; i++) { for (i = 0; i < sc->xinerama_no; i++) {
info = &sc->xinerama[i]; info = &sc->xinerama[i];
if (x >= info->x_org && x < info->x_org + info->width && if (x >= info->x_org && x < info->x_org + info->width &&
y >= info->y_org && y < info->y_org + info->height) y >= info->y_org && y < info->y_org + info->height) {
return (info); geom.x = info->x_org;
geom.y = info->y_org;
geom.w = info->width;
geom.h = info->height;
break;
}
} }
return (NULL); return (geom);
} }
void void
screen_update_geometry(struct screen_ctx *sc) screen_update_geometry(struct screen_ctx *sc)
{ {
XineramaScreenInfo *info = NULL;
int info_no = 0;
sc->view.x = 0; sc->view.x = 0;
sc->view.y = 0; sc->view.y = 0;
sc->view.w = DisplayWidth(X_Dpy, sc->which); sc->view.w = DisplayWidth(X_Dpy, sc->which);
@ -177,7 +167,13 @@ screen_update_geometry(struct screen_ctx *sc)
sc->work.w = sc->view.w - (sc->gap.left + sc->gap.right); sc->work.w = sc->view.w - (sc->gap.left + sc->gap.right);
sc->work.h = sc->view.h - (sc->gap.top + sc->gap.bottom); sc->work.h = sc->view.h - (sc->gap.top + sc->gap.bottom);
screen_init_xinerama(sc); /* RandR event may have a CTRC added or removed. */
if (XineramaIsActive(X_Dpy))
info = XineramaQueryScreens(X_Dpy, &info_no);
if (sc->xinerama != NULL)
XFree(sc->xinerama);
sc->xinerama = info;
sc->xinerama_no = info_no;
xu_ewmh_net_desktop_geometry(sc); xu_ewmh_net_desktop_geometry(sc);
xu_ewmh_net_workarea(sc); xu_ewmh_net_workarea(sc);

View File

@ -411,7 +411,7 @@ xu_ewmh_net_wm_desktop(struct client_ctx *cc)
long no = 0xffffffff; long no = 0xffffffff;
if (gc) if (gc)
no = gc->shortcut - 1; no = gc->shortcut;
XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_DESKTOP].atom, XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_DESKTOP].atom,
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&no, 1); XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&no, 1);