James Turner <[EMAIL PROTECTED]> writes:
> On Sat, Jun 16, 2007 at 04:06:44AM +0200, Engin Tola wrote:
>>
>> Can you tell at which places it fail ?
>> I just recently *manually* patched it. Maybe I can assist.
>>
>> > Does anybody know if there is an updated patch for bottomstack? It
>> > fails it two places while patching. Thanks.
>> >
> Sure, below is the output of running patch -p1 inside my dwm-4.2 dir.
>
> Hmm... Looks like a unified diff to me...
> The text leading up to this was:
> --------------------------
> |--- /usr/local/src/dwm/dwm-4.1-virgin/layout.c 2007-05-21
> 20:59:45.000000000 -0400
> |+++ layout.c 2007-05-22 16:06:19.000000000 -0400
> --------------------------
> Patching file layout.c using Plan A...
> Hunk #1 failed at 14.
> Hunk #2 failed at 38.
> Hunk #3 succeeded at 81 (offset 12 lines).
> Hunk #4 succeeded at 194 (offset -4 lines).
> Hunk #5 succeeded at 232 (offset 12 lines).
> Hunk #6 failed at 341.
> 3 out of 6 hunks failed--saving rejects to layout.c.rej
> Hmm... The next patch looks like a unified diff to me...
> The text leading up to this was:
> --------------------------
> |--- /usr/local/src/dwm/dwm-4.1-virgin/config.default.h 2007-05-21
> 20:59:45.000000000 -0400
> |+++ config.default.h 2007-05-21 21:33:42.000000000 -0400
> --------------------------
> Patching file config.default.h using Plan A...
> Hunk #1 succeeded at 29 (offset -2 lines).
> done
this is pretty much illegible with only line numbers. I suggest you to
open the diff file and layout.c. It is pretty much easy to follow the
diff file and make the necessary changes. I also attach my own layout.c
so that you can adapt yours appropriately. (if you haven't edited your
layout file before, then you should have this layout in the end actually.)
/* See LICENSE file for copyright and license details. */
#include "dwm.h"
#include <stdlib.h>
unsigned int blw = 0;
Layout *lt = NULL;
/* static */
static unsigned int nlayouts = 0;
static unsigned int masterw = MASTERWIDTH;
static unsigned int nmaster = NMASTER;
static void
ban(Client *c) {
if (c->isbanned)
return;
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
c->isbanned = True;
}
static void
unban(Client *c) {
if (!c->isbanned)
return;
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
}
static void
_tile(const Bool right) {
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
Client *c;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++;
/* window geoms */
mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
th = (n > nmaster) ? wah / (n - nmaster) : 0;
tw = waw - mw;
for(i = 0, c = clients; c; c = c->next)
if(isvisible(c)) {
unban(c);
if(c->isfloating)
continue;
c->ismax = False;
nx = wax;
ny = way;
if(i < nmaster) {
if( !right )
nx+= tw;
ny += i * mh;
nw = mw - 2 * c->border;
nh = mh;
if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */
nh = wah - mh * i;
nh -= 2 * c->border;
}
else { /* tile window */
nx += mw;
nw = tw - 2 * c->border;
if(th > 2 * c->border) {
ny += (i - nmaster) * th;
nh = th;
if(i + 1 == n) /* remainder */
nh = wah - th * (i - nmaster);
nh -= 2 * c->border;
}
else /* fallback if th <= 2 * c->border */
nh = wah - 2 * c->border;
}
resize(c, nx, ny, nw, nh, False);
i++;
}
else
ban(c);
focus(NULL);
restack();
}
static void
_bstack(const Bool portrait) {
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
Client *c;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++;
/* window geoms */
mh = (n > nmaster) ? ((wah * masterw) / 1000) / nmaster : wah / (n > 0 ? n : 1);
mw = waw;
th = (n > nmaster) ? ((wah * (1000 - masterw)) / 1000) / (portrait ? 1 : n - nmaster) : 0;
tw = (n > nmaster) ? waw / (portrait ? n - nmaster : 1) : 0;
for(i = 0, c = clients; c; c = c->next)
if(isvisible(c)) {
if(c->isbanned)
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
if(c->isfloating)
continue;
c->ismax = False;
nx = wax;
ny = way;
if(i < nmaster) {
ny += i * mh;
nw = mw - 2 * c->border;
nh = mh - 2 * c->border;
}
else if(portrait) { /* portrait bstack tiles */
nx += (i - nmaster) * tw;
ny += wah - th;
nw = tw - 2 * c->border;
nh = th - 2 * c->border;
} else { /* landscape bstack tiles */
ny += mh * nmaster;
nw = tw - 2 * c->border;
if(th > 2 * c->border) {
ny += (i - nmaster) * th;
nh = th - 2 * c->border;
if (i == n - 1)
nh += (n > nmaster) ? wah - mh - th * (n - nmaster) : 0;
}
else /* fallback if th <= 2 * c->border */
nh = wah - 2 * c->border;
}
resize(c, nx, ny, nw, nh, False);
i++;
}
else {
c->isbanned = True;
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
}
if(!sel || !isvisible(sel))
focus(c);
restack();
}
static void
tile(void) {
_tile(True);
}
static void
tileleft(void) {
_tile(False);
}
static void
bstackportrait(void) {
_bstack(True);
}
static void
bstacklandscape(void) {
_bstack(False);
}
LAYOUTS
/* extern */
void
floating(void) {
Client *c;
for(c = clients; c; c = c->next)
if(isvisible(c)) {
if(c->isbanned)
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
resize(c, c->x, c->y, c->w, c->h, True);
}
else
ban(c);
focus(NULL);
restack();
}
void
focusclient(const char *arg) {
Client *c;
if(!sel || !arg)
return;
if(atoi(arg) < 0) {
for(c = sel->prev; c && !isvisible(c); c = c->prev);
if(!c) {
for(c = clients; c && c->next; c = c->next);
for(; c && !isvisible(c); c = c->prev);
}
}
else {
for(c = sel->next; c && !isvisible(c); c = c->next);
if(!c)
for(c = clients; c && !isvisible(c); c = c->next);
}
if(c) {
focus(c);
restack();
}
}
void
incmasterw(const char *arg) {
int i;
if(lt->arrange == floating)
return;
if(!arg)
masterw = MASTERWIDTH;
else {
i = atoi(arg);
if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
|| waw * (masterw + i) / 1000 <= 2 * BORDERPX)
return;
masterw += i;
}
lt->arrange();
}
void
incnmaster(const char *arg) {
int i;
if(!arg)
nmaster = NMASTER;
else {
i = atoi(arg);
if((lt->arrange == floating) || (nmaster + i < 1)
|| (wah / (nmaster + i) <= 2 * BORDERPX))
return;
nmaster += i;
}
if(sel)
lt->arrange();
else
drawstatus();
}
void
initlayouts(void) {
unsigned int i, w;
lt = &layout[0];
nlayouts = sizeof layout / sizeof layout[0];
for(blw = i = 0; i < nlayouts; i++) {
w = textw(layout[i].symbol);
if(w > blw)
blw = w;
}
}
Client *
nexttiled(Client *c) {
for(; c && (c->isfloating || !isvisible(c)); c = c->next);
return c;
}
void
restack(void) {
Client *c;
XEvent ev;
drawstatus();
if(!sel)
return;
if(sel->isfloating || lt->arrange == floating)
XRaiseWindow(dpy, sel->win);
if(lt->arrange != floating) {
if(!sel->isfloating)
XLowerWindow(dpy, sel->win);
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
if(c == sel)
continue;
XLowerWindow(dpy, c->win);
}
}
XSync(dpy, False);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void
setlayout(const char *arg) {
int i;
if(!arg) {
lt++;
if(lt == layout + nlayouts)
lt = layout;
}
else {
i = atoi(arg);
if(i < 0 || i >= nlayouts)
return;
lt = &layout[i];
}
if(sel)
lt->arrange();
else
drawstatus();
}
void
togglebar(const char *arg) {
if(bpos == BarOff)
bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
else
bpos = BarOff;
updatebarpos();
lt->arrange();
}
void
togglemax(const char *arg) {
XEvent ev;
if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
return;
if((sel->ismax = !sel->ismax)) {
sel->rx = sel->x;
sel->ry = sel->y;
sel->rw = sel->w;
sel->rh = sel->h;
resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
}
else
resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
drawstatus();
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void
zoom(const char *arg) {
Client *c;
if(!sel || lt->arrange == floating || sel->isfloating)
return;
if((c = sel) == nexttiled(clients))
if(!(c = nexttiled(c->next)))
return;
detach(c);
attach(c);
focus(c);
lt->arrange();
}