* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
*/
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <search.h>
return new;
}
-static void win_remove(win_t *win)
+static void win_free(win_t *win)
{
- tdelete(win, &cache, win_cmp);
free(win->sys);
free(win);
}
+static void win_remove(win_t *win)
+{
+ tdelete(win, &cache, win_cmp);
+ win_free(win);
+}
+
static int win_viewable(win_t *win)
{
XWindowAttributes attr;
case st_show:
printf("sys_show: show\n");
XMapWindow(win->sys->dpy, win->sys->xid);
+ XSync(win->sys->dpy, False);
return;
case st_full:
printf("sys_show: full\n");
{
/* Use global copy of screens so we can add struts */
if (screens == NULL) {
- int n;
+ /* Add Xinerama screens */
+ int n = 0;
XineramaScreenInfo *info = NULL;
if (XineramaIsActive(win->sys->dpy))
info = XineramaQueryScreens(win->sys->dpy, &n);
- if (!info) {
- win_t *screen = new0(win_t);
- *screen = *win;
- return list_insert(NULL, screen);
- }
for (int i = 0; i < n; i++) {
win_t *screen = new0(win_t);
screen->x = info[i].x_org;
screens = list_append(screens, screen);
}
}
+ if (screens == NULL) {
+ /* No xinerama support */
+ win_t *screen = new0(win_t);
+ *screen = *win;
+ screens = list_insert(NULL, screen);
+ }
return screens;
}
unsigned int nkids;
Window par, xid, *kids = NULL;
if (XQueryTree(root->sys->dpy, root->sys->xid,
- &par, &xid, &kids, &nkids))
+ &par, &xid, &kids, &nkids)) {
for(int i = 0; i < nkids; i++) {
win_t *win = win_find(root->sys->dpy, kids[i], 1);
if (win && win_viewable(win) && !strut_add(root,win))
wm_insert(win);
}
+ XFree(kids);
+ }
wm_update(); // For struts
/* Main loop */
{
running = 0;
}
+
+void sys_free(win_t *root)
+{
+ XCloseDisplay(root->sys->dpy);
+ while (screens)
+ screens = list_remove(screens, screens, 1);
+ tdestroy(cache, (void(*)(void*))win_free);
+}
for (int i = 0; i < countof(keys_s); i++)
sys_watch(root, keys_s[i], MOD(.MODKEY=1,.shift=1));
}
+
+void wm_free(win_t *root)
+{
+ /* Re-show and free all windows */
+ while ( wm->tags) { tag_t *tag = wm->tags->data;
+ while (tag->dpys) { dpy_t *dpy = tag->dpys->data;
+ 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); }
+
+ /* Free remaining data */
+ free(wm);
+}