From 7b1461df6049d172f3c95f3adca510b528c9f390 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Thu, 14 Jun 2012 07:18:46 +0000 Subject: [PATCH] Add wm_handle_state functiton This tells the wm when a windows state changes from by some external means, such as a request by the application. Fullscreen windows are also saved across tab switches using this interface. --- sys-x11.c | 11 +++++------ wm-wmii.c | 28 +++++++++++++++++++++------- wm.h | 3 +++ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/sys-x11.c b/sys-x11.c index 28fb9d9..2120ee0 100644 --- a/sys-x11.c +++ b/sys-x11.c @@ -454,12 +454,11 @@ static void process_event(int type, XEvent *xe, win_t *root) (cme->message_type == atoms[NET_STATE]) && (cme->data.l[1] == atoms[NET_FULL] || cme->data.l[2] == atoms[NET_FULL])) { - if (cme->data.l[0] == 1 || /* _NET_WM_STATE_ADD */ - (cme->data.l[0] == 2 && /* _NET_WM_STATE_TOGGLE */ - win->state != ST_FULL)) - sys_show(win, ST_FULL); - else - sys_show(win, ST_SHOW); + state_t next = (cme->data.l[0] == 1 || /* _NET_WM_STATE_ADD */ + (cme->data.l[0] == 2 && /* _NET_WM_STATE_TOGGLE */ + win->state != ST_FULL)) ? ST_FULL : ST_SHOW; + wm_handle_state(win, win->state, next); + sys_show(win, next); } } else if (type == PropertyNotify) { diff --git a/wm-wmii.c b/wm-wmii.c index 90e0616..409b3e9 100644 --- a/wm-wmii.c +++ b/wm-wmii.c @@ -47,7 +47,6 @@ struct win_wm { }; typedef struct { win_t *win; // the window int height; // win height in _this_ tag - state_t state; // state of window } row_t; typedef struct { @@ -360,6 +359,7 @@ static void put_win_flt(win_t *win, tag_t *tag, dpy_t *dpy) flt->h = dpy->geom->h / 2; flt->x = dpy->geom->x + flt->w / 2; flt->y = dpy->geom->y + flt->h / 2; + flt->state = ST_SHOW; if (dpy->flt) { flt->x = dpy->flt->x + 20; flt->y = dpy->flt->y + 20; @@ -663,7 +663,6 @@ static void wm_update_cols(dpy_t *dpy) col->width, dpy->geom->h-2*margin); break; } - ROW(lrow)->state = state; sys_show(win, state); if (focus == win) sys_raise(win); @@ -685,13 +684,10 @@ void wm_update(void) flt_t *flt = lflt->data; sys_move(win, flt->x, flt->y, flt->w, flt->h); sys_raise(flt->win); + sys_show(flt->win, flt->state); } - /* Show/hide tags */ - tag_foreach_col(wm_tag, dpy, col, row, win) - sys_show(win, ROW(row)->state); - tag_foreach_flt(wm_tag, dpy, flt, win) - sys_show(win, FLT(flt)->state); + /* Hide other tags */ for (list_t *tag = wm ->tags; tag; tag = tag->next) if (tag->data != wm_tag) { tag_foreach_col(TAG(tag), dpy, col, row, win) @@ -857,6 +853,24 @@ int wm_handle_ptr(win_t *cwin, ptr_t ptr) return 0; } +int wm_handle_state(win_t *win, state_t prev, state_t next) +{ + flt_t *flt = NULL; + + if (FLOATING != search(wm_tag, win, NULL, NULL, NULL, &flt)) { + cut_win(win, wm_tag); + put_win(win, wm_tag, FLOATING); + search(wm_tag, win, NULL, NULL, NULL, &flt); + } + + flt->state = next; + + if (prev == ST_MAX || prev == ST_FULL) + wm_update(); + + return 1; +} + void wm_insert(win_t *win) { printf("wm_insert: %p\n", win); diff --git a/wm.h b/wm.h index 7f967b5..57d79a3 100644 --- a/wm.h +++ b/wm.h @@ -31,6 +31,9 @@ int wm_handle_event(win_t *win, event_t ev, mod_t mod, ptr_t ptr); /* Called for each mouse movement */ int wm_handle_ptr(win_t *win, ptr_t ptr); +/* Called when a window changes states */ +int wm_handle_state(win_t *win, state_t prev, state_t next); + /* Begin managing a window, called for each new window */ void wm_insert(win_t *win); -- 2.43.2