Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Added centred-floating
Browse files Browse the repository at this point in the history
  • Loading branch information
ok100 committed May 26, 2013
1 parent aa8e2f7 commit efc4132
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions dwm.c
Expand Up @@ -93,7 +93,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, needresize, iscentred;
Client *next;
Client *snext;
Monitor *mon;
Expand Down Expand Up @@ -153,6 +153,7 @@ typedef struct {
const char *title;
unsigned int tags;
Bool isfloating;
Bool iscentred;
int monitor;
} Rule;

Expand Down Expand Up @@ -305,6 +306,7 @@ applyrules(Client *c) {

/* rule matching */
c->isfloating = c->tags = 0;
c->iscentred = 1;
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken;
Expand All @@ -316,6 +318,7 @@ applyrules(Client *c) {
&& (!r->instance || strstr(instance, r->instance)))
{
c->isfloating = r->isfloating;
c->iscentred = r->iscentred;
c->tags |= r->tags;
for(m = mons; m && m->num != r->monitor; m = m->next);
if(m)
Expand Down Expand Up @@ -1153,8 +1156,14 @@ manage(Window w, XWindowAttributes *wa) {
applyrules(c);
}
/* geometry */
c->x = c->oldx = wa->x;
c->y = c->oldy = wa->y;
if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && c->iscentred) {
c->x = c->oldx = c->mon->wx + (c->mon->ww / 2 - wa->width / 2);
c->y = c->oldy = c->mon->wy + (c->mon->wh / 2 - 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;
Expand Down

0 comments on commit efc4132

Please sign in to comment.