]> Pileus Git - wmpus/commitdiff
Support show/hide for windows
authorAndy Spencer <andy753421@gmail.com>
Mon, 24 Dec 2012 09:12:57 +0000 (09:12 +0000)
committerAndy Spencer <andy753421@gmail.com>
Thu, 27 Dec 2012 04:05:30 +0000 (04:05 +0000)
sys-x11.c
wm-wmii.c

index d50595115eb403da7352d2a0c3391ce0069693b2..f475a83bd015c182f7734f6042ba5a19b59310ff 100644 (file)
--- a/sys-x11.c
+++ b/sys-x11.c
@@ -455,7 +455,7 @@ static void process_event(int type, XEvent *xe, win_t *root)
                printf("configure_req: %lx - (0x%lx) %dx%d @ %d,%d\n",
                                cre->window, cre->value_mask,
                                cre->height, cre->width, cre->x, cre->y);
-               if ((win = win_find(dpy,xe->xconfigurerequest.window,1))) {
+               if ((win = win_find(dpy,cre->window,1))) {
                        XSendEvent(dpy, cre->window, False, StructureNotifyMask, &(XEvent){
                                .xconfigure.type              = ConfigureNotify,
                                .xconfigure.display           = win->sys->dpy,
@@ -629,6 +629,8 @@ void sys_show(win_t *win, state_t state)
                        .width  = screen->w + screen->sys->strut.left + screen->sys->strut.right,
                        .height = screen->h + screen->sys->strut.top  + screen->sys->strut.bottom
                };
+               win->x = wc.x;     win->y = wc.y;
+               win->w = wc.width; win->h = wc.height;
                XConfigureWindow(win->sys->dpy, win->sys->xid, CWX|CWY|CWWidth|CWHeight, &wc);
                XMoveResizeWindow(win->sys->dpy, win->sys->xid, wc.x, wc.y, wc.width, wc.height);
        } else if (state == ST_SHADE) {
index 02d9eaa106095be8e0fe30d0ddb906c3be6657d7..f842f19116eec033bb6e08f2ab670fcd9728c17f 100644 (file)
--- a/wm-wmii.c
+++ b/wm-wmii.c
@@ -875,8 +875,14 @@ int wm_handle_state(win_t *win, state_t prev, state_t next)
        flt_t *flt = NULL;
 
        printf("wm_handle_state - %p %x -> %x\n", win, prev, next);
+
        search(wm_tag, win, NULL, NULL, &row, &flt);
 
+       if (!row && !flt && next == ST_SHOW)
+               return wm_insert(win), 1;
+       if ((row || flt) && next == ST_HIDE)
+               return wm_remove(win), 1;
+
        if (row) row->state = next;
        if (flt) flt->state = next;
 
@@ -897,7 +903,6 @@ void wm_insert(win_t *win)
                return wm_update();
 
        /* Initialize window */
-       win->wm = new0(win_wm_t);
        sys_watch(win, EV_ENTER, MOD());
        sys_watch(win, EV_FOCUS, MOD());
 
@@ -920,7 +925,6 @@ void wm_remove(win_t *win)
                return wm_update();
        for (list_t *tag = wm->tags; tag; tag = tag->next)
                cut_win(win, tag->data);
-       free(win->wm);
        set_focus(wm_focus);
        wm_update();
        print_txt();
@@ -965,12 +969,10 @@ void wm_free(win_t *root)
        while (dpy->cols) { col_t *col = dpy->cols->data;
        while (col->rows) { row_t *row = col->rows->data;
                sys_show(row->win, ST_SHOW);
-               free(row->win->wm);
        col->rows = list_remove(col->rows, col->rows, 1); }
        dpy->cols = list_remove(dpy->cols, dpy->cols, 1); }
        while (dpy->flts) { flt_t *flt = dpy->flts->data;
                sys_show(flt->win, ST_SHOW);
-               free(flt->win->wm);
        dpy->flts = list_remove(dpy->flts, dpy->flts, 1); }
        tag->dpys = list_remove(tag->dpys, tag->dpys, 1); }
         wm->tags = list_remove( wm->tags,  wm->tags, 1); }