mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
cvsimport
This commit is contained in:
commit
371902b3c9
2
calmwm.c
2
calmwm.c
|
@ -46,7 +46,7 @@ struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
|
||||||
|
|
||||||
int HasRandr, Randr_ev;
|
int HasRandr, Randr_ev;
|
||||||
struct conf Conf;
|
struct conf Conf;
|
||||||
char *homedir;
|
const char *homedir;
|
||||||
|
|
||||||
static void sigchld_cb(int);
|
static void sigchld_cb(int);
|
||||||
static int x_errorhandler(Display *, XErrorEvent *);
|
static int x_errorhandler(Display *, XErrorEvent *);
|
||||||
|
|
31
calmwm.h
31
calmwm.h
|
@ -95,6 +95,8 @@ size_t strlcat(char *, const char *, size_t);
|
||||||
#define CWM_GAP 0x0001
|
#define CWM_GAP 0x0001
|
||||||
#define CWM_NOGAP 0x0002
|
#define CWM_NOGAP 0x0002
|
||||||
|
|
||||||
|
#define CWM_WIN 0x0001
|
||||||
|
|
||||||
union arg {
|
union arg {
|
||||||
char *c;
|
char *c;
|
||||||
int i;
|
int i;
|
||||||
|
@ -259,7 +261,6 @@ struct keybinding {
|
||||||
union arg argument;
|
union arg argument;
|
||||||
unsigned int modmask;
|
unsigned int modmask;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
#define KBFLAG_NEEDCLIENT 0x0001
|
|
||||||
int flags;
|
int flags;
|
||||||
int argtype;
|
int argtype;
|
||||||
};
|
};
|
||||||
|
@ -271,17 +272,15 @@ struct mousebinding {
|
||||||
union arg argument;
|
union arg argument;
|
||||||
unsigned int modmask;
|
unsigned int modmask;
|
||||||
unsigned int button;
|
unsigned int button;
|
||||||
#define MOUSEBIND_CTX_ROOT 0x0001
|
|
||||||
#define MOUSEBIND_CTX_WIN 0x0002
|
|
||||||
int flags;
|
int flags;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(mousebinding_q, mousebinding);
|
TAILQ_HEAD(mousebinding_q, mousebinding);
|
||||||
|
|
||||||
struct cmd {
|
struct cmd {
|
||||||
TAILQ_ENTRY(cmd) entry;
|
TAILQ_ENTRY(cmd) entry;
|
||||||
char image[MAXPATHLEN];
|
#define CMD_MAXNAMELEN 256
|
||||||
#define CMD_MAXLABELLEN 256
|
char name[CMD_MAXNAMELEN];
|
||||||
char label[CMD_MAXLABELLEN];
|
char path[MAXPATHLEN];
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(cmd_q, cmd);
|
TAILQ_HEAD(cmd_q, cmd);
|
||||||
|
|
||||||
|
@ -338,7 +337,7 @@ extern Time Last_Event_Time;
|
||||||
extern struct screen_ctx_q Screenq;
|
extern struct screen_ctx_q Screenq;
|
||||||
extern struct client_ctx_q Clientq;
|
extern struct client_ctx_q Clientq;
|
||||||
extern struct conf Conf;
|
extern struct conf Conf;
|
||||||
extern char *homedir;
|
extern const char *homedir;
|
||||||
extern int HasRandr, Randr_ev;
|
extern int HasRandr, Randr_ev;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -507,8 +506,6 @@ void mousefunc_client_move(struct client_ctx *,
|
||||||
union arg *);
|
union arg *);
|
||||||
void mousefunc_client_raise(struct client_ctx *,
|
void mousefunc_client_raise(struct client_ctx *,
|
||||||
union arg *);
|
union arg *);
|
||||||
void mousefunc_client_rcyclegroup(struct client_ctx *,
|
|
||||||
union arg *);
|
|
||||||
void mousefunc_client_resize(struct client_ctx *,
|
void mousefunc_client_resize(struct client_ctx *,
|
||||||
union arg *);
|
union arg *);
|
||||||
void mousefunc_menu_cmd(struct client_ctx *, union arg *);
|
void mousefunc_menu_cmd(struct client_ctx *, union arg *);
|
||||||
|
@ -517,25 +514,29 @@ void mousefunc_menu_unhide(struct client_ctx *,
|
||||||
union arg *);
|
union arg *);
|
||||||
|
|
||||||
struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
||||||
char *, char *, int,
|
const char *, const char *, int,
|
||||||
void (*)(struct menu_q *, struct menu_q *, char *),
|
void (*)(struct menu_q *, struct menu_q *, char *),
|
||||||
void (*)(struct menu *, int));
|
void (*)(struct menu *, int));
|
||||||
|
void menuq_add(struct menu_q *, void *, const char *, ...);
|
||||||
void menuq_clear(struct menu_q *);
|
void menuq_clear(struct menu_q *);
|
||||||
|
|
||||||
int parse_config(const char *, struct conf *);
|
int parse_config(const char *, struct conf *);
|
||||||
|
|
||||||
void conf_atoms(void);
|
void conf_atoms(void);
|
||||||
void conf_autogroup(struct conf *, int, char *);
|
void conf_autogroup(struct conf *, int, const char *);
|
||||||
void conf_bind_kbd(struct conf *, char *, char *);
|
int conf_bind_kbd(struct conf *, const char *,
|
||||||
int conf_bind_mouse(struct conf *, char *, char *);
|
const char *);
|
||||||
|
int conf_bind_mouse(struct conf *, const char *,
|
||||||
|
const char *);
|
||||||
void conf_clear(struct conf *);
|
void conf_clear(struct conf *);
|
||||||
void conf_client(struct client_ctx *);
|
void conf_client(struct client_ctx *);
|
||||||
void conf_cmd_add(struct conf *, char *, char *);
|
void conf_cmd_add(struct conf *, const char *,
|
||||||
|
const char *);
|
||||||
void conf_cursor(struct conf *);
|
void conf_cursor(struct conf *);
|
||||||
void conf_grab_kbd(Window);
|
void conf_grab_kbd(Window);
|
||||||
void conf_grab_mouse(Window);
|
void conf_grab_mouse(Window);
|
||||||
void conf_init(struct conf *);
|
void conf_init(struct conf *);
|
||||||
void conf_ignore(struct conf *, char *);
|
void conf_ignore(struct conf *, const char *);
|
||||||
void conf_screen(struct screen_ctx *);
|
void conf_screen(struct screen_ctx *);
|
||||||
|
|
||||||
void xev_loop(void);
|
void xev_loop(void);
|
||||||
|
|
268
conf.c
268
conf.c
|
@ -37,23 +37,23 @@ static void conf_unbind_mouse(struct conf *, struct mousebinding *);
|
||||||
|
|
||||||
/* Add an command menu entry to the end of the menu */
|
/* Add an command menu entry to the end of the menu */
|
||||||
void
|
void
|
||||||
conf_cmd_add(struct conf *c, char *image, char *label)
|
conf_cmd_add(struct conf *c, const char *name, const char *path)
|
||||||
{
|
{
|
||||||
/* "term" and "lock" have special meanings. */
|
/* "term" and "lock" have special meanings. */
|
||||||
if (strcmp(label, "term") == 0)
|
if (strcmp(name, "term") == 0)
|
||||||
(void)strlcpy(c->termpath, image, sizeof(c->termpath));
|
(void)strlcpy(c->termpath, path, sizeof(c->termpath));
|
||||||
else if (strcmp(label, "lock") == 0)
|
else if (strcmp(name, "lock") == 0)
|
||||||
(void)strlcpy(c->lockpath, image, sizeof(c->lockpath));
|
(void)strlcpy(c->lockpath, path, sizeof(c->lockpath));
|
||||||
else {
|
else {
|
||||||
struct cmd *cmd = xmalloc(sizeof(*cmd));
|
struct cmd *cmd = xmalloc(sizeof(*cmd));
|
||||||
(void)strlcpy(cmd->image, image, sizeof(cmd->image));
|
(void)strlcpy(cmd->name, name, sizeof(cmd->name));
|
||||||
(void)strlcpy(cmd->label, label, sizeof(cmd->label));
|
(void)strlcpy(cmd->path, path, sizeof(cmd->path));
|
||||||
TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
|
TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
conf_autogroup(struct conf *c, int no, char *val)
|
conf_autogroup(struct conf *c, int no, const char *val)
|
||||||
{
|
{
|
||||||
struct autogroupwin *aw;
|
struct autogroupwin *aw;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -74,7 +74,7 @@ conf_autogroup(struct conf *c, int no, char *val)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
conf_ignore(struct conf *c, char *val)
|
conf_ignore(struct conf *c, const char *val)
|
||||||
{
|
{
|
||||||
struct winmatch *wm;
|
struct winmatch *wm;
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ conf_ignore(struct conf *c, char *val)
|
||||||
TAILQ_INSERT_TAIL(&c->ignoreq, wm, entry);
|
TAILQ_INSERT_TAIL(&c->ignoreq, wm, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *color_binds[] = {
|
static const char *color_binds[] = {
|
||||||
"#CCCCCC", /* CWM_COLOR_BORDER_ACTIVE */
|
"#CCCCCC", /* CWM_COLOR_BORDER_ACTIVE */
|
||||||
"#666666", /* CWM_COLOR_BORDER_INACTIVE */
|
"#666666", /* CWM_COLOR_BORDER_INACTIVE */
|
||||||
"#FC8814", /* CWM_COLOR_BORDER_URGENCY */
|
"#FC8814", /* CWM_COLOR_BORDER_URGENCY */
|
||||||
|
@ -147,9 +147,9 @@ conf_screen(struct screen_ctx *sc)
|
||||||
conf_grab_kbd(sc->rootwin);
|
conf_grab_kbd(sc->rootwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static const struct {
|
||||||
char *key;
|
const char *key;
|
||||||
char *func;
|
const char *func;
|
||||||
} kbd_binds[] = {
|
} kbd_binds[] = {
|
||||||
{ "CM-Return", "terminal" },
|
{ "CM-Return", "terminal" },
|
||||||
{ "CM-Delete", "lock" },
|
{ "CM-Delete", "lock" },
|
||||||
|
@ -318,21 +318,21 @@ conf_client(struct client_ctx *cc)
|
||||||
cc->flags |= ignore ? CLIENT_IGNORE : 0;
|
cc->flags |= ignore ? CLIENT_IGNORE : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static const struct {
|
||||||
char *tag;
|
const char *tag;
|
||||||
void (*handler)(struct client_ctx *, union arg *);
|
void (*handler)(struct client_ctx *, union arg *);
|
||||||
int flags;
|
int flags;
|
||||||
union arg argument;
|
union arg argument;
|
||||||
} name_to_kbfunc[] = {
|
} name_to_kbfunc[] = {
|
||||||
{ "lower", kbfunc_client_lower, KBFLAG_NEEDCLIENT, {0} },
|
{ "lower", kbfunc_client_lower, CWM_WIN, {0} },
|
||||||
{ "raise", kbfunc_client_raise, KBFLAG_NEEDCLIENT, {0} },
|
{ "raise", kbfunc_client_raise, CWM_WIN, {0} },
|
||||||
{ "search", kbfunc_client_search, 0, {0} },
|
{ "search", kbfunc_client_search, 0, {0} },
|
||||||
{ "menusearch", kbfunc_menu_search, 0, {0} },
|
{ "menusearch", kbfunc_menu_search, 0, {0} },
|
||||||
{ "hide", kbfunc_client_hide, KBFLAG_NEEDCLIENT, {0} },
|
{ "hide", kbfunc_client_hide, CWM_WIN, {0} },
|
||||||
{ "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} },
|
{ "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} },
|
||||||
{ "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} },
|
{ "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} },
|
||||||
{ "label", kbfunc_client_label, KBFLAG_NEEDCLIENT, {0} },
|
{ "label", kbfunc_client_label, CWM_WIN, {0} },
|
||||||
{ "delete", kbfunc_client_delete, KBFLAG_NEEDCLIENT, {0} },
|
{ "delete", kbfunc_client_delete, CWM_WIN, {0} },
|
||||||
{ "group1", kbfunc_client_group, 0, {.i = 1} },
|
{ "group1", kbfunc_client_group, 0, {.i = 1} },
|
||||||
{ "group2", kbfunc_client_group, 0, {.i = 2} },
|
{ "group2", kbfunc_client_group, 0, {.i = 2} },
|
||||||
{ "group3", kbfunc_client_group, 0, {.i = 3} },
|
{ "group3", kbfunc_client_group, 0, {.i = 3} },
|
||||||
|
@ -351,37 +351,28 @@ static struct {
|
||||||
{ "grouponly7", kbfunc_client_grouponly, 0, {.i = 7} },
|
{ "grouponly7", kbfunc_client_grouponly, 0, {.i = 7} },
|
||||||
{ "grouponly8", kbfunc_client_grouponly, 0, {.i = 8} },
|
{ "grouponly8", kbfunc_client_grouponly, 0, {.i = 8} },
|
||||||
{ "grouponly9", kbfunc_client_grouponly, 0, {.i = 9} },
|
{ "grouponly9", kbfunc_client_grouponly, 0, {.i = 9} },
|
||||||
{ "movetogroup1", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
{ "movetogroup1", kbfunc_client_movetogroup, CWM_WIN, {.i = 1} },
|
||||||
{.i = 1} },
|
{ "movetogroup2", kbfunc_client_movetogroup, CWM_WIN, {.i = 2} },
|
||||||
{ "movetogroup2", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
{ "movetogroup3", kbfunc_client_movetogroup, CWM_WIN, {.i = 3} },
|
||||||
{.i = 2} },
|
{ "movetogroup4", kbfunc_client_movetogroup, CWM_WIN, {.i = 4} },
|
||||||
{ "movetogroup3", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
{ "movetogroup5", kbfunc_client_movetogroup, CWM_WIN, {.i = 5} },
|
||||||
{.i = 3} },
|
{ "movetogroup6", kbfunc_client_movetogroup, CWM_WIN, {.i = 6} },
|
||||||
{ "movetogroup4", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
{ "movetogroup7", kbfunc_client_movetogroup, CWM_WIN, {.i = 7} },
|
||||||
{.i = 4} },
|
{ "movetogroup8", kbfunc_client_movetogroup, CWM_WIN, {.i = 8} },
|
||||||
{ "movetogroup5", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
{ "movetogroup9", kbfunc_client_movetogroup, CWM_WIN, {.i = 9} },
|
||||||
{.i = 5} },
|
|
||||||
{ "movetogroup6", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
|
||||||
{.i = 6} },
|
|
||||||
{ "movetogroup7", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
|
||||||
{.i = 7} },
|
|
||||||
{ "movetogroup8", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
|
||||||
{.i = 8} },
|
|
||||||
{ "movetogroup9", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
|
||||||
{.i = 9} },
|
|
||||||
{ "nogroup", kbfunc_client_nogroup, 0, {0} },
|
{ "nogroup", kbfunc_client_nogroup, 0, {0} },
|
||||||
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
|
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
|
||||||
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
|
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
|
||||||
{ "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT,
|
{ "cycleingroup", kbfunc_client_cycle, CWM_WIN,
|
||||||
{.i = CWM_CYCLE|CWM_INGROUP} },
|
{.i = CWM_CYCLE|CWM_INGROUP} },
|
||||||
{ "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT,
|
{ "rcycleingroup", kbfunc_client_cycle, CWM_WIN,
|
||||||
{.i = CWM_RCYCLE|CWM_INGROUP} },
|
{.i = CWM_RCYCLE|CWM_INGROUP} },
|
||||||
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}},
|
{ "grouptoggle", kbfunc_client_grouptoggle, CWM_WIN, {0}},
|
||||||
{ "fullscreen", kbfunc_client_fullscreen, KBFLAG_NEEDCLIENT, {0} },
|
{ "fullscreen", kbfunc_client_fullscreen, CWM_WIN, {0} },
|
||||||
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} },
|
{ "maximize", kbfunc_client_maximize, CWM_WIN, {0} },
|
||||||
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },
|
{ "vmaximize", kbfunc_client_vmaximize, CWM_WIN, {0} },
|
||||||
{ "hmaximize", kbfunc_client_hmaximize, KBFLAG_NEEDCLIENT, {0} },
|
{ "hmaximize", kbfunc_client_hmaximize, CWM_WIN, {0} },
|
||||||
{ "freeze", kbfunc_client_freeze, KBFLAG_NEEDCLIENT, {0} },
|
{ "freeze", kbfunc_client_freeze, CWM_WIN, {0} },
|
||||||
{ "restart", kbfunc_restart, 0, {0} },
|
{ "restart", kbfunc_restart, 0, {0} },
|
||||||
{ "quit", kbfunc_quit_wm, 0, {0} },
|
{ "quit", kbfunc_quit_wm, 0, {0} },
|
||||||
{ "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} },
|
{ "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} },
|
||||||
|
@ -389,37 +380,37 @@ static struct {
|
||||||
{ "ssh", kbfunc_ssh, 0, {0} },
|
{ "ssh", kbfunc_ssh, 0, {0} },
|
||||||
{ "terminal", kbfunc_term, 0, {0} },
|
{ "terminal", kbfunc_term, 0, {0} },
|
||||||
{ "lock", kbfunc_lock, 0, {0} },
|
{ "lock", kbfunc_lock, 0, {0} },
|
||||||
{ "moveup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "moveup", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_UP|CWM_MOVE)} },
|
{.i = (CWM_UP|CWM_MOVE)} },
|
||||||
{ "movedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "movedown", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_DOWN|CWM_MOVE)} },
|
{.i = (CWM_DOWN|CWM_MOVE)} },
|
||||||
{ "moveright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "moveright", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_RIGHT|CWM_MOVE)} },
|
{.i = (CWM_RIGHT|CWM_MOVE)} },
|
||||||
{ "moveleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "moveleft", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_LEFT|CWM_MOVE)} },
|
{.i = (CWM_LEFT|CWM_MOVE)} },
|
||||||
{ "bigmoveup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "bigmoveup", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_UP|CWM_MOVE|CWM_BIGMOVE)} },
|
{.i = (CWM_UP|CWM_MOVE|CWM_BIGMOVE)} },
|
||||||
{ "bigmovedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "bigmovedown", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_DOWN|CWM_MOVE|CWM_BIGMOVE)} },
|
{.i = (CWM_DOWN|CWM_MOVE|CWM_BIGMOVE)} },
|
||||||
{ "bigmoveright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "bigmoveright", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE)} },
|
{.i = (CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE)} },
|
||||||
{ "bigmoveleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "bigmoveleft", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_LEFT|CWM_MOVE|CWM_BIGMOVE)} },
|
{.i = (CWM_LEFT|CWM_MOVE|CWM_BIGMOVE)} },
|
||||||
{ "resizeup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "resizeup", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_UP|CWM_RESIZE)} },
|
{.i = (CWM_UP|CWM_RESIZE)} },
|
||||||
{ "resizedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "resizedown", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_DOWN|CWM_RESIZE)} },
|
{.i = (CWM_DOWN|CWM_RESIZE)} },
|
||||||
{ "resizeright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "resizeright", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_RIGHT|CWM_RESIZE)} },
|
{.i = (CWM_RIGHT|CWM_RESIZE)} },
|
||||||
{ "resizeleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "resizeleft", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_LEFT|CWM_RESIZE)} },
|
{.i = (CWM_LEFT|CWM_RESIZE)} },
|
||||||
{ "bigresizeup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "bigresizeup", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_UP|CWM_RESIZE|CWM_BIGMOVE)} },
|
{.i = (CWM_UP|CWM_RESIZE|CWM_BIGMOVE)} },
|
||||||
{ "bigresizedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "bigresizedown", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE)} },
|
{.i = (CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE)} },
|
||||||
{ "bigresizeright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "bigresizeright", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE)} },
|
{.i = (CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE)} },
|
||||||
{ "bigresizeleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
|
{ "bigresizeleft", kbfunc_client_moveresize, CWM_WIN,
|
||||||
{.i = (CWM_LEFT|CWM_RESIZE|CWM_BIGMOVE)} },
|
{.i = (CWM_LEFT|CWM_RESIZE|CWM_BIGMOVE)} },
|
||||||
{ "ptrmoveup", kbfunc_client_moveresize, 0,
|
{ "ptrmoveup", kbfunc_client_moveresize, 0,
|
||||||
{.i = (CWM_UP|CWM_PTRMOVE)} },
|
{.i = (CWM_UP|CWM_PTRMOVE)} },
|
||||||
|
@ -437,15 +428,13 @@ static struct {
|
||||||
{.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
{.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
||||||
{ "bigptrmoveright", kbfunc_client_moveresize, 0,
|
{ "bigptrmoveright", kbfunc_client_moveresize, 0,
|
||||||
{.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
{.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
||||||
{ "htile", kbfunc_tile, KBFLAG_NEEDCLIENT,
|
{ "htile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_HORIZ} },
|
||||||
{.i = CWM_TILE_HORIZ } },
|
{ "vtile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_VERT} },
|
||||||
{ "vtile", kbfunc_tile, KBFLAG_NEEDCLIENT,
|
|
||||||
{.i = CWM_TILE_VERT } },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct {
|
static const struct {
|
||||||
char ch;
|
const char ch;
|
||||||
int mask;
|
int mask;
|
||||||
} bind_mods[] = {
|
} bind_mods[] = {
|
||||||
{ 'C', ControlMask },
|
{ 'C', ControlMask },
|
||||||
{ 'M', Mod1Mask },
|
{ 'M', Mod1Mask },
|
||||||
|
@ -472,48 +461,50 @@ conf_bind_getmask(const char *name, unsigned int *mask)
|
||||||
return (dash + 1);
|
return (dash + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
conf_bind_kbd(struct conf *c, char *name, char *binding)
|
conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
|
||||||
{
|
{
|
||||||
struct keybinding *current_binding;
|
struct keybinding *kb;
|
||||||
const char *substring;
|
const char *key;
|
||||||
unsigned int i, mask;
|
unsigned int i, mask;
|
||||||
|
|
||||||
current_binding = xcalloc(1, sizeof(*current_binding));
|
kb = xcalloc(1, sizeof(*kb));
|
||||||
substring = conf_bind_getmask(name, &mask);
|
key = conf_bind_getmask(bind, &mask);
|
||||||
current_binding->modmask |= mask;
|
kb->modmask |= mask;
|
||||||
|
|
||||||
current_binding->keysym = XStringToKeysym(substring);
|
kb->keysym = XStringToKeysym(key);
|
||||||
if (current_binding->keysym == NoSymbol) {
|
if (kb->keysym == NoSymbol) {
|
||||||
free(current_binding);
|
warnx("unknown symbol: %s", key);
|
||||||
return;
|
free(kb);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We now have the correct binding, remove duplicates. */
|
/* We now have the correct binding, remove duplicates. */
|
||||||
conf_unbind_kbd(c, current_binding);
|
conf_unbind_kbd(c, kb);
|
||||||
|
|
||||||
if (strcmp("unmap", binding) == 0) {
|
if (strcmp("unmap", cmd) == 0) {
|
||||||
free(current_binding);
|
free(kb);
|
||||||
return;
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nitems(name_to_kbfunc); i++) {
|
for (i = 0; i < nitems(name_to_kbfunc); i++) {
|
||||||
if (strcmp(name_to_kbfunc[i].tag, binding) != 0)
|
if (strcmp(name_to_kbfunc[i].tag, cmd) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
current_binding->callback = name_to_kbfunc[i].handler;
|
kb->callback = name_to_kbfunc[i].handler;
|
||||||
current_binding->flags = name_to_kbfunc[i].flags;
|
kb->flags = name_to_kbfunc[i].flags;
|
||||||
current_binding->argument = name_to_kbfunc[i].argument;
|
kb->argument = name_to_kbfunc[i].argument;
|
||||||
current_binding->argtype |= ARG_INT;
|
kb->argtype |= ARG_INT;
|
||||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
|
||||||
return;
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_binding->callback = kbfunc_cmdexec;
|
kb->callback = kbfunc_cmdexec;
|
||||||
current_binding->flags = 0;
|
kb->flags = 0;
|
||||||
current_binding->argument.c = xstrdup(binding);
|
kb->argument.c = xstrdup(cmd);
|
||||||
current_binding->argtype |= ARG_CHAR;
|
kb->argtype |= ARG_CHAR;
|
||||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -534,73 +525,59 @@ conf_unbind_kbd(struct conf *c, struct keybinding *unbind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static const struct {
|
||||||
char *tag;
|
const char *tag;
|
||||||
void (*handler)(struct client_ctx *, union arg *);
|
void (*handler)(struct client_ctx *, union arg *);
|
||||||
int flags;
|
int flags;
|
||||||
union arg argument;
|
union arg argument;
|
||||||
} name_to_mousefunc[] = {
|
} name_to_mousefunc[] = {
|
||||||
{ "window_move", mousefunc_client_move, MOUSEBIND_CTX_WIN, {0} },
|
{ "window_move", mousefunc_client_move, CWM_WIN, {0} },
|
||||||
{ "window_resize", mousefunc_client_resize, MOUSEBIND_CTX_WIN, {0} },
|
{ "window_resize", mousefunc_client_resize, CWM_WIN, {0} },
|
||||||
{ "window_grouptoggle", mousefunc_client_grouptoggle,
|
{ "window_grouptoggle", mousefunc_client_grouptoggle, CWM_WIN, {0} },
|
||||||
MOUSEBIND_CTX_WIN, {0} },
|
{ "window_lower", mousefunc_client_lower, CWM_WIN, {0} },
|
||||||
{ "window_lower", mousefunc_client_lower, MOUSEBIND_CTX_WIN, {0} },
|
{ "window_raise", mousefunc_client_raise, CWM_WIN, {0} },
|
||||||
{ "window_raise", mousefunc_client_raise, MOUSEBIND_CTX_WIN, {0} },
|
{ "window_hide", mousefunc_client_hide, CWM_WIN, {0} },
|
||||||
{ "window_hide", mousefunc_client_hide, MOUSEBIND_CTX_WIN, {0} },
|
{ "cyclegroup", mousefunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
|
||||||
{ "cyclegroup", mousefunc_client_cyclegroup, MOUSEBIND_CTX_ROOT, {0} },
|
{ "rcyclegroup", mousefunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
|
||||||
{ "rcyclegroup", mousefunc_client_rcyclegroup,
|
{ "menu_group", mousefunc_menu_group, 0, {0} },
|
||||||
MOUSEBIND_CTX_ROOT, {0} },
|
{ "menu_unhide", mousefunc_menu_unhide, 0, {0} },
|
||||||
{ "menu_group", mousefunc_menu_group, MOUSEBIND_CTX_ROOT, {0} },
|
{ "menu_cmd", mousefunc_menu_cmd, 0, {0} },
|
||||||
{ "menu_unhide", mousefunc_menu_unhide, MOUSEBIND_CTX_ROOT, {0} },
|
|
||||||
{ "menu_cmd", mousefunc_menu_cmd, MOUSEBIND_CTX_ROOT, {0} },
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned int mouse_btns[] = {
|
|
||||||
Button1, Button2, Button3, Button4, Button5
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
conf_bind_mouse(struct conf *c, char *name, char *binding)
|
conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
|
||||||
{
|
{
|
||||||
struct mousebinding *current_binding;
|
struct mousebinding *mb;
|
||||||
const char *errstr, *substring;
|
const char *button, *errstr;
|
||||||
unsigned int button, i, mask;
|
unsigned int i, mask;
|
||||||
|
|
||||||
current_binding = xcalloc(1, sizeof(*current_binding));
|
mb = xcalloc(1, sizeof(*mb));
|
||||||
substring = conf_bind_getmask(name, &mask);
|
button = conf_bind_getmask(bind, &mask);
|
||||||
current_binding->modmask |= mask;
|
mb->modmask |= mask;
|
||||||
|
|
||||||
button = strtonum(substring, 1, 5, &errstr);
|
mb->button = strtonum(button, Button1, Button5, &errstr);
|
||||||
if (errstr)
|
if (errstr) {
|
||||||
warnx("button number is %s: %s", errstr, substring);
|
warnx("button number is %s: %s", errstr, button);
|
||||||
|
free(mb);
|
||||||
for (i = 0; i < nitems(mouse_btns); i++) {
|
|
||||||
if (button == mouse_btns[i]) {
|
|
||||||
current_binding->button = button;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!current_binding->button || errstr) {
|
|
||||||
free(current_binding);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We now have the correct binding, remove duplicates. */
|
/* We now have the correct binding, remove duplicates. */
|
||||||
conf_unbind_mouse(c, current_binding);
|
conf_unbind_mouse(c, mb);
|
||||||
|
|
||||||
if (strcmp("unmap", binding) == 0) {
|
if (strcmp("unmap", cmd) == 0) {
|
||||||
free(current_binding);
|
free(mb);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nitems(name_to_mousefunc); i++) {
|
for (i = 0; i < nitems(name_to_mousefunc); i++) {
|
||||||
if (strcmp(name_to_mousefunc[i].tag, binding) != 0)
|
if (strcmp(name_to_mousefunc[i].tag, cmd) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
current_binding->callback = name_to_mousefunc[i].handler;
|
mb->callback = name_to_mousefunc[i].handler;
|
||||||
current_binding->flags = name_to_mousefunc[i].flags;
|
mb->flags = name_to_mousefunc[i].flags;
|
||||||
current_binding->argument = name_to_mousefunc[i].argument;
|
mb->argument = name_to_mousefunc[i].argument;
|
||||||
TAILQ_INSERT_TAIL(&c->mousebindingq, current_binding, entry);
|
TAILQ_INSERT_TAIL(&c->mousebindingq, mb, entry);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,9 +625,8 @@ conf_grab_mouse(Window win)
|
||||||
xu_btn_ungrab(win);
|
xu_btn_ungrab(win);
|
||||||
|
|
||||||
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
|
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
|
||||||
if (mb->flags != MOUSEBIND_CTX_WIN)
|
if (mb->flags & CWM_WIN)
|
||||||
continue;
|
xu_btn_grab(win, mb->modmask, mb->button);
|
||||||
xu_btn_grab(win, mb->modmask, mb->button);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
group.c
11
group.c
|
@ -324,15 +324,8 @@ group_menu(struct screen_ctx *sc)
|
||||||
if (TAILQ_EMPTY(&gc->clients))
|
if (TAILQ_EMPTY(&gc->clients))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
menuq_add(&menuq, gc, gc->hidden ? "%d: [%s]" : "%d: %s",
|
||||||
if (gc->hidden)
|
gc->shortcut, sc->group_names[i]);
|
||||||
(void)snprintf(mi->text, sizeof(mi->text), "%d: [%s]",
|
|
||||||
gc->shortcut, sc->group_names[i]);
|
|
||||||
else
|
|
||||||
(void)snprintf(mi->text, sizeof(mi->text), "%d: %s",
|
|
||||||
gc->shortcut, sc->group_names[i]);
|
|
||||||
mi->ctx = gc;
|
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TAILQ_EMPTY(&menuq))
|
if (TAILQ_EMPTY(&menuq))
|
||||||
|
|
36
kbfunc.c
36
kbfunc.c
|
@ -41,6 +41,7 @@ extern sig_atomic_t xev_quit;
|
||||||
void
|
void
|
||||||
kbfunc_client_lower(struct client_ctx *cc, union arg *arg)
|
kbfunc_client_lower(struct client_ctx *cc, union arg *arg)
|
||||||
{
|
{
|
||||||
|
client_ptrsave(cc);
|
||||||
client_lower(cc);
|
client_lower(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,13 +152,8 @@ kbfunc_client_search(struct client_ctx *cc, union arg *arg)
|
||||||
old_cc = client_current();
|
old_cc = client_current();
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
|
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||||
TAILQ_FOREACH(cc, &Clientq, entry) {
|
menuq_add(&menuq, cc, "%s", cc->name);
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
|
||||||
(void)strlcpy(mi->text, cc->name, sizeof(mi->text));
|
|
||||||
mi->ctx = cc;
|
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mi = menu_filter(sc, &menuq, "window", NULL, 0,
|
if ((mi = menu_filter(sc, &menuq, "window", NULL, 0,
|
||||||
search_match_client, search_print_client)) != NULL) {
|
search_match_client, search_print_client)) != NULL) {
|
||||||
|
@ -182,17 +178,12 @@ kbfunc_menu_search(struct client_ctx *cc, union arg *arg)
|
||||||
struct menu_q menuq;
|
struct menu_q menuq;
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry)
|
||||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
menuq_add(&menuq, cmd, "%s", cmd->name);
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
|
||||||
(void)strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
|
||||||
mi->ctx = cmd;
|
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mi = menu_filter(sc, &menuq, "application", NULL, 0,
|
if ((mi = menu_filter(sc, &menuq, "application", NULL, 0,
|
||||||
search_match_text, NULL)) != NULL)
|
search_match_text, NULL)) != NULL)
|
||||||
u_spawn(((struct cmd *)mi->ctx)->image);
|
u_spawn(((struct cmd *)mi->ctx)->path);
|
||||||
|
|
||||||
menuq_clear(&menuq);
|
menuq_clear(&menuq);
|
||||||
}
|
}
|
||||||
|
@ -238,8 +229,9 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||||
{
|
{
|
||||||
#define NPATHS 256
|
#define NPATHS 256
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
char **ap, *paths[NPATHS], *path, *pathcpy, *label;
|
char **ap, *paths[NPATHS], *path, *pathcpy;
|
||||||
char tpath[MAXPATHLEN];
|
char tpath[MAXPATHLEN];
|
||||||
|
const char *label;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
|
@ -284,12 +276,8 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||||
/* check for truncation etc */
|
/* check for truncation etc */
|
||||||
if (l == -1 || l >= (int)sizeof(tpath))
|
if (l == -1 || l >= (int)sizeof(tpath))
|
||||||
continue;
|
continue;
|
||||||
if (access(tpath, X_OK) == 0) {
|
if (access(tpath, X_OK) == 0)
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
menuq_add(&menuq, NULL, "%s", dp->d_name);
|
||||||
(void)strlcpy(mi->text,
|
|
||||||
dp->d_name, sizeof(mi->text));
|
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
(void)closedir(dirp);
|
(void)closedir(dirp);
|
||||||
}
|
}
|
||||||
|
@ -360,9 +348,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
||||||
if (p - buf + 1 > sizeof(hostbuf))
|
if (p - buf + 1 > sizeof(hostbuf))
|
||||||
continue;
|
continue;
|
||||||
(void)strlcpy(hostbuf, buf, p - buf + 1);
|
(void)strlcpy(hostbuf, buf, p - buf + 1);
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
menuq_add(&menuq, NULL, hostbuf);
|
||||||
(void)strlcpy(mi->text, hostbuf, sizeof(mi->text));
|
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
||||||
}
|
}
|
||||||
free(lbuf);
|
free(lbuf);
|
||||||
(void)fclose(fp);
|
(void)fclose(fp);
|
||||||
|
|
21
menu.c
21
menu.c
|
@ -25,6 +25,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -77,8 +78,8 @@ static struct menu *menu_complete_path(struct menu_ctx *);
|
||||||
static int menu_keycode(XKeyEvent *, enum ctltype *, char *);
|
static int menu_keycode(XKeyEvent *, enum ctltype *, char *);
|
||||||
|
|
||||||
struct menu *
|
struct menu *
|
||||||
menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
menu_filter(struct screen_ctx *sc, struct menu_q *menuq, const char *prompt,
|
||||||
char *initial, int flags,
|
const char *initial, int flags,
|
||||||
void (*match)(struct menu_q *, struct menu_q *, char *),
|
void (*match)(struct menu_q *, struct menu_q *, char *),
|
||||||
void (*print)(struct menu *, int))
|
void (*print)(struct menu *, int))
|
||||||
{
|
{
|
||||||
|
@ -604,6 +605,22 @@ menu_keycode(XKeyEvent *ev, enum ctltype *ctl, char *chr)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
menuq_add(struct menu_q *mq, void *ctx, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
struct menu *mi;
|
||||||
|
|
||||||
|
mi = xcalloc(1, sizeof(*mi));
|
||||||
|
mi->ctx = ctx;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
(void)vsnprintf(mi->text, sizeof(mi->text), fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
TAILQ_INSERT_TAIL(mq, mi, entry);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
menuq_clear(struct menu_q *mq)
|
menuq_clear(struct menu_q *mq)
|
||||||
{
|
{
|
||||||
|
|
23
mousefunc.c
23
mousefunc.c
|
@ -200,13 +200,7 @@ mousefunc_client_hide(struct client_ctx *cc, union arg *arg)
|
||||||
void
|
void
|
||||||
mousefunc_client_cyclegroup(struct client_ctx *cc, union arg *arg)
|
mousefunc_client_cyclegroup(struct client_ctx *cc, union arg *arg)
|
||||||
{
|
{
|
||||||
group_cycle(cc->sc, CWM_CYCLE);
|
group_cycle(cc->sc, arg->i);
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
mousefunc_client_rcyclegroup(struct client_ctx *cc, union arg *arg)
|
|
||||||
{
|
|
||||||
group_cycle(cc->sc, CWM_RCYCLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -234,11 +228,8 @@ mousefunc_menu_unhide(struct client_ctx *cc, union arg *arg)
|
||||||
if (wname == NULL)
|
if (wname == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
menuq_add(&menuq, cc, "(%d) %s",
|
||||||
(void)snprintf(mi->text, sizeof(mi->text), "(%d) %s",
|
|
||||||
cc->group ? cc->group->shortcut : 0, wname);
|
cc->group ? cc->group->shortcut : 0, wname);
|
||||||
mi->ctx = cc;
|
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TAILQ_EMPTY(&menuq))
|
if (TAILQ_EMPTY(&menuq))
|
||||||
|
@ -267,18 +258,14 @@ mousefunc_menu_cmd(struct client_ctx *cc, union arg *arg)
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
|
|
||||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry)
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
menuq_add(&menuq, cmd, "%s", cmd->name);
|
||||||
(void)strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
|
||||||
mi->ctx = cmd;
|
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
|
||||||
}
|
|
||||||
if (TAILQ_EMPTY(&menuq))
|
if (TAILQ_EMPTY(&menuq))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL);
|
mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL);
|
||||||
if (mi != NULL)
|
if (mi != NULL)
|
||||||
u_spawn(((struct cmd *)mi->ctx)->image);
|
u_spawn(((struct cmd *)mi->ctx)->path);
|
||||||
|
|
||||||
menuq_clear(&menuq);
|
menuq_clear(&menuq);
|
||||||
}
|
}
|
||||||
|
|
9
parse.y
9
parse.y
|
@ -139,7 +139,7 @@ main : FONTNAME STRING {
|
||||||
conf->snapdist = $2;
|
conf->snapdist = $2;
|
||||||
}
|
}
|
||||||
| COMMAND STRING string {
|
| COMMAND STRING string {
|
||||||
conf_cmd_add(conf, $3, $2);
|
conf_cmd_add(conf, $2, $3);
|
||||||
free($2);
|
free($2);
|
||||||
free($3);
|
free($3);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,12 @@ main : FONTNAME STRING {
|
||||||
free($2);
|
free($2);
|
||||||
}
|
}
|
||||||
| BIND STRING string {
|
| BIND STRING string {
|
||||||
conf_bind_kbd(conf, $2, $3);
|
if (!conf_bind_kbd(conf, $2, $3)) {
|
||||||
|
yyerror("invalid bind: %s %s", $2, $3);
|
||||||
|
free($2);
|
||||||
|
free($3);
|
||||||
|
YYERROR;
|
||||||
|
}
|
||||||
free($2);
|
free($2);
|
||||||
free($3);
|
free($3);
|
||||||
}
|
}
|
||||||
|
|
11
search.c
11
search.c
|
@ -172,10 +172,9 @@ search_print_client(struct menu *mi, int list)
|
||||||
static void
|
static void
|
||||||
search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search, int flag)
|
search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search, int flag)
|
||||||
{
|
{
|
||||||
struct menu *mi;
|
char pattern[MAXPATHLEN];
|
||||||
char pattern[MAXPATHLEN];
|
glob_t g;
|
||||||
glob_t g;
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
TAILQ_INIT(resultq);
|
TAILQ_INIT(resultq);
|
||||||
|
|
||||||
|
@ -187,9 +186,7 @@ search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search, in
|
||||||
for (i = 0; i < g.gl_pathc; i++) {
|
for (i = 0; i < g.gl_pathc; i++) {
|
||||||
if ((flag & PATH_EXEC) && access(g.gl_pathv[i], X_OK))
|
if ((flag & PATH_EXEC) && access(g.gl_pathv[i], X_OK))
|
||||||
continue;
|
continue;
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
menuq_add(resultq, NULL, "%s", g.gl_pathv[i]);
|
||||||
(void)strlcpy(mi->text, g.gl_pathv[i], sizeof(mi->text));
|
|
||||||
TAILQ_INSERT_TAIL(resultq, mi, resultentry);
|
|
||||||
}
|
}
|
||||||
globfree(&g);
|
globfree(&g);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,11 +235,11 @@ xev_handle_buttonpress(XEvent *ee)
|
||||||
|
|
||||||
if (mb == NULL)
|
if (mb == NULL)
|
||||||
return;
|
return;
|
||||||
if (mb->flags == MOUSEBIND_CTX_WIN) {
|
if (mb->flags & CWM_WIN) {
|
||||||
if (((cc = client_find(e->window)) == NULL) &&
|
if (((cc = client_find(e->window)) == NULL) &&
|
||||||
(cc = client_current()) == NULL)
|
(cc = client_current()) == NULL)
|
||||||
return;
|
return;
|
||||||
} else { /* (mb->flags == MOUSEBIND_CTX_ROOT) */
|
} else {
|
||||||
if (e->window != e->root)
|
if (e->window != e->root)
|
||||||
return;
|
return;
|
||||||
cc = &fakecc;
|
cc = &fakecc;
|
||||||
|
@ -287,7 +287,7 @@ xev_handle_keypress(XEvent *ee)
|
||||||
|
|
||||||
if (kb == NULL)
|
if (kb == NULL)
|
||||||
return;
|
return;
|
||||||
if (kb->flags & KBFLAG_NEEDCLIENT) {
|
if (kb->flags & CWM_WIN) {
|
||||||
if (((cc = client_find(e->window)) == NULL) &&
|
if (((cc = client_find(e->window)) == NULL) &&
|
||||||
(cc = client_current()) == NULL)
|
(cc = client_current()) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user