From d7962431c1e307cc50a744b23b5aac314f4cda75 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 24 Dec 2012 09:12:57 +0000 Subject: [PATCH] Support show/hide for windows --- sys-x11.c | 4 +++- wm-wmii.c | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sys-x11.c b/sys-x11.c index d505951..f475a83 100644 --- 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) { diff --git a/wm-wmii.c b/wm-wmii.c index 02d9eaa..f842f19 100644 --- 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); } -- 2.43.2