diff -Nur skippy-0.5.1rc1.orig/clientwin.c skippy-0.5.1rc1/clientwin.c --- skippy-0.5.1rc1.orig/clientwin.c 2004-09-13 19:41:37.000000000 +0200 +++ skippy-0.5.1rc1/clientwin.c 2006-04-06 18:07:13.185126744 +0200 @@ -18,11 +18,18 @@ */ #include "skippy.h" +#include #define INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2) \ (((x1 >= x2 && x1 < (x2 + w2)) || (x2 >= x1 && x2 < (x1 + w1))) && \ ((y1 >= y2 && y1 < (y2 + h2)) || (y2 >= y1 && y2 < (y1 + h1)))) +static Atom atom; +static int done = 0; + +static void +childwin_focus(ClientWin *cw); + int clientwin_cmp_func(dlist *l, void *data) { @@ -37,9 +44,10 @@ w_desktop = wm_get_window_desktop(cw->mainwin->dpy, cw->client.window); #ifdef XINERAMA - if(cw->mainwin->xin_active && ! INTERSECTS(cw->client.x, cw->client.y, cw->client.width, cw->client.height, - cw->mainwin->xin_active->x_org, cw->mainwin->xin_active->y_org, - cw->mainwin->xin_active->width, cw->mainwin->xin_active->height)) + if(cw->mainwin->xin_active && ! INTERSECTS(cw->client.x, cw->client.y, + cw->client.width, cw->client.height, + cw->mainwin->xin_active->x_org, cw->mainwin->xin_active->y_org, + cw->mainwin->xin_active->width, cw->mainwin->xin_active->height)) return 0; #endif @@ -139,21 +147,57 @@ clientwin_snap(ClientWin *cw) { struct timespec req, rem; - + XEvent xev; + XWindowAttributes wattr; + + Display *dpy; Window w; + wm_snap_state_t state; - dpy = cw->mainwin->dpy; + req.tv_sec = 0; + req.tv_nsec = 200000000; + w = cw->client.window; + + XMapWindow(cw->mainwin->dpy, cw->client.window); + wm_prepare_snap(dpy, w, &state); XRaiseWindow(dpy, w); XFlush(dpy); - - req.tv_sec = 0; - req.tv_nsec = 500000000; + XGetWindowAttributes(cw->mainwin->dpy, cw->client.window, &wattr); + if (wattr.map_state == IsUnmapped || wattr.map_state == IsUnviewable) + return; + + if (!done) { + atom = XInternAtom (cw->mainwin->dpy, "_NET_ACTIVE_WINDOW", False); + done = 1; + } + + xev.xclient.type = ClientMessage; + xev.xclient.serial = 0; + xev.xclient.send_event = True; + xev.xclient.display = cw->mainwin->dpy; + xev.xclient.window = cw->client.window; + xev.xclient.message_type = atom; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 2; + xev.xclient.data.l[1] = 0; + xev.xclient.data.l[2] = 0; + xev.xclient.data.l[3] = 0; + xev.xclient.data.l[4] = 0; + + XSendEvent (cw->mainwin->dpy, + wattr.root, False, + SubstructureRedirectMask | SubstructureNotifyMask, + &xev); + + XFlush(cw->mainwin->dpy); + XSync(cw->mainwin->dpy, False); + while(nanosleep(&req, &rem)) req = rem; @@ -289,7 +333,10 @@ clientwin_render(cw); XFlush(cw->mainwin->dpy); } else if(ev->type == EnterNotify) { - XSetInputFocus(cw->mainwin->dpy, cw->mini.window, RevertToNone, CurrentTime); + /* + * Moinak: Commented out. Causing a crash + */ +/* XSetInputFocus(cw->mainwin->dpy, cw->mini.window, RevertToNone, CurrentTime);*/ if(cw->mainwin->tooltip) { int win_title_len = 0;