From b1e391850434aba0bc8799b2a204ba64fbc08ff9 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Wed, 3 Dec 2008 13:44:46 +0100 Subject: [PATCH] config: Add option place_at_mouse in the client section --- src/client.c | 36 +++++++++++++++++++++++------------- src/config.c | 2 ++ src/structs.h | 1 + 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/client.c b/src/client.c index 5ec54e7..8fb56d8 100644 --- a/src/client.c +++ b/src/client.c @@ -355,28 +355,38 @@ client_manage(Window w, XWindowAttributes *wa) Window trans; Status rettrans; XSetWindowAttributes at; - int mx = 0, my = 0, dint; - uint duint; - Window dw; + int mx, my; c = emalloc(1, sizeof(Client)); c->win = w; c->screen = screen_get_sel(); - XQueryPointer(dpy, root, &dw, &dw, &mx, &my, &dint, &dint, &duint); + if(conf.client.place_at_mouse) + { + int dint; + uint duint; + Window dw; - mx += BORDH; - my += TBARH; + XQueryPointer(dpy, root, &dw, &dw, &mx, &my, &dint, &dint, &duint); - if(mx == 0) mx += BORDH; - else if(mx == MAXW) - mx -= wa->width + BORDH; + my += TBARH; - if(my == 0) - my += TBARH + INFOBARH; - else if(my == MAXH) - my -= wa->height + BORDH; + if(mx == 0) + mx += BORDH; + else if(mx == MAXW) + mx -= wa->width + BORDH; + + if(my == 0) + my += TBARH + INFOBARH; + else if(my == MAXH) + my -= wa->height + BORDH; + } + else + { + mx = wa->x + BORDH; + my = wa->y + TBARH + INFOBARH; + } c->ogeo.x = c->geo.x = mx; c->ogeo.y = c->geo.y = my; diff --git a/src/config.c b/src/config.c index a3e1bcb..d21fda5 100644 --- a/src/config.c +++ b/src/config.c @@ -87,6 +87,7 @@ static cfg_opt_t titlebar_opts[] = static cfg_opt_t client_opts[]= { + CFG_BOOL("place_at_mouse", cfg_false, CFGF_NONE), CFG_INT("border_height", 1, CFGF_NONE), CFG_STR("border_normal", "#354B5C", CFGF_NONE), CFG_STR("border_focus", "#6286A1", CFGF_NONE), @@ -395,6 +396,7 @@ init_conf(void) /* client */ conf.client.borderheight = (cfg_getint(cfg_client, "border_height")) ? cfg_getint(cfg_client, "border_height") : 1; + conf.client.place_at_mouse = cfg_getbool(cfg_client, "place_at_mouse"); conf.client.bordernormal = getcolor(var_to_str(cfg_getstr(cfg_client, "border_normal"))); conf.client.borderfocus = getcolor(var_to_str(cfg_getstr(cfg_client, "border_focus"))); conf.client.resizecorner_normal = getcolor(var_to_str(cfg_getstr(cfg_client, "resize_corner_normal"))); diff --git a/src/structs.h b/src/structs.h index a2906a7..28c4a40 100644 --- a/src/structs.h +++ b/src/structs.h @@ -186,6 +186,7 @@ typedef struct } root; struct { + Bool place_at_mouse; int borderheight; uint bordernormal; uint borderfocus;