Merge branch 'master' of git@tux-atome.fr:wmfs
This commit is contained in:
3
local.h
3
local.h
@@ -125,7 +125,7 @@ void layoutswitch(char *cmd);
|
|||||||
void mapclient(Client *c);
|
void mapclient(Client *c);
|
||||||
void manage(Window w, XWindowAttributes *wa);
|
void manage(Window w, XWindowAttributes *wa);
|
||||||
void mouseaction(Client *c, int x, int y, int type);
|
void mouseaction(Client *c, int x, int y, int type);
|
||||||
void moveresize(Client *c, int x, int y, int w, int h);
|
void moveresize(Client *c, int x, int y, int w, int h, bool r);
|
||||||
void raiseclient(Client *c);
|
void raiseclient(Client *c);
|
||||||
void scan(void);
|
void scan(void);
|
||||||
void setborder(Window win, int color);
|
void setborder(Window win, int color);
|
||||||
@@ -169,4 +169,5 @@ Client *clients; /* Fisrt Client */
|
|||||||
Client *sel; /* selected client */
|
Client *sel; /* selected client */
|
||||||
int seltag;
|
int seltag;
|
||||||
char status[16];
|
char status[16];
|
||||||
|
float mwfact[MAXTAG];
|
||||||
#endif /* LOCAL_H */
|
#endif /* LOCAL_H */
|
||||||
|
|||||||
106
wmfs.c
106
wmfs.c
@@ -191,6 +191,7 @@ getevent(void) {
|
|||||||
break;
|
break;
|
||||||
case ConfigureRequest:
|
case ConfigureRequest:
|
||||||
/* configure size and window position */
|
/* configure size and window position */
|
||||||
|
|
||||||
wc.x = event.xconfigurerequest.x;
|
wc.x = event.xconfigurerequest.x;
|
||||||
wc.y = event.xconfigurerequest.y;
|
wc.y = event.xconfigurerequest.y;
|
||||||
wc.width = event.xconfigurerequest.width;
|
wc.width = event.xconfigurerequest.width;
|
||||||
@@ -198,9 +199,17 @@ getevent(void) {
|
|||||||
wc.border_width = event.xconfigurerequest.border_width;
|
wc.border_width = event.xconfigurerequest.border_width;
|
||||||
wc.sibling = event.xconfigurerequest.above;
|
wc.sibling = event.xconfigurerequest.above;
|
||||||
wc.stack_mode = event.xconfigurerequest.detail;
|
wc.stack_mode = event.xconfigurerequest.detail;
|
||||||
|
|
||||||
XConfigureWindow(dpy, event.xconfigurerequest.window,
|
XConfigureWindow(dpy, event.xconfigurerequest.window,
|
||||||
event.xconfigurerequest.value_mask, &wc);
|
event.xconfigurerequest.value_mask, &wc);
|
||||||
|
if((c = getclient(event.xconfigurerequest.window))) {
|
||||||
|
XResizeWindow(dpy, c->tbar, wc.width, conf.ttbarheight);
|
||||||
|
XMoveWindow(dpy, c->button, wc.x + wc.width - 10, BUTY(wc.y));
|
||||||
|
updatetitle(c);
|
||||||
|
c->y = wc.y;
|
||||||
|
c->x = wc.x;
|
||||||
|
c->w = wc.width;
|
||||||
|
c->h = wc.height;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UnmapNotify:
|
case UnmapNotify:
|
||||||
@@ -346,6 +355,8 @@ init(void) {
|
|||||||
mh = DisplayHeight (dpy, screen);
|
mh = DisplayHeight (dpy, screen);
|
||||||
seltag = 1;
|
seltag = 1;
|
||||||
init_conf();
|
init_conf();
|
||||||
|
for(i=0;i<MAXTAG;++i)
|
||||||
|
mwfact[i] = 0.5;
|
||||||
|
|
||||||
/* INIT FONT */
|
/* INIT FONT */
|
||||||
font = XLoadQueryFont(dpy, conf.font);
|
font = XLoadQueryFont(dpy, conf.font);
|
||||||
@@ -417,20 +428,20 @@ ishide(Client *c) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
keymovex(char *cmd) {
|
keymovex(char *cmd) {
|
||||||
if(sel && cmd && !ishide(sel) && !sel->max) {
|
if(sel && cmd && !ishide(sel) && !sel->max && sel->layout != Tile) {
|
||||||
int tmp;
|
int tmp;
|
||||||
tmp = sel->x + atoi(cmd);
|
tmp = sel->x + atoi(cmd);
|
||||||
moveresize(sel,tmp, sel->y, sel->w, sel->h);
|
moveresize(sel,tmp, sel->y, sel->w, sel->h, 1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
keymovey(char *cmd) {
|
keymovey(char *cmd) {
|
||||||
if(sel && cmd && !ishide(sel) && !sel->max) {
|
if(sel && cmd && !ishide(sel) && !sel->max && sel->layout != Tile) {
|
||||||
int tmp;
|
int tmp;
|
||||||
tmp = sel->y + atoi(cmd);
|
tmp = sel->y + atoi(cmd);
|
||||||
moveresize(sel, sel->x, tmp, sel->w, sel->h);
|
moveresize(sel, sel->x, tmp, sel->w, sel->h, 1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -456,7 +467,7 @@ keypress(XEvent *e) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
keyresize(char *cmd) {
|
keyresize(char *cmd) {
|
||||||
if(sel && !ishide(sel) && !sel->max) {
|
if(sel && !ishide(sel) && !sel->max && sel->layout != Tile) {
|
||||||
int temph=0, tempw=0, modh=0, modw=0,
|
int temph=0, tempw=0, modh=0, modw=0,
|
||||||
tmp=0;
|
tmp=0;
|
||||||
|
|
||||||
@@ -469,7 +480,7 @@ keyresize(char *cmd) {
|
|||||||
tempw = sel->w + modw;
|
tempw = sel->w + modw;
|
||||||
temph = (temph < 10) ? 10 : temph;
|
temph = (temph < 10) ? 10 : temph;
|
||||||
tempw = (tempw < 10) ? 10 : tempw;
|
tempw = (tempw < 10) ? 10 : tempw;
|
||||||
moveresize(sel, sel->x, sel->y, tempw, temph);
|
moveresize(sel, sel->x, sel->y, tempw, temph, 1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -561,7 +572,7 @@ manage(Window w, XWindowAttributes *wa) {
|
|||||||
grabbuttons(c, False);
|
grabbuttons(c, False);
|
||||||
setsizehints(c);
|
setsizehints(c);
|
||||||
attach(c);
|
attach(c);
|
||||||
moveresize(c, c->x, c->y, c->w, c->h);
|
moveresize(c, c->x, c->y, c->w, c->h, 0);
|
||||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||||
mapclient(c);
|
mapclient(c);
|
||||||
updatetitle(c);
|
updatetitle(c);
|
||||||
@@ -578,7 +589,7 @@ mouseaction(Client *c, int x, int y, int type) {
|
|||||||
int ocx, ocy;
|
int ocx, ocy;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
if(c->max)
|
if(c->max || c->layout == Tile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ocx = c->x;
|
ocx = c->x;
|
||||||
@@ -603,36 +614,36 @@ mouseaction(Client *c, int x, int y, int type) {
|
|||||||
if(type) /* Resize */
|
if(type) /* Resize */
|
||||||
moveresize(c, c->x, c->y,
|
moveresize(c, c->x, c->y,
|
||||||
((ev.xmotion.x - ocx <= 0) ? 1 : ev.xmotion.x - ocx),
|
((ev.xmotion.x - ocx <= 0) ? 1 : ev.xmotion.x - ocx),
|
||||||
((ev.xmotion.y - ocy <= 0) ? 1 : ev.xmotion.y - ocy));
|
((ev.xmotion.y - ocy <= 0) ? 1 : ev.xmotion.y - ocy),0);
|
||||||
else /* Move */
|
else /* Move */
|
||||||
moveresize(c,
|
moveresize(c,
|
||||||
(ocx + (ev.xmotion.x - x)),
|
(ocx + (ev.xmotion.x - x)),
|
||||||
(ocy + (ev.xmotion.y - y)),
|
(ocy + (ev.xmotion.y - y)),
|
||||||
c->w, c->h);
|
c->w, c->h,0);
|
||||||
|
|
||||||
if(conf.clientbarblock) {
|
if(conf.clientbarblock) {
|
||||||
if(c->y < barheight + conf.ttbarheight - 5) {
|
if(c->y < barheight + conf.ttbarheight - 5) {
|
||||||
moveresize(c, c->x, barheight+conf.ttbarheight, c->w, c->h);
|
moveresize(c, c->x, barheight+conf.ttbarheight, c->w, c->h, 0);
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
moveresize(Client *c, int x, int y, int w, int h) {
|
moveresize(Client *c, int x, int y, int w, int h, bool r) {
|
||||||
if(c) {
|
if(c) {
|
||||||
/* Resize hints {{{ */
|
/* Resize hints {{{ */
|
||||||
|
if(r) {
|
||||||
if(c->minw > 0 && w < c->minw) w = c->minw;
|
if(c->minw > 0 && w < c->minw) w = c->minw;
|
||||||
if(c->minh > 0 && h < c->minh) h = c->minh;
|
if(c->minh > 0 && h < c->minh) h = c->minh;
|
||||||
if(c->maxw > 0 && w > c->maxw) w = c->maxw;
|
if(c->maxw > 0 && w > c->maxw) w = c->maxw;
|
||||||
if(c->maxh > 0 && h > c->maxh) h = c->maxh;
|
if(c->maxh > 0 && h > c->maxh) h = c->maxh;
|
||||||
if(w <= 0 || h <= 0) return;
|
if(w <= 0 || h <= 0) return;
|
||||||
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
c->layout = Free;
|
c->layout = Free;
|
||||||
@@ -798,45 +809,37 @@ tile(char *cmd) {
|
|||||||
if(sel) {
|
if(sel) {
|
||||||
Client *c;
|
Client *c;
|
||||||
int i;
|
int i;
|
||||||
unsigned int x, y, w, h, bord;
|
unsigned int n, h, w, bord;
|
||||||
unsigned int barto;
|
unsigned int barto;
|
||||||
|
float mwf;
|
||||||
|
|
||||||
barto = conf.ttbarheight + barheight;
|
barto = conf.ttbarheight + barheight;
|
||||||
bord = conf.borderheight * 2;
|
bord = conf.borderheight * 2;
|
||||||
|
|
||||||
x = mw / 2 + conf.borderheight;
|
mwf = mw*mwfact[seltag];
|
||||||
y = barto;
|
|
||||||
w = ((mw - bord ) / 2 - bord);
|
|
||||||
if(clientpertag(seltag)-1)
|
|
||||||
h = ((mh-bord) - conf.ttbarheight - barheight) / (clientpertag(seltag) - 1) ;
|
|
||||||
|
|
||||||
sel->ox = sel->x;
|
n = clientpertag(seltag);
|
||||||
sel->oy = sel->y;
|
w = mw - mwf - bord;
|
||||||
sel->ow = sel->w;
|
if(n > 1)
|
||||||
sel->oh = sel->h;
|
h = (mh- barheight) / (n - 1);
|
||||||
|
else
|
||||||
|
h = mh - barheight;
|
||||||
|
|
||||||
/* Master client in first (always the sel window) */
|
|
||||||
moveresize(sel, 0, barto,
|
|
||||||
((clientpertag(seltag) > 1) ? (mw-bord) / 2 : (mw-bord)),
|
|
||||||
((mh-bord) - conf.ttbarheight - barheight));
|
|
||||||
sel->layout = Tile;
|
|
||||||
|
|
||||||
/* tiling */
|
|
||||||
for(i=0, c = clients; c; c = c->next, ++i) {
|
for(i=0, c = clients; c; c = c->next, ++i) {
|
||||||
if(c != sel && !ishide(c)) {
|
if(!ishide(c)) {
|
||||||
c->ox = c->x;
|
if(n == 1)
|
||||||
c->oy = c->y;
|
moveresize(c, 0, barto, mw-bord, mh-(bord+barto), 0);
|
||||||
c->ow = c->w;
|
else if(i == 0)
|
||||||
c->oh = c->h;
|
moveresize(c, 0, barto, mwf-bord, mh-(bord+barto), 0);
|
||||||
moveresize(c, x, y, w, h);
|
else
|
||||||
if(i < i + 1)
|
moveresize(c, mwf, (i-1)* h + barto, w, h - (conf.ttbarheight + bord), 0);
|
||||||
y = c->y + c->h + bord + conf.ttbarheight;
|
c->layout = Tile;
|
||||||
c->layout = Tile;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
togglemax(char *cmd) {
|
togglemax(char *cmd) {
|
||||||
if(sel && !ishide(sel)) {
|
if(sel && !ishide(sel)) {
|
||||||
@@ -848,15 +851,16 @@ togglemax(char *cmd) {
|
|||||||
moveresize(sel, 0,
|
moveresize(sel, 0,
|
||||||
conf.ttbarheight + barheight,
|
conf.ttbarheight + barheight,
|
||||||
(mw-(conf.borderheight * 2)),
|
(mw-(conf.borderheight * 2)),
|
||||||
(mh-(conf.borderheight * 2)- conf.ttbarheight - barheight));
|
(mh-(conf.borderheight * 2)- conf.ttbarheight - barheight),1);
|
||||||
sel->max = True;
|
sel->max = True;
|
||||||
sel->layout = Max;
|
sel->layout = Max;
|
||||||
} else if(sel->max) {
|
} else if(sel->max) {
|
||||||
raiseclient(sel);
|
moveresize(sel, sel->ox, sel->oy, sel->ow, sel->oh,0);
|
||||||
moveresize(sel, sel->ox, sel->oy, sel->ow, sel->oh);
|
|
||||||
sel->max = False;
|
sel->max = False;
|
||||||
sel->layout = Free;
|
sel->layout = Free;
|
||||||
|
raiseclient(c);
|
||||||
}
|
}
|
||||||
|
raiseclient(c);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -872,7 +876,7 @@ unhide(Client *c) {
|
|||||||
(c->y - 9));
|
(c->y - 9));
|
||||||
if(conf.clientbarblock)
|
if(conf.clientbarblock)
|
||||||
if(c->y+conf.ttbarheight <= barheight)
|
if(c->y+conf.ttbarheight <= barheight)
|
||||||
moveresize(c, c->x, barheight + conf.ttbarheight, c->w, c->h);
|
moveresize(c, c->x, barheight + conf.ttbarheight, c->w, c->h,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user