]> Pileus Git - wmpus/blobdiff - wm-wmii.c
Force WM requested size for configure requests
[wmpus] / wm-wmii.c
index c9ea15bb96c7a9d62bba0312610b0703463329b0..e432363d667876480f4eb006dfcaa2f4a559a3ce 100644 (file)
--- 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 */
@@ -86,8 +86,8 @@ static void arrange(list_t *cols)
        int tx=0, ty=0; // Total x/y size
        int mx=0, my=0; // Maximum x/y size (screen size)
 
-
        /* Scale horizontally */
+       x  = wm_root->x;
        mx = wm_root->w - (list_length(wm_cols)+1)*MARGIN;
        for (list_t *lx = cols; lx; lx = lx->next)
                tx += ((col_t*)lx->data)->width;
@@ -100,7 +100,7 @@ static void arrange(list_t *cols)
                ty = 0;
                for (list_t *ly = col->rows; ly; ly = ly->next)
                        ty += ((win_t*)ly->data)->h;
-               y = 0;
+               y  = wm_root->y;
                my = wm_root->h - (list_length(col->rows)+1)*MARGIN;
                for (list_t *ly = col->rows; ly; ly = ly->next) {
                        win_t *win = ly->data;
@@ -215,6 +215,11 @@ static void shift_focus(win_t *win, int col, int row)
 }
 
 /* Window management functions */
+void wm_update(void)
+{
+       arrange(wm_cols);
+}
+
 int wm_handle_key(win_t *win, Key_t key, mod_t mod, ptr_t ptr)
 {
        if (!win || win == wm_root) return 0;
@@ -264,6 +269,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 +327,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 +336,7 @@ void wm_insert(win_t *win)
 
        /* Arrange */
        arrange(wm_cols);
+       sys_focus(wm_focus);
        print_txt(wm_cols);
 }
 
@@ -350,6 +363,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));