mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
introduce nitems macro, with the appropriate ifndef.
ok oga@
This commit is contained in:
parent
8f88cd474a
commit
2c706e60c7
4
calmwm.h
4
calmwm.h
|
@ -51,6 +51,10 @@
|
||||||
PointerMotionMask)
|
PointerMotionMask)
|
||||||
#define SearchMask (KeyPressMask|ExposureMask)
|
#define SearchMask (KeyPressMask|ExposureMask)
|
||||||
|
|
||||||
|
#ifndef nitems
|
||||||
|
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
|
||||||
|
#endif
|
||||||
|
|
||||||
enum cwmcolor {
|
enum cwmcolor {
|
||||||
CWM_COLOR_BORDOR_ACTIVE,
|
CWM_COLOR_BORDOR_ACTIVE,
|
||||||
CWM_COLOR_BORDER_INACTIVE,
|
CWM_COLOR_BORDER_INACTIVE,
|
||||||
|
|
10
conf.c
10
conf.c
|
@ -191,10 +191,10 @@ conf_init(struct conf *c)
|
||||||
TAILQ_INIT(&c->autogroupq);
|
TAILQ_INIT(&c->autogroupq);
|
||||||
TAILQ_INIT(&c->mousebindingq);
|
TAILQ_INIT(&c->mousebindingq);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(kb_binds) / sizeof(kb_binds[0]); i++)
|
for (i = 0; i < nitems(kb_binds); i++)
|
||||||
conf_bindname(c, kb_binds[i].key, kb_binds[i].func);
|
conf_bindname(c, kb_binds[i].key, kb_binds[i].func);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(m_binds) / sizeof(m_binds[0]); 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);
|
||||||
|
|
||||||
/* Default term/lock */
|
/* Default term/lock */
|
||||||
|
@ -467,8 +467,7 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
||||||
current_binding = xcalloc(1, sizeof(*current_binding));
|
current_binding = xcalloc(1, sizeof(*current_binding));
|
||||||
|
|
||||||
if ((substring = strchr(name, '-')) != NULL) {
|
if ((substring = strchr(name, '-')) != NULL) {
|
||||||
for (iter = 0; iter < (sizeof(bind_mods) /
|
for (iter = 0; iter < nitems(bind_mods); iter++) {
|
||||||
sizeof(bind_mods[0])); iter++) {
|
|
||||||
if ((tmp = strchr(name, bind_mods[iter].chr)) !=
|
if ((tmp = strchr(name, bind_mods[iter].chr)) !=
|
||||||
NULL && tmp < substring) {
|
NULL && tmp < substring) {
|
||||||
current_binding->modmask |=
|
current_binding->modmask |=
|
||||||
|
@ -573,8 +572,7 @@ conf_mousebind(struct conf *c, char *name, char *binding)
|
||||||
current_binding = xcalloc(1, sizeof(*current_binding));
|
current_binding = xcalloc(1, sizeof(*current_binding));
|
||||||
|
|
||||||
if ((substring = strchr(name, '-')) != NULL) {
|
if ((substring = strchr(name, '-')) != NULL) {
|
||||||
for (iter = 0; iter < (sizeof(bind_mods) /
|
for (iter = 0; iter < nitems(bind_mods); iter++) {
|
||||||
sizeof(bind_mods[0])); iter++) {
|
|
||||||
if ((tmp = strchr(name, bind_mods[iter].chr)) !=
|
if ((tmp = strchr(name, bind_mods[iter].chr)) !=
|
||||||
NULL && tmp < substring) {
|
NULL && tmp < substring) {
|
||||||
current_binding->modmask |=
|
current_binding->modmask |=
|
||||||
|
|
7
search.c
7
search.c
|
@ -42,9 +42,6 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||||
{
|
{
|
||||||
struct winname *wn;
|
struct winname *wn;
|
||||||
struct menu *mi, *tierp[4], *before = NULL;
|
struct menu *mi, *tierp[4], *before = NULL;
|
||||||
int ntiers;
|
|
||||||
|
|
||||||
ntiers = sizeof(tierp) / sizeof(tierp[0]);
|
|
||||||
|
|
||||||
TAILQ_INIT(resultq);
|
TAILQ_INIT(resultq);
|
||||||
|
|
||||||
|
@ -92,14 +89,14 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||||
* window. Furthermore, this is denoted by a "!" when
|
* window. Furthermore, this is denoted by a "!" when
|
||||||
* printing the window name in the search menu.
|
* printing the window name in the search menu.
|
||||||
*/
|
*/
|
||||||
if (cc == client_current() && tier < ntiers - 1)
|
if (cc == client_current() && tier < nitems(tierp) - 1)
|
||||||
tier++;
|
tier++;
|
||||||
|
|
||||||
/* Clients that are hidden get ranked one up. */
|
/* Clients that are hidden get ranked one up. */
|
||||||
if (cc->flags & CLIENT_HIDDEN && tier > 0)
|
if (cc->flags & CLIENT_HIDDEN && tier > 0)
|
||||||
tier--;
|
tier--;
|
||||||
|
|
||||||
assert(tier < ntiers);
|
assert(tier < nitems(tierp));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If you have a tierp, insert after it, and make it
|
* If you have a tierp, insert after it, and make it
|
||||||
|
|
8
xutil.c
8
xutil.c
|
@ -57,7 +57,7 @@ void
|
||||||
xu_btn_grab(Window win, int mask, u_int btn)
|
xu_btn_grab(Window win, int mask, u_int btn)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++)
|
for (i = 0; i < nitems(ign_mods); i++)
|
||||||
XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
|
XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
|
||||||
False, ButtonMask, GrabModeAsync,
|
False, ButtonMask, GrabModeAsync,
|
||||||
GrabModeSync, None, None);
|
GrabModeSync, None, None);
|
||||||
|
@ -67,7 +67,7 @@ void
|
||||||
xu_btn_ungrab(Window win, int mask, u_int btn)
|
xu_btn_ungrab(Window win, int mask, u_int btn)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++)
|
for (i = 0; i < nitems(ign_mods); i++)
|
||||||
XUngrabButton(X_Dpy, btn, (mask | ign_mods[i]), win);
|
XUngrabButton(X_Dpy, btn, (mask | ign_mods[i]), win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ xu_key_grab(Window win, int mask, int keysym)
|
||||||
(XKeycodeToKeysym(X_Dpy, code, 1) == keysym))
|
(XKeycodeToKeysym(X_Dpy, code, 1) == keysym))
|
||||||
mask |= ShiftMask;
|
mask |= ShiftMask;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++)
|
for (i = 0; i < nitems(ign_mods); i++)
|
||||||
XGrabKey(X_Dpy, code, (mask | ign_mods[i]), win,
|
XGrabKey(X_Dpy, code, (mask | ign_mods[i]), win,
|
||||||
True, GrabModeAsync, GrabModeAsync);
|
True, GrabModeAsync, GrabModeAsync);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ xu_key_ungrab(Window win, int mask, int keysym)
|
||||||
(XKeycodeToKeysym(X_Dpy, code, 1) == keysym))
|
(XKeycodeToKeysym(X_Dpy, code, 1) == keysym))
|
||||||
mask |= ShiftMask;
|
mask |= ShiftMask;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++)
|
for (i = 0; i < nitems(ign_mods); i++)
|
||||||
XUngrabKey(X_Dpy, code, (mask | ign_mods[i]), win);
|
XUngrabKey(X_Dpy, code, (mask | ign_mods[i]), win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user