cvsimport

* refs/heads/master:
  drop obsolete comment
  Alter callbacks to take a struct instead of a growing number of arguments; greatly simplifies upcoming work.
  Ensure clients stay within the viewable bounds on placement, even with empty borders; based on a patch from Vadim Vygonets.
  Clean up, unify and accurately calculate edge distance with client move/resize actions, so as to not lose windows off the edge.
  Switch bwidth type; unfortunately X11 is inconsistent.
This commit is contained in:
okan 2017-05-09 18:43:40 +00:00
commit 4040f112e1
7 changed files with 272 additions and 294 deletions

111
calmwm.h
View File

@ -87,7 +87,6 @@ enum cwm_status {
CWM_RUNNING,
CWM_EXEC_WM
};
enum cursor_font {
CF_NORMAL,
CF_MOVE,
@ -140,7 +139,7 @@ struct client_ctx {
struct group_ctx *gc;
Window win;
Colormap colormap;
unsigned int bwidth; /* border width */
int bwidth; /* border width */
struct geom geom, savegeom, fullgeom;
struct {
long flags; /* defined hints */
@ -177,7 +176,6 @@ struct client_ctx {
#define CLIENT_FULLSCREEN 0x0800
#define CLIENT_STICKY 0x1000
#define CLIENT_ACTIVE 0x2000
#define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP)
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
#define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
@ -240,30 +238,29 @@ struct screen_ctx {
};
TAILQ_HEAD(screen_q, screen_ctx);
enum xev {
CWM_XEV_KEY,
CWM_XEV_BTN
};
union arg {
char *c;
int i;
};
union press {
KeySym keysym;
unsigned int button;
struct cargs {
char *cmd;
int flag;
enum {
CWM_XEV_KEY,
CWM_XEV_BTN
} xev;
};
enum context {
CWM_CONTEXT_NONE,
CWM_CONTEXT_NONE = 0,
CWM_CONTEXT_CC,
CWM_CONTEXT_SC
};
struct bind_ctx {
TAILQ_ENTRY(bind_ctx) entry;
void (*callback)(void *, union arg *, enum xev);
union arg argument;
unsigned int modmask;
union press press;
void (*callback)(void *, struct cargs *);
struct cargs *cargs;
enum context context;
unsigned int modmask;
union {
KeySym keysym;
unsigned int button;
} press;
};
TAILQ_HEAD(keybind_q, bind_ctx);
TAILQ_HEAD(mousebind_q, bind_ctx);
@ -420,6 +417,7 @@ void client_msg(struct client_ctx *, Atom, Time);
void client_move(struct client_ctx *);
int client_inbound(struct client_ctx *, int, int);
struct client_ctx *client_init(Window, struct screen_ctx *, int);
void client_ptr_inbound(struct client_ctx *, int);
void client_ptrsave(struct client_ctx *);
void client_ptrwarp(struct client_ctx *);
void client_raise(struct client_ctx *);
@ -482,49 +480,42 @@ void screen_update_geometry(struct screen_ctx *);
void screen_updatestackingorder(struct screen_ctx *);
void screen_assert_clients_within(struct screen_ctx *);
void kbfunc_cwm_status(void *, union arg *, enum xev);
void kbfunc_ptrmove(void *, union arg *, enum xev);
void kbfunc_client_move(void *, union arg *, enum xev);
void kbfunc_client_resize(void *, union arg *, enum xev);
void kbfunc_client_delete(void *, union arg *, enum xev);
void kbfunc_client_lower(void *, union arg *, enum xev);
void kbfunc_client_raise(void *, union arg *, enum xev);
void kbfunc_client_hide(void *, union arg *, enum xev);
void kbfunc_client_toggle_freeze(void *,
union arg *, enum xev);
void kbfunc_client_toggle_sticky(void *,
union arg *, enum xev);
void kbfunc_cwm_status(void *, struct cargs *);
void kbfunc_ptrmove(void *, struct cargs *);
void kbfunc_client_move(void *, struct cargs *);
void kbfunc_client_resize(void *, struct cargs *);
void kbfunc_client_delete(void *, struct cargs *);
void kbfunc_client_lower(void *, struct cargs *);
void kbfunc_client_raise(void *, struct cargs *);
void kbfunc_client_hide(void *, struct cargs *);
void kbfunc_client_toggle_freeze(void *, struct cargs *);
void kbfunc_client_toggle_sticky(void *, struct cargs *);
void kbfunc_client_toggle_fullscreen(void *,
union arg *, enum xev);
void kbfunc_client_toggle_maximize(void *,
union arg *, enum xev);
void kbfunc_client_toggle_hmaximize(void *,
union arg *, enum xev);
void kbfunc_client_toggle_vmaximize(void *,
union arg *, enum xev);
void kbfunc_client_htile(void *, union arg *, enum xev);
void kbfunc_client_vtile(void *, union arg *, enum xev);
void kbfunc_client_cycle(void *, union arg *, enum xev);
void kbfunc_client_toggle_group(void *,
union arg *, enum xev);
void kbfunc_client_movetogroup(void *,
union arg *, enum xev);
void kbfunc_group_toggle(void *, union arg *, enum xev);
void kbfunc_group_only(void *, union arg *, enum xev);
void kbfunc_group_cycle(void *, union arg *, enum xev);
void kbfunc_group_alltoggle(void *, union arg *, enum xev);
void kbfunc_menu_client(void *, union arg *, enum xev);
void kbfunc_menu_cmd(void *, union arg *, enum xev);
void kbfunc_menu_group(void *, union arg *, enum xev);
void kbfunc_menu_exec(void *, union arg *, enum xev);
void kbfunc_menu_ssh(void *, union arg *, enum xev);
void kbfunc_menu_client_label(void *, union arg *, enum xev);
void kbfunc_exec_cmd(void *, union arg *, enum xev);
void kbfunc_exec_lock(void *, union arg *, enum xev);
void kbfunc_exec_term(void *, union arg *, enum xev);
struct cargs *);
void kbfunc_client_toggle_maximize(void *, struct cargs *);
void kbfunc_client_toggle_hmaximize(void *, struct cargs *);
void kbfunc_client_toggle_vmaximize(void *, struct cargs *);
void kbfunc_client_htile(void *, struct cargs *);
void kbfunc_client_vtile(void *, struct cargs *);
void kbfunc_client_cycle(void *, struct cargs *);
void kbfunc_client_toggle_group(void *, struct cargs *);
void kbfunc_client_movetogroup(void *, struct cargs *);
void kbfunc_group_toggle(void *, struct cargs *);
void kbfunc_group_only(void *, struct cargs *);
void kbfunc_group_cycle(void *, struct cargs *);
void kbfunc_group_alltoggle(void *, struct cargs *);
void kbfunc_menu_client(void *, struct cargs *);
void kbfunc_menu_cmd(void *, struct cargs *);
void kbfunc_menu_group(void *, struct cargs *);
void kbfunc_menu_exec(void *, struct cargs *);
void kbfunc_menu_ssh(void *, struct cargs *);
void kbfunc_menu_client_label(void *, struct cargs *);
void kbfunc_exec_cmd(void *, struct cargs *);
void kbfunc_exec_lock(void *, struct cargs *);
void kbfunc_exec_term(void *, struct cargs *);
void mousefunc_client_move(void *, union arg *, enum xev);
void mousefunc_client_resize(void *, union arg *, enum xev);
void mousefunc_client_move(void *, struct cargs *);
void mousefunc_client_resize(void *, struct cargs *);
void menu_windraw(struct screen_ctx *, Window,
const char *, ...);

View File

@ -470,6 +470,24 @@ client_config(struct client_ctx *cc)
XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&cn);
}
void
client_ptr_inbound(struct client_ctx *cc, int getpos)
{
if (getpos)
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
if (cc->ptr.x < 0)
cc->ptr.x = 0;
else if (cc->ptr.x > cc->geom.w - 1)
cc->ptr.x = cc->geom.w - 1;
if (cc->ptr.y < 0)
cc->ptr.y = 0;
else if (cc->ptr.y > cc->geom.h - 1)
cc->ptr.y = cc->geom.h - 1;
client_ptrwarp(cc);
}
void
client_ptrwarp(struct client_ctx *cc)
{
@ -545,7 +563,7 @@ client_draw_border(struct client_ctx *cc)
if (cc->flags & CLIENT_URGENCY)
pixel = sc->xftcolor[CWM_COLOR_BORDER_URGENCY].pixel;
XSetWindowBorderWidth(X_Dpy, cc->win, cc->bwidth);
XSetWindowBorderWidth(X_Dpy, cc->win, (unsigned int)cc->bwidth);
XSetWindowBorder(X_Dpy, cc->win, pixel);
}
@ -743,14 +761,14 @@ client_placecalc(struct client_ctx *cc)
wmax = DisplayWidth(X_Dpy, sc->which);
hmax = DisplayHeight(X_Dpy, sc->which);
if (cc->geom.x + ((int)cc->bwidth * 2) >= wmax)
cc->geom.x = wmax - (cc->bwidth * 2);
if (cc->geom.x + cc->geom.w - ((int)cc->bwidth * 2) < 0)
cc->geom.x = -cc->geom.w;
if (cc->geom.y + ((int)cc->bwidth * 2) >= hmax)
cc->geom.y = hmax - (cc->bwidth * 2);
if (cc->geom.y + cc->geom.h - ((int)cc->bwidth * 2) < 0)
cc->geom.y = -cc->geom.h;
if (cc->geom.x >= wmax)
cc->geom.x = wmax - cc->bwidth - 1;
if (cc->geom.x + cc->geom.w + cc->bwidth <= 0)
cc->geom.x = -(cc->geom.w + cc->bwidth - 1);
if (cc->geom.y >= hmax)
cc->geom.x = hmax - cc->bwidth - 1;
if (cc->geom.y + cc->geom.h + cc->bwidth <= 0)
cc->geom.y = -(cc->geom.h + cc->bwidth - 1);
} else {
struct geom area;
int xmouse, ymouse;

212
conf.c
View File

@ -56,134 +56,134 @@ static const char *color_binds[] = {
};
static const struct {
const char *tag;
void (*handler)(void *, union arg *, enum xev);
void (*handler)(void *, struct cargs *);
enum context context;
union arg argument;
int flag;
} name_to_func[] = {
{ "window-menu-label", kbfunc_menu_client_label, CWM_CONTEXT_CC, {0} },
{ "window-lower", kbfunc_client_lower, CWM_CONTEXT_CC, {0} },
{ "window-raise", kbfunc_client_raise, CWM_CONTEXT_CC, {0} },
{ "window-hide", kbfunc_client_hide, CWM_CONTEXT_CC, {0} },
{ "window-delete", kbfunc_client_delete, CWM_CONTEXT_CC, {0} },
{ "window-htile", kbfunc_client_htile, CWM_CONTEXT_CC, {0} },
{ "window-vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, {0} },
{ "window-stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, {0} },
{ "window-fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, {0} },
{ "window-maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, {0} },
{ "window-vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CC, {0} },
{ "window-hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CC, {0} },
{ "window-freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CC, {0} },
{ "window-menu-label", kbfunc_menu_client_label, CWM_CONTEXT_CC, 0 },
{ "window-lower", kbfunc_client_lower, CWM_CONTEXT_CC, 0 },
{ "window-raise", kbfunc_client_raise, CWM_CONTEXT_CC, 0 },
{ "window-hide", kbfunc_client_hide, CWM_CONTEXT_CC, 0 },
{ "window-delete", kbfunc_client_delete, CWM_CONTEXT_CC, 0 },
{ "window-htile", kbfunc_client_htile, CWM_CONTEXT_CC, 0 },
{ "window-vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, 0 },
{ "window-stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, 0 },
{ "window-fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, 0 },
{ "window-maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, 0 },
{ "window-vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CC, 0 },
{ "window-hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CC, 0 },
{ "window-freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CC, 0 },
{ "window-cycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_FORWARD)} },
(CWM_CYCLE_FORWARD) },
{ "window-rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_REVERSE)} },
(CWM_CYCLE_REVERSE) },
{ "window-cycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP)} },
(CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP) },
{ "window-rcycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP)} },
{ "window-group", kbfunc_client_toggle_group, CWM_CONTEXT_CC, {0} },
{ "window-movetogroup-1", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 1} },
{ "window-movetogroup-2", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 2} },
{ "window-movetogroup-3", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 3} },
{ "window-movetogroup-4", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 4} },
{ "window-movetogroup-5", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 5} },
{ "window-movetogroup-6", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 6} },
{ "window-movetogroup-7", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 7} },
{ "window-movetogroup-8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 8} },
{ "window-movetogroup-9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 9} },
(CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP) },
{ "window-group", kbfunc_client_toggle_group, CWM_CONTEXT_CC, 0 },
{ "window-movetogroup-1", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 1 },
{ "window-movetogroup-2", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 2 },
{ "window-movetogroup-3", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 3 },
{ "window-movetogroup-4", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 4 },
{ "window-movetogroup-5", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 5 },
{ "window-movetogroup-6", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 6 },
{ "window-movetogroup-7", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 7 },
{ "window-movetogroup-8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 8 },
{ "window-movetogroup-9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 9 },
{ "window-move", mousefunc_client_move, CWM_CONTEXT_CC, {0} },
{ "window-move", mousefunc_client_move, CWM_CONTEXT_CC, 0 },
{ "window-move-up", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_UP)} },
(CWM_UP) },
{ "window-move-down", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_DOWN)} },
(CWM_DOWN) },
{ "window-move-right", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT)} },
(CWM_RIGHT) },
{ "window-move-left", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_LEFT)} },
(CWM_LEFT) },
{ "window-move-up-big", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
(CWM_UP | CWM_BIGAMOUNT) },
{ "window-move-down-big", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
(CWM_DOWN | CWM_BIGAMOUNT) },
{ "window-move-right-big", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
(CWM_RIGHT | CWM_BIGAMOUNT) },
{ "window-move-left-big", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
{ "window-resize", mousefunc_client_resize, CWM_CONTEXT_CC, {0} },
(CWM_LEFT | CWM_BIGAMOUNT) },
{ "window-resize", mousefunc_client_resize, CWM_CONTEXT_CC, 0 },
{ "window-resize-up", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_UP)} },
(CWM_UP) },
{ "window-resize-down", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_DOWN)} },
(CWM_DOWN) },
{ "window-resize-right", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT)} },
(CWM_RIGHT) },
{ "window-resize-left", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_LEFT)} },
(CWM_LEFT) },
{ "window-resize-up-big", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
(CWM_UP | CWM_BIGAMOUNT) },
{ "window-resize-down-big", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
(CWM_DOWN | CWM_BIGAMOUNT) },
{ "window-resize-right-big", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
(CWM_RIGHT | CWM_BIGAMOUNT) },
{ "window-resize-left-big", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
(CWM_LEFT | CWM_BIGAMOUNT) },
{ "group-cycle", kbfunc_group_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_FORWARD)} },
(CWM_CYCLE_FORWARD) },
{ "group-rcycle", kbfunc_group_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_REVERSE)} },
{ "group-toggle-all", kbfunc_group_alltoggle, CWM_CONTEXT_SC, {0} },
{ "group-toggle-1", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 1} },
{ "group-toggle-2", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 2} },
{ "group-toggle-3", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 3} },
{ "group-toggle-4", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 4} },
{ "group-toggle-5", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 5} },
{ "group-toggle-6", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 6} },
{ "group-toggle-7", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 7} },
{ "group-toggle-8", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 8} },
{ "group-toggle-9", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 9} },
{ "group-only-1", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 1} },
{ "group-only-2", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 2} },
{ "group-only-3", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 3} },
{ "group-only-4", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 4} },
{ "group-only-5", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 5} },
{ "group-only-6", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 6} },
{ "group-only-7", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 7} },
{ "group-only-8", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 8} },
{ "group-only-9", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 9} },
(CWM_CYCLE_REVERSE) },
{ "group-toggle-all", kbfunc_group_alltoggle, CWM_CONTEXT_SC, 0 },
{ "group-toggle-1", kbfunc_group_toggle, CWM_CONTEXT_SC, 1 },
{ "group-toggle-2", kbfunc_group_toggle, CWM_CONTEXT_SC, 2 },
{ "group-toggle-3", kbfunc_group_toggle, CWM_CONTEXT_SC, 3 },
{ "group-toggle-4", kbfunc_group_toggle, CWM_CONTEXT_SC, 4 },
{ "group-toggle-5", kbfunc_group_toggle, CWM_CONTEXT_SC, 5 },
{ "group-toggle-6", kbfunc_group_toggle, CWM_CONTEXT_SC, 6 },
{ "group-toggle-7", kbfunc_group_toggle, CWM_CONTEXT_SC, 7 },
{ "group-toggle-8", kbfunc_group_toggle, CWM_CONTEXT_SC, 8 },
{ "group-toggle-9", kbfunc_group_toggle, CWM_CONTEXT_SC, 9 },
{ "group-only-1", kbfunc_group_only, CWM_CONTEXT_SC, 1 },
{ "group-only-2", kbfunc_group_only, CWM_CONTEXT_SC, 2 },
{ "group-only-3", kbfunc_group_only, CWM_CONTEXT_SC, 3 },
{ "group-only-4", kbfunc_group_only, CWM_CONTEXT_SC, 4 },
{ "group-only-5", kbfunc_group_only, CWM_CONTEXT_SC, 5 },
{ "group-only-6", kbfunc_group_only, CWM_CONTEXT_SC, 6 },
{ "group-only-7", kbfunc_group_only, CWM_CONTEXT_SC, 7 },
{ "group-only-8", kbfunc_group_only, CWM_CONTEXT_SC, 8 },
{ "group-only-9", kbfunc_group_only, CWM_CONTEXT_SC, 9 },
{ "pointer-move-up", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_UP)} },
(CWM_UP) },
{ "pointer-move-down", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_DOWN)} },
(CWM_DOWN) },
{ "pointer-move-left", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_LEFT)} },
(CWM_LEFT) },
{ "pointer-move-right", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_RIGHT)} },
(CWM_RIGHT) },
{ "pointer-move-up-big", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
(CWM_UP | CWM_BIGAMOUNT) },
{ "pointer-move-down-big", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
(CWM_DOWN | CWM_BIGAMOUNT) },
{ "pointer-move-left-big", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
(CWM_LEFT | CWM_BIGAMOUNT) },
{ "pointer-move-right-big", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
(CWM_RIGHT | CWM_BIGAMOUNT) },
{ "menu-cmd", kbfunc_menu_cmd, CWM_CONTEXT_SC, {0} },
{ "menu-group", kbfunc_menu_group, CWM_CONTEXT_SC, {0} },
{ "menu-ssh", kbfunc_menu_ssh, CWM_CONTEXT_SC, {0} },
{ "menu-cmd", kbfunc_menu_cmd, CWM_CONTEXT_SC, 0 },
{ "menu-group", kbfunc_menu_group, CWM_CONTEXT_SC, 0 },
{ "menu-ssh", kbfunc_menu_ssh, CWM_CONTEXT_SC, 0 },
{ "menu-window", kbfunc_menu_client, CWM_CONTEXT_SC,
{.i = CWM_MENU_WINDOW_ALL} },
CWM_MENU_WINDOW_ALL },
{ "menu-window-hidden", kbfunc_menu_client, CWM_CONTEXT_SC,
{.i = CWM_MENU_WINDOW_HIDDEN} },
CWM_MENU_WINDOW_HIDDEN },
{ "menu-exec", kbfunc_menu_exec, CWM_CONTEXT_SC,
{.i = CWM_MENU_EXEC_EXEC} },
CWM_MENU_EXEC_EXEC },
{ "menu-exec-wm", kbfunc_menu_exec, CWM_CONTEXT_SC,
{.i = CWM_MENU_EXEC_WM} },
CWM_MENU_EXEC_WM },
{ "terminal", kbfunc_exec_term, CWM_CONTEXT_SC, {0} },
{ "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, {0} },
{ "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_EXEC_WM} },
{ "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_QUIT} },
{ "terminal", kbfunc_exec_term, CWM_CONTEXT_SC, 0 },
{ "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, 0 },
{ "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, CWM_EXEC_WM },
{ "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, CWM_QUIT },
};
static unsigned int ignore_mods[] = {
@ -510,12 +510,13 @@ int
conf_bind_key(struct conf *c, const char *bind, const char *cmd)
{
struct bind_ctx *kb;
struct cargs *cargs;
const char *key;
unsigned int i;
if ((strcmp(bind, "all") == 0) && (cmd == NULL)) {
conf_unbind_key(c, NULL);
goto out;
return(1);
}
kb = xmalloc(sizeof(*kb));
key = conf_bind_getmask(bind, &kb->modmask);
@ -528,22 +529,24 @@ conf_bind_key(struct conf *c, const char *bind, const char *cmd)
conf_unbind_key(c, kb);
if (cmd == NULL) {
free(kb);
goto out;
return(1);
}
cargs = xcalloc(1, sizeof(*cargs));
for (i = 0; i < nitems(name_to_func); i++) {
if (strcmp(name_to_func[i].tag, cmd) != 0)
continue;
kb->callback = name_to_func[i].handler;
kb->context = name_to_func[i].context;
kb->argument = name_to_func[i].argument;
TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
cargs->flag = name_to_func[i].flag;
goto out;
}
kb->callback = kbfunc_exec_cmd;
kb->context = CWM_CONTEXT_NONE;
kb->argument.c = xstrdup(cmd);
TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
cargs->flag = 0;
cargs->cmd = xstrdup(cmd);
out:
kb->cargs = cargs;
TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
return(1);
}
@ -557,8 +560,8 @@ conf_unbind_key(struct conf *c, struct bind_ctx *unbind)
((key->modmask == unbind->modmask) &&
(key->press.keysym == unbind->press.keysym))) {
TAILQ_REMOVE(&c->keybindq, key, entry);
if (key->context == CWM_CONTEXT_NONE)
free(key->argument.c);
free(key->cargs->cmd);
free(key->cargs);
free(key);
}
}
@ -568,12 +571,13 @@ int
conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
{
struct bind_ctx *mb;
struct cargs *cargs;
const char *button, *errstr;
unsigned int i;
if ((strcmp(bind, "all") == 0) && (cmd == NULL)) {
conf_unbind_mouse(c, NULL);
goto out;
return(1);
}
mb = xmalloc(sizeof(*mb));
button = conf_bind_getmask(bind, &mb->modmask);
@ -586,22 +590,24 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
conf_unbind_mouse(c, mb);
if (cmd == NULL) {
free(mb);
goto out;
return(1);
}
cargs = xcalloc(1, sizeof(*cargs));
for (i = 0; i < nitems(name_to_func); i++) {
if (strcmp(name_to_func[i].tag, cmd) != 0)
continue;
mb->callback = name_to_func[i].handler;
mb->context = name_to_func[i].context;
mb->argument = name_to_func[i].argument;
TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry);
cargs->flag = name_to_func[i].flag;
goto out;
}
mb->callback = kbfunc_exec_cmd;
mb->context = CWM_CONTEXT_NONE;
mb->argument.c = xstrdup(cmd);
TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry);
cargs->flag = 0;
cargs->cmd = xstrdup(cmd);
out:
mb->cargs = cargs;
TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry);
return(1);
}
@ -615,8 +621,8 @@ conf_unbind_mouse(struct conf *c, struct bind_ctx *unbind)
((mb->modmask == unbind->modmask) &&
(mb->press.button == unbind->press.button))) {
TAILQ_REMOVE(&c->mousebindq, mb, entry);
if (mb->context == CWM_CONTEXT_NONE)
free(mb->argument.c);
free(mb->cargs->cmd);
free(mb->cargs);
free(mb);
}
}

163
kbfunc.c
View File

@ -38,16 +38,16 @@
extern sig_atomic_t cwm_status;
static void kbfunc_amount(int, int, unsigned int *, unsigned int *);
static void kbfunc_amount(int, int, int *, int *);
void
kbfunc_cwm_status(void *ctx, union arg *arg, enum xev xev)
kbfunc_cwm_status(void *ctx, struct cargs *cargs)
{
cwm_status = arg->i;
cwm_status = cargs->flag;
}
static void
kbfunc_amount(int flags, int amt, unsigned int *mx, unsigned int *my)
kbfunc_amount(int flags, int amt, int *mx, int *my)
{
#define CWM_FACTOR 10
@ -71,54 +71,41 @@ kbfunc_amount(int flags, int amt, unsigned int *mx, unsigned int *my)
}
void
kbfunc_ptrmove(void *ctx, union arg *arg, enum xev xev)
kbfunc_ptrmove(void *ctx, struct cargs *cargs)
{
struct screen_ctx *sc = ctx;
int x, y;
unsigned int mx = 0, my = 0;
int mx = 0, my = 0;
kbfunc_amount(arg->i, Conf.mamount, &mx, &my);
kbfunc_amount(cargs->flag, Conf.mamount, &mx, &my);
xu_ptr_getpos(sc->rootwin, &x, &y);
xu_ptr_setpos(sc->rootwin, x + mx, y + my);
}
void
kbfunc_client_move(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_move(void *ctx, struct cargs *cargs)
{
struct client_ctx *cc = ctx;
struct screen_ctx *sc = cc->sc;
struct geom area;
int x, y, px, py;
unsigned int mx = 0, my = 0;
int mx = 0, my = 0;
if (cc->flags & CLIENT_FREEZE)
return;
xu_ptr_getpos(cc->win, &px, &py);
if (px < 0)
px = 0;
else if (px > cc->geom.w)
px = cc->geom.w;
if (py < 0)
py = 0;
else if (py > cc->geom.h)
py = cc->geom.h;
xu_ptr_setpos(cc->win, px, py);
kbfunc_amount(arg->i, Conf.mamount, &mx, &my);
kbfunc_amount(cargs->flag, Conf.mamount, &mx, &my);
cc->geom.x += mx;
if (cc->geom.x + cc->geom.w < 0)
cc->geom.x = -cc->geom.w;
if (cc->geom.x > sc->view.w - 1)
cc->geom.x = sc->view.w - 1;
if (cc->geom.x < -(cc->geom.w + cc->bwidth - 1))
cc->geom.x = -(cc->geom.w + cc->bwidth - 1);
if (cc->geom.x > (sc->view.w - cc->bwidth - 1))
cc->geom.x = sc->view.w - cc->bwidth - 1;
cc->geom.y += my;
if (cc->geom.y + cc->geom.h < 0)
cc->geom.y = -cc->geom.h;
if (cc->geom.y > sc->view.h - 1)
cc->geom.y = sc->view.h - 1;
if (cc->geom.y < -(cc->geom.h + cc->bwidth - 1))
cc->geom.y = -(cc->geom.h + cc->bwidth - 1);
if (cc->geom.y > (sc->view.h - cc->bwidth - 1))
cc->geom.y = sc->view.h - cc->bwidth - 1;
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
@ -129,19 +116,16 @@ kbfunc_client_move(void *ctx, union arg *arg, enum xev xev)
cc->geom.y += client_snapcalc(cc->geom.y,
cc->geom.y + cc->geom.h + (cc->bwidth * 2),
area.y, area.y + area.h, sc->snapdist);
client_move(cc);
xu_ptr_getpos(cc->win, &x, &y);
cc->ptr.x = x + mx;
cc->ptr.y = y + my;
client_ptrwarp(cc);
client_move(cc);
client_ptr_inbound(cc, 1);
}
void
kbfunc_client_resize(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_resize(void *ctx, struct cargs *cargs)
{
struct client_ctx *cc = ctx;
unsigned int mx = 0, my = 0;
int mx = 0, my = 0;
int amt = 1;
if (cc->flags & CLIENT_FREEZE)
@ -150,159 +134,152 @@ kbfunc_client_resize(void *ctx, union arg *arg, enum xev xev)
if (!(cc->hint.flags & PResizeInc))
amt = Conf.mamount;
kbfunc_amount(arg->i, amt, &mx, &my);
kbfunc_amount(cargs->flag, amt, &mx, &my);
if ((cc->geom.w += mx * cc->hint.incw) < cc->hint.minw)
cc->geom.w = cc->hint.minw;
if ((cc->geom.h += my * cc->hint.inch) < cc->hint.minh)
cc->geom.h = cc->hint.minh;
if (cc->geom.x + cc->geom.w < 0)
cc->geom.x = -cc->geom.w;
if (cc->geom.y + cc->geom.h < 0)
cc->geom.y = -cc->geom.h;
client_resize(cc, 1);
if (cc->geom.x + cc->geom.w + cc->bwidth - 1 < 0)
cc->geom.x = -(cc->geom.w + cc->bwidth - 1);
if (cc->geom.y + cc->geom.h + cc->bwidth - 1 < 0)
cc->geom.y = -(cc->geom.h + cc->bwidth - 1);
/* Make sure the pointer stays within the window. */
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
if (cc->ptr.x > cc->geom.w)
cc->ptr.x = cc->geom.w - cc->bwidth;
if (cc->ptr.y > cc->geom.h)
cc->ptr.y = cc->geom.h - cc->bwidth;
client_ptrwarp(cc);
client_resize(cc, 1);
client_ptr_inbound(cc, 1);
}
void
kbfunc_client_delete(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_delete(void *ctx, struct cargs *cargs)
{
client_send_delete(ctx);
}
void
kbfunc_client_lower(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_lower(void *ctx, struct cargs *cargs)
{
client_ptrsave(ctx);
client_lower(ctx);
}
void
kbfunc_client_raise(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_raise(void *ctx, struct cargs *cargs)
{
client_raise(ctx);
}
void
kbfunc_client_hide(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_hide(void *ctx, struct cargs *cargs)
{
client_hide(ctx);
}
void
kbfunc_client_toggle_freeze(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_toggle_freeze(void *ctx, struct cargs *cargs)
{
client_toggle_freeze(ctx);
}
void
kbfunc_client_toggle_sticky(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_toggle_sticky(void *ctx, struct cargs *cargs)
{
client_toggle_sticky(ctx);
}
void
kbfunc_client_toggle_fullscreen(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_toggle_fullscreen(void *ctx, struct cargs *cargs)
{
client_toggle_fullscreen(ctx);
}
void
kbfunc_client_toggle_maximize(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_toggle_maximize(void *ctx, struct cargs *cargs)
{
client_toggle_maximize(ctx);
}
void
kbfunc_client_toggle_hmaximize(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_toggle_hmaximize(void *ctx, struct cargs *cargs)
{
client_toggle_hmaximize(ctx);
}
void
kbfunc_client_toggle_vmaximize(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_toggle_vmaximize(void *ctx, struct cargs *cargs)
{
client_toggle_vmaximize(ctx);
}
void
kbfunc_client_htile(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_htile(void *ctx, struct cargs *cargs)
{
client_htile(ctx);
}
void
kbfunc_client_vtile(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_vtile(void *ctx, struct cargs *cargs)
{
client_vtile(ctx);
}
void
kbfunc_client_cycle(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_cycle(void *ctx, struct cargs *cargs)
{
client_cycle(ctx, arg->i);
client_cycle(ctx, cargs->flag);
}
void
kbfunc_client_toggle_group(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_toggle_group(void *ctx, struct cargs *cargs)
{
struct client_ctx *cc = ctx;
if (xev == CWM_XEV_KEY) {
/* For X apps that steal events. */
/* For X apps that steal events. */
if (cargs->xev == CWM_XEV_KEY)
XGrabKeyboard(X_Dpy, cc->win, True,
GrabModeAsync, GrabModeAsync, CurrentTime);
}
group_toggle_membership_enter(cc);
}
void
kbfunc_client_movetogroup(void *ctx, union arg *arg, enum xev xev)
kbfunc_client_movetogroup(void *ctx, struct cargs *cargs)
{
group_movetogroup(ctx, arg->i);
group_movetogroup(ctx, cargs->flag);
}
void
kbfunc_group_toggle(void *ctx, union arg *arg, enum xev xev)
kbfunc_group_toggle(void *ctx, struct cargs *cargs)
{
group_hidetoggle(ctx, arg->i);
group_hidetoggle(ctx, cargs->flag);
}
void
kbfunc_group_only(void *ctx, union arg *arg, enum xev xev)
kbfunc_group_only(void *ctx, struct cargs *cargs)
{
group_only(ctx, arg->i);
group_only(ctx, cargs->flag);
}
void
kbfunc_group_cycle(void *ctx, union arg *arg, enum xev xev)
kbfunc_group_cycle(void *ctx, struct cargs *cargs)
{
group_cycle(ctx, arg->i);
group_cycle(ctx, cargs->flag);
}
void
kbfunc_group_alltoggle(void *ctx, union arg *arg, enum xev xev)
kbfunc_group_alltoggle(void *ctx, struct cargs *cargs)
{
group_alltoggle(ctx);
}
void
kbfunc_menu_client(void *ctx, union arg *arg, enum xev xev)
kbfunc_menu_client(void *ctx, struct cargs *cargs)
{
struct screen_ctx *sc = ctx;
struct client_ctx *cc, *old_cc;
struct menu *mi;
struct menu_q menuq;
int m = (xev == CWM_XEV_BTN);
int all = (arg->i & CWM_MENU_WINDOW_ALL);
int m = (cargs->xev == CWM_XEV_BTN);
int all = (cargs->flag & CWM_MENU_WINDOW_ALL);
old_cc = client_current();
@ -333,13 +310,13 @@ kbfunc_menu_client(void *ctx, union arg *arg, enum xev xev)
}
void
kbfunc_menu_cmd(void *ctx, union arg *arg, enum xev xev)
kbfunc_menu_cmd(void *ctx, struct cargs *cargs)
{
struct screen_ctx *sc = ctx;
struct cmd_ctx *cmd;
struct menu *mi;
struct menu_q menuq;
int m = (xev == CWM_XEV_BTN);
int m = (cargs->xev == CWM_XEV_BTN);
TAILQ_INIT(&menuq);
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
@ -362,13 +339,13 @@ kbfunc_menu_cmd(void *ctx, union arg *arg, enum xev xev)
}
void
kbfunc_menu_group(void *ctx, union arg *arg, enum xev xev)
kbfunc_menu_group(void *ctx, struct cargs *cargs)
{
struct screen_ctx *sc = ctx;
struct group_ctx *gc;
struct menu *mi;
struct menu_q menuq;
int m = (xev == CWM_XEV_BTN);
int m = (cargs->xev == CWM_XEV_BTN);
TAILQ_INIT(&menuq);
TAILQ_FOREACH(gc, &sc->groupq, entry) {
@ -389,7 +366,7 @@ kbfunc_menu_group(void *ctx, union arg *arg, enum xev xev)
}
void
kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev)
kbfunc_menu_exec(void *ctx, struct cargs *cargs)
{
#define NPATHS 256
struct screen_ctx *sc = ctx;
@ -401,7 +378,7 @@ kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev)
struct dirent *dp;
struct menu *mi;
struct menu_q menuq;
int l, i, cmd = arg->i;
int l, i, cmd = cargs->flag;
switch (cmd) {
case CWM_MENU_EXEC_EXEC:
@ -479,7 +456,7 @@ out:
}
void
kbfunc_menu_ssh(void *ctx, union arg *arg, enum xev xev)
kbfunc_menu_ssh(void *ctx, struct cargs *cargs)
{
struct screen_ctx *sc = ctx;
struct cmd_ctx *cmd;
@ -546,7 +523,7 @@ out:
}
void
kbfunc_menu_client_label(void *ctx, union arg *arg, enum xev xev)
kbfunc_menu_client_label(void *ctx, struct cargs *cargs)
{
struct client_ctx *cc = ctx;
struct menu *mi;
@ -566,13 +543,13 @@ kbfunc_menu_client_label(void *ctx, union arg *arg, enum xev xev)
}
void
kbfunc_exec_cmd(void *ctx, union arg *arg, enum xev xev)
kbfunc_exec_cmd(void *ctx, struct cargs *cargs)
{
u_spawn(arg->c);
u_spawn(cargs->cmd);
}
void
kbfunc_exec_term(void *ctx, union arg *arg, enum xev xev)
kbfunc_exec_term(void *ctx, struct cargs *cargs)
{
struct cmd_ctx *cmd;
@ -583,7 +560,7 @@ kbfunc_exec_term(void *ctx, union arg *arg, enum xev xev)
}
void
kbfunc_exec_lock(void *ctx, union arg *arg, enum xev xev)
kbfunc_exec_lock(void *ctx, struct cargs *cargs)
{
struct cmd_ctx *cmd;

View File

@ -33,7 +33,7 @@
#include "calmwm.h"
void
mousefunc_client_resize(void *ctx, union arg *arg, enum xev xev)
mousefunc_client_resize(void *ctx, struct cargs *cargs)
{
struct client_ctx *cc = ctx;
XEvent ev;
@ -79,11 +79,7 @@ mousefunc_client_resize(void *ctx, union arg *arg, enum xev xev)
XUngrabPointer(X_Dpy, CurrentTime);
/* Make sure the pointer stays within the window. */
if (cc->ptr.x > cc->geom.w)
cc->ptr.x = cc->geom.w - cc->bwidth;
if (cc->ptr.y > cc->geom.h)
cc->ptr.y = cc->geom.h - cc->bwidth;
client_ptrwarp(cc);
client_ptr_inbound(cc, 0);
return;
}
}
@ -91,31 +87,20 @@ mousefunc_client_resize(void *ctx, union arg *arg, enum xev xev)
}
void
mousefunc_client_move(void *ctx, union arg *arg, enum xev xev)
mousefunc_client_move(void *ctx, struct cargs *cargs)
{
struct client_ctx *cc = ctx;
XEvent ev;
Time ltime = 0;
struct screen_ctx *sc = cc->sc;
struct geom area;
int px, py;
client_raise(cc);
if (cc->flags & CLIENT_FREEZE)
return;
xu_ptr_getpos(cc->win, &px, &py);
if (px < 0)
px = 0;
else if (px > cc->geom.w)
px = cc->geom.w;
if (py < 0)
py = 0;
else if (py > cc->geom.h)
py = cc->geom.h;
xu_ptr_setpos(cc->win, px, py);
client_ptr_inbound(cc, 1);
if (XGrabPointer(X_Dpy, cc->win, False, MOUSEMASK,
GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_MOVE],
@ -134,8 +119,8 @@ mousefunc_client_move(void *ctx, union arg *arg, enum xev xev)
continue;
ltime = ev.xmotion.time;
cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
cc->geom.x = ev.xmotion.x_root - cc->ptr.x - cc->bwidth;
cc->geom.y = ev.xmotion.y_root - cc->ptr.y - cc->bwidth;
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,

View File

@ -118,7 +118,7 @@ main : FONTNAME STRING {
conf->stickygroups = $2;
}
| BORDERWIDTH NUMBER {
if ($2 < 0 || $2 > UINT_MAX) {
if ($2 < 0 || $2 > INT_MAX) {
yyerror("invalid borderwidth");
YYERROR;
}

View File

@ -215,7 +215,6 @@ xev_handle_enternotify(XEvent *ee)
client_setactive(cc);
}
/* We can split this into two event handlers. */
static void
xev_handle_buttonpress(XEvent *ee)
{
@ -233,22 +232,23 @@ xev_handle_buttonpress(XEvent *ee)
if (mb == NULL)
return;
mb->cargs->xev = CWM_XEV_BTN;
switch (mb->context) {
case CWM_CONTEXT_CC:
if (((cc = client_find(e->window)) == NULL) &&
(cc = client_current()) == NULL)
return;
(*mb->callback)(cc, &mb->argument, CWM_XEV_BTN);
(*mb->callback)(cc, mb->cargs);
break;
case CWM_CONTEXT_SC:
if (e->window != e->root)
return;
if ((sc = screen_find(e->window)) == NULL)
return;
(*mb->callback)(sc, &mb->argument, CWM_XEV_BTN);
(*mb->callback)(sc, mb->cargs);
break;
case CWM_CONTEXT_NONE:
(*mb->callback)(NULL, &mb->argument, CWM_XEV_BTN);
(*mb->callback)(NULL, mb->cargs);
break;
}
}
@ -295,20 +295,21 @@ xev_handle_keypress(XEvent *ee)
if (kb == NULL)
return;
kb->cargs->xev = CWM_XEV_KEY;
switch (kb->context) {
case CWM_CONTEXT_CC:
if (((cc = client_find(e->window)) == NULL) &&
(cc = client_current()) == NULL)
return;
(*kb->callback)(cc, &kb->argument, CWM_XEV_KEY);
(*kb->callback)(cc, kb->cargs);
break;
case CWM_CONTEXT_SC:
if ((sc = screen_find(e->window)) == NULL)
return;
(*kb->callback)(sc, &kb->argument, CWM_XEV_KEY);
(*kb->callback)(sc, kb->cargs);
break;
case CWM_CONTEXT_NONE:
(*kb->callback)(NULL, &kb->argument, CWM_XEV_KEY);
(*kb->callback)(NULL, kb->cargs);
break;
}
}