From a10bee93be3f2ad370a6dfc360e1b05cb84e7f5c Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 18 Oct 2016 17:03:30 +0000 Subject: 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. --- calmwm.h | 242 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 122 insertions(+), 120 deletions(-) (limited to 'calmwm.h') diff --git a/calmwm.h b/calmwm.h index 2f92b0e..cf0f0dc 100644 --- a/calmwm.h +++ b/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.328 2016/10/12 16:11:15 okan Exp $ + * $OpenBSD: calmwm.h,v 1.329 2016/10/18 17:03:30 okan Exp $ */ #ifndef _CALMWM_H_ @@ -57,41 +57,14 @@ #define CWM_BIGAMOUNT 0x0010 #define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT) -#define CWM_CLIENT_CYCLE 0x0001 -#define CWM_CLIENT_RCYCLE 0x0002 -#define CWM_CLIENT_CYCLE_INGRP 0x0004 +#define CWM_CYCLE_FORWARD 0x0001 +#define CWM_CYCLE_REVERSE 0x0002 +#define CWM_CYCLE_INGROUP 0x0004 -#define CWM_CLIENT_TILE_HORIZ 0x0001 -#define CWM_CLIENT_TILE_VERT 0x0002 - -#define CWM_MENU_EXEC 0x0001 -#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 cwm_status { + CWM_QUIT, + CWM_RUNNING, + CWM_EXEC_WM }; enum cursor_font { @@ -121,6 +94,10 @@ struct geom { int h; }; +enum apply_gap { + CWM_NOGAP = 0, + CWM_GAP +}; struct gap { int top; int bottom; @@ -132,7 +109,7 @@ struct winname { TAILQ_ENTRY(winname) entry; char *name; }; -TAILQ_HEAD(winname_q, winname); +TAILQ_HEAD(name_q, winname); TAILQ_HEAD(ignore_q, winname); struct client_ctx { @@ -185,31 +162,31 @@ struct client_ctx { #define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) int flags; int stackingorder; - struct winname_q nameq; + struct name_q nameq; char *name; char *label; char *matchname; XClassHint ch; XWMHints *wmh; }; -TAILQ_HEAD(client_ctx_q, client_ctx); +TAILQ_HEAD(client_q, client_ctx); struct group_ctx { TAILQ_ENTRY(group_ctx) entry; struct screen_ctx *sc; char *name; 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 { - TAILQ_ENTRY(autogroupwin) entry; - char *class; - char *name; - int num; +struct autogroup { + TAILQ_ENTRY(autogroup) entry; + char *class; + char *name; + int num; }; -TAILQ_HEAD(autogroupwin_q, autogroupwin); +TAILQ_HEAD(autogroup_q, autogroup); struct region_ctx { TAILQ_ENTRY(region_ctx) entry; @@ -218,7 +195,7 @@ struct region_ctx { struct geom view; /* viewable area */ struct geom work; /* workable area, gap-applied */ }; -TAILQ_HEAD(region_ctx_q, region_ctx); +TAILQ_HEAD(region_q, region_ctx); struct screen_ctx { TAILQ_ENTRY(screen_ctx) entry; @@ -230,9 +207,9 @@ struct screen_ctx { struct geom view; /* viewable area */ struct geom work; /* workable area, gap-applied */ struct gap gap; - struct client_ctx_q clientq; - struct region_ctx_q regionq; - struct group_ctx_q groupq; + struct client_q clientq; + struct region_q regionq; + struct group_q groupq; struct group_ctx *group_active; struct { Window win; @@ -241,25 +218,50 @@ struct screen_ctx { XftColor xftcolor[CWM_COLOR_NITEMS]; XftFont *xftfont; }; -TAILQ_HEAD(screen_ctx_q, screen_ctx); +TAILQ_HEAD(screen_q, screen_ctx); -struct binding { - TAILQ_ENTRY(binding) entry; - void (*callback)(struct client_ctx *, union arg *, int); +enum xev { + CWM_XEV_KEY, + 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; unsigned int modmask; union press press; - int context; + enum context context; }; -TAILQ_HEAD(keybinding_q, binding); -TAILQ_HEAD(mousebinding_q, binding); +TAILQ_HEAD(keybind_q, bind_ctx); +TAILQ_HEAD(mousebind_q, bind_ctx); -struct cmd { - TAILQ_ENTRY(cmd) entry; +struct cmd_ctx { + TAILQ_ENTRY(cmd_ctx) entry; char *name; 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 { TAILQ_ENTRY(menu) entry; @@ -274,9 +276,9 @@ struct menu { TAILQ_HEAD(menu_q, menu); struct conf { - struct keybinding_q keybindingq; - struct mousebinding_q mousebindingq; - struct autogroupwin_q autogroupq; + struct keybind_q keybindq; + struct mousebind_q mousebindq; + struct autogroup_q autogroupq; struct ignore_q ignoreq; struct cmd_q cmdq; int ngroups; @@ -291,6 +293,9 @@ struct conf { char *font; char *wmname; Cursor cursor[CF_NITEMS]; + int xrandr; + int xrandr_event_base; + char *wm_argv; }; /* MWM hints */ @@ -321,15 +326,7 @@ struct mwm_hints { unsigned long decorations; }; -extern Display *X_Dpy; -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 { +enum cwmh { WM_STATE, WM_DELETE_WINDOW, WM_TAKE_FOCUS, @@ -339,7 +336,7 @@ enum { WM_CHANGE_STATE, CWMH_NITEMS }; -enum { +enum ewmh { _NET_SUPPORTED, _NET_SUPPORTING_WM_CHECK, _NET_ACTIVE_WINDOW, @@ -367,13 +364,19 @@ enum { _CWM_WM_STATE_FREEZE, EWMH_NITEMS }; -enum { +enum net_wm_state { _NET_WM_STATE_REMOVE, _NET_WM_STATE_ADD, _NET_WM_STATE_TOGGLE }; + +extern Display *X_Dpy; +extern Time Last_Event_Time; extern Atom cwmh[CWMH_NITEMS]; extern Atom ewmh[EWMH_NITEMS]; +extern struct screen_q Screenq; +extern struct conf Conf; +extern const char *homedir; __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 geom screen_apply_gap(struct screen_ctx *, struct geom); 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_update_geometry(struct screen_ctx *); void screen_updatestackingorder(struct screen_ctx *); void screen_assert_clients_within(struct screen_ctx *); -void kbfunc_client_cycle(struct client_ctx *, union arg *, int); -void kbfunc_client_delete(struct client_ctx *, union arg *, int); -void kbfunc_client_hide(struct client_ctx *, union arg *, int); -void kbfunc_menu_client_label(struct client_ctx *, union arg *, int); -void kbfunc_client_lower(struct client_ctx *, union arg *, int); -void kbfunc_client_move(struct client_ctx *, union arg *, int); -void kbfunc_client_movetogroup(struct client_ctx *, - union arg *, int); -void kbfunc_client_raise(struct client_ctx *, union arg *, int); -void kbfunc_client_resize(struct client_ctx *, union arg *, int); -void kbfunc_client_tile(struct client_ctx *, union arg *, int); -void kbfunc_client_toggle_group(struct client_ctx *, - union arg *, int); -void kbfunc_client_toggle_freeze(struct client_ctx *, - union arg *, int); -void kbfunc_client_toggle_fullscreen(struct client_ctx *, - union arg *, int); -void kbfunc_client_toggle_hmaximize(struct client_ctx *, - union arg *, int); -void kbfunc_client_toggle_maximize(struct client_ctx *, - union arg *, int); -void kbfunc_client_toggle_sticky(struct client_ctx *, - union arg *, int); -void kbfunc_client_toggle_vmaximize(struct client_ctx *, - union arg *, int); -void kbfunc_cwm_status(struct client_ctx *, union arg *, int); -void kbfunc_exec(struct client_ctx *, union arg *, int); -void kbfunc_exec_lock(struct client_ctx *, union arg *, int); -void kbfunc_exec_term(struct client_ctx *, union arg *, int); -void kbfunc_group_alltoggle(struct client_ctx *, - union arg *, int); -void kbfunc_group_cycle(struct client_ctx *, union arg *, int); -void kbfunc_group_only(struct client_ctx *, union arg *, int); -void kbfunc_group_toggle(struct client_ctx *, union arg *, int); -void kbfunc_menu_exec(struct client_ctx *, union arg *, int); -void kbfunc_menu_client(struct client_ctx *, union arg *, int); -void kbfunc_menu_cmd(struct client_ctx *, union arg *, int); -void kbfunc_menu_group(struct client_ctx *, union arg *, int); -void kbfunc_menu_ssh(struct client_ctx *, union arg *, int); -void kbfunc_ptrmove(struct client_ctx *, union arg *, int); - -void mousefunc_client_move(struct client_ctx *, - union arg *, int); -void mousefunc_client_resize(struct client_ctx *, - union arg *, int); +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_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); + +void mousefunc_client_move(void *, union arg *, enum xev); +void mousefunc_client_resize(void *, union arg *, enum xev); void menu_windraw(struct screen_ctx *, Window, const char *, ...); -- cgit v1.2.3-2-gb3c3