2007-04-27 11:58:48 -06:00
|
|
|
/*
|
|
|
|
* calmwm - the calm window manager
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@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.
|
|
|
|
*
|
2014-09-07 13:27:30 -06:00
|
|
|
* $OpenBSD: conf.c,v 1.179 2014/09/07 19:27:30 okan Exp $
|
2007-04-27 11:58:48 -06:00
|
|
|
*/
|
|
|
|
|
2009-12-14 21:10:42 -07:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
2012-11-08 20:52:02 -07:00
|
|
|
#include <stdio.h>
|
2009-12-14 21:10:42 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
#include "calmwm.h"
|
|
|
|
|
2014-01-03 08:29:06 -07:00
|
|
|
static const char *conf_bind_getmask(const char *, unsigned int *);
|
2014-01-29 11:43:27 -07:00
|
|
|
static void conf_cmd_remove(struct conf *, const char *);
|
2014-01-29 14:13:52 -07:00
|
|
|
static void conf_unbind_kbd(struct conf *, struct binding *);
|
|
|
|
static void conf_unbind_mouse(struct conf *, struct binding *);
|
2009-06-26 06:21:58 -06:00
|
|
|
|
2014-01-29 11:34:22 -07:00
|
|
|
int
|
2014-01-20 14:34:32 -07:00
|
|
|
conf_cmd_add(struct conf *c, const char *name, const char *path)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2014-01-29 11:34:22 -07:00
|
|
|
struct cmd *cmd;
|
|
|
|
|
2014-09-06 10:14:35 -06:00
|
|
|
cmd = xmalloc(sizeof(*cmd));
|
2014-01-29 11:43:27 -07:00
|
|
|
|
2014-09-06 10:14:35 -06:00
|
|
|
cmd->name = xstrdup(name);
|
|
|
|
if (strlcpy(cmd->path, path, sizeof(cmd->path)) >= sizeof(cmd->path)) {
|
|
|
|
free(cmd->name);
|
|
|
|
free(cmd);
|
|
|
|
return(0);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
2014-09-06 10:14:35 -06:00
|
|
|
|
|
|
|
conf_cmd_remove(c, name);
|
|
|
|
|
|
|
|
TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
|
|
|
|
return(1);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2014-01-29 11:43:27 -07:00
|
|
|
static void
|
|
|
|
conf_cmd_remove(struct conf *c, const char *name)
|
|
|
|
{
|
|
|
|
struct cmd *cmd = NULL, *cmdnxt;
|
|
|
|
|
|
|
|
TAILQ_FOREACH_SAFE(cmd, &c->cmdq, entry, cmdnxt) {
|
|
|
|
if (strcmp(cmd->name, name) == 0) {
|
|
|
|
TAILQ_REMOVE(&c->cmdq, cmd, entry);
|
2014-02-02 08:46:05 -07:00
|
|
|
free(cmd->name);
|
2014-01-29 11:43:27 -07:00
|
|
|
free(cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-17 07:30:38 -06:00
|
|
|
void
|
2014-08-20 09:15:29 -06:00
|
|
|
conf_autogroup(struct conf *c, int num, const char *val)
|
2013-04-17 07:30:38 -06:00
|
|
|
{
|
|
|
|
struct autogroupwin *aw;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
aw = xcalloc(1, sizeof(*aw));
|
|
|
|
|
|
|
|
if ((p = strchr(val, ',')) == NULL) {
|
|
|
|
aw->name = NULL;
|
|
|
|
aw->class = xstrdup(val);
|
|
|
|
} else {
|
|
|
|
*(p++) = '\0';
|
|
|
|
aw->name = xstrdup(val);
|
|
|
|
aw->class = xstrdup(p);
|
|
|
|
}
|
2014-08-20 09:15:29 -06:00
|
|
|
aw->num = num;
|
2013-04-17 07:30:38 -06:00
|
|
|
|
|
|
|
TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry);
|
|
|
|
}
|
|
|
|
|
2014-01-30 15:17:22 -07:00
|
|
|
void
|
|
|
|
conf_ignore(struct conf *c, const char *name)
|
2013-04-17 07:30:38 -06:00
|
|
|
{
|
2014-01-30 15:17:22 -07:00
|
|
|
struct winname *wn;
|
2013-04-17 07:30:38 -06:00
|
|
|
|
2014-01-30 15:17:22 -07:00
|
|
|
wn = xcalloc(1, sizeof(*wn));
|
|
|
|
wn->name = xstrdup(name);
|
|
|
|
TAILQ_INSERT_TAIL(&c->ignoreq, wn, entry);
|
2013-04-17 07:30:38 -06:00
|
|
|
}
|
|
|
|
|
2014-01-21 08:42:44 -07:00
|
|
|
static const char *color_binds[] = {
|
2013-01-04 09:23:51 -07:00
|
|
|
"#CCCCCC", /* CWM_COLOR_BORDER_ACTIVE */
|
|
|
|
"#666666", /* CWM_COLOR_BORDER_INACTIVE */
|
2013-12-13 07:40:52 -07:00
|
|
|
"#FC8814", /* CWM_COLOR_BORDER_URGENCY */
|
2013-01-04 09:23:51 -07:00
|
|
|
"blue", /* CWM_COLOR_BORDER_GROUP */
|
|
|
|
"red", /* CWM_COLOR_BORDER_UNGROUP */
|
2013-05-19 17:09:59 -06:00
|
|
|
"black", /* CWM_COLOR_MENU_FG */
|
|
|
|
"white", /* CWM_COLOR_MENU_BG */
|
|
|
|
"black", /* CWM_COLOR_MENU_FONT */
|
|
|
|
"", /* CWM_COLOR_MENU_FONT_SEL */
|
2011-09-03 03:25:39 -06:00
|
|
|
};
|
|
|
|
|
2009-05-17 17:40:57 -06:00
|
|
|
void
|
2013-05-11 15:46:27 -06:00
|
|
|
conf_screen(struct screen_ctx *sc)
|
2009-05-17 17:40:57 -06:00
|
|
|
{
|
2014-01-03 08:29:06 -07:00
|
|
|
unsigned int i;
|
2013-07-10 08:11:42 -06:00
|
|
|
XftColor xc;
|
2014-02-02 09:29:04 -07:00
|
|
|
Colormap colormap = DefaultColormap(X_Dpy, sc->which);
|
|
|
|
Visual *visual = DefaultVisual(X_Dpy, sc->which);
|
2009-05-17 17:40:57 -06:00
|
|
|
|
2013-05-11 15:46:27 -06:00
|
|
|
sc->gap = Conf.gap;
|
2013-11-27 11:34:34 -07:00
|
|
|
sc->snapdist = Conf.snapdist;
|
2013-05-11 15:46:27 -06:00
|
|
|
|
2013-10-07 07:40:26 -06:00
|
|
|
sc->xftfont = XftFontOpenXlfd(X_Dpy, sc->which, Conf.font);
|
|
|
|
if (sc->xftfont == NULL) {
|
|
|
|
sc->xftfont = XftFontOpenName(X_Dpy, sc->which, Conf.font);
|
|
|
|
if (sc->xftfont == NULL)
|
|
|
|
errx(1, "XftFontOpenName");
|
|
|
|
}
|
2013-05-11 15:46:27 -06:00
|
|
|
|
2013-06-23 11:57:50 -06:00
|
|
|
for (i = 0; i < nitems(color_binds); i++) {
|
|
|
|
if (i == CWM_COLOR_MENU_FONT_SEL && *Conf.color[i] == '\0') {
|
|
|
|
xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_BG],
|
|
|
|
sc->xftcolor[CWM_COLOR_MENU_FG], &xc);
|
|
|
|
xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_FONT], xc, &xc);
|
2014-02-02 09:29:04 -07:00
|
|
|
if (!XftColorAllocValue(X_Dpy, visual, colormap,
|
2013-06-23 11:57:50 -06:00
|
|
|
&xc.color, &sc->xftcolor[CWM_COLOR_MENU_FONT_SEL]))
|
2014-01-23 10:13:38 -07:00
|
|
|
warnx("XftColorAllocValue: %s", Conf.color[i]);
|
2013-05-19 17:09:59 -06:00
|
|
|
break;
|
2013-06-23 11:57:50 -06:00
|
|
|
}
|
2014-02-02 09:29:04 -07:00
|
|
|
if (XftColorAllocName(X_Dpy, visual, colormap,
|
2013-05-19 17:09:59 -06:00
|
|
|
Conf.color[i], &xc)) {
|
|
|
|
sc->xftcolor[i] = xc;
|
2014-02-02 09:29:04 -07:00
|
|
|
XftColorFree(X_Dpy, visual, colormap, &xc);
|
2013-05-19 17:09:59 -06:00
|
|
|
} else {
|
2014-01-23 10:13:38 -07:00
|
|
|
warnx("XftColorAllocName: %s", Conf.color[i]);
|
2014-02-02 09:29:04 -07:00
|
|
|
XftColorAllocName(X_Dpy, visual, colormap,
|
2013-05-19 17:09:59 -06:00
|
|
|
color_binds[i], &sc->xftcolor[i]);
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 11:57:50 -06:00
|
|
|
|
2013-05-20 14:21:04 -06:00
|
|
|
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1,
|
|
|
|
Conf.bwidth,
|
|
|
|
sc->xftcolor[CWM_COLOR_MENU_FG].pixel,
|
|
|
|
sc->xftcolor[CWM_COLOR_MENU_BG].pixel);
|
|
|
|
|
2014-02-02 09:29:04 -07:00
|
|
|
sc->xftdraw = XftDrawCreate(X_Dpy, sc->menuwin, visual, colormap);
|
2013-05-20 14:21:04 -06:00
|
|
|
if (sc->xftdraw == NULL)
|
|
|
|
errx(1, "XftDrawCreate");
|
2013-05-22 10:54:09 -06:00
|
|
|
|
2013-05-23 10:52:39 -06:00
|
|
|
conf_grab_kbd(sc->rootwin);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2014-01-21 08:42:44 -07:00
|
|
|
static const struct {
|
|
|
|
const char *key;
|
|
|
|
const char *func;
|
2013-07-08 10:32:51 -06:00
|
|
|
} kbd_binds[] = {
|
2009-08-24 19:42:05 -06:00
|
|
|
{ "CM-Return", "terminal" },
|
|
|
|
{ "CM-Delete", "lock" },
|
|
|
|
{ "M-question", "exec" },
|
|
|
|
{ "CM-w", "exec_wm" },
|
|
|
|
{ "M-period", "ssh" },
|
|
|
|
{ "M-Return", "hide" },
|
|
|
|
{ "M-Down", "lower" },
|
|
|
|
{ "M-Up", "raise" },
|
|
|
|
{ "M-slash", "search" },
|
|
|
|
{ "C-slash", "menusearch" },
|
|
|
|
{ "M-Tab", "cycle" },
|
|
|
|
{ "MS-Tab", "rcycle" },
|
|
|
|
{ "CM-n", "label" },
|
|
|
|
{ "CM-x", "delete" },
|
|
|
|
{ "CM-0", "nogroup" },
|
|
|
|
{ "CM-1", "group1" },
|
|
|
|
{ "CM-2", "group2" },
|
|
|
|
{ "CM-3", "group3" },
|
|
|
|
{ "CM-4", "group4" },
|
|
|
|
{ "CM-5", "group5" },
|
|
|
|
{ "CM-6", "group6" },
|
|
|
|
{ "CM-7", "group7" },
|
|
|
|
{ "CM-8", "group8" },
|
|
|
|
{ "CM-9", "group9" },
|
|
|
|
{ "M-Right", "cyclegroup" },
|
|
|
|
{ "M-Left", "rcyclegroup" },
|
|
|
|
{ "CM-g", "grouptoggle" },
|
2013-12-16 12:02:17 -07:00
|
|
|
{ "CM-f", "fullscreen" },
|
|
|
|
{ "CM-m", "maximize" },
|
2014-08-25 06:49:19 -06:00
|
|
|
{ "CM-s", "sticky" },
|
2009-08-24 19:42:05 -06:00
|
|
|
{ "CM-equal", "vmaximize" },
|
|
|
|
{ "CMS-equal", "hmaximize" },
|
2011-05-07 11:15:37 -06:00
|
|
|
{ "CMS-f", "freeze" },
|
2012-10-31 13:30:19 -06:00
|
|
|
{ "CMS-r", "restart" },
|
2009-08-24 19:42:05 -06:00
|
|
|
{ "CMS-q", "quit" },
|
|
|
|
{ "M-h", "moveleft" },
|
|
|
|
{ "M-j", "movedown" },
|
|
|
|
{ "M-k", "moveup" },
|
|
|
|
{ "M-l", "moveright" },
|
|
|
|
{ "M-H", "bigmoveleft" },
|
|
|
|
{ "M-J", "bigmovedown" },
|
|
|
|
{ "M-K", "bigmoveup" },
|
|
|
|
{ "M-L", "bigmoveright" },
|
|
|
|
{ "CM-h", "resizeleft" },
|
|
|
|
{ "CM-j", "resizedown" },
|
|
|
|
{ "CM-k", "resizeup" },
|
|
|
|
{ "CM-l", "resizeright" },
|
|
|
|
{ "CM-H", "bigresizeleft" },
|
|
|
|
{ "CM-J", "bigresizedown" },
|
|
|
|
{ "CM-K", "bigresizeup" },
|
|
|
|
{ "CM-L", "bigresizeright" },
|
|
|
|
{ "C-Left", "ptrmoveleft" },
|
|
|
|
{ "C-Down", "ptrmovedown" },
|
|
|
|
{ "C-Up", "ptrmoveup" },
|
|
|
|
{ "C-Right", "ptrmoveright" },
|
|
|
|
{ "CS-Left", "bigptrmoveleft" },
|
|
|
|
{ "CS-Down", "bigptrmovedown" },
|
|
|
|
{ "CS-Up", "bigptrmoveup" },
|
|
|
|
{ "CS-Right", "bigptrmoveright" },
|
|
|
|
},
|
2013-07-08 10:32:51 -06:00
|
|
|
mouse_binds[] = {
|
2009-08-24 19:42:05 -06:00
|
|
|
{ "1", "menu_unhide" },
|
|
|
|
{ "2", "menu_group" },
|
|
|
|
{ "3", "menu_cmd" },
|
|
|
|
{ "M-1", "window_move" },
|
|
|
|
{ "CM-1", "window_grouptoggle" },
|
|
|
|
{ "M-2", "window_resize" },
|
|
|
|
{ "M-3", "window_lower" },
|
|
|
|
{ "CMS-3", "window_hide" },
|
|
|
|
};
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
2008-03-23 09:09:21 -06:00
|
|
|
conf_init(struct conf *c)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2014-01-03 08:29:06 -07:00
|
|
|
unsigned int i;
|
2009-08-24 19:42:05 -06:00
|
|
|
|
2009-01-21 08:04:38 -07:00
|
|
|
c->bwidth = CONF_BWIDTH;
|
2009-02-07 14:07:00 -07:00
|
|
|
c->mamount = CONF_MAMOUNT;
|
2011-06-24 00:06:24 -06:00
|
|
|
c->snapdist = CONF_SNAPDIST;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2008-03-23 09:09:21 -06:00
|
|
|
TAILQ_INIT(&c->ignoreq);
|
|
|
|
TAILQ_INIT(&c->cmdq);
|
2008-04-15 14:24:41 -06:00
|
|
|
TAILQ_INIT(&c->keybindingq);
|
2008-03-23 09:09:21 -06:00
|
|
|
TAILQ_INIT(&c->autogroupq);
|
2008-06-14 15:48:54 -06:00
|
|
|
TAILQ_INIT(&c->mousebindingq);
|
2007-11-19 15:18:16 -07:00
|
|
|
|
2013-07-08 10:32:51 -06:00
|
|
|
for (i = 0; i < nitems(kbd_binds); i++)
|
|
|
|
conf_bind_kbd(c, kbd_binds[i].key, kbd_binds[i].func);
|
2009-08-24 19:42:05 -06:00
|
|
|
|
2013-07-08 10:32:51 -06:00
|
|
|
for (i = 0; i < nitems(mouse_binds); i++)
|
|
|
|
conf_bind_mouse(c, mouse_binds[i].key, mouse_binds[i].func);
|
2008-06-14 15:48:54 -06:00
|
|
|
|
2011-09-03 03:25:39 -06:00
|
|
|
for (i = 0; i < nitems(color_binds); i++)
|
2013-01-04 09:23:04 -07:00
|
|
|
c->color[i] = xstrdup(color_binds[i]);
|
2011-09-03 03:25:39 -06:00
|
|
|
|
2014-01-29 11:34:22 -07:00
|
|
|
conf_cmd_add(c, "lock", "xlock");
|
|
|
|
conf_cmd_add(c, "term", "xterm");
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2012-12-17 16:54:57 -07:00
|
|
|
(void)snprintf(c->known_hosts, sizeof(c->known_hosts), "%s/%s",
|
|
|
|
homedir, ".ssh/known_hosts");
|
|
|
|
|
2011-09-03 03:17:16 -06:00
|
|
|
c->font = xstrdup(CONF_FONT);
|
2008-03-23 09:09:21 -06:00
|
|
|
}
|
|
|
|
|
2009-01-23 12:00:59 -07:00
|
|
|
void
|
|
|
|
conf_clear(struct conf *c)
|
|
|
|
{
|
2014-01-30 08:43:53 -07:00
|
|
|
struct autogroupwin *aw;
|
2014-01-29 14:13:52 -07:00
|
|
|
struct binding *kb, *mb;
|
2014-01-30 15:17:22 -07:00
|
|
|
struct winname *wn;
|
2009-01-23 12:00:59 -07:00
|
|
|
struct cmd *cmd;
|
2009-05-17 17:40:57 -06:00
|
|
|
int i;
|
2009-01-23 12:00:59 -07:00
|
|
|
|
|
|
|
while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&c->cmdq, cmd, entry);
|
2014-02-02 08:46:05 -07:00
|
|
|
free(cmd->name);
|
2012-11-07 13:34:39 -07:00
|
|
|
free(cmd);
|
2009-01-23 12:00:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
while ((kb = TAILQ_FIRST(&c->keybindingq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&c->keybindingq, kb, entry);
|
2012-11-07 13:34:39 -07:00
|
|
|
free(kb);
|
2009-01-23 12:00:59 -07:00
|
|
|
}
|
|
|
|
|
2014-01-30 08:43:53 -07:00
|
|
|
while ((aw = TAILQ_FIRST(&c->autogroupq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&c->autogroupq, aw, entry);
|
|
|
|
free(aw->class);
|
|
|
|
free(aw->name);
|
|
|
|
free(aw);
|
2009-01-23 12:00:59 -07:00
|
|
|
}
|
|
|
|
|
2014-01-30 15:17:22 -07:00
|
|
|
while ((wn = TAILQ_FIRST(&c->ignoreq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&c->ignoreq, wn, entry);
|
2014-04-21 06:52:14 -06:00
|
|
|
free(wn->name);
|
2014-01-30 15:17:22 -07:00
|
|
|
free(wn);
|
2009-01-23 12:00:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
while ((mb = TAILQ_FIRST(&c->mousebindingq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&c->mousebindingq, mb, entry);
|
2012-11-07 13:34:39 -07:00
|
|
|
free(mb);
|
2009-01-23 12:00:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-16 08:04:44 -06:00
|
|
|
for (i = 0; i < CWM_COLOR_NITEMS; i++)
|
2013-01-04 09:23:04 -07:00
|
|
|
free(c->color[i]);
|
2009-05-17 17:40:57 -06:00
|
|
|
|
2012-11-07 13:34:39 -07:00
|
|
|
free(c->font);
|
2009-01-23 12:00:59 -07:00
|
|
|
}
|
|
|
|
|
2008-05-18 13:43:50 -06:00
|
|
|
void
|
|
|
|
conf_client(struct client_ctx *cc)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2014-01-30 15:17:22 -07:00
|
|
|
struct winname *wn;
|
2008-05-18 13:43:50 -06:00
|
|
|
int ignore = 0;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2014-01-30 15:17:22 -07:00
|
|
|
TAILQ_FOREACH(wn, &Conf.ignoreq, entry) {
|
|
|
|
if (strncasecmp(wn->name, cc->name, strlen(wn->name)) == 0) {
|
2009-05-29 18:30:27 -06:00
|
|
|
ignore = 1;
|
|
|
|
break;
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
2009-05-29 18:30:27 -06:00
|
|
|
}
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2009-01-21 08:04:38 -07:00
|
|
|
cc->bwidth = ignore ? 0 : Conf.bwidth;
|
2008-05-18 13:43:50 -06:00
|
|
|
cc->flags |= ignore ? CLIENT_IGNORE : 0;
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2014-01-21 08:42:44 -07:00
|
|
|
static const struct {
|
|
|
|
const char *tag;
|
2009-01-23 11:58:40 -07:00
|
|
|
void (*handler)(struct client_ctx *, union arg *);
|
|
|
|
int flags;
|
|
|
|
union arg argument;
|
2014-08-24 09:49:58 -06:00
|
|
|
} name_to_func[] = {
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "lower", kbfunc_client_lower, CWM_WIN, {0} },
|
|
|
|
{ "raise", kbfunc_client_raise, CWM_WIN, {0} },
|
2009-01-23 11:58:40 -07:00
|
|
|
{ "search", kbfunc_client_search, 0, {0} },
|
2014-01-29 15:30:00 -07:00
|
|
|
{ "menusearch", kbfunc_menu_cmd, 0, {0} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "hide", kbfunc_client_hide, CWM_WIN, {0} },
|
2009-01-23 11:58:40 -07:00
|
|
|
{ "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} },
|
|
|
|
{ "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "label", kbfunc_client_label, CWM_WIN, {0} },
|
|
|
|
{ "delete", kbfunc_client_delete, CWM_WIN, {0} },
|
2009-01-23 11:58:40 -07:00
|
|
|
{ "group1", kbfunc_client_group, 0, {.i = 1} },
|
|
|
|
{ "group2", kbfunc_client_group, 0, {.i = 2} },
|
|
|
|
{ "group3", kbfunc_client_group, 0, {.i = 3} },
|
|
|
|
{ "group4", kbfunc_client_group, 0, {.i = 4} },
|
|
|
|
{ "group5", kbfunc_client_group, 0, {.i = 5} },
|
|
|
|
{ "group6", kbfunc_client_group, 0, {.i = 6} },
|
|
|
|
{ "group7", kbfunc_client_group, 0, {.i = 7} },
|
|
|
|
{ "group8", kbfunc_client_group, 0, {.i = 8} },
|
|
|
|
{ "group9", kbfunc_client_group, 0, {.i = 9} },
|
2009-05-14 10:24:04 -06:00
|
|
|
{ "grouponly1", kbfunc_client_grouponly, 0, {.i = 1} },
|
|
|
|
{ "grouponly2", kbfunc_client_grouponly, 0, {.i = 2} },
|
|
|
|
{ "grouponly3", kbfunc_client_grouponly, 0, {.i = 3} },
|
|
|
|
{ "grouponly4", kbfunc_client_grouponly, 0, {.i = 4} },
|
|
|
|
{ "grouponly5", kbfunc_client_grouponly, 0, {.i = 5} },
|
|
|
|
{ "grouponly6", kbfunc_client_grouponly, 0, {.i = 6} },
|
|
|
|
{ "grouponly7", kbfunc_client_grouponly, 0, {.i = 7} },
|
|
|
|
{ "grouponly8", kbfunc_client_grouponly, 0, {.i = 8} },
|
|
|
|
{ "grouponly9", kbfunc_client_grouponly, 0, {.i = 9} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "movetogroup1", kbfunc_client_movetogroup, CWM_WIN, {.i = 1} },
|
|
|
|
{ "movetogroup2", kbfunc_client_movetogroup, CWM_WIN, {.i = 2} },
|
|
|
|
{ "movetogroup3", kbfunc_client_movetogroup, CWM_WIN, {.i = 3} },
|
|
|
|
{ "movetogroup4", kbfunc_client_movetogroup, CWM_WIN, {.i = 4} },
|
|
|
|
{ "movetogroup5", kbfunc_client_movetogroup, CWM_WIN, {.i = 5} },
|
|
|
|
{ "movetogroup6", kbfunc_client_movetogroup, CWM_WIN, {.i = 6} },
|
|
|
|
{ "movetogroup7", kbfunc_client_movetogroup, CWM_WIN, {.i = 7} },
|
|
|
|
{ "movetogroup8", kbfunc_client_movetogroup, CWM_WIN, {.i = 8} },
|
|
|
|
{ "movetogroup9", kbfunc_client_movetogroup, CWM_WIN, {.i = 9} },
|
2009-01-23 11:58:40 -07:00
|
|
|
{ "nogroup", kbfunc_client_nogroup, 0, {0} },
|
2011-06-23 23:30:42 -06:00
|
|
|
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
|
|
|
|
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "cycleingroup", kbfunc_client_cycle, CWM_WIN,
|
2012-05-09 18:39:47 -06:00
|
|
|
{.i = CWM_CYCLE|CWM_INGROUP} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "rcycleingroup", kbfunc_client_cycle, CWM_WIN,
|
2012-05-09 18:39:47 -06:00
|
|
|
{.i = CWM_RCYCLE|CWM_INGROUP} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "grouptoggle", kbfunc_client_grouptoggle, CWM_WIN, {0}},
|
2014-08-25 06:49:19 -06:00
|
|
|
{ "sticky", kbfunc_client_sticky, CWM_WIN, {0} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "fullscreen", kbfunc_client_fullscreen, CWM_WIN, {0} },
|
|
|
|
{ "maximize", kbfunc_client_maximize, CWM_WIN, {0} },
|
|
|
|
{ "vmaximize", kbfunc_client_vmaximize, CWM_WIN, {0} },
|
|
|
|
{ "hmaximize", kbfunc_client_hmaximize, CWM_WIN, {0} },
|
|
|
|
{ "freeze", kbfunc_client_freeze, CWM_WIN, {0} },
|
2014-01-22 14:48:27 -07:00
|
|
|
{ "restart", kbfunc_cwm_status, 0, {.i = CWM_RESTART} },
|
|
|
|
{ "quit", kbfunc_cwm_status, 0, {.i = CWM_QUIT} },
|
2009-01-23 11:58:40 -07:00
|
|
|
{ "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} },
|
|
|
|
{ "exec_wm", kbfunc_exec, 0, {.i = CWM_EXEC_WM} },
|
|
|
|
{ "ssh", kbfunc_ssh, 0, {0} },
|
|
|
|
{ "terminal", kbfunc_term, 0, {0} },
|
|
|
|
{ "lock", kbfunc_lock, 0, {0} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "moveup", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_UP|CWM_MOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "movedown", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_DOWN|CWM_MOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "moveright", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_RIGHT|CWM_MOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "moveleft", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_LEFT|CWM_MOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "bigmoveup", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_UP|CWM_MOVE|CWM_BIGMOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "bigmovedown", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_DOWN|CWM_MOVE|CWM_BIGMOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "bigmoveright", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "bigmoveleft", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_LEFT|CWM_MOVE|CWM_BIGMOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "resizeup", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_UP|CWM_RESIZE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "resizedown", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_DOWN|CWM_RESIZE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "resizeright", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_RIGHT|CWM_RESIZE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "resizeleft", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_LEFT|CWM_RESIZE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "bigresizeup", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_UP|CWM_RESIZE|CWM_BIGMOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "bigresizedown", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "bigresizeright", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "bigresizeleft", kbfunc_client_moveresize, CWM_WIN,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_LEFT|CWM_RESIZE|CWM_BIGMOVE)} },
|
2013-07-08 12:19:22 -06:00
|
|
|
{ "ptrmoveup", kbfunc_client_moveresize, 0,
|
|
|
|
{.i = (CWM_UP|CWM_PTRMOVE)} },
|
|
|
|
{ "ptrmovedown", kbfunc_client_moveresize, 0,
|
|
|
|
{.i = (CWM_DOWN|CWM_PTRMOVE)} },
|
|
|
|
{ "ptrmoveleft", kbfunc_client_moveresize, 0,
|
|
|
|
{.i = (CWM_LEFT|CWM_PTRMOVE)} },
|
|
|
|
{ "ptrmoveright", kbfunc_client_moveresize, 0,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_RIGHT|CWM_PTRMOVE)} },
|
2013-07-08 12:19:22 -06:00
|
|
|
{ "bigptrmoveup", kbfunc_client_moveresize, 0,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_UP|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
2013-07-08 12:19:22 -06:00
|
|
|
{ "bigptrmovedown", kbfunc_client_moveresize, 0,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_DOWN|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
2013-07-08 12:19:22 -06:00
|
|
|
{ "bigptrmoveleft", kbfunc_client_moveresize, 0,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
2013-07-08 12:19:22 -06:00
|
|
|
{ "bigptrmoveright", kbfunc_client_moveresize, 0,
|
2009-01-23 11:58:40 -07:00
|
|
|
{.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
2014-01-20 16:03:51 -07:00
|
|
|
{ "htile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_HORIZ} },
|
|
|
|
{ "vtile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_VERT} },
|
2014-08-24 09:49:58 -06:00
|
|
|
{ "window_lower", kbfunc_client_lower, CWM_WIN, {0} },
|
|
|
|
{ "window_raise", kbfunc_client_raise, CWM_WIN, {0} },
|
|
|
|
{ "window_hide", kbfunc_client_hide, CWM_WIN, {0} },
|
|
|
|
{ "window_move", mousefunc_client_move, CWM_WIN, {0} },
|
|
|
|
{ "window_resize", mousefunc_client_resize, CWM_WIN, {0} },
|
|
|
|
{ "window_grouptoggle", mousefunc_client_grouptoggle, CWM_WIN, {0} },
|
|
|
|
{ "menu_group", mousefunc_menu_group, 0, {0} },
|
|
|
|
{ "menu_unhide", mousefunc_menu_unhide, 0, {0} },
|
|
|
|
{ "menu_cmd", mousefunc_menu_cmd, 0, {0} },
|
2007-04-27 11:58:48 -06:00
|
|
|
};
|
|
|
|
|
2014-01-21 08:42:44 -07:00
|
|
|
static const struct {
|
|
|
|
const char ch;
|
|
|
|
int mask;
|
2009-08-24 19:44:39 -06:00
|
|
|
} bind_mods[] = {
|
|
|
|
{ 'C', ControlMask },
|
|
|
|
{ 'M', Mod1Mask },
|
|
|
|
{ '4', Mod4Mask },
|
|
|
|
{ 'S', ShiftMask },
|
|
|
|
};
|
|
|
|
|
2013-07-08 10:10:55 -06:00
|
|
|
static const char *
|
2014-01-03 08:29:06 -07:00
|
|
|
conf_bind_getmask(const char *name, unsigned int *mask)
|
2013-07-08 10:10:55 -06:00
|
|
|
{
|
|
|
|
char *dash;
|
|
|
|
const char *ch;
|
2014-01-03 08:29:06 -07:00
|
|
|
unsigned int i;
|
2013-07-08 10:10:55 -06:00
|
|
|
|
|
|
|
*mask = 0;
|
|
|
|
if ((dash = strchr(name, '-')) == NULL)
|
2014-09-07 13:27:30 -06:00
|
|
|
return(name);
|
2013-07-08 10:10:55 -06:00
|
|
|
for (i = 0; i < nitems(bind_mods); i++) {
|
2013-07-08 10:32:51 -06:00
|
|
|
if ((ch = strchr(name, bind_mods[i].ch)) != NULL && ch < dash)
|
2013-07-08 10:10:55 -06:00
|
|
|
*mask |= bind_mods[i].mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip past modifiers. */
|
2014-09-07 13:27:30 -06:00
|
|
|
return(dash + 1);
|
2013-07-08 10:10:55 -06:00
|
|
|
}
|
|
|
|
|
2014-01-20 12:06:04 -07:00
|
|
|
int
|
|
|
|
conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
|
2007-11-13 16:26:04 -07:00
|
|
|
{
|
2014-01-29 14:13:52 -07:00
|
|
|
struct binding *kb;
|
|
|
|
const char *key;
|
|
|
|
unsigned int i, mask;
|
2014-01-20 12:06:04 -07:00
|
|
|
|
|
|
|
kb = xcalloc(1, sizeof(*kb));
|
|
|
|
key = conf_bind_getmask(bind, &mask);
|
|
|
|
kb->modmask |= mask;
|
|
|
|
|
2014-01-29 14:13:52 -07:00
|
|
|
kb->press.keysym = XStringToKeysym(key);
|
|
|
|
if (kb->press.keysym == NoSymbol) {
|
2014-01-20 12:06:04 -07:00
|
|
|
warnx("unknown symbol: %s", key);
|
|
|
|
free(kb);
|
2014-09-07 13:27:30 -06:00
|
|
|
return(0);
|
2007-11-13 16:26:04 -07:00
|
|
|
}
|
|
|
|
|
2007-11-19 15:18:16 -07:00
|
|
|
/* We now have the correct binding, remove duplicates. */
|
2014-01-20 12:06:04 -07:00
|
|
|
conf_unbind_kbd(c, kb);
|
2007-11-19 15:18:16 -07:00
|
|
|
|
2014-01-20 12:06:04 -07:00
|
|
|
if (strcmp("unmap", cmd) == 0) {
|
|
|
|
free(kb);
|
2014-09-07 13:27:30 -06:00
|
|
|
return(1);
|
2012-11-07 13:37:55 -07:00
|
|
|
}
|
2007-11-19 15:18:16 -07:00
|
|
|
|
2014-08-24 09:49:58 -06:00
|
|
|
for (i = 0; i < nitems(name_to_func); i++) {
|
|
|
|
if (strcmp(name_to_func[i].tag, cmd) != 0)
|
2007-04-27 11:58:48 -06:00
|
|
|
continue;
|
|
|
|
|
2014-08-24 09:49:58 -06:00
|
|
|
kb->callback = name_to_func[i].handler;
|
|
|
|
kb->flags = name_to_func[i].flags;
|
|
|
|
kb->argument = name_to_func[i].argument;
|
2014-01-20 12:06:04 -07:00
|
|
|
kb->argtype |= ARG_INT;
|
|
|
|
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
|
2014-09-07 13:27:30 -06:00
|
|
|
return(1);
|
2008-05-18 13:47:19 -06:00
|
|
|
}
|
2007-11-13 16:26:04 -07:00
|
|
|
|
2014-01-20 12:06:04 -07:00
|
|
|
kb->callback = kbfunc_cmdexec;
|
|
|
|
kb->flags = 0;
|
|
|
|
kb->argument.c = xstrdup(cmd);
|
|
|
|
kb->argtype |= ARG_CHAR;
|
|
|
|
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
|
2014-09-07 13:27:30 -06:00
|
|
|
return(1);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2009-06-26 06:21:58 -06:00
|
|
|
static void
|
2014-01-29 14:13:52 -07:00
|
|
|
conf_unbind_kbd(struct conf *c, struct binding *unbind)
|
2007-11-19 15:18:16 -07:00
|
|
|
{
|
2014-01-29 14:13:52 -07:00
|
|
|
struct binding *key = NULL, *keynxt;
|
2008-05-18 13:47:19 -06:00
|
|
|
|
2012-11-07 14:01:48 -07:00
|
|
|
TAILQ_FOREACH_SAFE(key, &c->keybindingq, entry, keynxt) {
|
2007-11-19 15:18:16 -07:00
|
|
|
if (key->modmask != unbind->modmask)
|
|
|
|
continue;
|
|
|
|
|
2014-01-29 14:13:52 -07:00
|
|
|
if (key->press.keysym == unbind->press.keysym) {
|
2007-11-19 15:18:16 -07:00
|
|
|
TAILQ_REMOVE(&c->keybindingq, key, entry);
|
2013-01-01 07:33:52 -07:00
|
|
|
if (key->argtype & ARG_CHAR)
|
|
|
|
free(key->argument.c);
|
2012-11-07 13:34:39 -07:00
|
|
|
free(key);
|
2008-05-18 13:47:19 -06:00
|
|
|
}
|
2007-11-19 15:18:16 -07:00
|
|
|
}
|
|
|
|
}
|
2008-06-14 15:48:54 -06:00
|
|
|
|
2013-05-22 10:32:15 -06:00
|
|
|
int
|
2014-01-20 12:06:04 -07:00
|
|
|
conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
|
2008-06-14 15:48:54 -06:00
|
|
|
{
|
2014-01-29 14:13:52 -07:00
|
|
|
struct binding *mb;
|
|
|
|
const char *button, *errstr;
|
|
|
|
unsigned int i, mask;
|
2008-06-14 15:48:54 -06:00
|
|
|
|
2014-01-20 12:06:04 -07:00
|
|
|
mb = xcalloc(1, sizeof(*mb));
|
|
|
|
button = conf_bind_getmask(bind, &mask);
|
|
|
|
mb->modmask |= mask;
|
2013-05-22 10:32:15 -06:00
|
|
|
|
2014-01-29 14:13:52 -07:00
|
|
|
mb->press.button = strtonum(button, Button1, Button5, &errstr);
|
2014-01-20 12:06:04 -07:00
|
|
|
if (errstr) {
|
|
|
|
warnx("button number is %s: %s", errstr, button);
|
|
|
|
free(mb);
|
2014-09-07 13:27:30 -06:00
|
|
|
return(0);
|
2013-05-22 10:32:15 -06:00
|
|
|
}
|
2008-06-14 15:48:54 -06:00
|
|
|
|
2012-11-07 14:04:55 -07:00
|
|
|
/* We now have the correct binding, remove duplicates. */
|
2014-01-20 12:06:04 -07:00
|
|
|
conf_unbind_mouse(c, mb);
|
2008-06-14 15:48:54 -06:00
|
|
|
|
2014-01-20 12:06:04 -07:00
|
|
|
if (strcmp("unmap", cmd) == 0) {
|
|
|
|
free(mb);
|
2014-09-07 13:27:30 -06:00
|
|
|
return(1);
|
2012-11-07 13:37:55 -07:00
|
|
|
}
|
2008-06-14 15:48:54 -06:00
|
|
|
|
2014-08-24 09:49:58 -06:00
|
|
|
for (i = 0; i < nitems(name_to_func); i++) {
|
|
|
|
if (strcmp(name_to_func[i].tag, cmd) != 0)
|
2008-06-14 15:48:54 -06:00
|
|
|
continue;
|
|
|
|
|
2014-08-24 09:49:58 -06:00
|
|
|
mb->callback = name_to_func[i].handler;
|
|
|
|
mb->flags = name_to_func[i].flags;
|
|
|
|
mb->argument = name_to_func[i].argument;
|
2014-01-20 12:06:04 -07:00
|
|
|
TAILQ_INSERT_TAIL(&c->mousebindingq, mb, entry);
|
2014-09-07 13:27:30 -06:00
|
|
|
return(1);
|
2008-06-14 15:48:54 -06:00
|
|
|
}
|
2013-05-22 10:32:15 -06:00
|
|
|
|
2014-09-07 13:27:30 -06:00
|
|
|
return(0);
|
2008-06-14 15:48:54 -06:00
|
|
|
}
|
|
|
|
|
2009-06-26 06:21:58 -06:00
|
|
|
static void
|
2014-01-29 14:13:52 -07:00
|
|
|
conf_unbind_mouse(struct conf *c, struct binding *unbind)
|
2008-06-14 15:48:54 -06:00
|
|
|
{
|
2014-01-29 14:13:52 -07:00
|
|
|
struct binding *mb = NULL, *mbnxt;
|
2008-06-14 15:48:54 -06:00
|
|
|
|
2012-11-07 14:01:48 -07:00
|
|
|
TAILQ_FOREACH_SAFE(mb, &c->mousebindingq, entry, mbnxt) {
|
2008-06-14 15:48:54 -06:00
|
|
|
if (mb->modmask != unbind->modmask)
|
|
|
|
continue;
|
|
|
|
|
2014-01-29 14:13:52 -07:00
|
|
|
if (mb->press.button == unbind->press.button) {
|
2008-06-14 15:48:54 -06:00
|
|
|
TAILQ_REMOVE(&c->mousebindingq, mb, entry);
|
2012-11-07 13:34:39 -07:00
|
|
|
free(mb);
|
2008-06-14 15:48:54 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-16 08:22:25 -06:00
|
|
|
static int cursor_binds[] = {
|
2013-06-17 11:11:10 -06:00
|
|
|
XC_X_cursor, /* CF_DEFAULT */
|
|
|
|
XC_fleur, /* CF_MOVE */
|
|
|
|
XC_left_ptr, /* CF_NORMAL */
|
|
|
|
XC_question_arrow, /* CF_QUESTION */
|
|
|
|
XC_bottom_right_corner, /* CF_RESIZE */
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
conf_cursor(struct conf *c)
|
|
|
|
{
|
2014-01-03 08:29:06 -07:00
|
|
|
unsigned int i;
|
2013-06-17 11:11:10 -06:00
|
|
|
|
|
|
|
for (i = 0; i < nitems(cursor_binds); i++)
|
|
|
|
c->cursor[i] = XCreateFontCursor(X_Dpy, cursor_binds[i]);
|
|
|
|
}
|
|
|
|
|
2008-06-25 16:37:29 -06:00
|
|
|
void
|
2013-05-23 10:52:39 -06:00
|
|
|
conf_grab_mouse(Window win)
|
2008-06-25 16:37:29 -06:00
|
|
|
{
|
2014-01-29 14:13:52 -07:00
|
|
|
struct binding *mb;
|
2008-06-25 16:37:29 -06:00
|
|
|
|
2013-10-19 13:39:34 -06:00
|
|
|
xu_btn_ungrab(win);
|
|
|
|
|
2008-06-25 16:37:29 -06:00
|
|
|
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
|
2014-01-20 16:03:51 -07:00
|
|
|
if (mb->flags & CWM_WIN)
|
2014-01-29 14:13:52 -07:00
|
|
|
xu_btn_grab(win, mb->modmask, mb->press.button);
|
2008-06-25 16:37:29 -06:00
|
|
|
}
|
|
|
|
}
|
2013-05-23 10:52:39 -06:00
|
|
|
|
|
|
|
void
|
|
|
|
conf_grab_kbd(Window win)
|
|
|
|
{
|
2014-01-29 14:13:52 -07:00
|
|
|
struct binding *kb;
|
2013-05-23 10:52:39 -06:00
|
|
|
|
2013-10-19 19:55:32 -06:00
|
|
|
xu_key_ungrab(win);
|
2013-05-23 10:52:39 -06:00
|
|
|
|
|
|
|
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
2014-01-29 14:13:52 -07:00
|
|
|
xu_key_grab(win, kb->modmask, kb->press.keysym);
|
2013-05-23 10:52:39 -06:00
|
|
|
}
|
2013-07-15 08:50:44 -06:00
|
|
|
|
|
|
|
static char *cwmhints[] = {
|
|
|
|
"WM_STATE",
|
|
|
|
"WM_DELETE_WINDOW",
|
|
|
|
"WM_TAKE_FOCUS",
|
|
|
|
"WM_PROTOCOLS",
|
|
|
|
"_MOTIF_WM_HINTS",
|
|
|
|
"UTF8_STRING",
|
|
|
|
"WM_CHANGE_STATE",
|
|
|
|
};
|
|
|
|
static char *ewmhints[] = {
|
|
|
|
"_NET_SUPPORTED",
|
|
|
|
"_NET_SUPPORTING_WM_CHECK",
|
|
|
|
"_NET_ACTIVE_WINDOW",
|
|
|
|
"_NET_CLIENT_LIST",
|
|
|
|
"_NET_NUMBER_OF_DESKTOPS",
|
|
|
|
"_NET_CURRENT_DESKTOP",
|
|
|
|
"_NET_DESKTOP_VIEWPORT",
|
|
|
|
"_NET_DESKTOP_GEOMETRY",
|
|
|
|
"_NET_VIRTUAL_ROOTS",
|
|
|
|
"_NET_SHOWING_DESKTOP",
|
|
|
|
"_NET_DESKTOP_NAMES",
|
|
|
|
"_NET_WORKAREA",
|
|
|
|
"_NET_WM_NAME",
|
|
|
|
"_NET_WM_DESKTOP",
|
|
|
|
"_NET_CLOSE_WINDOW",
|
|
|
|
"_NET_WM_STATE",
|
2014-08-25 06:49:19 -06:00
|
|
|
"_NET_WM_STATE_STICKY",
|
2013-07-15 08:50:44 -06:00
|
|
|
"_NET_WM_STATE_MAXIMIZED_VERT",
|
|
|
|
"_NET_WM_STATE_MAXIMIZED_HORZ",
|
2013-12-16 12:02:17 -07:00
|
|
|
"_NET_WM_STATE_FULLSCREEN",
|
2013-12-13 07:40:52 -07:00
|
|
|
"_NET_WM_STATE_DEMANDS_ATTENTION",
|
2013-07-15 08:50:44 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
conf_atoms(void)
|
|
|
|
{
|
|
|
|
XInternAtoms(X_Dpy, cwmhints, nitems(cwmhints), False, cwmh);
|
|
|
|
XInternAtoms(X_Dpy, ewmhints, nitems(ewmhints), False, ewmh);
|
|
|
|
}
|