c->w = attr->width;
c->h = attr->height;
mons_addclient(c);
-
- /* get window name */
client_readprops(c);
- /* get normal hints ? */
- /* get transient_for property ? */
- /* set client flags appropriately */
-
-
- /* get registered protocols */
- Atom* protos;
- int nprotos;
- if (XGetWMProtocols(X.disp, c->win, &protos, &nprotos) != 0)
- {
- for (int i = 0; i < nprotos; i++)
- {
- if (protos[i] == atom("WM_DELETE_WINDOW"))
- {
- c->flags |= F_WM_DELETE;
- }
- }
- xfree(protos);
- }
-
-
/* Reparent the window if applicable */
c->frame = XCreateSimpleWindow(X.disp, X.root,
c->x - BORDER_WIDTH,
c->y - TITLE_HEIGHT - BORDER_WIDTH,
c->w + (2 * BORDER_WIDTH),
c->h + TITLE_HEIGHT + 2*BORDER_WIDTH,
- 1, X.black, X.white);
+ 1, X.black, X.gray);
XSelectInput(X.disp, c->frame,
ExposureMask | EnterWindowMask |
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
/* Map the window and draw the frame */
XAddToSaveSet(X.disp, c->win);
- XMapWindow(X.disp, c->frame);
- XMapWindow(X.disp, c->win);
+ client_show(c, 1);
client_draw(c);
- /* Set focus and state? */
-
return c;
}
void client_show(Client* c, int show)
{
- if (show)
- {
- XMapWindow(X.disp, c->frame);
- XMapWindow(X.disp, c->win);
- }
- else
- {
- XUnmapWindow(X.disp, c->frame);
- XUnmapWindow(X.disp, c->win);
- }
+ int (*mapfn)(Display*,Window) = (show ? XMapWindow : XUnmapWindow);
+ mapfn(X.disp, c->frame);
+ mapfn(X.disp, c->win);
}
void client_readprops(Client* c)
{
- Atom actual_type;
- int format;
+ Atom *protos = NULL, actual_type;
+ int format, nprotos = 0;
unsigned long n, extra;
xfree(c->name);
c->name = NULL;
XGetWindowProperty(
X.disp, c->win, XA_WM_NAME, 0L, 100L, False, AnyPropertyType, &actual_type, &format, &n, &extra, (unsigned char **)&c->name);
+ XGetWMNormalHints(X.disp, c->win, &(c->hints), &(c->hint_flags));
+ XGetWMProtocols(X.disp, c->win, &protos, &nprotos);
+ for (int i = 0; i < nprotos; i++)
+ {
+ if (protos[i] == atom("WM_DELETE_WINDOW"))
+ {
+ c->flags |= F_WM_DELETE;
+ }
+ }
+ xfree(protos);
}