#include <draw.h>
#include <locale.h>
#include <sys/wait.h>
+#include <X11/cursorfont.h>
#define INCLUDE_DEFS
#include "config.h"
XConf X = {0};
Client* Clients = NULL;
+Cursor Move_Cursor;
/* configuration */
uint32_t BorderWidth = 1;
/* Client Handling
*****************************************************************************/
-void client_add(XConf* x, Client* c) {
+void client_add(Client* parent, Client* c) {
+ c->next = parent->next;
+ c->prev = parent;
+ parent->next = c;
+ if (c->next) c->next->prev = c;
}
-void client_del(XConf* x, Client* c) {
- /* first remove it from the list */
+void client_del(Client* c) {
if (c->prev) c->prev->next = c->next;
if (c->next) c->next->prev = c->prev;
if (Clients == c) Clients = c->next;
biggy->h /= 2;
c->y = biggy->y + biggy->h;
client_config(x, biggy, biggy->x, biggy->y, biggy->w, biggy->h);
-
- /* add the new client to the list after the biggest */
- c->next = biggy->next;
- c->prev = biggy;
- biggy->next = c;
- if (c->next) c->next->prev = c;
+ client_add(biggy, c);
} else {
Clients = c;
}
XSync(x->display, False);
XUngrabServer(x->display);
-
}
void client_destroy(XConf* x, Client* c) {
- client_del(x, c);
+ client_del(c);
XGrabServer(x->display);
XftDrawDestroy(c->xft);
XDestroyWindow(x->display, c->frame);
void client_redraw(XConf* x, Client* c) {
puts("redraw");
XftColor clr;
+ if (!c->name) return;
xftcolor(x, &clr, -1);
XftDrawStringUtf8(c->xft, &clr, x->font, 0, x->font->ascent, (const FcChar8*)c->name, strlen(c->name));
XftColorFree(x->display, x->visual, x->colormap, &clr);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
-
+Cursor cursor;
static void xbtnpress(XConf* x, XEvent* e) {
printf("btn\n");
/*
* Shift+B1: Move one column to the left
* Shift+B1: Move one column to the right
*/
+ Client* c = client_find(e->xbutton.window);
+ if (c && c->frame == e->xbutton.window) {
+ if (ButtonPress == e->type)
+ XDefineCursor(X.display, e->xbutton.window, Move_Cursor);
+ else
+ XUndefineCursor(X.display, e->xbutton.window);
+ }
+ XSync(X.display, False);
}
static void xconfigrequest(XConf* x, XEvent* e) {
XSync(X.display, False);
if (x11_error_get())
die("Could not start. Is another WM running?\n");
+
+ Move_Cursor = XCreateFontCursor(X.display, XC_draped_box);
X.eventfns[ButtonPress] = xbtnpress;
+ X.eventfns[ButtonRelease] = xbtnpress;
X.eventfns[ConfigureRequest] = xconfigrequest;
X.eventfns[MapRequest] = xmaprequest;
X.eventfns[UnmapNotify] = xunmapnotify;