static void xbtnpress(XEvent* e)
{
XButtonEvent* ev = &(e->xbutton);
+ printf("BTN_DN(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root);
X.start_x = ev->x_root, X.start_y = ev->y_root;
X.last_x = ev->x_root, X.last_y = ev->y_root;
Location loc;
static void xbtnrelease(XEvent* e)
{
XButtonEvent* ev = &(e->xbutton);
+ printf("BTN_UP(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root);
Location loc;
Client* c = client_get(e->xbutton.window, &loc);
if (c && (ev->window == c->frame))
{
/* make sure we get just the latest event */
XMotionEvent *ev = &e->xmotion;
+ printf("BTN_MV(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root);
while (XCheckTypedWindowEvent(X.disp, ev->window, ev->type, e));
Location loc;
Client* c = client_get(ev->window, &loc);
static void xconfigrequest(XEvent* e)
{
XConfigureRequestEvent* ev = &(e->xconfigurerequest);
+ printf("CONF(w: 0x%lx x: %d y: %d w: %d h: %d)\n", ev->window, ev->x, ev->y, ev->width, ev->height);
XWindowChanges wc;
wc.x = ev->x;
wc.y = ev->y;
static void xmaprequest(XEvent* e)
{
XMapRequestEvent* ev = &(e->xmaprequest);
+ printf("MAP(w: 0x%lx)\n", ev->window);
XWindowAttributes attr;
if (!client_get(ev->window, NULL))
{
static void xunmapnotify(XEvent* e)
{
XUnmapEvent* ev = &(e->xunmap);
+ printf("UNMAP(w: 0x%lx)\n", ev->window);
Client* c = client_get(ev->window, NULL);
if (c && c->win == ev->window && !(c->flags & F_SHADED))
{
static void xdestroynotify(XEvent* e)
{
XDestroyWindowEvent* ev = &(e->xdestroywindow);
+ printf("DESTROY(w: 0x%lx)\n", ev->window);
Client* c = client_get(ev->window, NULL);
if (c)
{
static void xpropnotify(XEvent* e)
{
XPropertyEvent* ev = &(e->xproperty);
+ printf("PROP_NOTIFY(w: 0x%lx)\n", ev->window);
Client* c = client_get(ev->window, NULL);
if (c)
{
{
XCrossingEvent* ev = &(e->xcrossing);
Client* c = client_get(ev->window, NULL);
+ printf("ENTER(w: 0x%lx c: 0x%lx)\n", ev->window, c ? c->win : 0);
if (c)
{
client_focus(c);
static void xexpose(XEvent* e)
{
- if (e->xexpose.count == 0)
+ XExposeEvent* ev = &(e->xexpose);
+// printf("EXPOSE(w: 0x%lx)\n", ev->window);
+ if (ev->count == 0)
{
- Client* c = client_get(e->xexpose.window, NULL);
+ Client* c = client_get(ev->window, NULL);
if (c)
{
client_draw(c);
static void xkeypress(XEvent* e)
{
- keys_run(&(e->xkey));
+ XKeyEvent* ev = &(e->xkey);
+ printf("KEY_DN(w: 0x%lx)\n", ev->window);
+ keys_run(ev);
}
static void init_cursors(void)
Client* client_add(Window win, XWindowAttributes* attr)
{
+ printf("ADD(w: %lx)\n", win);
Client* c = ecalloc(1, sizeof(Client));
c->win = win;
c->x = attr->x;
client_show(c, 1);
XSync(X.disp, False);
client_draw(c);
-
+ printf("PLACE(w: %lx x: %d y: %d w: %d h: %d)\n", win, c->x, c->y, c->w, c->y);
return c;
}
void client_focus(Client* c)
{
+ printf("SET_FOCUS(w: 0x%lx c: 0x%lx)\n", c->frame, c->win);
Client* prev = Focused;
Focused = c;
XSetInputFocus(X.disp, c->win, RevertToPointerRoot, CurrentTime);
void client_warpmouse(Client* c)
{
- XWarpPointer(X.disp, None, c->frame, 0, 0, 0, 0, (c->w/2), (MIN_HEIGHT/2));
+ (void)c;
+// XWarpPointer(X.disp, None, X.root, 0, 0, 0, 0, (c->x + c->w/2), c->y + (MIN_HEIGHT/2));
}
for (; prev && prev->next != c; prev = prev->next);
if (prev)
{
- amount = (amount == 0 ? min((int)(-c->h * 0.25), -2*MIN_HEIGHT) : amount);
+ amount = (abs(amount) < BORDER_WIDTH ? min((int)(-c->h * 0.25), -2*MIN_HEIGHT) : amount);
int miny = (prev->y + MIN_HEIGHT);
int maxy = min((mon->y + mon->h) , (c->y + c->h)) - MIN_HEIGHT;
c->y = max(miny, min(maxy, c->y + amount));
prev->h = c->y - prev->y;
c->h = (c->next ? c->next->y : mon->y + mon->h) - c->y;
+ printf("ADD_HEIGHT1(w: %lx x: %d y: %d w: %d h: %d)\n", c->frame, c->x, c->y, c->w, c->h);
client_setshade(prev, (prev->h <= MIN_HEIGHT));
client_setshade(c, (c->h <= MIN_HEIGHT));
client_adjust(prev);
+ client_warpmouse(c);
client_adjust(c);
}
}