/* Client Handling
*****************************************************************************/
+int client_flags(Client* c, int mask) {
+ return (c->flags & mask);
+}
+
void client_add(Client* parent, Client* c) {
c->next = parent->next;
c->prev = parent;
c->flags |= TOO_SMALL;
} else {
XMoveResizeWindow(xs->display, c->win, c->x, c->y + height, c->w - 2, c->h - height - 2);
- if (c->flags & TOO_SMALL) {
+ if (client_flags(c, TOO_SMALL)) {
c->flags &= ~TOO_SMALL;
XMapWindow(xs->display, c->win);
}
if (((Atom*)data)[0] == XA_NET_WM_WINDOW_TYPE_DIALOG)
c->flags |= FLOATING;
} else if (props[i] == XA_WM_PROTOCOLS) {
-
+ /* register desire for WM_DELETE message here */
}
data = xfree(data);
}
client_initprops(x, c);
/* create the frame window */
- if (c->flags & FLOATING) {
+ if (client_flags(c, FLOATING)) {
XWindowAttributes attr;
- XGetWindowAttributes(x->display, win, &attr);
+ XGetWindowAttributes(x->display, c->win, &attr);
c->x = attr.x, c->y = attr.y;
c->w = attr.width;
c->h = attr.height;
c->w = WidthOfScreen(DefaultScreenOfDisplay(x->display));
c->h = HeightOfScreen(DefaultScreenOfDisplay(x->display));
}
-
c->frame = XCreateSimpleWindow(x->display, x->root, c->x, c->y, 1, 1, BorderWidth, BorderColor, BackgroundColor);
c->xft = XftDrawCreate(x->display, (Drawable) c->frame, x->visual, x->colormap);
XSetWindowAttributes pattr = { .override_redirect = True };
EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
/* position the window and frame */
- if (!(c->flags & FLOATING)) {
+ if (!client_flags(c, FLOATING)) {
Client* biggy = Clients;
for (Client* curr = Clients; curr; curr = curr->next)
if (curr->h > biggy->h) biggy = curr;
Clients = c;
}
} else {
-// client_add(c, Floating);
-// Floating = c;
+ if (Floating)
+ client_add(c, Floating);
+ else
+ Floating = c;
}
client_config(x, c, c->x, c->y, c->w, c->h);
client_raise(x, c);
}
Client* client_find(Window win) {
- Client *c = Clients;
- for (; c; c = c->next)
+ Client *c;
+ for (c = Clients; c; c = c->next)
if ((c->frame == win) || (c->win == win))
return c;
+// for (c = Floating; c; c = c->next)
+// if ((c->frame == win) || (c->win == win))
+// return c;
return NULL;
}
static void xbtnpress(XConf* x, XEvent* e) {
printf("btn\n");
Client* c = client_find(e->xbutton.window);
- if (!c || c->frame != e->xbutton.window)
+ if (!c || c->frame != e->xbutton.window || client_flags(c, FLOATING))
return;
if (Button1 == e->xbutton.button) {
static void xbtnrelease(XConf* x, XEvent* e) {
printf("btn\n");
Client* c = client_find(e->xbutton.window);
- if (!c || c->frame != e->xbutton.window)
+ if (!c || c->frame != e->xbutton.window || client_flags(c, FLOATING))
return;
if (Button1 == e->xbutton.button) {
wc.border_width = e->xconfigurerequest.border_width;
wc.sibling = e->xconfigurerequest.above;
wc.stack_mode = e->xconfigurerequest.detail;
- if (c && !(c->flags & FLOATING))
+ if (c && !client_flags(c, FLOATING))
return;
XConfigureWindow(x->display, e->xconfigurerequest.window, e->xconfigurerequest.value_mask, &wc);
}
/* This is where we cleanup windows we care about. destroy them and their frames. */
Client* c = client_find(e->xdestroywindow.window);
if (c) {
- int y = c->y, h = c->h;
- if (c->prev) {
- c->prev->h += h;
- client_config(x, c->prev, c->prev->x, c->prev->y, c->prev->w, c->prev->h);
- client_raise(x, c->prev);
- } else if (c->next) {
- c->next->y = y, c->next->h += h;
- client_config(x, c->next, c->next->x, c->next->y, c->next->w, c->next->h);
- client_raise(x, c->next);
+ if (!client_flags(c, FLOATING)) {
+ int y = c->y, h = c->h;
+ if (c->prev) {
+ c->prev->h += h;
+ client_config(x, c->prev, c->prev->x, c->prev->y, c->prev->w, c->prev->h);
+ client_raise(x, c->prev);
+ } else if (c->next) {
+ c->next->y = y, c->next->h += h;
+ client_config(x, c->next, c->next->x, c->next->y, c->next->w, c->next->h);
+ client_raise(x, c->next);
+ }
}
client_destroy(x, c);
}