dwm-xcursor-20250909-cf65f6f.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-xcursor-20250909-cf65f6f.diff (2815B)
---
1 commit cf65f6f14e8266dd317396fe9a4ad32d768a75e5
2 Author: iwuvkittens <iwuvkittens@cock.li>
3 Date: Tue Sep 9 00:18:08 2025 -0400
4
5 cursor: replace font cursors with xcursor lib
6
7 diff --git a/config.mk b/config.mk
8 index b469a2b..c57985c 100644
9 --- a/config.mk
10 +++ b/config.mk
11 @@ -23,7 +23,7 @@ FREETYPEINC = /usr/include/freetype2
12
13 # includes and libs
14 INCS = -I${X11INC} -I${FREETYPEINC}
15 -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
16 +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXcursor
17
18 # flags
19 CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
20 diff --git a/drw.c b/drw.c
21 index c41e6af..80d2c2d 100644
22 --- a/drw.c
23 +++ b/drw.c
24 @@ -4,6 +4,7 @@
25 #include <string.h>
26 #include <X11/Xlib.h>
27 #include <X11/Xft/Xft.h>
28 +#include <X11/Xcursor/Xcursor.h>
29
30 #include "drw.h"
31 #include "util.h"
32 @@ -425,14 +426,14 @@ drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w,
33 }
34
35 Cur *
36 -drw_cur_create(Drw *drw, int shape)
37 +drw_cur_create(Drw *drw, const char *shape)
38 {
39 Cur *cur;
40
41 if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
42 return NULL;
43
44 - cur->cursor = XCreateFontCursor(drw->dpy, shape);
45 + cur->cursor = XcursorLibraryLoadCursor(drw->dpy, shape);
46
47 return cur;
48 }
49 diff --git a/drw.h b/drw.h
50 index 6471431..22295a3 100644
51 --- a/drw.h
52 +++ b/drw.h
53 @@ -43,7 +43,7 @@ void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
54 Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
55
56 /* Cursor abstraction */
57 -Cur *drw_cur_create(Drw *drw, int shape);
58 +Cur *drw_cur_create(Drw *drw, const char *shape);
59 void drw_cur_free(Drw *drw, Cur *cursor);
60
61 /* Drawing context manipulation */
62 diff --git a/dwm.c b/dwm.c
63 index 4cf07eb..15d53a7 100644
64 --- a/dwm.c
65 +++ b/dwm.c
66 @@ -30,7 +30,6 @@
67 #include <unistd.h>
68 #include <sys/types.h>
69 #include <sys/wait.h>
70 -#include <X11/cursorfont.h>
71 #include <X11/keysym.h>
72 #include <X11/Xatom.h>
73 #include <X11/Xlib.h>
74 @@ -40,6 +39,7 @@
75 #include <X11/extensions/Xinerama.h>
76 #endif /* XINERAMA */
77 #include <X11/Xft/Xft.h>
78 +#include <X11/Xcursor/Xcursor.h>
79
80 #include "drw.h"
81 #include "util.h"
82 @@ -1579,9 +1579,9 @@ setup(void)
83 netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
84 netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
85 /* init cursors */
86 - cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
87 - cursor[CurResize] = drw_cur_create(drw, XC_sizing);
88 - cursor[CurMove] = drw_cur_create(drw, XC_fleur);
89 + cursor[CurNormal] = drw_cur_create(drw, "left_ptr");
90 + cursor[CurResize] = drw_cur_create(drw, "se-resize");
91 + cursor[CurMove] = drw_cur_create(drw, "fleur");
92 /* init appearance */
93 scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
94 for (i = 0; i < LENGTH(colors); i++)