From 6f9eafa3b63b7b95af52187bc550d0d4527c1f23 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sun, 18 Sep 2011 08:20:15 +0000 Subject: [PATCH] Reset focus after focus change event --- .vimrc | 1 + sys-x11.c | 4 ++-- wm-wmii.c | 11 ++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .vimrc diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..b24f8ee --- /dev/null +++ b/.vimrc @@ -0,0 +1 @@ +set makeprg=make\ debug diff --git a/sys-x11.c b/sys-x11.c index db711c9..e60b97c 100644 --- a/sys-x11.c +++ b/sys-x11.c @@ -230,10 +230,10 @@ static void process_event(int type, XEvent *ev, win_t *root) wm_handle_key(win, key, MOD(), PTR()); } else if (type == ConfigureNotify) { - //printf("configure: %d\n", type); + printf("configure: %d\n", type); } else if (type == MapNotify) { - //printf("map: %d\n", type); + printf("map: %d\n", type); } else if (type == UnmapNotify) { //printf("unmap: %d\n", type); diff --git a/wm-wmii.c b/wm-wmii.c index c9ea15b..30ded07 100644 --- a/wm-wmii.c +++ b/wm-wmii.c @@ -5,7 +5,7 @@ #include "sys.h" #include "wm.h" -#define MODKEY ctrl +#define MODKEY alt #define MARGIN 10 /* Loca types */ @@ -264,6 +264,12 @@ int wm_handle_key(win_t *win, Key_t key, mod_t mod, ptr_t ptr) if (key == key_enter) set_focus(win); + /* Reset focus after after focus change, + * not sure what is causing the focus change in the first place + * but preventing that would be a better solution */ + if (key == key_focus) + set_focus(wm_focus); + return 0; } @@ -316,6 +322,7 @@ void wm_insert(win_t *win) /* Initialize window */ win->wm = new0(win_wm_t); sys_watch(win, key_enter, MOD()); + sys_watch(win, key_focus, MOD()); /* Add to screen */ list_t *lcol = wm_focus && wm_focus->wm ? @@ -324,6 +331,7 @@ void wm_insert(win_t *win) /* Arrange */ arrange(wm_cols); + sys_focus(wm_focus); print_txt(wm_cols); } @@ -350,6 +358,7 @@ void wm_init(win_t *root) sys_watch(root, key_mouse1, MOD(.MODKEY=1)); sys_watch(root, key_mouse3, MOD(.MODKEY=1)); sys_watch(root, key_enter, MOD()); + sys_watch(root, key_focus, MOD()); Key_t keys[] = {'h', 'j', 'k', 'l'}; for (int i = 0; i < countof(keys); i++) { sys_watch(root, keys[i], MOD(.MODKEY=1)); -- 2.43.2