Add toggle for tag previews. This means you can now fully disable

imlib2 dependency if you want.
This commit is contained in:
speediegq 2022-09-03 17:44:49 +02:00
parent bd5267be8b
commit 12bbf6da98
5 changed files with 62 additions and 11 deletions

View file

@ -13,6 +13,11 @@ USEIPC = true # Comment if you don't use IPC
YAJLLIBS = -lyajl # Comment if you don't use IPC
YAJLINC = /usr/include/yajl # Comment if you don't use IPC
# Tag previews and window icons
# If you use tag previews or window icons (enabled by default), these must be uncommented.
# If you do not use them, disable them in toggle.h and comment these lines.
IMLIB2LIBS = -lImlib2
# Solaris support
# If you use Solaris, uncomment this line. (remove the # at the start of the line below)
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
@ -56,7 +61,7 @@ FREETYPEINC = /usr/include/freetype2
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC} -I${YAJLINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lImlib2 -lX11-xcb -lxcb -lxcb-res -lXext ${YAJLLIBS}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender ${IMLIB2LIBS} -lX11-xcb -lxcb -lxcb-res -lXext ${YAJLLIBS}
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}

View file

@ -95,6 +95,7 @@
#define SHCMD(cmd) { .v = (const char*[]){ shell, "-c", cmd, NULL } }
#define TAGKEYS(CHAIN,KEY,TAG) { MODKEY, CHAIN, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ShiftMask, CHAIN, KEY, previewtag, {.ui = TAG} }, \
/* Options
*
* If xrdb is installed, you can simply edit ~/.config/speedwm-de/speedwmrc instead of recompiling.
@ -136,12 +137,14 @@ static int roundedcorners = 0; /* Enable (1) rounded corners
static int cornerradius = 3; /* Radius of rounded corners, 10 is the default. */
/* Tag preview options */
#if USETAGPREVIEW
static int tagpreview = 1; /* Enable tag previews */
static int tagpreviewpaddingv = 0; /* Vertical tag padding */
static int tagpreviewpaddingh = 0; /* Horizontal tag padding */
static int mousepreview = 1; /* Display tag previews if hovering over a tag */
static int barpreview = 0; /* Display the bar in the preview */
static int scalepreview = 4; /* Size of tag preview. Lower is bigger, higher is smaller. */
#endif
/* Window spawning options */
static int attachdirection = 3; /* 0 default, 1 above, 2 aside, 3 below, 4 bottom, 5 top */

View file

@ -31,7 +31,9 @@
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
#include <X11/Xft/Xft.h>
#if USEIMLIB2
#include <Imlib2.h>
#endif
#include <X11/Xlib-xcb.h>
#include <xcb/res.h>
#ifdef __OpenBSD__
@ -203,7 +205,9 @@ struct Monitor {
#if USEIPC
TagState tagstate;
#endif
#if USETAGPREVIEW
int previewshow;
#endif
int showbar;
int barposition;
int hidsel;
@ -217,8 +221,10 @@ struct Monitor {
Monitor *next;
Window barwin;
Window traywin;
#if USETAGPREVIEW
Window tagwin;
Pixmap *tagmap;
#endif
const Layout *lt[2];
#if USEIPC
const Layout *lastlt;
@ -414,7 +420,9 @@ static void seturgent(Client *c, int urg);
static void show(const Arg *arg);
static void showwin(Client *c);
static void showhide(Client *c);
#if USETAGPREVIEW
static void showtagpreview(unsigned int i);
#endif
static void sigchld(int unused);
#ifdef XINERAMA
static void sortscreens(XineramaScreenInfo *screens, int n);
@ -425,7 +433,9 @@ static void spawn(const Arg *arg);
static void spawnbar();
static void unmanagealtbar(Window w);
static void unmanagetray(Window w);
#if USETAGPREVIEW
static void getpreview(void);
#endif
static void tagmon(const Arg *arg);
static void tile(Monitor *);
static void tile54(Monitor *);
@ -456,8 +466,10 @@ static void updatesizehints(Client *c);
static void updatestatus(void);
static void updaterules(Client *c);
static void updatetitle(Client *c);
static void updatepreview(void);
#if USEWINICON
#if USETAGPREVIEW
static void updatepreview(void);
#endif
static void updateicon(Client *c);
#endif
static void updatewindowtype(Client *c);
@ -1101,7 +1113,9 @@ void
cleanupmon(Monitor *mon)
{
Monitor *m;
#if USETAGPREVIEW
size_t i;
#endif
if (mon == mons)
mons = mons->next;
@ -1109,17 +1123,22 @@ cleanupmon(Monitor *mon)
for (m = mons; m && m->next != mon; m = m->next);
m->next = mon->next;
}
#if USETAGPREVIEW
for (i = 0; i < LENGTH(tags); i++) {
if (mon->tagmap[i])
XFreePixmap(dpy, mon->tagmap[i]);
free(mon->tagmap);
if (!altbar) {
XUnmapWindow(dpy, mon->tagwin);
XDestroyWindow(dpy, mon->tagwin);
}
#endif
free(mon);
#if USETAGPREVIEW
}
#endif
}
void
@ -1354,7 +1373,9 @@ createmon(void)
m->pertag->showbars[i] = m->showbar;
}
#if USETAGPREVIEW
m->tagmap = ecalloc(LENGTH(tags), sizeof(Pixmap));
#endif
return m;
}
@ -2752,9 +2773,9 @@ motionnotify(XEvent *e)
for (c = selmon->clients; c; c = c->next)
occ |= c->tags == 255 ? 0 : c->tags;
if (leftlayout) {
if (leftlayout)
x += blw;
} do {
do {
if (!(occ & 1 << i || selmon->tagset[selmon->seltags] & 1 << i))
continue;
@ -2762,6 +2783,7 @@ motionnotify(XEvent *e)
} while (ev->x >= x && ++i < (LENGTH(tags)));
#if USETAGPREVIEW
if (mousepreview && !hidetags) {
if (i < LENGTH(tags)) {
if ((i + 1) != selmon->previewshow && !(selmon->tagset[selmon->seltags] & 1 << i)) {
@ -2779,6 +2801,7 @@ motionnotify(XEvent *e)
showtagpreview(0);
XUnmapWindow(dpy, selmon->tagwin);
}
#endif
}
if (ev->window != root)
return;
@ -4005,7 +4028,9 @@ setup(void)
/* init bars */
updatebars();
updatestatus();
#if USETAGPREVIEW
updatepreview();
#endif
/* supporting window for NetWMCheck */
if (fullscreenhidebar) {
@ -4093,10 +4118,10 @@ seturgent(Client *c, int urg)
XFree(wmh);
}
#if USETAGPREVIEW
void
showtagpreview(unsigned int i)
{
if (!selmon->previewshow || !selmon->tagmap[i]) {
XUnmapWindow(dpy, selmon->tagwin);
return;
@ -4111,6 +4136,7 @@ showtagpreview(unsigned int i)
XMapWindow(dpy, selmon->tagwin);
}
}
#endif
void
sigchld(int unused)
@ -4136,6 +4162,7 @@ sigchld(int unused)
}
}
#if USETAGPREVIEW
void
getpreview(void)
{
@ -4177,6 +4204,7 @@ getpreview(void)
imlib_free_image();
}
}
#endif
void
sighup(int unused)
@ -4874,6 +4902,7 @@ updateicon(Client *c)
}
#endif
#if USETAGPREVIEW
void
updatepreview(void)
{
@ -4899,6 +4928,7 @@ updatepreview(void)
XUnmapWindow(dpy, m->tagwin);
}
}
#endif
void
updatewindowtype(Client *c)
@ -4942,13 +4972,17 @@ view(const Arg *arg)
selmon->mouseactivated = 1;
#endif
#if USETAGPREVIEW
/* fix: tag preview gets captured in the next tag preview if the user switched tag while a preview is showing */
if (selmon->previewshow && !selmon->mouseactivated)
return;
#endif
if(arg->ui && (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
#if USETAGPREVIEW
getpreview();
#endif
for (m = mons; m; m = m->next)
m->seltags ^= 1;
if (arg->ui & TAGMASK) {
@ -4980,7 +5014,9 @@ view(const Arg *arg)
togglebar(NULL);
}
#if USETAGPREVIEW
XUnmapWindow(dpy, selmon->tagwin);
#endif
selmon->mouseactivated = 0;
focus(NULL);
arrange(NULL);
@ -5337,11 +5373,13 @@ load_xresources(void)
void
previewtag(const Arg *arg)
{
#if USETAGPREVIEW
if (selmon->previewshow != (arg->ui + 1))
selmon->previewshow = arg->ui + 1;
else
selmon->previewshow = 0;
showtagpreview(arg->ui);
#endif
}
void

View file

@ -1,7 +1,10 @@
/* Toggle patches
* This header allows you to enable/disable patches that can break compability with certain OSes or configurations.
* This header allows you to enable/disable patches that can break compability or decrease performance with certain OSes or configurations.
*/
#define USEIPC 1 /* Whether or not to use IPC. If you set this to 1, set USEIPC to true in config.mk and comment the YAJLLIBS and YAJLINC lines in config.mk. Not compatible with BSDs so for those, set this to 0. */
#define USEALPHA 1 /* Whether or not to use transparency for the bar */
#define USEMOUSE 1 /* Whether or not to use mouse binds */
#define USEIMLIB2 1 /* Whether or not to use imlib2. Required by USEWINICON and USETAGPREVIEW. */
#define USEWINICON 1 /* Whether or not to use window icons. Requires imlib to be enabled in config.mk and it must be installed. */
#define USETAGPREVIEW 1 /* Whether or not to use tag previews. Requires imlib to be enabled in config.mk and it must be installed. */

View file

@ -134,12 +134,14 @@ ResourcePref resources[] = {
{ "i3nmaster", INTEGER, &i3nmaster },
{ "monocleclientcount", INTEGER, &monocleclientcount },
{ "monoclecount", INTEGER, &monoclecount },
#if USETAGPREVIEW
{ "scalepreview", INTEGER, &scalepreview },
{ "tagpreview", INTEGER, &tagpreview },
{ "tagpreviewpaddingv", INTEGER, &tagpreviewpaddingv },
{ "tagpreviewpaddingh", INTEGER, &tagpreviewpaddingh },
{ "barpreview", INTEGER, &barpreview },
{ "mousepreview", INTEGER, &mousepreview },
#endif
{ "leftlayout", INTEGER, &leftlayout },
{ "hidelayout", INTEGER, &hidelayout },
{ "hidetitle", INTEGER, &hidetitle },