diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-12-16 13:42:52 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-12-16 13:48:38 +0100 |
commit | 775ba78311768b7a944db95273822c0a567dc171 (patch) | |
tree | 13ea9cb9db8e9121cc80e9cce4186a925fb889e2 /kbfunc.c | |
parent | dcb741d2b1378432e226bbeea274c2e5e2508c2d (diff) | |
parent | 8b4666cb926121481905b68bf93d6e81c307e9e3 (diff) | |
download | cwm-775ba78311768b7a944db95273822c0a567dc171.tar.gz cwm-775ba78311768b7a944db95273822c0a567dc171.tar.xz cwm-775ba78311768b7a944db95273822c0a567dc171.zip |
cvsimport
* refs/heads/master: stray newlines Add search_print_text(), a default callback for mi->print in menu_filter(). While here, normalize the remaining search_print_* argument paramters. Consistent use of menuq_add for ssh menu. Now that dim.{x,y} are available early, use them before requiring a MotionNotify event. Set dim.{x,y} during client_init and update on resize, instead of (re)calculating only when applying hints. 'window-search' is spelled 'menu-window'; the former snuck in during the conversion('menu-window' already existed and was properlly documented); found the hard way by sthen@ while trying to convert. Fold unbinding functions into one for each, key and mouse; plugs a leak when unbinding a mouse button bound to a command. use the correct type Tame the number of 'exec' and 'path' search_match wrappers. No functional change now, though more can likely go later, losing the (paritally complete or incomplete/broken) argument completion bits. Switch ssh menu to search_match_text; like group/window/cmd menus, use only a substring match. The previous matching is only intended for the exec menus. Change 'menu-window' to display all windows; then add 'menu-window-hidden' for the previous behaviour of 'menu-window'. 'menu-window' becomes the default binding; use 'bind-mouse "1" menu-window-hidden' to restore old behaviour for those who prefer. Normalize bind function names, based on a few categories: window, group, menu and pointer. Use an additional check with lstat(2) when d_type is unknown. revert previous; upcoming changes will hopefully deal with these more naturally. Add a wrapper based upon xevent handlers around client move/resize for key and mouse bindings. Define callbacks, then default bindings. Reorganize for upcoming changes. Remove the (8) default bindings for pointer move since they conflict with default bindings for emacs, which wins; the feature remains and can be bound to whatever users wish with cwmrc(5).
Diffstat (limited to 'kbfunc.c')
-rw-r--r-- | kbfunc.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/kbfunc.c b/kbfunc.c index 5f5a163..5edb59d 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -298,12 +298,13 @@ kbfunc_menu_client(void *ctx, union arg *arg, enum xev xev) struct menu *mi; struct menu_q menuq; int m = (xev == CWM_XEV_BTN); + int all = (arg->i & CWM_MENU_WINDOW_ALL); old_cc = client_current(); TAILQ_INIT(&menuq); TAILQ_FOREACH(cc, &sc->clientq, entry) { - if (m) { + if (!all) { if (cc->flags & CLIENT_HIDDEN) menuq_add(&menuq, cc, NULL); } else @@ -390,6 +391,7 @@ kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev) struct screen_ctx *sc = ctx; char **ap, *paths[NPATHS], *path, *pathcpy; char tpath[PATH_MAX]; + struct stat sb; const char *label; DIR *dirp; struct dirent *dp; @@ -432,12 +434,13 @@ kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev) dp->d_name); if (l == -1 || l >= sizeof(tpath)) continue; - /* skip everything but regular files and symlinks */ + /* Skip everything but regular files and symlinks. */ if (dp->d_type != DT_REG && dp->d_type != DT_LNK) { - /* use an additional stat-based check in case d_type isn't supported */ - if (lstat(tpath, &sb) < 0) + /* lstat(2) in case d_type isn't supported. */ + if (lstat(tpath, &sb) == -1) continue; - if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode)) + if (!S_ISREG(sb.st_mode) && + !S_ISLNK(sb.st_mode)) continue; } if (access(tpath, X_OK) == 0) @@ -449,7 +452,7 @@ kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev) if ((mi = menu_filter(sc, &menuq, label, NULL, (CWM_MENU_DUMMY | CWM_MENU_FILE), - search_match_exec_path, NULL)) != NULL) { + search_match_exec, search_print_text)) != NULL) { if (mi->text[0] == '\0') goto out; switch (cmd) { @@ -518,13 +521,13 @@ kbfunc_menu_ssh(void *ctx, union arg *arg, enum xev xev) if (p - buf + 1 > sizeof(hostbuf)) continue; (void)strlcpy(hostbuf, buf, p - buf + 1); - menuq_add(&menuq, NULL, hostbuf); + menuq_add(&menuq, NULL, "%s", hostbuf); } free(lbuf); (void)fclose(fp); menu: if ((mi = menu_filter(sc, &menuq, "ssh", NULL, (CWM_MENU_DUMMY), - search_match_exec, NULL)) != NULL) { + search_match_text, search_print_text)) != NULL) { if (mi->text[0] == '\0') goto out; l = snprintf(path, sizeof(path), "%s -T '[ssh] %s' -e ssh %s", @@ -550,7 +553,7 @@ kbfunc_menu_client_label(void *ctx, union arg *arg, enum xev xev) /* dummy is set, so this will always return */ mi = menu_filter(cc->sc, &menuq, "label", cc->label, (CWM_MENU_DUMMY), - search_match_text, NULL); + search_match_text, search_print_text); if (!mi->abort) { free(cc->label); |