2007-04-27 11:58:48 -06:00
|
|
|
/*
|
|
|
|
* calmwm - the calm window manager
|
2008-04-15 14:24:41 -06:00
|
|
|
*
|
2007-04-27 11:58:48 -06:00
|
|
|
* Copyright (c) 2004 Martin Murray <mmurray@monkey.org>
|
|
|
|
*
|
2008-01-11 09:06:44 -07:00
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
2009-12-14 20:24:36 -07:00
|
|
|
* $Id: kbfunc.c,v 1.48 2009/12/15 03:24:36 okan Exp $
|
2007-04-27 11:58:48 -06:00
|
|
|
*/
|
|
|
|
|
2007-06-26 13:34:26 -06:00
|
|
|
#include <paths.h>
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
#include "calmwm.h"
|
|
|
|
|
2008-04-15 14:24:41 -06:00
|
|
|
#define KNOWN_HOSTS ".ssh/known_hosts"
|
|
|
|
#define HASH_MARKER "|1|"
|
2007-06-26 13:34:26 -06:00
|
|
|
|
2008-04-15 14:24:41 -06:00
|
|
|
extern int _xev_quit;
|
2008-04-07 17:47:09 -06:00
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_lower(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
|
|
|
client_lower(cc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_raise(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
|
|
|
client_raise(cc);
|
|
|
|
}
|
|
|
|
|
2008-04-16 07:47:29 -06:00
|
|
|
#define typemask (CWM_MOVE | CWM_RESIZE | CWM_PTRMOVE)
|
|
|
|
#define movemask (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
|
2007-06-27 07:28:22 -06:00
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
2007-06-27 07:28:22 -06:00
|
|
|
{
|
2008-07-11 08:21:28 -06:00
|
|
|
struct screen_ctx *sc;
|
2008-05-19 12:53:09 -06:00
|
|
|
int x, y, flags, amt;
|
|
|
|
u_int mx, my;
|
2007-06-27 07:28:22 -06:00
|
|
|
|
2009-12-07 12:45:36 -07:00
|
|
|
sc = cc->sc;
|
2007-06-27 07:28:22 -06:00
|
|
|
mx = my = 0;
|
|
|
|
|
2009-01-23 11:58:40 -07:00
|
|
|
flags = arg->i;
|
2009-02-07 14:07:00 -07:00
|
|
|
amt = Conf.mamount;
|
2007-06-27 07:28:22 -06:00
|
|
|
|
|
|
|
if (flags & CWM_BIGMOVE) {
|
|
|
|
flags -= CWM_BIGMOVE;
|
2008-05-19 12:53:09 -06:00
|
|
|
amt = amt * 10;
|
2007-06-27 07:28:22 -06:00
|
|
|
}
|
|
|
|
|
2008-04-16 07:47:29 -06:00
|
|
|
switch (flags & movemask) {
|
2007-06-27 07:28:22 -06:00
|
|
|
case CWM_UP:
|
|
|
|
my -= amt;
|
|
|
|
break;
|
2008-04-15 14:24:41 -06:00
|
|
|
case CWM_DOWN:
|
2007-06-27 07:28:22 -06:00
|
|
|
my += amt;
|
|
|
|
break;
|
|
|
|
case CWM_RIGHT:
|
|
|
|
mx += amt;
|
|
|
|
break;
|
|
|
|
case CWM_LEFT:
|
|
|
|
mx -= amt;
|
|
|
|
break;
|
|
|
|
}
|
2008-04-16 07:47:29 -06:00
|
|
|
switch (flags & typemask) {
|
|
|
|
case CWM_MOVE:
|
|
|
|
cc->geom.y += my;
|
2008-06-24 18:52:47 -06:00
|
|
|
if (cc->geom.y + cc->geom.height < 0)
|
|
|
|
cc->geom.y = -cc->geom.height;
|
2009-02-03 15:20:31 -07:00
|
|
|
if (cc->geom.y > cc->sc->ymax - 1)
|
|
|
|
cc->geom.y = cc->sc->ymax - 1;
|
2008-06-24 18:52:47 -06:00
|
|
|
|
2008-04-16 07:47:29 -06:00
|
|
|
cc->geom.x += mx;
|
2008-06-24 18:52:47 -06:00
|
|
|
if (cc->geom.x + cc->geom.width < 0)
|
|
|
|
cc->geom.x = -cc->geom.width;
|
2009-02-03 15:20:31 -07:00
|
|
|
if (cc->geom.x > cc->sc->xmax - 1)
|
|
|
|
cc->geom.x = cc->sc->xmax - 1;
|
2008-06-24 18:52:47 -06:00
|
|
|
|
2008-04-16 07:47:29 -06:00
|
|
|
client_move(cc);
|
2009-01-16 08:24:14 -07:00
|
|
|
xu_ptr_getpos(cc->win, &x, &y);
|
2008-04-16 07:47:29 -06:00
|
|
|
cc->ptr.y = y + my;
|
|
|
|
cc->ptr.x = x + mx;
|
|
|
|
client_ptrwarp(cc);
|
2007-11-13 16:08:49 -07:00
|
|
|
break;
|
2008-04-16 07:47:29 -06:00
|
|
|
case CWM_RESIZE:
|
2008-06-24 18:52:47 -06:00
|
|
|
if ((cc->geom.height += my) < 1)
|
|
|
|
cc->geom.height = 1;
|
|
|
|
if ((cc->geom.width += mx) < 1)
|
|
|
|
cc->geom.width = 1;
|
2008-04-16 07:47:29 -06:00
|
|
|
client_resize(cc);
|
|
|
|
|
2008-06-12 12:32:06 -06:00
|
|
|
/* Make sure the pointer stays within the window. */
|
2009-01-16 08:24:14 -07:00
|
|
|
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
|
2008-06-12 12:32:06 -06:00
|
|
|
if (cc->ptr.x > cc->geom.width)
|
|
|
|
cc->ptr.x = cc->geom.width - cc->bwidth;
|
|
|
|
if (cc->ptr.y > cc->geom.height)
|
|
|
|
cc->ptr.y = cc->geom.height - cc->bwidth;
|
2008-04-16 07:47:29 -06:00
|
|
|
client_ptrwarp(cc);
|
2007-11-13 16:08:49 -07:00
|
|
|
break;
|
2008-04-16 07:47:29 -06:00
|
|
|
case CWM_PTRMOVE:
|
|
|
|
if (cc) {
|
2009-01-16 08:24:14 -07:00
|
|
|
xu_ptr_getpos(cc->win, &x, &y);
|
|
|
|
xu_ptr_setpos(cc->win, x + mx, y + my);
|
2008-04-16 07:47:29 -06:00
|
|
|
} else {
|
|
|
|
xu_ptr_getpos(sc->rootwin, &x, &y);
|
|
|
|
xu_ptr_setpos(sc->rootwin, x + mx, y + my);
|
|
|
|
}
|
2007-11-13 16:08:49 -07:00
|
|
|
break;
|
2008-04-16 07:47:29 -06:00
|
|
|
default:
|
|
|
|
warnx("invalid flags passed to kbfunc_client_moveresize");
|
2007-11-13 16:08:49 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
2009-12-07 12:44:31 -07:00
|
|
|
kbfunc_client_search(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-12-10 10:16:51 -07:00
|
|
|
struct screen_ctx *sc;
|
2009-12-07 12:44:31 -07:00
|
|
|
struct client_ctx *old_cc;
|
2008-05-19 12:53:09 -06:00
|
|
|
struct menu *mi;
|
2008-07-11 08:21:28 -06:00
|
|
|
struct menu_q menuq;
|
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
sc = cc->sc;
|
2008-07-11 08:21:28 -06:00
|
|
|
old_cc = client_current();
|
2008-04-15 14:24:41 -06:00
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
TAILQ_INIT(&menuq);
|
2008-04-15 14:24:41 -06:00
|
|
|
|
2007-05-28 12:34:27 -06:00
|
|
|
TAILQ_FOREACH(cc, &Clientq, entry) {
|
2009-06-19 18:22:39 -06:00
|
|
|
mi = xcalloc(1, sizeof(*mi));
|
2007-04-27 11:58:48 -06:00
|
|
|
strlcpy(mi->text, cc->name, sizeof(mi->text));
|
|
|
|
mi->ctx = cc;
|
|
|
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
|
|
}
|
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
if ((mi = menu_filter(sc, &menuq, "window", NULL, 0,
|
2008-05-20 08:50:51 -06:00
|
|
|
search_match_client, search_print_client)) != NULL) {
|
2007-04-27 11:58:48 -06:00
|
|
|
cc = (struct client_ctx *)mi->ctx;
|
|
|
|
if (cc->flags & CLIENT_HIDDEN)
|
|
|
|
client_unhide(cc);
|
|
|
|
|
|
|
|
if (old_cc)
|
|
|
|
client_ptrsave(old_cc);
|
|
|
|
client_ptrwarp(cc);
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&menuq, mi, entry);
|
|
|
|
xfree(mi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-07 12:44:31 -07:00
|
|
|
kbfunc_menu_search(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-12-10 10:16:51 -07:00
|
|
|
struct screen_ctx *sc;
|
|
|
|
struct cmd *cmd;
|
|
|
|
struct menu *mi;
|
|
|
|
struct menu_q menuq;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
sc = cc->sc;
|
2007-04-27 11:58:48 -06:00
|
|
|
TAILQ_INIT(&menuq);
|
|
|
|
|
2007-05-28 12:34:27 -06:00
|
|
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
2009-06-19 18:22:39 -06:00
|
|
|
mi = xcalloc(1, sizeof(*mi));
|
2007-04-27 11:58:48 -06:00
|
|
|
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
|
|
|
mi->ctx = cmd;
|
|
|
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
|
|
}
|
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
if ((mi = menu_filter(sc, &menuq, "application", NULL, 0,
|
2008-05-20 08:50:51 -06:00
|
|
|
search_match_text, NULL)) != NULL)
|
2007-04-27 11:58:48 -06:00
|
|
|
u_spawn(((struct cmd *)mi->ctx)->image);
|
|
|
|
|
|
|
|
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&menuq, mi, entry);
|
|
|
|
xfree(mi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-07 12:44:31 -07:00
|
|
|
kbfunc_client_cycle(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2008-07-11 08:21:28 -06:00
|
|
|
struct screen_ctx *sc;
|
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
sc = cc->sc;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2008-05-19 09:17:50 -06:00
|
|
|
/* XXX for X apps that ignore events */
|
|
|
|
XGrabKeyboard(X_Dpy, sc->rootwin, True,
|
|
|
|
GrabModeAsync, GrabModeAsync, CurrentTime);
|
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
client_cycle(sc, arg->i);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_hide(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
|
|
|
client_hide(cc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_cmdexec(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-01-23 11:58:40 -07:00
|
|
|
u_spawn(arg->c);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_term(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2007-05-28 12:34:27 -06:00
|
|
|
u_spawn(Conf.termpath);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_lock(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2007-05-28 12:34:27 -06:00
|
|
|
u_spawn(Conf.lockpath);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2007-04-27 12:08:14 -06:00
|
|
|
void
|
2009-12-07 12:44:31 -07:00
|
|
|
kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
2007-04-27 12:08:14 -06:00
|
|
|
{
|
2007-09-06 00:01:14 -06:00
|
|
|
#define NPATHS 256
|
2009-12-10 10:16:51 -07:00
|
|
|
struct screen_ctx *sc;
|
|
|
|
char **ap, *paths[NPATHS], *path, *pathcpy, *label;
|
|
|
|
char tpath[MAXPATHLEN];
|
|
|
|
DIR *dirp;
|
|
|
|
struct dirent *dp;
|
|
|
|
struct menu *mi;
|
|
|
|
struct menu_q menuq;
|
|
|
|
int l, i, cmd = arg->i;
|
2007-11-28 09:35:52 -07:00
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
sc = cc->sc;
|
2008-04-15 14:24:41 -06:00
|
|
|
switch (cmd) {
|
2007-11-28 09:35:52 -07:00
|
|
|
case CWM_EXEC_PROGRAM:
|
|
|
|
label = "exec";
|
|
|
|
break;
|
|
|
|
case CWM_EXEC_WM:
|
|
|
|
label = "wm";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err(1, "kbfunc_exec: invalid cmd %d", cmd);
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
2007-06-26 13:34:26 -06:00
|
|
|
|
|
|
|
TAILQ_INIT(&menuq);
|
2008-04-05 15:09:19 -06:00
|
|
|
|
|
|
|
if ((path = getenv("PATH")) == NULL)
|
|
|
|
path = _PATH_DEFPATH;
|
|
|
|
pathcpy = path = xstrdup(path);
|
|
|
|
|
2007-09-06 00:01:14 -06:00
|
|
|
for (ap = paths; ap < &paths[NPATHS - 1] &&
|
2008-04-05 15:09:19 -06:00
|
|
|
(*ap = strsep(&pathcpy, ":")) != NULL;) {
|
2007-06-26 13:34:26 -06:00
|
|
|
if (**ap != '\0')
|
|
|
|
ap++;
|
|
|
|
}
|
|
|
|
*ap = NULL;
|
2007-09-06 00:01:14 -06:00
|
|
|
for (i = 0; i < NPATHS && paths[i] != NULL; i++) {
|
2007-06-26 13:34:26 -06:00
|
|
|
if ((dirp = opendir(paths[i])) == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
while ((dp = readdir(dirp)) != NULL) {
|
|
|
|
/* skip everything but regular files and symlinks */
|
|
|
|
if (dp->d_type != DT_REG && dp->d_type != DT_LNK)
|
|
|
|
continue;
|
|
|
|
memset(tpath, '\0', sizeof(tpath));
|
|
|
|
l = snprintf(tpath, sizeof(tpath), "%s/%s", paths[i],
|
|
|
|
dp->d_name);
|
|
|
|
/* check for truncation etc */
|
|
|
|
if (l == -1 || l >= (int)sizeof(tpath))
|
|
|
|
continue;
|
2009-08-24 20:02:59 -06:00
|
|
|
if (access(tpath, X_OK) == 0) {
|
|
|
|
mi = xcalloc(1, sizeof(*mi));
|
|
|
|
strlcpy(mi->text, dp->d_name, sizeof(mi->text));
|
|
|
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
2008-03-22 09:09:45 -06:00
|
|
|
}
|
2007-06-26 13:34:26 -06:00
|
|
|
}
|
2008-07-11 08:21:28 -06:00
|
|
|
(void)closedir(dirp);
|
2007-06-26 13:34:26 -06:00
|
|
|
}
|
2008-04-08 11:38:27 -06:00
|
|
|
xfree(path);
|
2007-06-26 13:34:26 -06:00
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
if ((mi = menu_filter(sc, &menuq, label, NULL, 1,
|
2008-05-20 08:50:51 -06:00
|
|
|
search_match_exec, NULL)) != NULL) {
|
2009-09-05 10:06:15 -06:00
|
|
|
if (mi->text[0] == '\0')
|
|
|
|
goto out;
|
2007-11-28 09:35:52 -07:00
|
|
|
switch (cmd) {
|
|
|
|
case CWM_EXEC_PROGRAM:
|
|
|
|
u_spawn(mi->text);
|
|
|
|
break;
|
|
|
|
case CWM_EXEC_WM:
|
2008-04-15 15:20:56 -06:00
|
|
|
u_exec(mi->text);
|
|
|
|
warn("%s", mi->text);
|
2007-11-28 09:35:52 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err(1, "kb_func: egad, cmd changed value!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-09-05 10:06:15 -06:00
|
|
|
out:
|
2007-06-26 13:34:26 -06:00
|
|
|
if (mi != NULL && mi->dummy)
|
|
|
|
xfree(mi);
|
|
|
|
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&menuq, mi, entry);
|
|
|
|
xfree(mi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-07 12:44:31 -07:00
|
|
|
kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
2007-06-26 13:34:26 -06:00
|
|
|
{
|
2009-12-10 10:16:51 -07:00
|
|
|
struct screen_ctx *sc;
|
|
|
|
struct menu *mi;
|
|
|
|
struct menu_q menuq;
|
|
|
|
FILE *fp;
|
|
|
|
char *buf, *lbuf, *p, *home;
|
|
|
|
char hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN];
|
|
|
|
char cmd[256];
|
|
|
|
int l;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
sc = cc->sc;
|
2007-06-26 13:34:26 -06:00
|
|
|
|
|
|
|
if ((home = getenv("HOME")) == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
l = snprintf(filename, sizeof(filename), "%s/%s", home, KNOWN_HOSTS);
|
|
|
|
if (l == -1 || l >= sizeof(filename))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((fp = fopen(filename, "r")) == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TAILQ_INIT(&menuq);
|
|
|
|
lbuf = NULL;
|
|
|
|
while ((buf = fgetln(fp, &len))) {
|
|
|
|
if (buf[len - 1] == '\n')
|
|
|
|
buf[len - 1] = '\0';
|
|
|
|
else {
|
|
|
|
/* EOF without EOL, copy and add the NUL */
|
|
|
|
lbuf = xmalloc(len + 1);
|
|
|
|
memcpy(lbuf, buf, len);
|
|
|
|
lbuf[len] = '\0';
|
|
|
|
buf = lbuf;
|
|
|
|
}
|
|
|
|
/* skip hashed hosts */
|
|
|
|
if (strncmp(buf, HASH_MARKER, strlen(HASH_MARKER)) == 0)
|
|
|
|
continue;
|
|
|
|
for (p = buf; *p != ',' && *p != ' ' && p != buf + len; p++) {
|
|
|
|
/* do nothing */
|
|
|
|
}
|
|
|
|
/* ignore badness */
|
|
|
|
if (p - buf + 1 > sizeof(hostbuf))
|
|
|
|
continue;
|
|
|
|
(void) strlcpy(hostbuf, buf, p - buf + 1);
|
2009-06-19 18:22:39 -06:00
|
|
|
mi = xcalloc(1, sizeof(*mi));
|
2007-06-26 13:34:26 -06:00
|
|
|
(void) strlcpy(mi->text, hostbuf, sizeof(mi->text));
|
|
|
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
|
|
}
|
|
|
|
xfree(lbuf);
|
|
|
|
fclose(fp);
|
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
if ((mi = menu_filter(sc, &menuq, "ssh", NULL, 1,
|
2008-05-20 08:50:51 -06:00
|
|
|
search_match_exec, NULL)) != NULL) {
|
2009-09-05 10:06:15 -06:00
|
|
|
if (mi->text[0] == '\0')
|
|
|
|
goto out;
|
2007-06-26 13:34:26 -06:00
|
|
|
l = snprintf(cmd, sizeof(cmd), "%s -e ssh %s", Conf.termpath,
|
|
|
|
mi->text);
|
|
|
|
if (l != -1 && l < sizeof(cmd))
|
|
|
|
u_spawn(cmd);
|
|
|
|
}
|
2009-09-05 10:06:15 -06:00
|
|
|
out:
|
2007-06-26 13:34:26 -06:00
|
|
|
if (mi != NULL && mi->dummy)
|
|
|
|
xfree(mi);
|
|
|
|
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&menuq, mi, entry);
|
|
|
|
xfree(mi);
|
|
|
|
}
|
2007-04-27 12:08:14 -06:00
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_label(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2008-05-20 08:50:51 -06:00
|
|
|
struct menu *mi;
|
|
|
|
struct menu_q menuq;
|
2008-07-11 08:21:28 -06:00
|
|
|
char *current;
|
2008-05-20 08:50:51 -06:00
|
|
|
|
|
|
|
TAILQ_INIT(&menuq);
|
2009-11-28 10:52:12 -07:00
|
|
|
|
2009-06-19 18:55:41 -06:00
|
|
|
current = cc->label;
|
2008-05-20 08:50:51 -06:00
|
|
|
|
2009-12-10 10:16:51 -07:00
|
|
|
if ((mi = menu_filter(cc->sc, &menuq, "label", current, 1,
|
2008-05-20 08:50:51 -06:00
|
|
|
search_match_text, NULL)) != NULL) {
|
|
|
|
if (cc->label != NULL)
|
|
|
|
xfree(cc->label);
|
|
|
|
cc->label = xstrdup(mi->text);
|
|
|
|
xfree(mi);
|
|
|
|
}
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_delete(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
|
|
|
client_send_delete(cc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_group(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-12-10 10:16:51 -07:00
|
|
|
group_hidetoggle(cc->sc, KBTOGROUP(arg->i));
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2009-05-14 10:24:04 -06:00
|
|
|
void
|
|
|
|
kbfunc_client_grouponly(struct client_ctx *cc, union arg *arg)
|
|
|
|
{
|
2009-12-10 10:16:51 -07:00
|
|
|
group_only(cc->sc, KBTOGROUP(arg->i));
|
2009-05-14 10:24:04 -06:00
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_cyclegroup(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-12-10 10:16:51 -07:00
|
|
|
group_cycle(cc->sc, arg->i);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_nogroup(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-12-10 10:16:51 -07:00
|
|
|
group_alltoggle(cc->sc);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2008-05-19 06:56:58 -06:00
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_grouptoggle(struct client_ctx *cc, union arg *arg)
|
2008-05-19 06:56:58 -06:00
|
|
|
{
|
|
|
|
/* XXX for stupid X apps like xpdf and gvim */
|
2009-01-16 08:24:14 -07:00
|
|
|
XGrabKeyboard(X_Dpy, cc->win, True,
|
2008-05-19 06:56:58 -06:00
|
|
|
GrabModeAsync, GrabModeAsync, CurrentTime);
|
|
|
|
|
|
|
|
group_sticky_toggle_enter(cc);
|
|
|
|
}
|
|
|
|
|
2009-05-17 11:04:59 -06:00
|
|
|
void
|
|
|
|
kbfunc_client_movetogroup(struct client_ctx *cc, union arg *arg)
|
|
|
|
{
|
|
|
|
group_movetogroup(cc, KBTOGROUP(arg->i));
|
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_maximize(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
|
|
|
client_maximize(cc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_client_vmaximize(struct client_ctx *cc, union arg *arg)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
|
|
|
client_vertmaximize(cc);
|
|
|
|
}
|
2008-04-07 17:47:09 -06:00
|
|
|
|
2009-08-24 17:54:41 -06:00
|
|
|
void
|
|
|
|
kbfunc_client_hmaximize(struct client_ctx *cc, union arg *arg)
|
|
|
|
{
|
|
|
|
client_horizmaximize(cc);
|
|
|
|
}
|
|
|
|
|
2008-04-07 17:47:09 -06:00
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_quit_wm(struct client_ctx *cc, union arg *arg)
|
2008-04-07 17:47:09 -06:00
|
|
|
{
|
|
|
|
_xev_quit = 1;
|
|
|
|
}
|
2008-07-11 09:18:29 -06:00
|
|
|
|
|
|
|
void
|
2009-01-23 11:58:40 -07:00
|
|
|
kbfunc_reload(struct client_ctx *cc, union arg *arg)
|
2008-07-11 09:18:29 -06:00
|
|
|
{
|
|
|
|
conf_reload(&Conf);
|
|
|
|
}
|