mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Refactor callbacks to take a void * so as to not try and generalize into
client_ctx in keypress and buttonpress event handlers; pass appropriate *ctx's based on context. While here, limit some globals, replace defines with appropriate variables and fix some naming.
This commit is contained in:
parent
38eac7d7e9
commit
0bb1be86c6
27
calmwm.c
27
calmwm.c
@ -36,18 +36,14 @@
|
|||||||
|
|
||||||
#include "calmwm.h"
|
#include "calmwm.h"
|
||||||
|
|
||||||
Display *X_Dpy;
|
Display *X_Dpy;
|
||||||
Time Last_Event_Time = CurrentTime;
|
Time Last_Event_Time = CurrentTime;
|
||||||
Atom cwmh[CWMH_NITEMS];
|
Atom cwmh[CWMH_NITEMS];
|
||||||
Atom ewmh[EWMH_NITEMS];
|
Atom ewmh[EWMH_NITEMS];
|
||||||
|
struct screen_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
|
||||||
struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
|
struct conf Conf;
|
||||||
|
const char *homedir;
|
||||||
int HasRandr, Randr_ev;
|
volatile sig_atomic_t cwm_status;
|
||||||
struct conf Conf;
|
|
||||||
const char *homedir;
|
|
||||||
char *wm_argv;
|
|
||||||
volatile sig_atomic_t cwm_status;
|
|
||||||
|
|
||||||
static void sighdlr(int);
|
static void sighdlr(int);
|
||||||
static int x_errorhandler(Display *, XErrorEvent *);
|
static int x_errorhandler(Display *, XErrorEvent *);
|
||||||
@ -67,7 +63,7 @@ main(int argc, char **argv)
|
|||||||
warnx("no locale support");
|
warnx("no locale support");
|
||||||
mbtowc(NULL, NULL, MB_CUR_MAX);
|
mbtowc(NULL, NULL, MB_CUR_MAX);
|
||||||
|
|
||||||
wm_argv = u_argv(argv);
|
Conf.wm_argv = u_argv(argv);
|
||||||
while ((ch = getopt(argc, argv, "c:d:")) != -1) {
|
while ((ch = getopt(argc, argv, "c:d:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'c':
|
case 'c':
|
||||||
@ -107,6 +103,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
conf_init(&Conf);
|
conf_init(&Conf);
|
||||||
|
|
||||||
if (conf_path && (parse_config(conf_path, &Conf) == -1))
|
if (conf_path && (parse_config(conf_path, &Conf) == -1))
|
||||||
warnx("config file %s has errors", conf_path);
|
warnx("config file %s has errors", conf_path);
|
||||||
free(conf_path);
|
free(conf_path);
|
||||||
@ -121,7 +118,7 @@ main(int argc, char **argv)
|
|||||||
xev_process();
|
xev_process();
|
||||||
x_teardown();
|
x_teardown();
|
||||||
if (cwm_status == CWM_EXEC_WM)
|
if (cwm_status == CWM_EXEC_WM)
|
||||||
u_exec(wm_argv);
|
u_exec(Conf.wm_argv);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@ -139,7 +136,7 @@ x_init(const char *dpyname)
|
|||||||
XSync(X_Dpy, False);
|
XSync(X_Dpy, False);
|
||||||
XSetErrorHandler(x_errorhandler);
|
XSetErrorHandler(x_errorhandler);
|
||||||
|
|
||||||
HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
|
Conf.xrandr = XRRQueryExtension(X_Dpy, &Conf.xrandr_event_base, &i);
|
||||||
|
|
||||||
conf_atoms();
|
conf_atoms();
|
||||||
conf_cursor(&Conf);
|
conf_cursor(&Conf);
|
||||||
|
238
calmwm.h
238
calmwm.h
@ -57,41 +57,14 @@
|
|||||||
#define CWM_BIGAMOUNT 0x0010
|
#define CWM_BIGAMOUNT 0x0010
|
||||||
#define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
|
#define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
|
||||||
|
|
||||||
#define CWM_CLIENT_CYCLE 0x0001
|
#define CWM_CYCLE_FORWARD 0x0001
|
||||||
#define CWM_CLIENT_RCYCLE 0x0002
|
#define CWM_CYCLE_REVERSE 0x0002
|
||||||
#define CWM_CLIENT_CYCLE_INGRP 0x0004
|
#define CWM_CYCLE_INGROUP 0x0004
|
||||||
|
|
||||||
#define CWM_CLIENT_TILE_HORIZ 0x0001
|
enum cwm_status {
|
||||||
#define CWM_CLIENT_TILE_VERT 0x0002
|
CWM_QUIT,
|
||||||
|
CWM_RUNNING,
|
||||||
#define CWM_MENU_EXEC 0x0001
|
CWM_EXEC_WM
|
||||||
#define CWM_MENU_EXEC_WM 0x0002
|
|
||||||
|
|
||||||
#define CWM_MENU_DUMMY 0x0001
|
|
||||||
#define CWM_MENU_FILE 0x0002
|
|
||||||
#define CWM_MENU_LIST 0x0004
|
|
||||||
|
|
||||||
#define CWM_GAP 0x0001
|
|
||||||
#define CWM_NOGAP 0x0002
|
|
||||||
|
|
||||||
#define CWM_KEY 0x0001
|
|
||||||
#define CWM_BTN 0x0002
|
|
||||||
|
|
||||||
#define CWM_CONTEXT_NONE 0x0000
|
|
||||||
#define CWM_CONTEXT_CLIENT 0x0001
|
|
||||||
#define CWM_CONTEXT_SCREEN 0x0002
|
|
||||||
|
|
||||||
#define CWM_QUIT 0x0000
|
|
||||||
#define CWM_RUNNING 0x0001
|
|
||||||
#define CWM_EXEC_WM 0x0002
|
|
||||||
|
|
||||||
union arg {
|
|
||||||
char *c;
|
|
||||||
int i;
|
|
||||||
};
|
|
||||||
union press {
|
|
||||||
KeySym keysym;
|
|
||||||
unsigned int button;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cursor_font {
|
enum cursor_font {
|
||||||
@ -121,6 +94,10 @@ struct geom {
|
|||||||
int h;
|
int h;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum apply_gap {
|
||||||
|
CWM_NOGAP = 0,
|
||||||
|
CWM_GAP
|
||||||
|
};
|
||||||
struct gap {
|
struct gap {
|
||||||
int top;
|
int top;
|
||||||
int bottom;
|
int bottom;
|
||||||
@ -132,7 +109,7 @@ struct winname {
|
|||||||
TAILQ_ENTRY(winname) entry;
|
TAILQ_ENTRY(winname) entry;
|
||||||
char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(winname_q, winname);
|
TAILQ_HEAD(name_q, winname);
|
||||||
TAILQ_HEAD(ignore_q, winname);
|
TAILQ_HEAD(ignore_q, winname);
|
||||||
|
|
||||||
struct client_ctx {
|
struct client_ctx {
|
||||||
@ -185,31 +162,31 @@ struct client_ctx {
|
|||||||
#define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
|
#define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
|
||||||
int flags;
|
int flags;
|
||||||
int stackingorder;
|
int stackingorder;
|
||||||
struct winname_q nameq;
|
struct name_q nameq;
|
||||||
char *name;
|
char *name;
|
||||||
char *label;
|
char *label;
|
||||||
char *matchname;
|
char *matchname;
|
||||||
XClassHint ch;
|
XClassHint ch;
|
||||||
XWMHints *wmh;
|
XWMHints *wmh;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(client_ctx_q, client_ctx);
|
TAILQ_HEAD(client_q, client_ctx);
|
||||||
|
|
||||||
struct group_ctx {
|
struct group_ctx {
|
||||||
TAILQ_ENTRY(group_ctx) entry;
|
TAILQ_ENTRY(group_ctx) entry;
|
||||||
struct screen_ctx *sc;
|
struct screen_ctx *sc;
|
||||||
char *name;
|
char *name;
|
||||||
int num;
|
int num;
|
||||||
struct client_ctx_q clientq;
|
struct client_q clientq;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(group_ctx_q, group_ctx);
|
TAILQ_HEAD(group_q, group_ctx);
|
||||||
|
|
||||||
struct autogroupwin {
|
struct autogroup {
|
||||||
TAILQ_ENTRY(autogroupwin) entry;
|
TAILQ_ENTRY(autogroup) entry;
|
||||||
char *class;
|
char *class;
|
||||||
char *name;
|
char *name;
|
||||||
int num;
|
int num;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(autogroupwin_q, autogroupwin);
|
TAILQ_HEAD(autogroup_q, autogroup);
|
||||||
|
|
||||||
struct region_ctx {
|
struct region_ctx {
|
||||||
TAILQ_ENTRY(region_ctx) entry;
|
TAILQ_ENTRY(region_ctx) entry;
|
||||||
@ -218,7 +195,7 @@ struct region_ctx {
|
|||||||
struct geom view; /* viewable area */
|
struct geom view; /* viewable area */
|
||||||
struct geom work; /* workable area, gap-applied */
|
struct geom work; /* workable area, gap-applied */
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(region_ctx_q, region_ctx);
|
TAILQ_HEAD(region_q, region_ctx);
|
||||||
|
|
||||||
struct screen_ctx {
|
struct screen_ctx {
|
||||||
TAILQ_ENTRY(screen_ctx) entry;
|
TAILQ_ENTRY(screen_ctx) entry;
|
||||||
@ -230,9 +207,9 @@ struct screen_ctx {
|
|||||||
struct geom view; /* viewable area */
|
struct geom view; /* viewable area */
|
||||||
struct geom work; /* workable area, gap-applied */
|
struct geom work; /* workable area, gap-applied */
|
||||||
struct gap gap;
|
struct gap gap;
|
||||||
struct client_ctx_q clientq;
|
struct client_q clientq;
|
||||||
struct region_ctx_q regionq;
|
struct region_q regionq;
|
||||||
struct group_ctx_q groupq;
|
struct group_q groupq;
|
||||||
struct group_ctx *group_active;
|
struct group_ctx *group_active;
|
||||||
struct {
|
struct {
|
||||||
Window win;
|
Window win;
|
||||||
@ -241,25 +218,50 @@ struct screen_ctx {
|
|||||||
XftColor xftcolor[CWM_COLOR_NITEMS];
|
XftColor xftcolor[CWM_COLOR_NITEMS];
|
||||||
XftFont *xftfont;
|
XftFont *xftfont;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(screen_ctx_q, screen_ctx);
|
TAILQ_HEAD(screen_q, screen_ctx);
|
||||||
|
|
||||||
struct binding {
|
enum xev {
|
||||||
TAILQ_ENTRY(binding) entry;
|
CWM_XEV_KEY,
|
||||||
void (*callback)(struct client_ctx *, union arg *, int);
|
CWM_XEV_BTN
|
||||||
|
};
|
||||||
|
union arg {
|
||||||
|
char *c;
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
union press {
|
||||||
|
KeySym keysym;
|
||||||
|
unsigned int button;
|
||||||
|
};
|
||||||
|
enum context {
|
||||||
|
CWM_CONTEXT_NONE,
|
||||||
|
CWM_CONTEXT_CC,
|
||||||
|
CWM_CONTEXT_SC
|
||||||
|
};
|
||||||
|
struct bind_ctx {
|
||||||
|
TAILQ_ENTRY(bind_ctx) entry;
|
||||||
|
void (*callback)(void *, union arg *, enum xev);
|
||||||
union arg argument;
|
union arg argument;
|
||||||
unsigned int modmask;
|
unsigned int modmask;
|
||||||
union press press;
|
union press press;
|
||||||
int context;
|
enum context context;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(keybinding_q, binding);
|
TAILQ_HEAD(keybind_q, bind_ctx);
|
||||||
TAILQ_HEAD(mousebinding_q, binding);
|
TAILQ_HEAD(mousebind_q, bind_ctx);
|
||||||
|
|
||||||
struct cmd {
|
struct cmd_ctx {
|
||||||
TAILQ_ENTRY(cmd) entry;
|
TAILQ_ENTRY(cmd_ctx) entry;
|
||||||
char *name;
|
char *name;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(cmd_q, cmd);
|
TAILQ_HEAD(cmd_q, cmd_ctx);
|
||||||
|
|
||||||
|
enum menu_exec {
|
||||||
|
CWM_MENU_EXEC_EXEC,
|
||||||
|
CWM_MENU_EXEC_WM
|
||||||
|
};
|
||||||
|
#define CWM_MENU_DUMMY 0x0001
|
||||||
|
#define CWM_MENU_FILE 0x0002
|
||||||
|
#define CWM_MENU_LIST 0x0004
|
||||||
|
|
||||||
struct menu {
|
struct menu {
|
||||||
TAILQ_ENTRY(menu) entry;
|
TAILQ_ENTRY(menu) entry;
|
||||||
@ -274,9 +276,9 @@ struct menu {
|
|||||||
TAILQ_HEAD(menu_q, menu);
|
TAILQ_HEAD(menu_q, menu);
|
||||||
|
|
||||||
struct conf {
|
struct conf {
|
||||||
struct keybinding_q keybindingq;
|
struct keybind_q keybindq;
|
||||||
struct mousebinding_q mousebindingq;
|
struct mousebind_q mousebindq;
|
||||||
struct autogroupwin_q autogroupq;
|
struct autogroup_q autogroupq;
|
||||||
struct ignore_q ignoreq;
|
struct ignore_q ignoreq;
|
||||||
struct cmd_q cmdq;
|
struct cmd_q cmdq;
|
||||||
int ngroups;
|
int ngroups;
|
||||||
@ -291,6 +293,9 @@ struct conf {
|
|||||||
char *font;
|
char *font;
|
||||||
char *wmname;
|
char *wmname;
|
||||||
Cursor cursor[CF_NITEMS];
|
Cursor cursor[CF_NITEMS];
|
||||||
|
int xrandr;
|
||||||
|
int xrandr_event_base;
|
||||||
|
char *wm_argv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* MWM hints */
|
/* MWM hints */
|
||||||
@ -321,15 +326,7 @@ struct mwm_hints {
|
|||||||
unsigned long decorations;
|
unsigned long decorations;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Display *X_Dpy;
|
enum cwmh {
|
||||||
extern Time Last_Event_Time;
|
|
||||||
extern struct screen_ctx_q Screenq;
|
|
||||||
extern struct conf Conf;
|
|
||||||
extern char *wm_argv;
|
|
||||||
extern const char *homedir;
|
|
||||||
extern int HasRandr, Randr_ev;
|
|
||||||
|
|
||||||
enum {
|
|
||||||
WM_STATE,
|
WM_STATE,
|
||||||
WM_DELETE_WINDOW,
|
WM_DELETE_WINDOW,
|
||||||
WM_TAKE_FOCUS,
|
WM_TAKE_FOCUS,
|
||||||
@ -339,7 +336,7 @@ enum {
|
|||||||
WM_CHANGE_STATE,
|
WM_CHANGE_STATE,
|
||||||
CWMH_NITEMS
|
CWMH_NITEMS
|
||||||
};
|
};
|
||||||
enum {
|
enum ewmh {
|
||||||
_NET_SUPPORTED,
|
_NET_SUPPORTED,
|
||||||
_NET_SUPPORTING_WM_CHECK,
|
_NET_SUPPORTING_WM_CHECK,
|
||||||
_NET_ACTIVE_WINDOW,
|
_NET_ACTIVE_WINDOW,
|
||||||
@ -367,13 +364,19 @@ enum {
|
|||||||
_CWM_WM_STATE_FREEZE,
|
_CWM_WM_STATE_FREEZE,
|
||||||
EWMH_NITEMS
|
EWMH_NITEMS
|
||||||
};
|
};
|
||||||
enum {
|
enum net_wm_state {
|
||||||
_NET_WM_STATE_REMOVE,
|
_NET_WM_STATE_REMOVE,
|
||||||
_NET_WM_STATE_ADD,
|
_NET_WM_STATE_ADD,
|
||||||
_NET_WM_STATE_TOGGLE
|
_NET_WM_STATE_TOGGLE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern Display *X_Dpy;
|
||||||
|
extern Time Last_Event_Time;
|
||||||
extern Atom cwmh[CWMH_NITEMS];
|
extern Atom cwmh[CWMH_NITEMS];
|
||||||
extern Atom ewmh[EWMH_NITEMS];
|
extern Atom ewmh[EWMH_NITEMS];
|
||||||
|
extern struct screen_q Screenq;
|
||||||
|
extern struct conf Conf;
|
||||||
|
extern const char *homedir;
|
||||||
|
|
||||||
__dead void usage(void);
|
__dead void usage(void);
|
||||||
|
|
||||||
@ -451,57 +454,56 @@ void search_print_group(struct menu *, int);
|
|||||||
struct region_ctx *region_find(struct screen_ctx *, int, int);
|
struct region_ctx *region_find(struct screen_ctx *, int, int);
|
||||||
struct geom screen_apply_gap(struct screen_ctx *, struct geom);
|
struct geom screen_apply_gap(struct screen_ctx *, struct geom);
|
||||||
struct screen_ctx *screen_find(Window);
|
struct screen_ctx *screen_find(Window);
|
||||||
struct geom screen_area(struct screen_ctx *, int, int, int);
|
struct geom screen_area(struct screen_ctx *, int, int,
|
||||||
|
enum apply_gap);
|
||||||
void screen_init(int);
|
void screen_init(int);
|
||||||
void screen_update_geometry(struct screen_ctx *);
|
void screen_update_geometry(struct screen_ctx *);
|
||||||
void screen_updatestackingorder(struct screen_ctx *);
|
void screen_updatestackingorder(struct screen_ctx *);
|
||||||
void screen_assert_clients_within(struct screen_ctx *);
|
void screen_assert_clients_within(struct screen_ctx *);
|
||||||
|
|
||||||
void kbfunc_client_cycle(struct client_ctx *, union arg *, int);
|
void kbfunc_cwm_status(void *, union arg *, enum xev);
|
||||||
void kbfunc_client_delete(struct client_ctx *, union arg *, int);
|
void kbfunc_ptrmove(void *, union arg *, enum xev);
|
||||||
void kbfunc_client_hide(struct client_ctx *, union arg *, int);
|
void kbfunc_client_move(void *, union arg *, enum xev);
|
||||||
void kbfunc_menu_client_label(struct client_ctx *, union arg *, int);
|
void kbfunc_client_resize(void *, union arg *, enum xev);
|
||||||
void kbfunc_client_lower(struct client_ctx *, union arg *, int);
|
void kbfunc_client_delete(void *, union arg *, enum xev);
|
||||||
void kbfunc_client_move(struct client_ctx *, union arg *, int);
|
void kbfunc_client_lower(void *, union arg *, enum xev);
|
||||||
void kbfunc_client_movetogroup(struct client_ctx *,
|
void kbfunc_client_raise(void *, union arg *, enum xev);
|
||||||
union arg *, int);
|
void kbfunc_client_hide(void *, union arg *, enum xev);
|
||||||
void kbfunc_client_raise(struct client_ctx *, union arg *, int);
|
void kbfunc_client_toggle_freeze(void *,
|
||||||
void kbfunc_client_resize(struct client_ctx *, union arg *, int);
|
union arg *, enum xev);
|
||||||
void kbfunc_client_tile(struct client_ctx *, union arg *, int);
|
void kbfunc_client_toggle_sticky(void *,
|
||||||
void kbfunc_client_toggle_group(struct client_ctx *,
|
union arg *, enum xev);
|
||||||
union arg *, int);
|
void kbfunc_client_toggle_fullscreen(void *,
|
||||||
void kbfunc_client_toggle_freeze(struct client_ctx *,
|
union arg *, enum xev);
|
||||||
union arg *, int);
|
void kbfunc_client_toggle_maximize(void *,
|
||||||
void kbfunc_client_toggle_fullscreen(struct client_ctx *,
|
union arg *, enum xev);
|
||||||
union arg *, int);
|
void kbfunc_client_toggle_hmaximize(void *,
|
||||||
void kbfunc_client_toggle_hmaximize(struct client_ctx *,
|
union arg *, enum xev);
|
||||||
union arg *, int);
|
void kbfunc_client_toggle_vmaximize(void *,
|
||||||
void kbfunc_client_toggle_maximize(struct client_ctx *,
|
union arg *, enum xev);
|
||||||
union arg *, int);
|
void kbfunc_client_htile(void *, union arg *, enum xev);
|
||||||
void kbfunc_client_toggle_sticky(struct client_ctx *,
|
void kbfunc_client_vtile(void *, union arg *, enum xev);
|
||||||
union arg *, int);
|
void kbfunc_client_cycle(void *, union arg *, enum xev);
|
||||||
void kbfunc_client_toggle_vmaximize(struct client_ctx *,
|
void kbfunc_client_toggle_group(void *,
|
||||||
union arg *, int);
|
union arg *, enum xev);
|
||||||
void kbfunc_cwm_status(struct client_ctx *, union arg *, int);
|
void kbfunc_client_movetogroup(void *,
|
||||||
void kbfunc_exec(struct client_ctx *, union arg *, int);
|
union arg *, enum xev);
|
||||||
void kbfunc_exec_lock(struct client_ctx *, union arg *, int);
|
void kbfunc_group_toggle(void *, union arg *, enum xev);
|
||||||
void kbfunc_exec_term(struct client_ctx *, union arg *, int);
|
void kbfunc_group_only(void *, union arg *, enum xev);
|
||||||
void kbfunc_group_alltoggle(struct client_ctx *,
|
void kbfunc_group_cycle(void *, union arg *, enum xev);
|
||||||
union arg *, int);
|
void kbfunc_group_alltoggle(void *, union arg *, enum xev);
|
||||||
void kbfunc_group_cycle(struct client_ctx *, union arg *, int);
|
void kbfunc_menu_client(void *, union arg *, enum xev);
|
||||||
void kbfunc_group_only(struct client_ctx *, union arg *, int);
|
void kbfunc_menu_cmd(void *, union arg *, enum xev);
|
||||||
void kbfunc_group_toggle(struct client_ctx *, union arg *, int);
|
void kbfunc_menu_group(void *, union arg *, enum xev);
|
||||||
void kbfunc_menu_exec(struct client_ctx *, union arg *, int);
|
void kbfunc_menu_exec(void *, union arg *, enum xev);
|
||||||
void kbfunc_menu_client(struct client_ctx *, union arg *, int);
|
void kbfunc_menu_ssh(void *, union arg *, enum xev);
|
||||||
void kbfunc_menu_cmd(struct client_ctx *, union arg *, int);
|
void kbfunc_menu_client_label(void *, union arg *, enum xev);
|
||||||
void kbfunc_menu_group(struct client_ctx *, union arg *, int);
|
void kbfunc_exec_cmd(void *, union arg *, enum xev);
|
||||||
void kbfunc_menu_ssh(struct client_ctx *, union arg *, int);
|
void kbfunc_exec_lock(void *, union arg *, enum xev);
|
||||||
void kbfunc_ptrmove(struct client_ctx *, union arg *, int);
|
void kbfunc_exec_term(void *, union arg *, enum xev);
|
||||||
|
|
||||||
void mousefunc_client_move(struct client_ctx *,
|
void mousefunc_client_move(void *, union arg *, enum xev);
|
||||||
union arg *, int);
|
void mousefunc_client_resize(void *, union arg *, enum xev);
|
||||||
void mousefunc_client_resize(struct client_ctx *,
|
|
||||||
union arg *, int);
|
|
||||||
|
|
||||||
void menu_windraw(struct screen_ctx *, Window,
|
void menu_windraw(struct screen_ctx *, Window,
|
||||||
const char *, ...);
|
const char *, ...);
|
||||||
|
12
client.c
12
client.c
@ -653,20 +653,20 @@ client_cycle(struct screen_ctx *sc, int flags)
|
|||||||
|
|
||||||
oldcc = client_current();
|
oldcc = client_current();
|
||||||
if (oldcc == NULL)
|
if (oldcc == NULL)
|
||||||
oldcc = (flags & CWM_CLIENT_RCYCLE) ?
|
oldcc = (flags & CWM_CYCLE_REVERSE) ?
|
||||||
TAILQ_LAST(&sc->clientq, client_ctx_q) :
|
TAILQ_LAST(&sc->clientq, client_q) :
|
||||||
TAILQ_FIRST(&sc->clientq);
|
TAILQ_FIRST(&sc->clientq);
|
||||||
|
|
||||||
newcc = oldcc;
|
newcc = oldcc;
|
||||||
while (again) {
|
while (again) {
|
||||||
again = 0;
|
again = 0;
|
||||||
|
|
||||||
newcc = (flags & CWM_CLIENT_RCYCLE) ? client_prev(newcc) :
|
newcc = (flags & CWM_CYCLE_REVERSE) ? client_prev(newcc) :
|
||||||
client_next(newcc);
|
client_next(newcc);
|
||||||
|
|
||||||
/* Only cycle visible and non-ignored windows. */
|
/* Only cycle visible and non-ignored windows. */
|
||||||
if ((newcc->flags & (CLIENT_HIDDEN | CLIENT_IGNORE))
|
if ((newcc->flags & (CLIENT_HIDDEN | CLIENT_IGNORE))
|
||||||
|| ((flags & CWM_CLIENT_CYCLE_INGRP) &&
|
|| ((flags & CWM_CYCLE_INGROUP) &&
|
||||||
(newcc->gc != oldcc->gc)))
|
(newcc->gc != oldcc->gc)))
|
||||||
again = 1;
|
again = 1;
|
||||||
|
|
||||||
@ -721,8 +721,8 @@ client_prev(struct client_ctx *cc)
|
|||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
struct client_ctx *newcc;
|
struct client_ctx *newcc;
|
||||||
|
|
||||||
return(((newcc = TAILQ_PREV(cc, client_ctx_q, entry)) != NULL) ?
|
return(((newcc = TAILQ_PREV(cc, client_q, entry)) != NULL) ?
|
||||||
newcc : TAILQ_LAST(&sc->clientq, client_ctx_q));
|
newcc : TAILQ_LAST(&sc->clientq, client_q));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
306
conf.c
306
conf.c
@ -34,13 +34,13 @@
|
|||||||
|
|
||||||
static const char *conf_bind_getmask(const char *, unsigned int *);
|
static const char *conf_bind_getmask(const char *, unsigned int *);
|
||||||
static void conf_cmd_remove(struct conf *, const char *);
|
static void conf_cmd_remove(struct conf *, const char *);
|
||||||
static void conf_unbind_kbd(struct conf *, struct binding *);
|
static void conf_unbind_kbd(struct conf *, struct bind_ctx *);
|
||||||
static void conf_unbind_mouse(struct conf *, struct binding *);
|
static void conf_unbind_mouse(struct conf *, struct bind_ctx *);
|
||||||
|
|
||||||
int
|
int
|
||||||
conf_cmd_add(struct conf *c, const char *name, const char *path)
|
conf_cmd_add(struct conf *c, const char *name, const char *path)
|
||||||
{
|
{
|
||||||
struct cmd *cmd;
|
struct cmd_ctx *cmd;
|
||||||
|
|
||||||
cmd = xmalloc(sizeof(*cmd));
|
cmd = xmalloc(sizeof(*cmd));
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ conf_cmd_add(struct conf *c, const char *name, const char *path)
|
|||||||
static void
|
static void
|
||||||
conf_cmd_remove(struct conf *c, const char *name)
|
conf_cmd_remove(struct conf *c, const char *name)
|
||||||
{
|
{
|
||||||
struct cmd *cmd = NULL, *cmdnxt;
|
struct cmd_ctx *cmd = NULL, *cmdnxt;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(cmd, &c->cmdq, entry, cmdnxt) {
|
TAILQ_FOREACH_SAFE(cmd, &c->cmdq, entry, cmdnxt) {
|
||||||
if (strcmp(cmd->name, name) == 0) {
|
if (strcmp(cmd->name, name) == 0) {
|
||||||
@ -74,31 +74,31 @@ conf_cmd_remove(struct conf *c, const char *name)
|
|||||||
void
|
void
|
||||||
conf_autogroup(struct conf *c, int num, const char *name, const char *class)
|
conf_autogroup(struct conf *c, int num, const char *name, const char *class)
|
||||||
{
|
{
|
||||||
struct autogroupwin *aw;
|
struct autogroup *ag;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
aw = xmalloc(sizeof(*aw));
|
ag = xmalloc(sizeof(*ag));
|
||||||
|
|
||||||
if ((p = strchr(class, ',')) == NULL) {
|
if ((p = strchr(class, ',')) == NULL) {
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
aw->name = NULL;
|
ag->name = NULL;
|
||||||
else
|
else
|
||||||
aw->name = xstrdup(name);
|
ag->name = xstrdup(name);
|
||||||
|
|
||||||
aw->class = xstrdup(class);
|
ag->class = xstrdup(class);
|
||||||
} else {
|
} else {
|
||||||
*(p++) = '\0';
|
*(p++) = '\0';
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
aw->name = xstrdup(class);
|
ag->name = xstrdup(class);
|
||||||
else
|
else
|
||||||
aw->name = xstrdup(name);
|
ag->name = xstrdup(name);
|
||||||
|
|
||||||
aw->class = xstrdup(p);
|
ag->class = xstrdup(p);
|
||||||
}
|
}
|
||||||
aw->num = num;
|
ag->num = num;
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry);
|
TAILQ_INSERT_TAIL(&c->autogroupq, ag, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -264,9 +264,9 @@ conf_init(struct conf *c)
|
|||||||
|
|
||||||
TAILQ_INIT(&c->ignoreq);
|
TAILQ_INIT(&c->ignoreq);
|
||||||
TAILQ_INIT(&c->cmdq);
|
TAILQ_INIT(&c->cmdq);
|
||||||
TAILQ_INIT(&c->keybindingq);
|
TAILQ_INIT(&c->keybindq);
|
||||||
TAILQ_INIT(&c->autogroupq);
|
TAILQ_INIT(&c->autogroupq);
|
||||||
TAILQ_INIT(&c->mousebindingq);
|
TAILQ_INIT(&c->mousebindq);
|
||||||
|
|
||||||
for (i = 0; i < nitems(kbd_binds); i++)
|
for (i = 0; i < nitems(kbd_binds); i++)
|
||||||
conf_bind_kbd(c, kbd_binds[i].key, kbd_binds[i].func);
|
conf_bind_kbd(c, kbd_binds[i].key, kbd_binds[i].func);
|
||||||
@ -290,10 +290,10 @@ conf_init(struct conf *c)
|
|||||||
void
|
void
|
||||||
conf_clear(struct conf *c)
|
conf_clear(struct conf *c)
|
||||||
{
|
{
|
||||||
struct autogroupwin *aw;
|
struct autogroup *ag;
|
||||||
struct binding *kb, *mb;
|
struct bind_ctx *kb, *mb;
|
||||||
struct winname *wn;
|
struct winname *wn;
|
||||||
struct cmd *cmd;
|
struct cmd_ctx *cmd;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) {
|
while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) {
|
||||||
@ -302,16 +302,16 @@ conf_clear(struct conf *c)
|
|||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((kb = TAILQ_FIRST(&c->keybindingq)) != NULL) {
|
while ((kb = TAILQ_FIRST(&c->keybindq)) != NULL) {
|
||||||
TAILQ_REMOVE(&c->keybindingq, kb, entry);
|
TAILQ_REMOVE(&c->keybindq, kb, entry);
|
||||||
free(kb);
|
free(kb);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((aw = TAILQ_FIRST(&c->autogroupq)) != NULL) {
|
while ((ag = TAILQ_FIRST(&c->autogroupq)) != NULL) {
|
||||||
TAILQ_REMOVE(&c->autogroupq, aw, entry);
|
TAILQ_REMOVE(&c->autogroupq, ag, entry);
|
||||||
free(aw->class);
|
free(ag->class);
|
||||||
free(aw->name);
|
free(ag->name);
|
||||||
free(aw);
|
free(ag);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((wn = TAILQ_FIRST(&c->ignoreq)) != NULL) {
|
while ((wn = TAILQ_FIRST(&c->ignoreq)) != NULL) {
|
||||||
@ -320,8 +320,8 @@ conf_clear(struct conf *c)
|
|||||||
free(wn);
|
free(wn);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((mb = TAILQ_FIRST(&c->mousebindingq)) != NULL) {
|
while ((mb = TAILQ_FIRST(&c->mousebindq)) != NULL) {
|
||||||
TAILQ_REMOVE(&c->mousebindingq, mb, entry);
|
TAILQ_REMOVE(&c->mousebindq, mb, entry);
|
||||||
free(mb);
|
free(mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,147 +351,133 @@ conf_client(struct client_ctx *cc)
|
|||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *tag;
|
const char *tag;
|
||||||
void (*handler)(struct client_ctx *, union arg *, int);
|
void (*handler)(void *, union arg *, enum xev);
|
||||||
int context;
|
int context;
|
||||||
union arg argument;
|
union arg argument;
|
||||||
} name_to_func[] = {
|
} name_to_func[] = {
|
||||||
{ "lower", kbfunc_client_lower, CWM_CONTEXT_CLIENT, {0} },
|
{ "lower", kbfunc_client_lower, CWM_CONTEXT_CC, {0} },
|
||||||
{ "raise", kbfunc_client_raise, CWM_CONTEXT_CLIENT, {0} },
|
{ "raise", kbfunc_client_raise, CWM_CONTEXT_CC, {0} },
|
||||||
{ "search", kbfunc_menu_client, CWM_CONTEXT_SCREEN, {0} },
|
{ "search", kbfunc_menu_client, CWM_CONTEXT_SC, {0} },
|
||||||
{ "menusearch", kbfunc_menu_cmd, CWM_CONTEXT_SCREEN, {0} },
|
{ "menusearch", kbfunc_menu_cmd, CWM_CONTEXT_SC, {0} },
|
||||||
{ "groupsearch", kbfunc_menu_group, CWM_CONTEXT_SCREEN, {0} },
|
{ "groupsearch", kbfunc_menu_group, CWM_CONTEXT_SC, {0} },
|
||||||
{ "hide", kbfunc_client_hide, CWM_CONTEXT_CLIENT, {0} },
|
{ "hide", kbfunc_client_hide, CWM_CONTEXT_CC, {0} },
|
||||||
{ "cycle", kbfunc_client_cycle, CWM_CONTEXT_SCREEN,
|
{ "cycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
|
||||||
{.i = CWM_CLIENT_CYCLE} },
|
{.i = CWM_CYCLE_FORWARD} },
|
||||||
{ "rcycle", kbfunc_client_cycle, CWM_CONTEXT_SCREEN,
|
{ "rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
|
||||||
{.i = CWM_CLIENT_RCYCLE} },
|
{.i = CWM_CYCLE_REVERSE} },
|
||||||
{ "label", kbfunc_menu_client_label, CWM_CONTEXT_CLIENT, {0} },
|
{ "label", kbfunc_menu_client_label, CWM_CONTEXT_CC, {0} },
|
||||||
{ "delete", kbfunc_client_delete, CWM_CONTEXT_CLIENT, {0} },
|
{ "delete", kbfunc_client_delete, CWM_CONTEXT_CC, {0} },
|
||||||
{ "group1", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 1} },
|
{ "group1", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 1} },
|
||||||
{ "group2", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 2} },
|
{ "group2", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 2} },
|
||||||
{ "group3", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 3} },
|
{ "group3", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 3} },
|
||||||
{ "group4", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 4} },
|
{ "group4", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 4} },
|
||||||
{ "group5", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 5} },
|
{ "group5", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 5} },
|
||||||
{ "group6", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 6} },
|
{ "group6", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 6} },
|
||||||
{ "group7", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 7} },
|
{ "group7", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 7} },
|
||||||
{ "group8", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 8} },
|
{ "group8", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 8} },
|
||||||
{ "group9", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 9} },
|
{ "group9", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 9} },
|
||||||
{ "grouponly1", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 1} },
|
{ "grouponly1", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 1} },
|
||||||
{ "grouponly2", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 2} },
|
{ "grouponly2", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 2} },
|
||||||
{ "grouponly3", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 3} },
|
{ "grouponly3", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 3} },
|
||||||
{ "grouponly4", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 4} },
|
{ "grouponly4", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 4} },
|
||||||
{ "grouponly5", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 5} },
|
{ "grouponly5", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 5} },
|
||||||
{ "grouponly6", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 6} },
|
{ "grouponly6", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 6} },
|
||||||
{ "grouponly7", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 7} },
|
{ "grouponly7", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 7} },
|
||||||
{ "grouponly8", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 8} },
|
{ "grouponly8", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 8} },
|
||||||
{ "grouponly9", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 9} },
|
{ "grouponly9", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 9} },
|
||||||
{ "movetogroup1", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
|
{ "movetogroup1", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 1} },
|
||||||
{.i = 1} },
|
{ "movetogroup2", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 2} },
|
||||||
{ "movetogroup2", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
|
{ "movetogroup3", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 3} },
|
||||||
{.i = 2} },
|
{ "movetogroup4", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 4} },
|
||||||
{ "movetogroup3", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
|
{ "movetogroup5", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 5} },
|
||||||
{.i = 3} },
|
{ "movetogroup6", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 6} },
|
||||||
{ "movetogroup4", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
|
{ "movetogroup7", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 7} },
|
||||||
{.i = 4} },
|
{ "movetogroup8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 8} },
|
||||||
{ "movetogroup5", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
|
{ "movetogroup9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 9} },
|
||||||
{.i = 5} },
|
{ "nogroup", kbfunc_group_alltoggle, CWM_CONTEXT_SC, {0} },
|
||||||
{ "movetogroup6", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
|
{ "cyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SC,
|
||||||
{.i = 6} },
|
{.i = CWM_CYCLE_FORWARD} },
|
||||||
{ "movetogroup7", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
|
{ "rcyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SC,
|
||||||
{.i = 7} },
|
{.i = CWM_CYCLE_REVERSE} },
|
||||||
{ "movetogroup8", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
|
{ "cycleingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
|
||||||
{.i = 8} },
|
{.i = (CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP)} },
|
||||||
{ "movetogroup9", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
|
{ "rcycleingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
|
||||||
{.i = 9} },
|
{.i = (CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP)} },
|
||||||
{ "nogroup", kbfunc_group_alltoggle, CWM_CONTEXT_SCREEN, {0} },
|
{ "grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CC, {0} },
|
||||||
{ "cyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SCREEN,
|
{ "stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, {0} },
|
||||||
{.i = CWM_CLIENT_CYCLE} },
|
{ "fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, {0} },
|
||||||
{ "rcyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SCREEN,
|
{ "maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, {0} },
|
||||||
{.i = CWM_CLIENT_RCYCLE} },
|
{ "vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CC, {0} },
|
||||||
{ "cycleingroup", kbfunc_client_cycle, CWM_CONTEXT_CLIENT,
|
{ "hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CC, {0} },
|
||||||
{.i = (CWM_CLIENT_CYCLE | CWM_CLIENT_CYCLE_INGRP)} },
|
{ "freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CC, {0} },
|
||||||
{ "rcycleingroup", kbfunc_client_cycle, CWM_CONTEXT_CLIENT,
|
{ "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_EXEC_WM} },
|
||||||
{.i = (CWM_CLIENT_RCYCLE | CWM_CLIENT_CYCLE_INGRP)} },
|
{ "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_QUIT} },
|
||||||
{ "grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CLIENT, {0} },
|
{ "exec", kbfunc_menu_exec, CWM_CONTEXT_SC,
|
||||||
{ "stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CLIENT, {0} },
|
{.i = CWM_MENU_EXEC_EXEC} },
|
||||||
{ "fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CLIENT,
|
{ "exec_wm", kbfunc_menu_exec, CWM_CONTEXT_SC,
|
||||||
{0} },
|
|
||||||
{ "maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CLIENT, {0} },
|
|
||||||
{ "vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CLIENT,
|
|
||||||
{0} },
|
|
||||||
{ "hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CLIENT,
|
|
||||||
{0} },
|
|
||||||
{ "freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CLIENT, {0} },
|
|
||||||
{ "restart", kbfunc_cwm_status, CWM_CONTEXT_SCREEN,
|
|
||||||
{.i = CWM_EXEC_WM} },
|
|
||||||
{ "quit", kbfunc_cwm_status, CWM_CONTEXT_SCREEN, {.i = CWM_QUIT} },
|
|
||||||
{ "exec", kbfunc_menu_exec, CWM_CONTEXT_SCREEN, {.i = CWM_MENU_EXEC} },
|
|
||||||
{ "exec_wm", kbfunc_menu_exec, CWM_CONTEXT_SCREEN,
|
|
||||||
{.i = CWM_MENU_EXEC_WM} },
|
{.i = CWM_MENU_EXEC_WM} },
|
||||||
{ "ssh", kbfunc_menu_ssh, CWM_CONTEXT_SCREEN, {0} },
|
{ "ssh", kbfunc_menu_ssh, CWM_CONTEXT_SC, {0} },
|
||||||
{ "terminal", kbfunc_exec_term, CWM_CONTEXT_SCREEN, {0} },
|
{ "terminal", kbfunc_exec_term, CWM_CONTEXT_SC, {0} },
|
||||||
{ "lock", kbfunc_exec_lock, CWM_CONTEXT_SCREEN, {0} },
|
{ "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, {0} },
|
||||||
{ "moveup", kbfunc_client_move, CWM_CONTEXT_CLIENT,
|
{ "moveup", kbfunc_client_move, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_UP)} },
|
{.i = (CWM_UP)} },
|
||||||
{ "movedown", kbfunc_client_move, CWM_CONTEXT_CLIENT,
|
{ "movedown", kbfunc_client_move, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_DOWN)} },
|
{.i = (CWM_DOWN)} },
|
||||||
{ "moveright", kbfunc_client_move, CWM_CONTEXT_CLIENT,
|
{ "moveright", kbfunc_client_move, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_RIGHT)} },
|
{.i = (CWM_RIGHT)} },
|
||||||
{ "moveleft", kbfunc_client_move, CWM_CONTEXT_CLIENT,
|
{ "moveleft", kbfunc_client_move, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_LEFT)} },
|
{.i = (CWM_LEFT)} },
|
||||||
{ "bigmoveup", kbfunc_client_move, CWM_CONTEXT_CLIENT,
|
{ "bigmoveup", kbfunc_client_move, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
|
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
|
||||||
{ "bigmovedown", kbfunc_client_move, CWM_CONTEXT_CLIENT,
|
{ "bigmovedown", kbfunc_client_move, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
|
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
|
||||||
{ "bigmoveright", kbfunc_client_move, CWM_CONTEXT_CLIENT,
|
{ "bigmoveright", kbfunc_client_move, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
|
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
|
||||||
{ "bigmoveleft", kbfunc_client_move, CWM_CONTEXT_CLIENT,
|
{ "bigmoveleft", kbfunc_client_move, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
|
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
|
||||||
{ "resizeup", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
|
{ "resizeup", kbfunc_client_resize, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_UP)} },
|
{.i = (CWM_UP)} },
|
||||||
{ "resizedown", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
|
{ "resizedown", kbfunc_client_resize, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_DOWN)} },
|
{.i = (CWM_DOWN)} },
|
||||||
{ "resizeright", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
|
{ "resizeright", kbfunc_client_resize, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_RIGHT)} },
|
{.i = (CWM_RIGHT)} },
|
||||||
{ "resizeleft", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
|
{ "resizeleft", kbfunc_client_resize, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_LEFT)} },
|
{.i = (CWM_LEFT)} },
|
||||||
{ "bigresizeup", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
|
{ "bigresizeup", kbfunc_client_resize, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
|
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
|
||||||
{ "bigresizedown", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
|
{ "bigresizedown", kbfunc_client_resize, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
|
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
|
||||||
{ "bigresizeright", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
|
{ "bigresizeright", kbfunc_client_resize, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
|
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
|
||||||
{ "bigresizeleft", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
|
{ "bigresizeleft", kbfunc_client_resize, CWM_CONTEXT_CC,
|
||||||
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
|
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
|
||||||
{ "ptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
|
{ "ptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SC,
|
||||||
{.i = (CWM_UP)} },
|
{.i = (CWM_UP)} },
|
||||||
{ "ptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
|
{ "ptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SC,
|
||||||
{.i = (CWM_DOWN)} },
|
{.i = (CWM_DOWN)} },
|
||||||
{ "ptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
|
{ "ptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SC,
|
||||||
{.i = (CWM_LEFT)} },
|
{.i = (CWM_LEFT)} },
|
||||||
{ "ptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
|
{ "ptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SC,
|
||||||
{.i = (CWM_RIGHT)} },
|
{.i = (CWM_RIGHT)} },
|
||||||
{ "bigptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
|
{ "bigptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SC,
|
||||||
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
|
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
|
||||||
{ "bigptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
|
{ "bigptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SC,
|
||||||
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
|
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
|
||||||
{ "bigptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
|
{ "bigptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SC,
|
||||||
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
|
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
|
||||||
{ "bigptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
|
{ "bigptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SC,
|
||||||
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
|
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
|
||||||
{ "htile", kbfunc_client_tile, CWM_CONTEXT_CLIENT,
|
{ "htile", kbfunc_client_htile, CWM_CONTEXT_CC, {0} },
|
||||||
{.i = CWM_CLIENT_TILE_HORIZ} },
|
{ "vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, {0} },
|
||||||
{ "vtile", kbfunc_client_tile, CWM_CONTEXT_CLIENT,
|
{ "window_lower", kbfunc_client_lower, CWM_CONTEXT_CC, {0} },
|
||||||
{.i = CWM_CLIENT_TILE_VERT} },
|
{ "window_raise", kbfunc_client_raise, CWM_CONTEXT_CC, {0} },
|
||||||
{ "window_lower", kbfunc_client_lower, CWM_CONTEXT_CLIENT, {0} },
|
{ "window_hide", kbfunc_client_hide, CWM_CONTEXT_CC, {0} },
|
||||||
{ "window_raise", kbfunc_client_raise, CWM_CONTEXT_CLIENT, {0} },
|
{ "window_move", mousefunc_client_move, CWM_CONTEXT_CC, {0} },
|
||||||
{ "window_hide", kbfunc_client_hide, CWM_CONTEXT_CLIENT, {0} },
|
{ "window_resize", mousefunc_client_resize, CWM_CONTEXT_CC, {0} },
|
||||||
{ "window_move", mousefunc_client_move, CWM_CONTEXT_CLIENT, {0} },
|
{ "window_grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CC, {0} },
|
||||||
{ "window_resize", mousefunc_client_resize, CWM_CONTEXT_CLIENT, {0} },
|
{ "menu_group", kbfunc_menu_group, CWM_CONTEXT_SC, {0} },
|
||||||
{ "window_grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CLIENT, {0} },
|
{ "menu_unhide", kbfunc_menu_client, CWM_CONTEXT_SC, {0} },
|
||||||
{ "menu_group", kbfunc_menu_group, CWM_CONTEXT_SCREEN, {0} },
|
{ "menu_cmd", kbfunc_menu_cmd, CWM_CONTEXT_SC, {0} },
|
||||||
{ "menu_unhide", kbfunc_menu_client, CWM_CONTEXT_SCREEN, {0} },
|
|
||||||
{ "menu_cmd", kbfunc_menu_cmd, CWM_CONTEXT_SCREEN, {0} },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
@ -526,7 +512,7 @@ conf_bind_getmask(const char *name, unsigned int *mask)
|
|||||||
int
|
int
|
||||||
conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
|
conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
|
||||||
{
|
{
|
||||||
struct binding *kb;
|
struct bind_ctx *kb;
|
||||||
const char *key;
|
const char *key;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@ -555,28 +541,28 @@ conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
|
|||||||
kb->callback = name_to_func[i].handler;
|
kb->callback = name_to_func[i].handler;
|
||||||
kb->context = name_to_func[i].context;
|
kb->context = name_to_func[i].context;
|
||||||
kb->argument = name_to_func[i].argument;
|
kb->argument = name_to_func[i].argument;
|
||||||
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
|
TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
kb->callback = kbfunc_exec;
|
kb->callback = kbfunc_exec_cmd;
|
||||||
kb->context = CWM_CONTEXT_NONE;
|
kb->context = CWM_CONTEXT_NONE;
|
||||||
kb->argument.c = xstrdup(cmd);
|
kb->argument.c = xstrdup(cmd);
|
||||||
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
|
TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
conf_unbind_kbd(struct conf *c, struct binding *unbind)
|
conf_unbind_kbd(struct conf *c, struct bind_ctx *unbind)
|
||||||
{
|
{
|
||||||
struct binding *key = NULL, *keynxt;
|
struct bind_ctx *key = NULL, *keynxt;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(key, &c->keybindingq, entry, keynxt) {
|
TAILQ_FOREACH_SAFE(key, &c->keybindq, entry, keynxt) {
|
||||||
if (key->modmask != unbind->modmask)
|
if (key->modmask != unbind->modmask)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (key->press.keysym == unbind->press.keysym) {
|
if (key->press.keysym == unbind->press.keysym) {
|
||||||
TAILQ_REMOVE(&c->keybindingq, key, entry);
|
TAILQ_REMOVE(&c->keybindq, key, entry);
|
||||||
if (key->context == CWM_CONTEXT_NONE)
|
if (key->context == CWM_CONTEXT_NONE)
|
||||||
free(key->argument.c);
|
free(key->argument.c);
|
||||||
free(key);
|
free(key);
|
||||||
@ -587,7 +573,7 @@ conf_unbind_kbd(struct conf *c, struct binding *unbind)
|
|||||||
int
|
int
|
||||||
conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
|
conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
|
||||||
{
|
{
|
||||||
struct binding *mb;
|
struct bind_ctx *mb;
|
||||||
const char *button, *errstr;
|
const char *button, *errstr;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@ -616,7 +602,7 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
|
|||||||
mb->callback = name_to_func[i].handler;
|
mb->callback = name_to_func[i].handler;
|
||||||
mb->context = name_to_func[i].context;
|
mb->context = name_to_func[i].context;
|
||||||
mb->argument = name_to_func[i].argument;
|
mb->argument = name_to_func[i].argument;
|
||||||
TAILQ_INSERT_TAIL(&c->mousebindingq, mb, entry);
|
TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,16 +610,16 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
conf_unbind_mouse(struct conf *c, struct binding *unbind)
|
conf_unbind_mouse(struct conf *c, struct bind_ctx *unbind)
|
||||||
{
|
{
|
||||||
struct binding *mb = NULL, *mbnxt;
|
struct bind_ctx *mb = NULL, *mbnxt;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(mb, &c->mousebindingq, entry, mbnxt) {
|
TAILQ_FOREACH_SAFE(mb, &c->mousebindq, entry, mbnxt) {
|
||||||
if (mb->modmask != unbind->modmask)
|
if (mb->modmask != unbind->modmask)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (mb->press.button == unbind->press.button) {
|
if (mb->press.button == unbind->press.button) {
|
||||||
TAILQ_REMOVE(&c->mousebindingq, mb, entry);
|
TAILQ_REMOVE(&c->mousebindq, mb, entry);
|
||||||
free(mb);
|
free(mb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -660,13 +646,13 @@ static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask };
|
|||||||
void
|
void
|
||||||
conf_grab_mouse(Window win)
|
conf_grab_mouse(Window win)
|
||||||
{
|
{
|
||||||
struct binding *mb;
|
struct bind_ctx *mb;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
XUngrabButton(X_Dpy, AnyButton, AnyModifier, win);
|
XUngrabButton(X_Dpy, AnyButton, AnyModifier, win);
|
||||||
|
|
||||||
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
|
TAILQ_FOREACH(mb, &Conf.mousebindq, entry) {
|
||||||
if (mb->context != CWM_CONTEXT_CLIENT)
|
if (mb->context != CWM_CONTEXT_CC)
|
||||||
continue;
|
continue;
|
||||||
for (i = 0; i < nitems(ign_mods); i++) {
|
for (i = 0; i < nitems(ign_mods); i++) {
|
||||||
XGrabButton(X_Dpy, mb->press.button,
|
XGrabButton(X_Dpy, mb->press.button,
|
||||||
@ -681,13 +667,13 @@ conf_grab_mouse(Window win)
|
|||||||
void
|
void
|
||||||
conf_grab_kbd(Window win)
|
conf_grab_kbd(Window win)
|
||||||
{
|
{
|
||||||
struct binding *kb;
|
struct bind_ctx *kb;
|
||||||
KeyCode kc;
|
KeyCode kc;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
|
XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
|
||||||
|
|
||||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry) {
|
TAILQ_FOREACH(kb, &Conf.keybindq, entry) {
|
||||||
kc = XKeysymToKeycode(X_Dpy, kb->press.keysym);
|
kc = XKeysymToKeycode(X_Dpy, kb->press.keysym);
|
||||||
if ((XkbKeycodeToKeysym(X_Dpy, kc, 0, 0) != kb->press.keysym) &&
|
if ((XkbKeycodeToKeysym(X_Dpy, kc, 0, 0) != kb->press.keysym) &&
|
||||||
(XkbKeycodeToKeysym(X_Dpy, kc, 0, 1) == kb->press.keysym))
|
(XkbKeycodeToKeysym(X_Dpy, kc, 0, 1) == kb->press.keysym))
|
||||||
|
22
group.c
22
group.c
@ -265,7 +265,7 @@ group_cycle(struct screen_ctx *sc, int flags)
|
|||||||
|
|
||||||
newgc = oldgc;
|
newgc = oldgc;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
newgc = (flags & CWM_CLIENT_RCYCLE) ? group_prev(newgc) :
|
newgc = (flags & CWM_CYCLE_REVERSE) ? group_prev(newgc) :
|
||||||
group_next(newgc);
|
group_next(newgc);
|
||||||
|
|
||||||
if (newgc == oldgc)
|
if (newgc == oldgc)
|
||||||
@ -304,8 +304,8 @@ group_prev(struct group_ctx *gc)
|
|||||||
struct screen_ctx *sc = gc->sc;
|
struct screen_ctx *sc = gc->sc;
|
||||||
struct group_ctx *newgc;
|
struct group_ctx *newgc;
|
||||||
|
|
||||||
return(((newgc = TAILQ_PREV(gc, group_ctx_q, entry)) != NULL) ?
|
return(((newgc = TAILQ_PREV(gc, group_q, entry)) != NULL) ?
|
||||||
newgc : TAILQ_LAST(&sc->groupq, group_ctx_q));
|
newgc : TAILQ_LAST(&sc->groupq, group_q));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -351,21 +351,21 @@ int
|
|||||||
group_autogroup(struct client_ctx *cc)
|
group_autogroup(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
struct autogroupwin *aw;
|
struct autogroup *ag;
|
||||||
struct group_ctx *gc;
|
struct group_ctx *gc;
|
||||||
int num = -1, both_match = 0;
|
int num = -1, both_match = 0;
|
||||||
|
|
||||||
if (cc->ch.res_class == NULL || cc->ch.res_name == NULL)
|
if (cc->ch.res_class == NULL || cc->ch.res_name == NULL)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
TAILQ_FOREACH(aw, &Conf.autogroupq, entry) {
|
TAILQ_FOREACH(ag, &Conf.autogroupq, entry) {
|
||||||
if (strcmp(aw->class, cc->ch.res_class) == 0) {
|
if (strcmp(ag->class, cc->ch.res_class) == 0) {
|
||||||
if ((aw->name != NULL) &&
|
if ((ag->name != NULL) &&
|
||||||
(strcmp(aw->name, cc->ch.res_name) == 0)) {
|
(strcmp(ag->name, cc->ch.res_name) == 0)) {
|
||||||
num = aw->num;
|
num = ag->num;
|
||||||
both_match = 1;
|
both_match = 1;
|
||||||
} else if (aw->name == NULL && !both_match)
|
} else if (ag->name == NULL && !both_match)
|
||||||
num = aw->num;
|
num = ag->num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
348
kbfunc.c
348
kbfunc.c
@ -41,16 +41,9 @@ extern sig_atomic_t cwm_status;
|
|||||||
static void kbfunc_amount(int, int, unsigned int *, unsigned int *);
|
static void kbfunc_amount(int, int, unsigned int *, unsigned int *);
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_client_lower(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_cwm_status(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
client_ptrsave(cc);
|
cwm_status = arg->i;
|
||||||
client_lower(cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_raise(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
client_raise(cc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -78,9 +71,9 @@ kbfunc_amount(int flags, int amt, unsigned int *mx, unsigned int *my)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_ptrmove(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_ptrmove(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = ctx;
|
||||||
int x, y;
|
int x, y;
|
||||||
unsigned int mx = 0, my = 0;
|
unsigned int mx = 0, my = 0;
|
||||||
|
|
||||||
@ -91,8 +84,9 @@ kbfunc_ptrmove(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_client_move(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_client_move(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
|
struct client_ctx *cc = ctx;
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
struct geom area;
|
struct geom area;
|
||||||
int x, y, px, py;
|
int x, y, px, py;
|
||||||
@ -144,8 +138,9 @@ kbfunc_client_move(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_client_resize(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_client_resize(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
|
struct client_ctx *cc = ctx;
|
||||||
unsigned int mx = 0, my = 0;
|
unsigned int mx = 0, my = 0;
|
||||||
int amt = 1;
|
int amt = 1;
|
||||||
|
|
||||||
@ -173,13 +168,136 @@ kbfunc_client_resize(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_menu_client(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_client_delete(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
client_send_delete(ctx);
|
||||||
struct client_ctx *old_cc;
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_lower(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_ptrsave(ctx);
|
||||||
|
client_lower(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_raise(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_raise(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_hide(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_hide(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_toggle_freeze(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_toggle_freeze(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_toggle_sticky(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_toggle_sticky(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_toggle_fullscreen(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_toggle_fullscreen(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_toggle_maximize(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_toggle_maximize(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_toggle_hmaximize(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_toggle_hmaximize(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_toggle_vmaximize(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_toggle_vmaximize(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_htile(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_htile(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_vtile(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_vtile(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_cycle(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
client_cycle(ctx, arg->i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_toggle_group(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc = ctx;
|
||||||
|
|
||||||
|
if (xev == CWM_XEV_KEY) {
|
||||||
|
/* For X apps that steal events. */
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
group_movetogroup(ctx, arg->i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_group_toggle(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
group_hidetoggle(ctx, arg->i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_group_only(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
group_only(ctx, arg->i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_group_cycle(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
group_cycle(ctx, arg->i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_group_alltoggle(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
group_alltoggle(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_menu_client(void *ctx, union arg *arg, enum xev xev)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = ctx;
|
||||||
|
struct client_ctx *cc, *old_cc;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
struct menu_q menuq;
|
struct menu_q menuq;
|
||||||
int m = (xev == CWM_BTN);
|
int m = (xev == CWM_XEV_BTN);
|
||||||
|
|
||||||
old_cc = client_current();
|
old_cc = client_current();
|
||||||
|
|
||||||
@ -210,13 +328,13 @@ kbfunc_menu_client(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_menu_cmd(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = ctx;
|
||||||
struct cmd *cmd;
|
struct cmd_ctx *cmd;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
struct menu_q menuq;
|
struct menu_q menuq;
|
||||||
int m = (xev == CWM_BTN);
|
int m = (xev == CWM_XEV_BTN);
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||||
@ -231,7 +349,7 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
(m) ? NULL : "application", NULL,
|
(m) ? NULL : "application", NULL,
|
||||||
(m) ? CWM_MENU_LIST : 0,
|
(m) ? CWM_MENU_LIST : 0,
|
||||||
search_match_text, search_print_cmd)) != NULL) {
|
search_match_text, search_print_cmd)) != NULL) {
|
||||||
cmd = (struct cmd *)mi->ctx;
|
cmd = (struct cmd_ctx *)mi->ctx;
|
||||||
u_spawn(cmd->path);
|
u_spawn(cmd->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,13 +357,13 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_menu_group(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_menu_group(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = ctx;
|
||||||
struct group_ctx *gc;
|
struct group_ctx *gc;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
struct menu_q menuq;
|
struct menu_q menuq;
|
||||||
int m = (xev == CWM_BTN);
|
int m = (xev == CWM_XEV_BTN);
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
||||||
@ -266,50 +384,10 @@ kbfunc_menu_group(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_client_cycle(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
|
||||||
client_cycle(cc->sc, arg->i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_hide(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
client_hide(cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_exec(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
u_spawn(arg->c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_exec_term(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
struct cmd *cmd;
|
|
||||||
|
|
||||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
|
||||||
if (strcmp(cmd->name, "term") == 0)
|
|
||||||
u_spawn(cmd->path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_exec_lock(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
struct cmd *cmd;
|
|
||||||
|
|
||||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
|
||||||
if (strcmp(cmd->name, "lock") == 0)
|
|
||||||
u_spawn(cmd->path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_menu_exec(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
{
|
||||||
#define NPATHS 256
|
#define NPATHS 256
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = ctx;
|
||||||
char **ap, *paths[NPATHS], *path, *pathcpy;
|
char **ap, *paths[NPATHS], *path, *pathcpy;
|
||||||
char tpath[PATH_MAX];
|
char tpath[PATH_MAX];
|
||||||
const char *label;
|
const char *label;
|
||||||
@ -320,7 +398,7 @@ kbfunc_menu_exec(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
int l, i, cmd = arg->i;
|
int l, i, cmd = arg->i;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case CWM_MENU_EXEC:
|
case CWM_MENU_EXEC_EXEC:
|
||||||
label = "exec";
|
label = "exec";
|
||||||
break;
|
break;
|
||||||
case CWM_MENU_EXEC_WM:
|
case CWM_MENU_EXEC_WM:
|
||||||
@ -328,7 +406,7 @@ kbfunc_menu_exec(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errx(1, "kbfunc_menu_exec: invalid cmd %d", cmd);
|
errx(1, "kbfunc_menu_exec: invalid cmd %d", cmd);
|
||||||
/*NOTREACHED*/
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
@ -369,17 +447,17 @@ kbfunc_menu_exec(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
if (mi->text[0] == '\0')
|
if (mi->text[0] == '\0')
|
||||||
goto out;
|
goto out;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case CWM_MENU_EXEC:
|
case CWM_MENU_EXEC_EXEC:
|
||||||
u_spawn(mi->text);
|
u_spawn(mi->text);
|
||||||
break;
|
break;
|
||||||
case CWM_MENU_EXEC_WM:
|
case CWM_MENU_EXEC_WM:
|
||||||
cwm_status = CWM_EXEC_WM;
|
cwm_status = CWM_EXEC_WM;
|
||||||
free(wm_argv);
|
free(Conf.wm_argv);
|
||||||
wm_argv = xstrdup(mi->text);
|
Conf.wm_argv = xstrdup(mi->text);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errx(1, "kb_func: egad, cmd changed value!");
|
errx(1, "kb_func: egad, cmd changed value!");
|
||||||
break;
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
@ -389,10 +467,10 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_menu_ssh(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_menu_ssh(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = ctx;
|
||||||
struct cmd *cmd;
|
struct cmd_ctx *cmd;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
struct menu_q menuq;
|
struct menu_q menuq;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -456,10 +534,11 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_menu_client_label(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_menu_client_label(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
struct menu *mi;
|
struct client_ctx *cc = ctx;
|
||||||
struct menu_q menuq;
|
struct menu *mi;
|
||||||
|
struct menu_q menuq;
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
|
|
||||||
@ -475,104 +554,29 @@ kbfunc_menu_client_label(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_client_delete(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_exec_cmd(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
client_send_delete(cc);
|
u_spawn(arg->c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_group_toggle(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_exec_term(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
group_hidetoggle(cc->sc, arg->i);
|
struct cmd_ctx *cmd;
|
||||||
}
|
|
||||||
|
|
||||||
void
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||||
kbfunc_group_only(struct client_ctx *cc, union arg *arg, int xev)
|
if (strcmp(cmd->name, "term") == 0)
|
||||||
{
|
u_spawn(cmd->path);
|
||||||
group_only(cc->sc, arg->i);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_group_cycle(struct client_ctx *cc, union arg *arg, int xev)
|
kbfunc_exec_lock(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
group_cycle(cc->sc, arg->i);
|
struct cmd_ctx *cmd;
|
||||||
}
|
|
||||||
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||||
void
|
if (strcmp(cmd->name, "lock") == 0)
|
||||||
kbfunc_group_alltoggle(struct client_ctx *cc, union arg *arg, int xev)
|
u_spawn(cmd->path);
|
||||||
{
|
|
||||||
group_alltoggle(cc->sc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_toggle_group(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
if (xev == CWM_KEY) {
|
|
||||||
/* For X apps that steal events. */
|
|
||||||
XGrabKeyboard(X_Dpy, cc->win, True,
|
|
||||||
GrabModeAsync, GrabModeAsync, CurrentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
group_toggle_membership_enter(cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_movetogroup(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
group_movetogroup(cc, arg->i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_toggle_sticky(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
client_toggle_sticky(cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_toggle_fullscreen(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
client_toggle_fullscreen(cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_toggle_maximize(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
client_toggle_maximize(cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_toggle_vmaximize(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
client_toggle_vmaximize(cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_toggle_hmaximize(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
client_toggle_hmaximize(cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_toggle_freeze(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
client_toggle_freeze(cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_cwm_status(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
cwm_status = arg->i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_tile(struct client_ctx *cc, union arg *arg, int xev)
|
|
||||||
{
|
|
||||||
switch (arg->i) {
|
|
||||||
case CWM_CLIENT_TILE_HORIZ:
|
|
||||||
client_htile(cc);
|
|
||||||
break;
|
|
||||||
case CWM_CLIENT_TILE_VERT:
|
|
||||||
client_vtile(cc);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,9 @@
|
|||||||
#include "calmwm.h"
|
#include "calmwm.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
mousefunc_client_resize(struct client_ctx *cc, union arg *arg, int xev)
|
mousefunc_client_resize(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
|
struct client_ctx *cc = ctx;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
Time ltime = 0;
|
Time ltime = 0;
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
@ -88,8 +89,9 @@ mousefunc_client_resize(struct client_ctx *cc, union arg *arg, int xev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mousefunc_client_move(struct client_ctx *cc, union arg *arg, int xev)
|
mousefunc_client_move(void *ctx, union arg *arg, enum xev xev)
|
||||||
{
|
{
|
||||||
|
struct client_ctx *cc = ctx;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
Time ltime = 0;
|
Time ltime = 0;
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
|
8
screen.c
8
screen.c
@ -84,7 +84,7 @@ screen_init(int which)
|
|||||||
}
|
}
|
||||||
screen_updatestackingorder(sc);
|
screen_updatestackingorder(sc);
|
||||||
|
|
||||||
if (HasRandr)
|
if (Conf.xrandr)
|
||||||
XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask);
|
XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask);
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&Screenq, sc, entry);
|
TAILQ_INSERT_TAIL(&Screenq, sc, entry);
|
||||||
@ -140,7 +140,7 @@ region_find(struct screen_ctx *sc, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct geom
|
struct geom
|
||||||
screen_area(struct screen_ctx *sc, int x, int y, int flags)
|
screen_area(struct screen_ctx *sc, int x, int y, enum apply_gap apply_gap)
|
||||||
{
|
{
|
||||||
struct region_ctx *rc;
|
struct region_ctx *rc;
|
||||||
struct geom area = sc->work;
|
struct geom area = sc->work;
|
||||||
@ -152,7 +152,7 @@ screen_area(struct screen_ctx *sc, int x, int y, int flags)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flags & CWM_GAP)
|
if (apply_gap)
|
||||||
area = screen_apply_gap(sc, area);
|
area = screen_apply_gap(sc, area);
|
||||||
return(area);
|
return(area);
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ screen_update_geometry(struct screen_ctx *sc)
|
|||||||
free(rc);
|
free(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasRandr) {
|
if (Conf.xrandr) {
|
||||||
XRRScreenResources *sr;
|
XRRScreenResources *sr;
|
||||||
XRRCrtcInfo *ci;
|
XRRCrtcInfo *ci;
|
||||||
int i;
|
int i;
|
||||||
|
4
search.c
4
search.c
@ -72,7 +72,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
|||||||
|
|
||||||
/* Then, on window names. */
|
/* Then, on window names. */
|
||||||
if (tier < 0) {
|
if (tier < 0) {
|
||||||
TAILQ_FOREACH_REVERSE(wn, &cc->nameq, winname_q, entry)
|
TAILQ_FOREACH_REVERSE(wn, &cc->nameq, name_q, entry)
|
||||||
if (strsubmatch(search, wn->name, 0)) {
|
if (strsubmatch(search, wn->name, 0)) {
|
||||||
cc->matchname = wn->name;
|
cc->matchname = wn->name;
|
||||||
tier = 2;
|
tier = 2;
|
||||||
@ -126,7 +126,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
|||||||
void
|
void
|
||||||
search_print_cmd(struct menu *mi, int i)
|
search_print_cmd(struct menu *mi, int i)
|
||||||
{
|
{
|
||||||
struct cmd *cmd = (struct cmd *)mi->ctx;
|
struct cmd_ctx *cmd = (struct cmd_ctx *)mi->ctx;
|
||||||
|
|
||||||
(void)snprintf(mi->print, sizeof(mi->print), "%s", cmd->name);
|
(void)snprintf(mi->print, sizeof(mi->print), "%s", cmd->name);
|
||||||
}
|
}
|
||||||
|
50
xevents.c
50
xevents.c
@ -220,31 +220,37 @@ static void
|
|||||||
xev_handle_buttonpress(XEvent *ee)
|
xev_handle_buttonpress(XEvent *ee)
|
||||||
{
|
{
|
||||||
XButtonEvent *e = &ee->xbutton;
|
XButtonEvent *e = &ee->xbutton;
|
||||||
struct client_ctx *cc, fakecc;
|
struct client_ctx *cc;
|
||||||
struct binding *mb;
|
struct screen_ctx *sc;
|
||||||
|
struct bind_ctx *mb;
|
||||||
|
|
||||||
e->state &= ~IGNOREMODMASK;
|
e->state &= ~IGNOREMODMASK;
|
||||||
|
|
||||||
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
|
TAILQ_FOREACH(mb, &Conf.mousebindq, entry) {
|
||||||
if (e->button == mb->press.button && e->state == mb->modmask)
|
if (e->button == mb->press.button && e->state == mb->modmask)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mb == NULL)
|
if (mb == NULL)
|
||||||
return;
|
return;
|
||||||
if (mb->context == CWM_CONTEXT_CLIENT) {
|
switch (mb->context) {
|
||||||
|
case CWM_CONTEXT_CC:
|
||||||
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->callback)(cc, &mb->argument, CWM_XEV_BTN);
|
||||||
|
break;
|
||||||
|
case CWM_CONTEXT_SC:
|
||||||
if (e->window != e->root)
|
if (e->window != e->root)
|
||||||
return;
|
return;
|
||||||
cc = &fakecc;
|
if ((sc = screen_find(e->window)) == NULL)
|
||||||
if ((cc->sc = screen_find(e->window)) == NULL)
|
|
||||||
return;
|
return;
|
||||||
|
(*mb->callback)(sc, &mb->argument, CWM_XEV_BTN);
|
||||||
|
break;
|
||||||
|
case CWM_CONTEXT_NONE:
|
||||||
|
(*mb->callback)(NULL, &mb->argument, CWM_XEV_BTN);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*mb->callback)(cc, &mb->argument, CWM_BTN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -263,8 +269,9 @@ static void
|
|||||||
xev_handle_keypress(XEvent *ee)
|
xev_handle_keypress(XEvent *ee)
|
||||||
{
|
{
|
||||||
XKeyEvent *e = &ee->xkey;
|
XKeyEvent *e = &ee->xkey;
|
||||||
struct client_ctx *cc = NULL, fakecc;
|
struct client_ctx *cc;
|
||||||
struct binding *kb;
|
struct screen_ctx *sc;
|
||||||
|
struct bind_ctx *kb;
|
||||||
KeySym keysym, skeysym;
|
KeySym keysym, skeysym;
|
||||||
unsigned int modshift;
|
unsigned int modshift;
|
||||||
|
|
||||||
@ -273,7 +280,7 @@ xev_handle_keypress(XEvent *ee)
|
|||||||
|
|
||||||
e->state &= ~IGNOREMODMASK;
|
e->state &= ~IGNOREMODMASK;
|
||||||
|
|
||||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry) {
|
TAILQ_FOREACH(kb, &Conf.keybindq, entry) {
|
||||||
if (keysym != kb->press.keysym && skeysym == kb->press.keysym)
|
if (keysym != kb->press.keysym && skeysym == kb->press.keysym)
|
||||||
modshift = ShiftMask;
|
modshift = ShiftMask;
|
||||||
else
|
else
|
||||||
@ -288,17 +295,22 @@ xev_handle_keypress(XEvent *ee)
|
|||||||
|
|
||||||
if (kb == NULL)
|
if (kb == NULL)
|
||||||
return;
|
return;
|
||||||
if (kb->context == CWM_CONTEXT_CLIENT) {
|
switch (kb->context) {
|
||||||
|
case CWM_CONTEXT_CC:
|
||||||
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 {
|
(*kb->callback)(cc, &kb->argument, CWM_XEV_KEY);
|
||||||
cc = &fakecc;
|
break;
|
||||||
if ((cc->sc = screen_find(e->window)) == NULL)
|
case CWM_CONTEXT_SC:
|
||||||
|
if ((sc = screen_find(e->window)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
(*kb->callback)(sc, &kb->argument, CWM_XEV_KEY);
|
||||||
|
break;
|
||||||
|
case CWM_CONTEXT_NONE:
|
||||||
|
(*kb->callback)(NULL, &kb->argument, CWM_XEV_KEY);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*kb->callback)(cc, &kb->argument, CWM_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -424,7 +436,7 @@ xev_process(void)
|
|||||||
XEvent e;
|
XEvent e;
|
||||||
|
|
||||||
XNextEvent(X_Dpy, &e);
|
XNextEvent(X_Dpy, &e);
|
||||||
if (e.type - Randr_ev == RRScreenChangeNotify)
|
if (e.type - Conf.xrandr_event_base == RRScreenChangeNotify)
|
||||||
xev_handle_randr(&e);
|
xev_handle_randr(&e);
|
||||||
else if (e.type < LASTEvent && xev_handlers[e.type] != NULL)
|
else if (e.type < LASTEvent && xev_handlers[e.type] != NULL)
|
||||||
(*xev_handlers[e.type])(&e);
|
(*xev_handlers[e.type])(&e);
|
||||||
|
Loading…
Reference in New Issue
Block a user