static const char *cvstag = "$scrotwm$";
-#define SWM_VERSION "1.0"
+#define SWM_VERSION "0.9.12"
#include <stdio.h>
#include <stdlib.h>
long data[] = {state, None};
XEvent ev;
XWindowAttributes wa;
+ int putback;
DNPRINTF(SWM_D_EVENT, "set_win_state: window: %lu\n", win->id);
(unsigned char *)data, 2);
/* wait for completion of XChangeProperty */
+ putback = 0;
while (XCheckIfEvent(display, &ev, set_win_notify_cb, (char *)win))
- ;
+ putback = 1;
+ if (putback)
+ XPutBackEvent(display, &ev);
}
long
{
XClientMessageEvent cm;
+ if (win == NULL)
+ return;
+
bzero(&cm, sizeof cm);
cm.type = ClientMessage;
cm.window = win->id;
DNPRINTF(SWM_D_MISC, "config_win: win %lu x %d y %d w %d h %d\n",
win->id, win->g.x, win->g.y, win->g.w, win->g.h);
+
+ if (win == NULL)
+ return;
+
ce.type = ConfigureNotify;
ce.display = display;
ce.event = win->id;
{
struct ws_win *win;
int count = 0;
- int state;
-
- /*
- * Under stress conditions windows sometimes do not get removed from
- * the managed list quickly enough. Use a very large hammer to get rid
- * of them. A smaller hammer would be nice.
- */
- TAILQ_FOREACH(win, &ws->winlist, entry) {
- state = getstate(win->id);
- if (state == -1) {
- DNPRINTF(SWM_D_MISC, "count_win:removing: %lu\n",
- win->id);
- unmanage_window(win);
- }
- }
TAILQ_FOREACH(win, &ws->winlist, entry) {
if (count_transient == 0 && win->floating)
{
XEvent ev;
XWindowAttributes wa;
+ int putback;
if (win == NULL)
return;
XUnmapWindow(display, win->id);
/* make sure we wait for XUnmapWindow completion */
+ putback = 0;
while (XCheckIfEvent(display, &ev, unmap_window_cb, (char *)win))
- ;
+ putback = 1;
+ if (putback)
+ XPutBackEvent(display, &ev);
}
void
{
XKeyEvent event;
+ if (win == NULL)
+ return;
+
event.display = display; /* Ignored, but what the hell */
event.window = win->id;
event.root = win->s->root;
{
if (win == NULL)
return;
-
+ if (win->ws == NULL)
+ return;
if (win->ws->r == NULL)
return;
if (win == NULL)
return;
+ if (win->ws == NULL)
+ return;
/* use big hammer to make sure it works under all use cases */
unfocus_all();
struct ws_win *win, *winfocus = NULL, *parent = NULL;
struct workspace *new_ws, *old_ws;
- if (!(r && r->s))
- return;
+ if (!(r && r->s)) {
+ fprintf(stderr, "r && r->s failed\n");
+ abort();
+ }
+ if (wsid < 0 || wsid > SWM_WS_MAX) {
+ fprintf(stderr, "illegal wsid\n");
+ abort();
+ }
this_r = r;
old_ws = this_r->ws;
"%d -> %d\n", r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r),
old_ws->idx, wsid);
- if (new_ws == NULL || old_ws == NULL || new_ws == old_ws)
+ if (new_ws == NULL || old_ws == NULL) {
+ fprintf(stderr, "new_ws = %p old_ws = %p\n", new_ws, old_ws);
+ abort();
+ }
+
+ if (new_ws == old_ws)
return;
/* get focus window */
else
return;
}
+ if (target == NULL || source == NULL)
+ return;
source->ws->focus_prev = target;
TAILQ_REMOVE(wl, target, entry);
TAILQ_INSERT_BEFORE(source, target, entry);
"(screen %d, region %d)\n", r->ws->idx, i, j++);
/* start with screen geometry, adjust for bar */
+ if (r == NULL) {
+ fprintf(stderr, "illegal r\n");
+ abort();
+ }
g = r->g;
g.w -= 2;
g.h -= 2;
g.y += bar_height;
g.h -= bar_height;
}
-
+ if (r->ws == NULL) {
+ fprintf(stderr, "illegal ws\n");
+ abort();
+ }
+ if (r->ws->cur_layout == NULL) {
+ fprintf(stderr, "illegal cur_layout\n");
+ abort();
+ }
r->ws->restack = 0;
+ if (r->ws->cur_layout->l_stack == NULL) {
+ fprintf(stderr, "illegal l_stack\n");
+ abort();
+ }
r->ws->cur_layout->l_stack(r->ws, &g);
}
}
}
}
+Bool
+destroy_notify_cb(Display *d, XEvent *e, char *arg)
+{
+ struct ws_win *win = (struct ws_win *)arg;
+ if (win && win->id == e->xany.window && e->xany.type == DestroyNotify)
+ return (True);
+ return (False);
+}
+
void
expose(XEvent *e)
{
void
destroynotify(XEvent *e)
{
- struct ws_win *win, *winfocus = NULL;
+ struct ws_win *win, *w, *winfocus = NULL;
struct workspace *ws;
struct ws_win_list *wl;
XDestroyWindowEvent *ev = &e->xdestroywindow;
+ XEvent de;
DNPRINTF(SWM_D_EVENT, "destroynotify: window %lu\n", ev->window);
}
unmanage_window(win);
+ /*
+ * Under stress conditions windows sometimes do not get removed
+ * from the managed list. Use a very large hammer to get rid
+ * of them. A smaller hammer would be nice.
+ */
+ TAILQ_FOREACH(w, &ws->winlist, entry) {
+ if (win == w)
+ continue; /* can't happen but oh well */
+
+ if (getstate(w->id) != -1)
+ continue;
+
+ /* see if we have a destroy event */
+ if (XCheckIfEvent(display, &de, destroy_notify_cb,
+ (char *)w) == False)
+ unmanage_window(w); /* no event, help it */
+ else
+ XPutBackEvent(display, &de); /* oops */
+ }
+
ignore_enter = 1;
stack();
if (winfocus)
struct passwd *pwd;
struct swm_region *r, *rr;
struct ws_win *winfocus = NULL;
+ struct timeval tv;
char conf[PATH_MAX], *cfile = NULL;
struct stat sb;
XEvent e;
FD_ZERO(&rd);
FD_SET(xfd, &rd);
- if (select(xfd + 1, &rd, NULL, NULL, NULL) == -1)
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ if (select(xfd + 1, &rd, NULL, NULL, &tv) == -1)
if (errno != EINTR)
DNPRINTF(SWM_D_MISC, "select failed");
if (running == 0)