/* Utility Functions
*****************************************************************************/
-void dbg(char* fmt, ...) {
- va_list args;
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
-}
-
void die(char* errstr) {
fprintf(stderr, "error: %s\n", errstr);
exit(1);
return XInternAtom(x->display, s, False);
}
-void xfree(void* p) {
+void* xfree(void* p) {
if (p) XFree(p);
+ return NULL;
}
/* Client Handling
XSetWindowBorderWidth(x->display, c->win, 0);
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);
+
XMapRaised(x->display, c->frame);
XMapRaised(x->display, c->win);
-
XSync(x->display, False);
XUngrabServer(x->display);
}
return NULL;
}
+void client_redraw(XConf* x, Client* c) {
+ (void)x, (void)c;
+}
+
/* X11 Event Handling
*****************************************************************************/
#pragma GCC diagnostic ignored "-Wunused-parameter"
static void xbtnpress(XConf* x, XEvent* e) {
- dbg("btn\n");
+ printf("btn\n");
}
static void xconfigrequest(XConf* x, XEvent* e) {
- dbg("config\n");
+ printf("config\n");
/*
Check if it's a window we care about. If it is, and it's floating, just
grant the request. Otherwise, deny it as we have it tiled already. All
}
static void xmaprequest(XConf* x, XEvent* e) {
- dbg("map\n");
+ printf("map\n");
static XWindowAttributes attr = {0};
if (XGetWindowAttributes(x->display, e->xmaprequest.window, &attr)) {
if (attr.override_redirect) return; /* ignore certain windows (like frames) */
}
static void xunmapnotify(XConf* x, XEvent* e) {
- dbg("unmap\n");
+ printf("unmap\n");
}
static void xdestroynotify(XConf* x, XEvent* e) {
- dbg("destroy\n");
+ printf("destroy\n");
/*
This is where we cleanup windows we care about. destroy them and their frames.
*/
}
static void xclientmsg(XConf* x, XEvent* e) {
- dbg("client\n");
+ printf("client\n");
}
static void xpropnotify(XConf* x, XEvent* e) {
- dbg("prop\n");
+ printf("prop\n");
/*
We only care about updating the window titles here for now
*/
+ Client* c = client_find(e->xproperty.window);
+ if (c && e->xproperty.atom == XA_WM_NAME) {
+ c->name = xfree(c->name);
+ XFetchName(x->display, c->win, &c->name);
+ client_redraw(x, c);
+ }
}
static void xenternotify(XConf* x, XEvent* e) {
- dbg("enter\n");
+ printf("enter\n");
/*
Handle focus follows mouse here.
*/
}
static void xexpose(XConf* x, XEvent* e) {
- dbg("expose\n");
+ printf("expose\n");
+ Client* c = client_find(e->xexpose.window);
+ if (c && e->xexpose.count == 0)
+ client_redraw(x, c);
}
#pragma GCC diagnostic pop