From 8c47a12a8669ffec92a6b9ca922eaec0f192b546 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 8 Apr 2013 00:56:21 +0000 Subject: missing prototype --- menu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/menu.c b/menu.c index 381da6c..28eac9f 100644 --- a/menu.c +++ b/menu.c @@ -74,6 +74,7 @@ static void menu_draw_entry(struct screen_ctx *, struct menu_ctx *, struct menu_q *, int, int); static int menu_calc_entry(struct screen_ctx *, struct menu_ctx *, int, int); +static struct menu *menu_complete_path(struct menu_ctx *); static int menu_keycode(XKeyEvent *, enum ctltype *, char *); -- cgit 1.4.1 From 28b54db2217c0398132a6b049231c99a99a84160 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 8 Apr 2013 13:02:31 +0000 Subject: consistency --- group.c | 1 + kbfunc.c | 1 + menu.c | 1 + mousefunc.c | 2 ++ 4 files changed, 5 insertions(+) diff --git a/group.c b/group.c index 307b5c7..dd47e06 100644 --- a/group.c +++ b/group.c @@ -351,6 +351,7 @@ group_menu(XButtonEvent *e) int i; sc = screen_fromroot(e->root); + TAILQ_INIT(&menuq); for (i = 0; i < CALMWM_NGROUPS; i++) { diff --git a/kbfunc.c b/kbfunc.c index c742f7e..7a406ea 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -335,6 +335,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg) } TAILQ_INIT(&menuq); + lbuf = NULL; while ((buf = fgetln(fp, &len))) { if (buf[len - 1] == '\n') diff --git a/menu.c b/menu.c index 28eac9f..465244f 100644 --- a/menu.c +++ b/menu.c @@ -209,6 +209,7 @@ menu_complete_path(struct menu_ctx *mc) mr = xcalloc(1, sizeof(*mr)); TAILQ_INIT(&menuq); + if ((mi = menu_filter(mc->sc, &menuq, mc->searchstr, NULL, CWM_MENU_DUMMY, search_match_path_any, NULL)) != NULL) { mr->abort = mi->abort; diff --git a/mousefunc.c b/mousefunc.c index 1d2b287..c8edf6a 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -227,6 +227,7 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg) old_cc = client_current(); TAILQ_INIT(&menuq); + TAILQ_FOREACH(cc, &Clientq, entry) if (cc->flags & CLIENT_HIDDEN) { wname = (cc->label) ? cc->label : cc->name; @@ -263,6 +264,7 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg) struct cmd *cmd; TAILQ_INIT(&menuq); + TAILQ_FOREACH(cmd, &Conf.cmdq, entry) { mi = xcalloc(1, sizeof(*mi)); (void)strlcpy(mi->text, cmd->label, sizeof(mi->text)); -- cgit 1.4.1 From 62a685d82a7c2c91ce82323778f0105d34ad7321 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 8 Apr 2013 13:05:27 +0000 Subject: reverse logic to make it like the others --- group.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/group.c b/group.c index dd47e06..cda8d0a 100644 --- a/group.c +++ b/group.c @@ -375,15 +375,11 @@ group_menu(XButtonEvent *e) return; mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL); + if (mi != NULL && mi->ctx != NULL) { + gc = (struct group_ctx *)mi->ctx; + (gc->hidden) ? group_show(sc, gc) : group_hide(sc, gc); + } - if (mi == NULL || mi->ctx == NULL) - goto cleanup; - - gc = (struct group_ctx *)mi->ctx; - - (gc->hidden) ? group_show(sc, gc) : group_hide(sc, gc); - -cleanup: menuq_clear(&menuq); } -- cgit 1.4.1 From 58c1d48d10cd7bec3bd186ef2f584b1ad1974f5b Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 8 Apr 2013 15:43:04 +0000 Subject: plug memleak; always need to menuq_clear even when a selection is made. --- mousefunc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mousefunc.c b/mousefunc.c index c8edf6a..878f63a 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -251,8 +251,9 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg) if (old_cc != NULL) client_ptrsave(old_cc); client_ptrwarp(cc); - } else - menuq_clear(&menuq); + } + + menuq_clear(&menuq); } void @@ -277,6 +278,6 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg) mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL); if (mi != NULL) u_spawn(((struct cmd *)mi->ctx)->image); - else - menuq_clear(&menuq); + + menuq_clear(&menuq); } -- cgit 1.4.1 From 90f95416c6f4461625dd37d5cc44dd92a067a030 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 10 Apr 2013 19:08:09 +0000 Subject: _NET_WM_NAME is UTF8_STRING type --- xutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xutil.c b/xutil.c index 32a9974..3605e71 100644 --- a/xutil.c +++ b/xutil.c @@ -292,7 +292,7 @@ xu_ewmh_net_supported_wm_check(struct screen_ctx *sc) XChangeProperty(X_Dpy, w, ewmh[_NET_SUPPORTING_WM_CHECK].atom, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1); XChangeProperty(X_Dpy, w, ewmh[_NET_WM_NAME].atom, - XA_WM_NAME, 8, PropModeReplace, (unsigned char *)WMNAME, + cwmh[UTF8_STRING].atom, 8, PropModeReplace, (unsigned char *)WMNAME, strlen(WMNAME)); } -- cgit 1.4.1 From 6296efadaa6bcc09068030bec4cb01904ca1a010 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 12 Apr 2013 14:46:30 +0000 Subject: push Screenq into screen_init --- calmwm.c | 8 ++------ calmwm.h | 2 +- screen.c | 7 ++++++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/calmwm.c b/calmwm.c index 25ac559..d2aecf9 100644 --- a/calmwm.c +++ b/calmwm.c @@ -146,7 +146,6 @@ dpy_init(const char *dpyname) static void x_setup(void) { - struct screen_ctx *sc; struct keybinding *kb; int i; @@ -156,11 +155,8 @@ x_setup(void) Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow); Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner); - for (i = 0; i < ScreenCount(X_Dpy); i++) { - sc = xcalloc(1, sizeof(*sc)); - screen_init(sc, i); - TAILQ_INSERT_TAIL(&Screenq, sc, entry); - } + for (i = 0; i < ScreenCount(X_Dpy); i++) + screen_init(i); /* * XXX key grabs weren't done before, since Screenq was empty, diff --git a/calmwm.h b/calmwm.h index c02db59..86650ca 100644 --- a/calmwm.h +++ b/calmwm.h @@ -375,7 +375,7 @@ void search_print_client(struct menu *, int); struct geom screen_find_xinerama(struct screen_ctx *, int, int); struct screen_ctx *screen_fromroot(Window); -void screen_init(struct screen_ctx *, u_int); +void screen_init(u_int); void screen_update_geometry(struct screen_ctx *); void screen_updatestackingorder(struct screen_ctx *); diff --git a/screen.c b/screen.c index 6b7de6b..7eac18d 100644 --- a/screen.c +++ b/screen.c @@ -31,13 +31,16 @@ #include "calmwm.h" void -screen_init(struct screen_ctx *sc, u_int which) +screen_init(u_int which) { + struct screen_ctx *sc; Window *wins, w0, w1; XWindowAttributes winattr; XSetWindowAttributes rootattr; u_int nwins, i; + sc = xcalloc(1, sizeof(*sc)); + sc->which = which; sc->visual = DefaultVisual(X_Dpy, sc->which); sc->colormap = DefaultColormap(X_Dpy, sc->which); @@ -84,6 +87,8 @@ screen_init(struct screen_ctx *sc, u_int which) if (HasRandr) XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask); + TAILQ_INSERT_TAIL(&Screenq, sc, entry); + XSync(X_Dpy, False); } -- cgit 1.4.1 From b5f6bd205c97405e85cf19f3a1f4f162400d7897 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 12 Apr 2013 14:49:16 +0000 Subject: makes no sense to set an error handler which uses X_Dpy before XOpenDisplay. --- calmwm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/calmwm.c b/calmwm.c index d2aecf9..7bc204a 100644 --- a/calmwm.c +++ b/calmwm.c @@ -129,8 +129,6 @@ dpy_init(const char *dpyname) { int i; - XSetErrorHandler(x_errorhandler); - if ((X_Dpy = XOpenDisplay(dpyname)) == NULL) errx(1, "unable to open display \"%s\"", XDisplayName(dpyname)); -- cgit 1.4.1 From ef1b78f4649612a9db2614abcfe968cdec13e139 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 12 Apr 2013 20:45:57 +0000 Subject: we already set window state in client_hide or client_unhide right before, so there's no need to do it again. --- client.c | 1 - 1 file changed, 1 deletion(-) diff --git a/client.c b/client.c index 1750360..663b7c5 100644 --- a/client.c +++ b/client.c @@ -125,7 +125,6 @@ client_new(Window win, struct screen_ctx *sc, int mapped) xu_configure(cc); (state == IconicState) ? client_hide(cc) : client_unhide(cc); - xu_setstate(cc, cc->state); TAILQ_INSERT_TAIL(&sc->mruq, cc, mru_entry); TAILQ_INSERT_TAIL(&Clientq, cc, entry); -- cgit 1.4.1 From f3dfc4968cee2080cfa4a4f24f0977b962aa367d Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 12 Apr 2013 20:54:27 +0000 Subject: we handle WM_STATE here, so remove misleading comment. --- client.c | 1 - 1 file changed, 1 deletion(-) diff --git a/client.c b/client.c index 663b7c5..495625f 100644 --- a/client.c +++ b/client.c @@ -447,7 +447,6 @@ client_ptrsave(struct client_ctx *cc) void client_hide(struct client_ctx *cc) { - /* XXX - add wm_state stuff */ XUnmapWindow(X_Dpy, cc->win); cc->active = 0; -- cgit 1.4.1 From 16ed8bf8e4f561049b732b326f3d0ee475fe13f6 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 14 Apr 2013 16:13:17 +0000 Subject: only a window is required to set WM_STATE. also un-confuse xu_ptr_getpos by using 'win' instead of 'rootwin' so as not to imply only the root window is queried, rather any window. --- calmwm.h | 2 +- client.c | 2 +- xutil.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/calmwm.h b/calmwm.h index 86650ca..6f39aeb 100644 --- a/calmwm.h +++ b/calmwm.h @@ -466,7 +466,7 @@ void xu_configure(struct client_ctx *); void xu_getatoms(void); unsigned long xu_getcolor(struct screen_ctx *, char *); int xu_getprop(Window, Atom, Atom, long, u_char **); -int xu_getstate(struct client_ctx *, int *); +int xu_getstate(Window, int *); int xu_getstrprop(Window, Atom, char **); void xu_key_grab(Window, int, int); void xu_key_ungrab(Window, int, int); diff --git a/client.c b/client.c index 495625f..932b4bc 100644 --- a/client.c +++ b/client.c @@ -111,7 +111,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped) } client_draw_border(cc); - if (xu_getstate(cc, &state) < 0) + if (xu_getstate(cc->win, &state) < 0) state = NormalState; XSelectInput(X_Dpy, cc->win, ColormapChangeMask | EnterWindowMask | diff --git a/xutil.c b/xutil.c index 3605e71..a663150 100644 --- a/xutil.c +++ b/xutil.c @@ -72,13 +72,13 @@ xu_btn_ungrab(Window win, int mask, u_int btn) } void -xu_ptr_getpos(Window rootwin, int *x, int *y) +xu_ptr_getpos(Window win, int *x, int *y) { Window w0, w1; int tmp0, tmp1; u_int tmp2; - XQueryPointer(X_Dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); + XQueryPointer(X_Dpy, win, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); } void @@ -203,11 +203,11 @@ xu_getstrprop(Window win, Atom atm, char **text) { } int -xu_getstate(struct client_ctx *cc, int *state) +xu_getstate(Window win, int *state) { long *p = NULL; - if (xu_getprop(cc->win, cwmh[WM_STATE].atom, cwmh[WM_STATE].atom, 2L, + if (xu_getprop(win, cwmh[WM_STATE].atom, cwmh[WM_STATE].atom, 2L, (u_char **)&p) <= 0) return (-1); -- cgit 1.4.1