#include "config.h"
typedef struct Client {
- struct Client* next;
+ struct Client *next, *prev;
Window win;
Window frame;
char* name;
/* configuration */
uint32_t BorderWidth = 1;
-uint32_t BorderColor = 0x000077;
+uint32_t BorderColor = 0xFF0000;
uint32_t BackgroundColor = 0x000077;
/* Utility Functions
/* Client Handling
*****************************************************************************/
+
+
+void client_config(XConf* xs, Client* c, int x, int y, int w, int h) {
+ c->x = x, c->y = y, c->w = w, c->h = h;
+ XMoveResizeWindow(xs->display, c->frame, x, y, c->w-2, xs->font->height);
+ XMoveResizeWindow(xs->display, c->win, x, y + xs->font->height, c->w - 2, c->h - xs->font->height - 2);
+}
+
+void client_raise(XConf* x, Client* c) {
+ XMapRaised(x->display, c->frame);
+ XMapRaised(x->display, c->win);
+}
+
void client_add(XConf* x, Window win) {
Client* c = calloc(1, sizeof(Client));
c->win = win;
/* create the frame window */
XWindowAttributes attr;
XGetWindowAttributes(x->display, win, &attr);
- c->x = attr.x, c->y = attr.y;
- c->w = attr.width, c->h = attr.height;
- c->frame = XCreateSimpleWindow(x->display, x->root, 0, 0, 1, 1,
- BorderWidth, BorderColor, BackgroundColor);
+ c->x = 0, c->y = 0;
+ c->w = WidthOfScreen(DefaultScreenOfDisplay(x->display));
+ c->h = HeightOfScreen(DefaultScreenOfDisplay(x->display));
+ c->frame = XCreateSimpleWindow(x->display, x->root, 0, 0, 1, 1, BorderWidth, BorderColor, BackgroundColor);
c->xft = XftDrawCreate(x->display, (Drawable) c->frame, x->visual, x->colormap);
XSetWindowAttributes pattr = { .override_redirect = True };
XChangeWindowAttributes(x->display, c->frame, CWOverrideRedirect, &pattr);
+ XSetWindowBorder(x->display, c->win, BorderColor);
+ XSetWindowBorderWidth(x->display, c->win, BorderWidth);
/* setup event handling on both windows */
XSelectInput(x->display, c->frame,
EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
/* position the window and frame */
- XSetWindowBorder(x->display, c->win, BorderColor);
- XSetWindowBorderWidth(x->display, c->win, BorderWidth);
- XMoveResizeWindow(x->display, c->frame, 100, 100 - x->font->height, c->w, x->font->height);
- XMoveResizeWindow(x->display, c->win, 100, 100, c->w, c->h);
+ client_config(x, c, c->x, c->y, c->w, c->h);
+ client_raise(x, c);
- XMapRaised(x->display, c->frame);
- XMapRaised(x->display, c->win);
XSync(x->display, False);
XUngrabServer(x->display);
}