Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fullgaps + alpha + winicon on dwm 6.4 #8

Open
Jemi opened this issue Jun 25, 2023 · 6 comments
Open

fullgaps + alpha + winicon on dwm 6.4 #8

Jemi opened this issue Jun 25, 2023 · 6 comments

Comments

@Jemi
Copy link

Jemi commented Jun 25, 2023

Hi.
I'm trying to patch dwm 6.4 with fullgaps, alpha and winicon. It patches with just fullgaps + winicon, but fails with alpha + winicon and fullgaps + alpha + winicon. Here is the patch output:

$ patch <dwm-winicon-6.3-v2.1.diff
patching file config.def.h
Hunk #1 succeeded at 5 with fuzz 1.
patching file config.mk
Hunk #1 FAILED at 22.
1 out of 1 hunk FAILED -- saving rejects to file config.mk.rej
patching file drw.c
Hunk #2 FAILED at 72.
Hunk #3 FAILED at 86.
Hunk #4 succeeded at 226 (offset -11 lines).
Hunk #5 succeeded at 447 (offset 6 lines).
2 out of 5 hunks FAILED -- saving rejects to file drw.c.rej
patching file drw.h
Hunk #1 succeeded at 24 with fuzz 2 (offset 3 lines).
Hunk #2 succeeded at 54 (offset 4 lines).
patching file dwm.c
Hunk #2 succeeded at 66 (offset 4 lines).
Hunk #3 succeeded at 99 (offset 4 lines).
Hunk #4 succeeded at 177 (offset 4 lines).
Hunk #5 succeeded at 222 (offset 4 lines).
Hunk #6 succeeded at 234 (offset 4 lines).
Hunk #7 succeeded at 754 (offset 13 lines).
Hunk #8 succeeded at 895 (offset 13 lines).
Hunk #9 succeeded at 1113 (offset 11 lines).
Hunk #10 succeeded at 1320 (offset 7 lines).
Hunk #11 succeeded at 1642 (offset 8 lines).
Hunk #12 succeeded at 1831 (offset 4 lines).
Hunk #13 succeeded at 1861 (offset 4 lines).
Hunk #14 succeeded at 2100 (offset 8 lines).

@Jemi
Copy link
Author

Jemi commented Jun 25, 2023

$ cat config.mk.rej
--- config.mk
+++ config.mk
@@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2

includes and libs

INCS = -I${X11INC} -I${FREETYPEINC}
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lImlib2

flags

CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION="${VERSION}" ${XINERAMAFLAGS}

@Jemi
Copy link
Author

Jemi commented Jun 25, 2023

$ cat drw.c.rej
--- drw.c
+++ drw.c
@@ -72,6 +73,7 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
drw->w = w;
drw->h = h;
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));

  • drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, DefaultVisual(dpy, screen)), 0, NULL);
    drw->gc = XCreateGC(dpy, root, 0, NULL);
    XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);

@@ -86,14 +88,18 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)

drw->w = w;
drw->h = h;
  • if (drw->picture)
  •   XRenderFreePicture(drw->dpy, drw->picture);
    
    if (drw->drawable)
    XFreePixmap(drw->dpy, drw->drawable);
    drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
  • drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, DefaultVisual(drw->dpy, drw->screen)), 0, NULL);
    }

void
drw_free(Drw *drw)
{

  • XRenderFreePicture(drw->dpy, drw->picture);
    XFreePixmap(drw->dpy, drw->drawable);
    XFreeGC(drw->dpy, drw->gc);
    drw_fontset_free(drw->fonts);

@Jemi
Copy link
Author

Jemi commented Jun 25, 2023

Any help much appreciated.

@bakkeby
Copy link

bakkeby commented Jun 25, 2023

Hi @Jemi,

Just a tip I personally find it more convenient to use a three-way merger using git in these situations, that is achieved using the -3 command line option, e.g.

$ git apply -3 dwm-winicon-6.3-v2.1.diff
dwm-winicon-6.3-v2.1.diff:256: trailing whitespace.
	if (XGetWindowProperty(dpy, win, netatom[NetWMIcon], 0L, LONG_MAX, False, AnyPropertyType,
dwm-winicon-6.3-v2.1.diff:258: trailing whitespace.
		return None;
Applied patch to 'config.def.h' cleanly.
Applied patch to 'config.mk' with conflicts.
Applied patch to 'drw.c' with conflicts.
Applied patch to 'drw.h' cleanly.
Applied patch to 'dwm.c' cleanly.
U config.mk
U drw.c
warning: 2 lines add whitespace errors.
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   config.def.h
	modified:   drw.h
	modified:   dwm.c

Unmerged paths:
  (use "git restore --staged <file>..." to unstage)
  (use "git add <file>..." to mark resolution)
	both modified:   config.mk
	both modified:   drw.c

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	dwm-alpha-20230401-348f655.diff
	dwm-winicon-6.3-v2.1.diff

The conflicts:

diff --cc config.mk
index d609c42,f3c01b0..0000000
--- a/config.mk
+++ b/config.mk
@@@ -23,10 -22,10 +23,14 @@@ FREETYPEINC = /usr/include/freetype

  # includes and libs
  INCS = -I${X11INC} -I${FREETYPEINC}
++<<<<<<< ours
 +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender
++=======
+ LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lImlib2
++>>>>>>> theirs

  # flags
 -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
 +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
  #CFLAGS   = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
  CFLAGS   = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
  LDFLAGS  = ${LIBS}

(keep the latter)

diff --cc drw.c
index d18e8d8,9b474c5..0000000
--- a/drw.c
+++ b/drw.c
@@@ -70,11 -71,9 +71,17 @@@ drw_create(Display *dpy, int screen, Wi
        drw->root = root;
        drw->w = w;
        drw->h = h;
++<<<<<<< ours
 +      drw->visual = visual;
 +      drw->depth = depth;
 +      drw->cmap = cmap;
 +      drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
 +      drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
++=======
+       drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
+       drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, DefaultVisual(dpy, screen)), 0, NULL);
+       drw->gc = XCreateGC(dpy, root, 0, NULL);
++>>>>>>> theirs
        XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);

        return drw;
@@@ -88,9 -87,12 +95,16 @@@ drw_resize(Drw *drw, unsigned int w, un

        drw->w = w;
        drw->h = h;
+       if (drw->picture)
+               XRenderFreePicture(drw->dpy, drw->picture);
        if (drw->drawable)
                XFreePixmap(drw->dpy, drw->drawable);
++<<<<<<< ours
 +      drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
++=======
+       drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
+       drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, DefaultVisual(drw->dpy, drw->screen)), 0, NULL);
++>>>>>>> theirs
  }

  void

If you look at the writeup in https://dwm.suckless.org/patches/winicon/ then we have that there are a few minor changes needed in drw_create and drw_resize, which aligns with the diff above.

It helps reading the actual diff as well as that will tell you that actually all what the patch changed was adding a single line of code in the conflicting areas:

@@ -71,6 +72,7 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
    drw->w = w;
    drw->h = h;
    drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
+   drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, DefaultVisual(dpy, screen)), 0, NULL);
    drw->gc = XCreateGC(dpy, root, 0, NULL);
    XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
 
@@ -85,14 +87,18 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
  
    drw->w = w;
    drw->h = h;
+   if (drw->picture)
+       XRenderFreePicture(drw->dpy, drw->picture);
    if (drw->drawable)
        XFreePixmap(drw->dpy, drw->drawable);
    drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
+   drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, DefaultVisual(drw->dpy, drw->screen)), 0, NULL);
 }

So if you combine that with the instructions on the patch page you end up with:

Drw *
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
{
	Drw *drw = ecalloc(1, sizeof(Drw));

	drw->dpy = dpy;
	drw->screen = screen;
	drw->root = root;
	drw->w = w;
	drw->h = h;
	drw->visual = visual;
	drw->depth = depth;
	drw->cmap = cmap;
	drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
	drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, drw->visual), 0, NULL);
	drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
	XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);

	return drw;
}
void
drw_resize(Drw *drw, unsigned int w, unsigned int h)
{
	if (!drw)
		return;

	drw->w = w;
	drw->h = h;
	if (drw->picture)
		XRenderFreePicture(drw->dpy, drw->picture);
	if (drw->drawable)
		XFreePixmap(drw->dpy, drw->drawable);

	drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
	drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, drw->visual), 0, NULL);
}

It is just changing DefaultVisual(drw->dpy, drw->screen) to drw->visual.

That should be all really.

@Jemi
Copy link
Author

Jemi commented Jun 26, 2023

Can you put these changes into the form of a patch please?

@AdamYuan
Copy link
Owner

AdamYuan commented Jun 26, 2023

You can simply replace drw_create and drw_resize functions in drw.c with bakkeby's code (#8 (comment)) with your text editor.

Also, I would recommend https://github.com/bakkeby/dwm-flexipatch since it has all the patches you need (Vanitygaps can be a substitution for fullgaps ) and it is much easier to customize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants