Git Product home page Git Product logo

Comments (6)

bakkeby avatar bakkeby commented on June 20, 2024 1

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.

from dwm-winicon.

Jemi avatar Jemi commented on June 20, 2024

$ 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}

from dwm-winicon.

Jemi avatar Jemi commented on June 20, 2024

$ 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);

from dwm-winicon.

Jemi avatar Jemi commented on June 20, 2024

Any help much appreciated.

from dwm-winicon.

Jemi avatar Jemi commented on June 20, 2024

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

from dwm-winicon.

AdamYuan avatar AdamYuan commented on June 20, 2024

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

from dwm-winicon.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.