diff options
author | okan | 2018-01-23 16:00:21 +0000 |
---|---|---|
committer | okan | 2018-01-23 16:00:21 +0000 |
commit | d2cd1c86d06be540f06d8e427d9dab5a39ae86db (patch) | |
tree | 8e7242f1e09ed125591905372b393982752a115b | |
parent | ca30474d6158fc5c81d963ca9d21ce4d9d964c28 (diff) | |
download | cwm-d2cd1c86d06be540f06d8e427d9dab5a39ae86db.tar.gz |
Generate name_to_func[] in a clean and readable fashion.
-rw-r--r-- | calmwm.h | 12 | ||||
-rw-r--r-- | conf.c | 248 |
2 files changed, 116 insertions, 144 deletions
@@ -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.351 2017/12/29 20:03:46 okan Exp $ + * $OpenBSD: calmwm.h,v 1.352 2018/01/23 16:00:21 okan Exp $ */ #ifndef _CALMWM_H_ @@ -55,7 +55,15 @@ #define CWM_LEFT 0x0004 #define CWM_RIGHT 0x0008 #define CWM_BIGAMOUNT 0x0010 -#define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT) +#define CWM_UP_BIG (CWM_UP | CWM_BIGAMOUNT) +#define CWM_DOWN_BIG (CWM_DOWN | CWM_BIGAMOUNT) +#define CWM_LEFT_BIG (CWM_LEFT | CWM_BIGAMOUNT) +#define CWM_RIGHT_BIG (CWM_RIGHT | CWM_BIGAMOUNT) +#define CWM_UP_RIGHT (CWM_UP | CWM_RIGHT) +#define CWM_UP_LEFT (CWM_UP | CWM_LEFT) +#define CWM_DOWN_RIGHT (CWM_DOWN | CWM_RIGHT) +#define CWM_DOWN_LEFT (CWM_DOWN | CWM_LEFT) +#define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT) #define CWM_CYCLE_FORWARD 0x0001 #define CWM_CYCLE_REVERSE 0x0002 @@ -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: conf.c,v 1.237 2017/12/29 20:03:46 okan Exp $ + * $OpenBSD: conf.c,v 1.238 2018/01/23 16:00:21 okan Exp $ */ #include <sys/types.h> @@ -60,147 +60,111 @@ static const struct { enum context context; int flag; } name_to_func[] = { - { "window-menu-label", kbfunc_client_menu_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, - (CWM_CYCLE_FORWARD) }, - { "window-rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC, - (CWM_CYCLE_REVERSE) }, - { "window-cycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC, - (CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP) }, - { "window-rcycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC, - (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-snap-up", kbfunc_client_snap, CWM_CONTEXT_CC, - (CWM_UP) }, - { "window-snap-down", kbfunc_client_snap, CWM_CONTEXT_CC, - (CWM_DOWN) }, - { "window-snap-left", kbfunc_client_snap, CWM_CONTEXT_CC, - (CWM_LEFT) }, - { "window-snap-right", kbfunc_client_snap, CWM_CONTEXT_CC, - (CWM_RIGHT) }, - - { "window-snap-up-right", kbfunc_client_snap, CWM_CONTEXT_CC, - (CWM_UP|CWM_RIGHT) }, - { "window-snap-up-left", kbfunc_client_snap, CWM_CONTEXT_CC, - (CWM_UP|CWM_LEFT) }, - { "window-snap-down-right", kbfunc_client_snap, CWM_CONTEXT_CC, - (CWM_DOWN|CWM_RIGHT) }, - { "window-snap-down-left", kbfunc_client_snap, CWM_CONTEXT_CC, - (CWM_DOWN|CWM_LEFT) }, - - { "window-move", kbfunc_client_move, CWM_CONTEXT_CC, 0 }, - { "window-move-up", kbfunc_client_move, CWM_CONTEXT_CC, - (CWM_UP) }, - { "window-move-down", kbfunc_client_move, CWM_CONTEXT_CC, - (CWM_DOWN) }, - { "window-move-right", kbfunc_client_move, CWM_CONTEXT_CC, - (CWM_RIGHT) }, - { "window-move-left", kbfunc_client_move, CWM_CONTEXT_CC, - (CWM_LEFT) }, - { "window-move-up-big", kbfunc_client_move, CWM_CONTEXT_CC, - (CWM_UP | CWM_BIGAMOUNT) }, - { "window-move-down-big", kbfunc_client_move, CWM_CONTEXT_CC, - (CWM_DOWN | CWM_BIGAMOUNT) }, - { "window-move-right-big", kbfunc_client_move, CWM_CONTEXT_CC, - (CWM_RIGHT | CWM_BIGAMOUNT) }, - { "window-move-left-big", kbfunc_client_move, CWM_CONTEXT_CC, - (CWM_LEFT | CWM_BIGAMOUNT) }, - { "window-resize", kbfunc_client_resize, CWM_CONTEXT_CC, 0 }, - { "window-resize-up", kbfunc_client_resize, CWM_CONTEXT_CC, - (CWM_UP) }, - { "window-resize-down", kbfunc_client_resize, CWM_CONTEXT_CC, - (CWM_DOWN) }, - { "window-resize-right", kbfunc_client_resize, CWM_CONTEXT_CC, - (CWM_RIGHT) }, - { "window-resize-left", kbfunc_client_resize, CWM_CONTEXT_CC, - (CWM_LEFT) }, - { "window-resize-up-big", kbfunc_client_resize, CWM_CONTEXT_CC, - (CWM_UP | CWM_BIGAMOUNT) }, - { "window-resize-down-big", kbfunc_client_resize, CWM_CONTEXT_CC, - (CWM_DOWN | CWM_BIGAMOUNT) }, - { "window-resize-right-big", kbfunc_client_resize, CWM_CONTEXT_CC, - (CWM_RIGHT | CWM_BIGAMOUNT) }, - { "window-resize-left-big", kbfunc_client_resize, CWM_CONTEXT_CC, - (CWM_LEFT | CWM_BIGAMOUNT) }, - - { "group-cycle", kbfunc_group_cycle, CWM_CONTEXT_SC, - (CWM_CYCLE_FORWARD) }, - { "group-rcycle", kbfunc_group_cycle, CWM_CONTEXT_SC, - (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, - (CWM_UP) }, - { "pointer-move-down", kbfunc_ptrmove, CWM_CONTEXT_SC, - (CWM_DOWN) }, - { "pointer-move-left", kbfunc_ptrmove, CWM_CONTEXT_SC, - (CWM_LEFT) }, - { "pointer-move-right", kbfunc_ptrmove, CWM_CONTEXT_SC, - (CWM_RIGHT) }, - { "pointer-move-up-big", kbfunc_ptrmove, CWM_CONTEXT_SC, - (CWM_UP | CWM_BIGAMOUNT) }, - { "pointer-move-down-big", kbfunc_ptrmove, CWM_CONTEXT_SC, - (CWM_DOWN | CWM_BIGAMOUNT) }, - { "pointer-move-left-big", kbfunc_ptrmove, CWM_CONTEXT_SC, - (CWM_LEFT | CWM_BIGAMOUNT) }, - { "pointer-move-right-big", kbfunc_ptrmove, CWM_CONTEXT_SC, - (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-window", kbfunc_menu_client, CWM_CONTEXT_SC, - CWM_MENU_WINDOW_ALL }, - { "menu-window-hidden", kbfunc_menu_client, CWM_CONTEXT_SC, - CWM_MENU_WINDOW_HIDDEN }, - { "menu-exec", kbfunc_menu_exec, CWM_CONTEXT_SC, 0 }, - { "menu-exec-wm", kbfunc_menu_wm, CWM_CONTEXT_SC, 0 }, - - { "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 }, - +#define FUNC_CC(t, h, n) \ + #t, kbfunc_ ## h, CWM_CONTEXT_CC, n +#define FUNC_SC(t, h, n) \ + #t, kbfunc_ ## h, CWM_CONTEXT_SC, n + + { FUNC_CC(window-lower, client_lower, 0) }, + { FUNC_CC(window-raise, client_raise, 0) }, + { FUNC_CC(window-hide, client_hide, 0) }, + { FUNC_CC(window-delete, client_delete, 0) }, + { FUNC_CC(window-htile, client_htile, 0) }, + { FUNC_CC(window-vtile, client_vtile, 0) }, + { FUNC_CC(window-stick, client_toggle_sticky, 0) }, + { FUNC_CC(window-fullscreen, client_toggle_fullscreen, 0) }, + { FUNC_CC(window-maximize, client_toggle_maximize, 0) }, + { FUNC_CC(window-vmaximize, client_toggle_vmaximize, 0) }, + { FUNC_CC(window-hmaximize, client_toggle_hmaximize, 0) }, + { FUNC_CC(window-freeze, client_toggle_freeze, 0) }, + { FUNC_CC(window-group, client_toggle_group, 0) }, + { FUNC_CC(window-movetogroup-1, client_movetogroup, 1) }, + { FUNC_CC(window-movetogroup-2, client_movetogroup, 2) }, + { FUNC_CC(window-movetogroup-3, client_movetogroup, 3) }, + { FUNC_CC(window-movetogroup-4, client_movetogroup, 4) }, + { FUNC_CC(window-movetogroup-5, client_movetogroup, 5) }, + { FUNC_CC(window-movetogroup-6, client_movetogroup, 6) }, + { FUNC_CC(window-movetogroup-7, client_movetogroup, 7) }, + { FUNC_CC(window-movetogroup-8, client_movetogroup, 8) }, + { FUNC_CC(window-movetogroup-9, client_movetogroup, 9) }, + { FUNC_CC(window-snap-up, client_snap, (CWM_UP)) }, + { FUNC_CC(window-snap-down, client_snap, (CWM_DOWN)) }, + { FUNC_CC(window-snap-right, client_snap, (CWM_RIGHT)) }, + { FUNC_CC(window-snap-left, client_snap, (CWM_LEFT)) }, + { FUNC_CC(window-snap-up-right, client_snap, (CWM_UP_RIGHT)) }, + { FUNC_CC(window-snap-up-left, client_snap, (CWM_UP_LEFT)) }, + { FUNC_CC(window-snap-down-right, client_snap, (CWM_DOWN_RIGHT)) }, + { FUNC_CC(window-snap-down-left, client_snap, (CWM_DOWN_LEFT)) }, + { FUNC_CC(window-move, client_move, 0) }, + { FUNC_CC(window-move-up, client_move, (CWM_UP)) }, + { FUNC_CC(window-move-down, client_move, (CWM_DOWN)) }, + { FUNC_CC(window-move-right, client_move, (CWM_RIGHT)) }, + { FUNC_CC(window-move-left, client_move, (CWM_LEFT)) }, + { FUNC_CC(window-move-up-big, client_move, (CWM_UP_BIG)) }, + { FUNC_CC(window-move-down-big, client_move, (CWM_DOWN_BIG)) }, + { FUNC_CC(window-move-right-big, client_move, (CWM_RIGHT_BIG)) }, + { FUNC_CC(window-move-left-big, client_move, (CWM_LEFT_BIG)) }, + { FUNC_CC(window-resize, client_resize, 0) }, + { FUNC_CC(window-resize-up, client_resize, (CWM_UP)) }, + { FUNC_CC(window-resize-down, client_resize, (CWM_DOWN)) }, + { FUNC_CC(window-resize-right, client_resize, (CWM_RIGHT)) }, + { FUNC_CC(window-resize-left, client_resize, (CWM_LEFT)) }, + { FUNC_CC(window-resize-up-big, client_resize, (CWM_UP_BIG)) }, + { FUNC_CC(window-resize-down-big, client_resize, (CWM_DOWN_BIG)) }, + { FUNC_CC(window-resize-right-big, client_resize, (CWM_RIGHT_BIG)) }, + { FUNC_CC(window-resize-left-big, client_resize, (CWM_LEFT_BIG)) }, + { FUNC_CC(window-menu-label, client_menu_label, 0) }, + + { FUNC_SC(window-cycle, client_cycle, (CWM_CYCLE_FORWARD)) }, + { FUNC_SC(window-rcycle, client_cycle, (CWM_CYCLE_REVERSE)) }, + { FUNC_SC(window-cycle-ingroup, client_cycle, + (CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP)) }, + { FUNC_SC(window-rcycle-ingroup, client_cycle, + (CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP)) }, + + { FUNC_SC(group-cycle, group_cycle, (CWM_CYCLE_FORWARD)) }, + { FUNC_SC(group-rcycle, group_cycle, (CWM_CYCLE_REVERSE)) }, + { FUNC_SC(group-toggle-all, group_alltoggle, 0) }, + { FUNC_SC(group-toggle-1, group_toggle, 1) }, + { FUNC_SC(group-toggle-2, group_toggle, 2) }, + { FUNC_SC(group-toggle-3, group_toggle, 3) }, + { FUNC_SC(group-toggle-4, group_toggle, 4) }, + { FUNC_SC(group-toggle-5, group_toggle, 5) }, + { FUNC_SC(group-toggle-6, group_toggle, 6) }, + { FUNC_SC(group-toggle-7, group_toggle, 7) }, + { FUNC_SC(group-toggle-8, group_toggle, 8) }, + { FUNC_SC(group-toggle-9, group_toggle, 9) }, + { FUNC_SC(group-only-1, group_only, 1) }, + { FUNC_SC(group-only-2, group_only, 2) }, + { FUNC_SC(group-only-3, group_only, 3) }, + { FUNC_SC(group-only-4, group_only, 4) }, + { FUNC_SC(group-only-5, group_only, 5) }, + { FUNC_SC(group-only-6, group_only, 6) }, + { FUNC_SC(group-only-7, group_only, 7) }, + { FUNC_SC(group-only-8, group_only, 8) }, + { FUNC_SC(group-only-9, group_only, 9) }, + + { FUNC_SC(pointer-move-up, ptrmove, (CWM_UP)) }, + { FUNC_SC(pointer-move-down, ptrmove, (CWM_DOWN)) }, + { FUNC_SC(pointer-move-left, ptrmove, (CWM_LEFT)) }, + { FUNC_SC(pointer-move-right, ptrmove, (CWM_RIGHT)) }, + { FUNC_SC(pointer-move-up-big, ptrmove, (CWM_UP_BIG)) }, + { FUNC_SC(pointer-move-down-big, ptrmove, (CWM_DOWN_BIG)) }, + { FUNC_SC(pointer-move-left-big, ptrmove, (CWM_LEFT_BIG)) }, + { FUNC_SC(pointer-move-right-big, ptrmove, (CWM_RIGHT_BIG)) }, + + { FUNC_SC(menu-cmd, menu_cmd, 0) }, + { FUNC_SC(menu-group, menu_group, 0) }, + { FUNC_SC(menu-ssh, menu_ssh, 0) }, + { FUNC_SC(menu-window, menu_client, CWM_MENU_WINDOW_ALL) }, + { FUNC_SC(menu-window-hidden, menu_client, CWM_MENU_WINDOW_HIDDEN) }, + { FUNC_SC(menu-exec, menu_exec, 0) }, + { FUNC_SC(menu-exec-wm, menu_wm, 0) }, + + { FUNC_SC(terminal, exec_term, 0) }, + { FUNC_SC(lock, exec_lock, 0) }, + { FUNC_SC(restart, cwm_status, CWM_EXEC_WM) }, + { FUNC_SC(quit, cwm_status, CWM_QUIT) }, }; static unsigned int ignore_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask |