You are not logged in.
Hello there.
I'm trying to handpatch the statuscolors-patch into my already xft-patched dwm source. However, my knowledge of C is quite small, so I have a question about removing and adding lines:
My status-color diff says the following:
typedef struct {
int x, y, w, h;
- unsigned long norm[ColLast];
- unsigned long sel[ColLast];
+ unsigned long colors[MAXCOLORS][ColLast];
Drawable drawable;
GC gc;
In my xft-patched dwm.c-file the passage looks like this:
typedef struct {
int x, y, w, h;
XftColor norm[ColLast];
XftColor sel[ColLast];
Drawable drawable;
GC gc;
So the "unsigned" bit is changed to "XftColor". Should I still remove the line, or is it needed for xft? Will it still work if I only add the line that needs to be added according to the diff/patch?
Last edited by graph (2013-05-22 18:51:46)
Offline
My patch looks like:
- XftColor norm[ColLast];
- XftColor sel[ColLast];
+ XftColor colors[MAXCOLORS][ColLast];
Drawable drawable;
Offline
I took a look at your patch, and now it's working - Thank you for that.
However, I get this error while compiling:
dwm build options:
CFLAGS = -std=c99 -pedantic -Wall -Os -I. -I/usr/include -I/usr/X11R6/include -DVERSION="6.0" -DXINERAMA -DXFT
LDFLAGS = -s -L/usr/lib -lc -L/usr/X11R6/lib -lX11 -L/usr/X11R6/lib -lXinerama -L/usr/X11R6/lib -lXft
CC = cc
CC dwm.c
In file included from /usr/include/X11/Xft/Xft.h:39:0,
from dwm.c:42:
/usr/include/ft2build.h:56:38: fatal error: freetype/config/ftheader.h: No such file or directory
#include <freetype/config/ftheader.h>
^
compilation terminated.
make: *** [dwm.o] Error 1
freetype2 is installed on my system:
extra/freetype2 2.4.12-1 [installed]
TrueType font rendering library
extra/libxft 2.3.1-1 [installed]
How do I get rid of that error? I'm guessing it's a missing dependency, but I'm not fluent in C yet, so I don't know which.
Last edited by graph (2013-05-22 08:59:23)
Offline
Are you using a PKGBUILD or just compiling youself?
Try adding the freetype libs:
INCS = -I${X11INC} -I/usr/include/freetype2
Offline
I'm compiling and applying the patches myself, without PKGBUILDs, and I'm using the xft-patch from suckless.org.
However, I just noticed that the suckless has the following:
#endif /* XINERAMA */
+#include <X11/Xft/Xft.h>
/* macros */
while Unias patch has:
#include <X11/Xutil.h>
+#include <fontconfig/fontconfig.h>
+#include <X11/Xft/Xft.h>
#ifdef XINERAMA
Could that be the reason? That dwms xft patch doesn't include fontconfig/fontconfig.h?
EDIT: I tried including fontconfig.h - Still got the same error.
My patch for config.mk looks like this:
--- a/config.mk 2011-12-19 16:02:46.000000000 +0100
+++ b/config.mk 2013-05-22 09:52:47.237000408 +0200
@@ -14,12 +14,17 @@
XINERAMALIBS = -L${X11LIB} -lXinerama
XINERAMAFLAGS = -DXINERAMA
+# Xft
+XFTINC = -I/usr/include/freetype2
+XFTLIBS = -L${X11LIB} -lXft
+XFTFLAGS = -DXFT
+
# includes and libs
INCS = -I. -I/usr/include -I${X11INC}
-LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
+LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} ${XFTLIBS}
# flags
-CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${XFTFLAGS}
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
#LDFLAGS = -g ${LIBS}
It seems that I'm already including /usr/include/freetype2, which annoys me a bit.
Last edited by graph (2013-05-22 10:26:24)
Offline
I sort-of fixed it by creating a symlink.
sudo ln -s /usr/include/freetype2/freetype /usr/include/freetype
Found the tip here.
Now my code is compiling, at least. However, I don't seem to be able to set the font, so this seems like a dead end.
My config.h:
static const char font[] = "Dejavu Sans Mono:size=10";
Last edited by graph (2013-05-22 11:23:36)
Offline
I sort-of fixed it by creating a symlink.
sudo ln -s /usr/include/freetype2/freetype /usr/include/freetype
Found the tip here.
Now my code is compiling, at least. However, I don't seem to be able to set the font, so this seems like a dead end.
My config.h:
static const char font[] = "Dejavu Sans Mono:size=10";
That should be "DejaVu Sans Mono".
Also, no. Don't do that symlink...that's a horrible idea. Just add "-I /usr/include/freetype2" to the INCS variable in config.mk. Also be sure to add "-lXft and -lfontconfig" to LIBS.
Last edited by jakobcreutzfeldt (2013-05-22 11:35:29)
Offline
@jakobcreutzfeldt
I've deleted the symlink, changed the font and corrected my config.mk-patch so it actually included my changes. Thank you for noticing that! It turned out it was just stupidity on my side, so thank you for helping, both of you.
This got rid of the annoying missing library and I can now install the xft-patch without any problems. However, If I try to apply my tailored statuscolor-patch, I'm left with the following error:
cleaning
dwm build options:
CFLAGS = -std=c99 -pedantic -Wall -Os -I. -I/usr/include -I/usr/X11R6/include -I/usr/include/freetype2 -DVERSION="6.0" -DXINERAMA
LDFLAGS = -s -L/usr/lib -lc -L/usr/X11R6/lib -lX11 -L/usr/X11R6/lib -lXinerama -L/usr/X11R6/lib -lXft -lfontconfig
CC = cc
CC dwm.c
dwm.c: In function 'drawtext':
dwm.c:816:33: error: 'invert' undeclared (first use in this function)
XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG].pixel);
^
dwm.c:816:33: note: each undeclared identifier is reported only once for each function it appears in
dwm.c: In function 'keypress':
dwm.c:1088:2: warning: 'XKeycodeToKeysym' is deprecated (declared at /usr/include/X11/Xlib.h:1695) [-Wdeprecated-declarations]
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
^
make: *** [dwm.o] Error 1
However, I expect that I've just done something wrong in the statuscolor-patch, which I'll try to fix tomorrow (Enough computer problems for today).
Last edited by graph (2013-05-22 12:16:59)
Offline
What does your drawtext function look like?
EDIT: Mine looks like this:
void
drawtext(const char *text, XftColor col[ColLast], Bool pad) {
char buf[256];
int i, x, y, h, len, olen;
XftDraw *d;
XSetForeground(dpy, dc.gc, col[ColBG].pixel);
XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
if(!text)
return;
olen = strlen(text);
h = pad ? (dc.font.ascent + dc.font.descent) : 0;
y = dc.y + ((dc.h + dc.font.ascent - dc.font.descent) / 2);
x = dc.x + (h / 2);
/* shorten text if necessary */
for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
if(!len)
return;
memcpy(buf, text, len);
if(len < olen)
for(i = len; i && i > len - 3; buf[--i] = '.');
d = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen));
XftDrawStringUtf8(d, (XftColor *)&col[ColFG].pixel, dc.font.xfont, x, y, (XftChar8 *)buf, len);
XftDrawDestroy(d);
}
I don't know if it's modified from other patches, though.
Last edited by Unia (2013-05-22 15:43:45)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
With pertag, xft and statuscolors, applied in that order, the only difference between mine and your is this line:
d = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy,screen));
I don't have a space in DefaultColormap, and you do. This seems to be because of my xft-patch (now corrected).
Last edited by graph (2013-05-22 16:34:48)
Offline
However, I've moved on, so that I'm now getting the following error instead:
dwm.c: In function 'drawbar':
dwm.c:761:19: error: request for member 'name' in something not a structure or union
drawtext(tags[i].name, col, True);
^
dwm.c: In function 'keypress':
dwm.c:1117:2: warning: 'XKeycodeToKeysym' is deprecated (declared at /usr/include/X11/Xlib.h:1695) [-Wdeprecated-declarations]
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
^
dwm.c: In function 'toggleview':
dwm.c:1817:9: error: 'i' undeclared (first use in this function)
for (i=0; !(newtagset & 1 << i); i++) ;
^
dwm.c:1817:9: note: each undeclared identifier is reported only once for each function it appears in
make: *** [dwm.o] Error 1
From the top:
The ".name" comes from my statuscolors-patch, which is based on Unias.
The XKeycodeToKeysym-error has always been there when I compile, but haven't been a problem.
I have no idea how to get rid of the "i undeclared (first use in this function)"-error.
Last edited by graph (2013-05-22 16:41:10)
Offline
Remove the .name, thats a leftover from pertag2 which you don't use.
Did you change anything in toggleview?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Thank you so much for taking the time to answer Unia - ".name" is now gone.
I'm quite sure that xft or pertag doesn't change anything in toggleview.
EDIT: I did a diff between the original dwm source and my patched source (w pertag + xft). The two toggleview functions are identical. Could "i" be set another place in dwm.c?
EDIT2: Made a mistake and forgot an "int i", which caused this problem. See this post
Last edited by graph (2013-05-22 18:51:16)
Offline
That's strange. Can I see your toggleview?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Another dwm helper here
Remove the "toggleview" func and add another from no patched dwm ad see what happens.
also try to add
toggleview(const Arg *arg) {
int i;
toggleview form pertag
void
toggleview(const Arg *arg) {
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
+ int i;
if(newtagset) {
+ if(newtagset == ~0) {
+ selmon->pertag->prevtag = selmon->pertag->curtag;
+ selmon->pertag->curtag = 0;
+ }
+ /* test if the user did not select the same tag */
+ if(!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
+ selmon->pertag->prevtag = selmon->pertag->curtag;
+ for (i=0; !(newtagset & 1 << i); i++) ;
+ selmon->pertag->curtag = i + 1;
+ }
selmon->tagset[selmon->seltags] = newtagset;
+
+ /* apply settings for this view */
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
+ togglebar(NULL);
focus(NULL);
arrange(selmon);
}
@@ -2043,11 +2096,33 @@
pertag
check this >> https://github.com/Barthalion/dwm-patch … ertag.diff
pertag2
https://github.com/Unia/DWM/blob/master … rtag2.diff
Last edited by ivoarch (2013-05-22 17:42:12)
Offline
He does not want to use pertag2. Also, I think simply declaring i is not a clean solution, since the cause of the problem is somewhere else.
The original toggleview function looks like this:
void
toggleview(const Arg *arg) {
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
if(newtagset) {
selmon->tagset[selmon->seltags] = newtagset;
focus(NULL);
arrange(selmon);
}
}
You must have modified it somewhere.
EDIT: Wait, scratch that. Your title says just XFT and statuscolors, but later on you add pertag.
Do you use pertag (or pertag2)?
EDIT2: Ah, you must be using pertag as pertag2 doesn't touch toggleview. In that case, you must've applied it wrongly. Look at ivo's suggestion, that should fix it.
Last edited by Unia (2013-05-22 18:02:06)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Yep, I added pertag to my patch-list, but decided not to update the title (To make the thread easier to find).
EDIT2: Ah, you must be using pertag as pertag2 doesn't touch toggleview. In that case, you must've applied it wrongly. Look at ivo's suggestion, that should fix it.
Turns out I messed up a line, and it was indeed "int i;" as suggested by ivoarch - Everything is working now, and it was entirely a human error.
Please excuse me, patching by hans is unknown land for me.
PS: What do I gain from using pertag2 (You appear to be the author, Unia)?
Offline
PS: What do I gain from using pertag2 (You appear to be the author, Unia)?
Nooo, I'm not To be honest, I don't know who is.
I think pertag2's advantage over pertag is that you can initialize tag layouts on startup, instead of having all the tags starting in the same layout.
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Here is the announcement of pertag2: https://bbs.archlinux.org/viewtopic.php … 92#p734292
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
the original autor is https://github.com/vodik
the pertag2 is modified by @jokerboy
Offline
PS: What do I gain from using pertag2 (You appear to be the author, Unia)?
Not a lot: you just learn to use dwm as a static window manager
Offline
Arh. In that case I'll just stick with pertag. Thank you for your help, all of you - I really love the community surrounding Arch.
Offline
graph wrote:PS: What do I gain from using pertag2 (You appear to be the author, Unia)?
Not a lot: you just learn to use dwm as a static window manager
And it just so happens to be that I am more comfortable with this approach
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline