X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=1522a17c841c6de8f9d55356e3c8ab908acec06e;hp=dc9f31800a171d738ae9be2844622a024f66ec04;hb=26d0a0b2ffd4e9a2b95fa86162aba92d37138cdd;hpb=9e9918ad967382660aea6bd7e9634f5995de04e0 diff --git a/dwm.c b/dwm.c index dc9f318..1522a17 100644 --- a/dwm.c +++ b/dwm.c @@ -211,6 +211,7 @@ static void setmfact(const Arg *arg); static void setup(void); static void showhide(Client *c); static void sigchld(int unused); +static void kbspawn(const Arg *arg); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); @@ -363,6 +364,9 @@ applyrules(Client *c) { && (!r->instance || strstr(instance, r->instance))) { c->isfloating = r->isfloating; + if(r->isfloating) { + c->x = -1; c->y = -2; // secret code for centered + } c->tags |= r->tags; c->screen_hog = r->screen_hog; for(m = mons; m && m->num != r->monitor; m = m->next); @@ -501,20 +505,7 @@ buttonpress(XEvent *e) { focus(NULL); } if(ev->window == selmon->barwin) { - i = x = 0; - do - x += TEXTW(tags[i]); - while(ev->x >= x && ++i < LENGTH(tags)); - if(i < LENGTH(tags)) { - click = ClkTagBar; - arg.ui = 1 << i; - } - else if(ev->x < x + blw) - click = ClkLtSymbol; - else if(ev->x > selmon->ww - TEXTW(stext)) - click = ClkStatusText; - else - click = ClkWinTitle; + return; } else if((c = wintoclient(ev->window))) { focus(c); @@ -1200,8 +1191,13 @@ manage(Window w, XWindowAttributes *wa) { applyrules(c); } /* geometry */ - c->x = c->oldx = wa->x; - c->y = c->oldy = wa->y; + if(c->x == -1 && c->y == -2) { // secret code for centered + c->x = c->oldx = (c->mon->ww - wa->width) / 2; + c->y = c->oldy = (c->mon->wh - wa->height) / 2; + } else { + c->x = c->oldx = wa->x; + c->y = c->oldy = wa->y; + } c->w = c->oldw = wa->width; c->h = c->oldh = wa->height; c->oldbw = wa->border_width; @@ -1269,8 +1265,11 @@ maprequest(XEvent *e) { if(!XGetWindowAttributes(dpy, ev->window, &wa)) return; - if(wa.override_redirect) + if(wa.override_redirect) { + key_buffer_len = 0; + key_buffering = False; return; + } if(!wintoclient(ev->window)) manage(ev->window, &wa); } @@ -1795,6 +1794,14 @@ sigchld(int unused) { } void +kbspawn(const Arg *arg) { + key_buffering = True; + key_buffer_len = 0; + grab_typing_keys(); + spawn(arg); +} + +void spawn(const Arg *arg) { int tag = 0, i; if(arg->v == termcmd) { @@ -1809,9 +1816,6 @@ spawn(const Arg *arg) { } if(arg->v == dmenucmd) dmenumon[0] = '0' + selmon->num; - key_buffering = True; - key_buffer_len = 0; - grab_typing_keys(); if(fork() == 0) { if(dpy) close(ConnectionNumber(dpy));