commit 7a4c19cc65824ae2c4a4d4cefb41626160cd6947
Author: explosion-mental <explosion0mental_AT_gmail.com>
Date: Tue Oct 12 12:24:11 2021 -0500
[dwm][patch][tag-previews]
fixed issue with `scalepreview` variable not applied to the preview window, better screenshot and remove text from index to comments on the patch and.
diff --git a/dwm.suckless.org/patches/tag-previews/dwm-tag-preview-6.2.diff b/dwm.suckless.org/patches/tag-previews/dwm-tag-preview-6.2.diff
index d33084dc..eec38fdc 100644
--- a/dwm.suckless.org/patches/tag-previews/dwm-tag-preview-6.2.diff
+++ b/dwm.suckless.org/patches/tag-previews/dwm-tag-preview-6.2.diff
_AT_@ -1,38 +1,37 @@
-From 7381bf4e11b76ad8f51c94bd226296bf971ad430 Mon Sep 17 00:00:00 2001
+From 64c79048e03345937c66fbee01b871e44cd579bc Mon Sep 17 00:00:00 2001
From: explosion-mental <explosion0mental_AT_gmail.com>
-Date: Wed, 11 Aug 2021 17:28:32 -0500
-Subject: [PATCH] Tag preview This is a patch extracted from
-
https://github.com/siduck76/chadwm build. First view a tag with at least a
- client, then move to any other tag. Finally hover you mouse over the tag you
- were previously and you got a tag preview.
+Date: Tue, 12 Oct 2021 11:57:54 -0500
+Subject: [PATCH] [update] fixed scale preview on `XCreateWindow` and added
+ some comments Allows you to see the contents of an already viewed tag. So a
+ more accurate description would be to re-view a tag.
---
config.def.h | 1 +
config.mk | 5 +-
- dwm.c | 157 +++++++++++++++++++++++++++++++++++++++++++--------
- 3 files changed, 140 insertions(+), 23 deletions(-)
+ dwm.c | 164 ++++++++++++++++++++++++++++++++++++++++++++-------
+ 3 files changed, 147 insertions(+), 23 deletions(-)
diff --git a/config.def.h b/config.def.h
-index 1c0b587..81a3d3d 100644
+index 1c0b587..897bf0c 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -3,6 +3,7 @@
/* appearance */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
-+static const int scalepreview = 4; /* Tag preview scaling */
++static const int scalepreview = 4; /* tag preview scaling */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" };
diff --git a/config.mk b/config.mk
-index 6d36cb7..70b2a3a 100644
+index 6d36cb7..699007f 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -20,9 +20,12 @@ FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
-+# Tag previews are done with Imlib2
++# Imlib2 (tag previews)
+IMLIB2LIBS = -lImlib2
+
# includes and libs
_AT_@ -43,7 +42,7 @@ index 6d36cb7..70b2a3a 100644
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff --git a/dwm.c b/dwm.c
-index 4465af1..aafdccc 100644
+index 4465af1..878abc1 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -40,6 +40,7 @@
_AT_@ -101,10 +100,13 @@ index 4465af1..aafdccc 100644
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
-_AT_@ -271,6 +254,31 @@ static Window root, wmcheckwin;
+_AT_@ -271,6 +254,36 @@ static Window root, wmcheckwin;
/* configuration, allows nested code to access above variables */
#include "config.h"
++/* We only move this here to get the length of the `tags` array, which probably
++ * will generate compatibility issues with other patches. To avoid it, I
++ * reccomend patching this at the end or continue with the comment below */
+struct Monitor {
+ char ltsymbol[16];
+ float mfact;
_AT_@ -116,6 +118,7 @@ index 4465af1..aafdccc 100644
+ unsigned int seltags;
+ unsigned int sellt;
+ unsigned int tagset[2];
++ int previewshow;
+ int showbar;
+ int topbar;
+ Client *clients;
_AT_@ -124,7 +127,8 @@ index 4465af1..aafdccc 100644
+ Monitor *next;
+ Window barwin;
+ Window tagwin;
-+ int previewshow;
++ //change 'LENGTH(tags)' to the actual number of tags you have (9 by def)
++ //if you wish to move this below config.h
+ Pixmap tagmap[LENGTH(tags)];
+ const Layout *lt[2];
+};
_AT_@ -133,7 +137,7 @@ index 4465af1..aafdccc 100644
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
-_AT_@ -430,6 +438,10 @@ buttonpress(XEvent *e)
+_AT_@ -430,6 +443,10 @@ buttonpress(XEvent *e)
focus(NULL);
}
if (ev->window == selmon->barwin) {
_AT_@ -144,11 +148,19 @@ index 4465af1..aafdccc 100644
i = x = 0;
do
x += TEXTW(tags[i]);
-_AT_@ -504,8 +516,13 @@ cleanupmon(Monitor *mon)
+_AT_@ -497,6 +514,7 @@ void
+ cleanupmon(Monitor *mon)
+ {
+ Monitor *m;
++ size_t i;
+
+ if (mon == mons)
+ mons = mons->next;
+_AT_@ -504,8 +522,13 @@ cleanupmon(Monitor *mon)
for (m = mons; m && m->next != mon; m = m->next);
m->next = mon->next;
}
-+ for (size_t i = 0; i < LENGTH(tags); i++)
++ for (i = 0; i < LENGTH(tags); i++)
+ if (mon->tagmap[i])
+ XFreePixmap(dpy, mon->tagmap[i]);
XUnmapWindow(dpy, mon->barwin);
_AT_@ -158,7 +170,7 @@ index 4465af1..aafdccc 100644
free(mon);
}
-_AT_@ -1121,7 +1138,31 @@ motionnotify(XEvent *e)
+_AT_@ -1121,7 +1144,30 @@ motionnotify(XEvent *e)
static Monitor *mon = NULL;
Monitor *m;
XMotionEvent *ev = &e->xmotion;
_AT_@ -167,30 +179,29 @@ index 4465af1..aafdccc 100644
+ if (ev->window == selmon->barwin) {
+ i = x = 0;
+ do
-+ x += TEXTW(tags[i]);
++ x += TEXTW(tags[i]);
+ while (ev->x >= x && ++i < LENGTH(tags));
-+ if (i < LENGTH(tags)) {
++ if (i < LENGTH(tags)) {
+ if ((i + 1) != selmon->previewshow && !(selmon->tagset[selmon->seltags] & 1 << i)) {
-+ selmon->previewshow = i + 1;
-+ showtagpreview(i);
-+ }
-+ else if (selmon->tagset[selmon->seltags] & 1 << i) {
++ selmon->previewshow = i + 1;
++ showtagpreview(i);
++ } else if (selmon->tagset[selmon->seltags] & 1 << i) {
+ selmon->previewshow = 0;
+ showtagpreview(0);
-+ }
++ }
+ } else if (selmon->previewshow != 0) {
-+ selmon->previewshow = 0;
-+ showtagpreview(0);
-+ }
++ selmon->previewshow = 0;
++ showtagpreview(0);
++ }
+ } else if (selmon->previewshow != 0) {
+ selmon->previewshow = 0;
-+ showtagpreview(0);
++ showtagpreview(0);
+ }
if (ev->window != root)
return;
if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
-_AT_@ -1573,6 +1614,7 @@ setup(void)
+_AT_@ -1573,6 +1619,7 @@ setup(void)
/* init bars */
updatebars();
updatestatus();
_AT_@ -198,7 +209,7 @@ index 4465af1..aafdccc 100644
/* supporting window for NetWMCheck */
wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0);
XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32,
-_AT_@ -1628,6 +1670,23 @@ showhide(Client *c)
+_AT_@ -1628,6 +1675,23 @@ showhide(Client *c)
}
}
_AT_@ -222,14 +233,14 @@ index 4465af1..aafdccc 100644
void
sigchld(int unused)
{
-_AT_@ -1652,6 +1711,38 @@ spawn(const Arg *arg)
+_AT_@ -1652,6 +1716,40 @@ spawn(const Arg *arg)
}
}
+void
+switchtag(void)
+{
-+ int i;
++ int i;
+ unsigned int occ = 0;
+ Client *c;
+ Imlib_Image image;
_AT_@ -238,16 +249,18 @@ index 4465af1..aafdccc 100644
+ occ |= c->tags;
+ for (i = 0; i < LENGTH(tags); i++) {
+ if (selmon->tagset[selmon->seltags] & 1 << i) {
-+ if (selmon->tagmap[i] != 0) {
-+ XFreePixmap(dpy, selmon->tagmap[i]);
-+ selmon->tagmap[i] = 0;
-+ }
++ if (selmon->tagmap[i] != 0) {
++ XFreePixmap(dpy, selmon->tagmap[i]);
++ selmon->tagmap[i] = 0;
++ }
+ if (occ & 1 << i) {
+ image = imlib_create_image(sw, sh);
+ imlib_context_set_image(image);
+ imlib_context_set_display(dpy);
+ imlib_context_set_visual(DefaultVisual(dpy, screen));
+ imlib_context_set_drawable(RootWindow(dpy, screen));
++ //uncomment the following line and comment the other imlin_copy.. line if you don't want the bar showing on the preview
++ //imlib_copy_drawable_to_image(0, selmon->wx, selmon->wy, selmon->ww ,selmon->wh, 0, 0, 1);
+ imlib_copy_drawable_to_image(0, selmon->mx, selmon->my, selmon->mw ,selmon->mh, 0, 0, 1);
+ selmon->tagmap[i] = XCreatePixmap(dpy, selmon->tagwin, selmon->mw / scalepreview, selmon->mh / scalepreview, DefaultDepth(dpy, screen));
+ imlib_context_set_drawable(selmon->tagmap[i]);
_AT_@ -261,7 +274,7 @@ index 4465af1..aafdccc 100644
void
tag(const Arg *arg)
{
-_AT_@ -1740,6 +1831,7 @@ toggleview(const Arg *arg)
+_AT_@ -1740,6 +1838,7 @@ toggleview(const Arg *arg)
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
if (newtagset) {
_AT_@ -269,7 +282,7 @@ index 4465af1..aafdccc 100644
selmon->tagset[selmon->seltags] = newtagset;
focus(NULL);
arrange(selmon);
-_AT_@ -1805,7 +1897,7 @@ updatebars(void)
+_AT_@ -1805,7 +1904,7 @@ updatebars(void)
XSetWindowAttributes wa = {
.override_redirect = True,
.background_pixmap = ParentRelative,
_AT_@ -278,7 +291,7 @@ index 4465af1..aafdccc 100644
};
XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) {
-_AT_@ -2001,6 +2093,26 @@ updatetitle(Client *c)
+_AT_@ -2001,6 +2100,26 @@ updatetitle(Client *c)
strcpy(c->name, broken);
}
_AT_@ -293,7 +306,7 @@ index 4465af1..aafdccc 100644
+ .event_mask = ButtonPressMask|ExposureMask
+ };
+ for (m = mons; m; m = m->next) {
-+ m->tagwin = XCreateWindow(dpy, root, m->wx, m->by + bh, m->mw / 4, m->mh / 4, 0,
++ m->tagwin = XCreateWindow(dpy, root, m->wx, m->by + bh, m->mw / scalepreview, m->mh / scalepreview, 0,
+ DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
+ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+ XDefineCursor(dpy, m->tagwin, cursor[CurNormal]->cursor);
_AT_@ -305,7 +318,7 @@ index 4465af1..aafdccc 100644
void
updatewindowtype(Client *c)
{
-_AT_@ -2037,6 +2149,7 @@ view(const Arg *arg)
+_AT_@ -2037,6 +2156,7 @@ view(const Arg *arg)
{
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
_AT_@ -314,5 +327,5 @@ index 4465af1..aafdccc 100644
if (arg->ui & TAGMASK)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
--
-2.32.0
+2.33.0
diff --git a/dwm.suckless.org/patches/tag-previews/index.md b/dwm.suckless.org/patches/tag-previews/index.md
index 9d781327..3a7ca4be 100644
--- a/dwm.suckless.org/patches/tag-previews/index.md
+++ b/dwm.suckless.org/patches/tag-previews/index.md
_AT_@ -9,48 +9,15 @@ description would be to re-view a tag.
![screenshot](screenshot.png)
-This is done with Imlib2. This patch is extracted from
-
https://github.com/siduck76/chadwm. Keep in mind this moves `monitor` struct
-below `#include config.h` so it can read the 'LENGTH' of your tags, since it's
-defined in config.h. A workaround if you get into compatibility issues is to
-just put 9 (or the number of tags you have) and remove the macro, the below
-a patch that does that.
-
-
- _AT_@ -271,6 +254,31 @@ static Window root, wmcheckwin;
- /* configuration, allows nested code to access above variables */
- #include "config.h"
-
- struct Monitor {
- char ltsymbol[16];
- float mfact;
- int nmaster;
- int num;
- int by; /* bar geometry */
- int mx, my, mw, mh; /* screen size */
- int wx, wy, ww, wh; /* window area */
- unsigned int seltags;
- unsigned int sellt;
- unsigned int tagset[2];
- int showbar;
- int topbar;
- Client *clients;
- Client *sel;
- Client *stack;
- Monitor *next;
- Window barwin;
- Window tagwin;
- int previewshow;
- - Pixmap tagmap[LENGTH(tags)];
- + Pixmap tagmap[9];
- const Layout *lt[2];
- };
+This is done with Imlib2, so it is a dependency. This patch is extracted from
+siduck76 [chadwm](
https://github.com/siduck76/chadwm)
+
Download
--------
* [dwm-tag-preview-6.2.diff](dwm-tag-preview-6.2.diff)
-* [github mirror](
https://github.com/explosion-mental/Dwm/blob/main/Patches/dwm-tag-preview-6.2.diff) (issues and contribs)
+* [github mirror](
https://github.com/explosion-mental/Dwm/blob/main/Patches/dwm-tag-preview-6.2.diff)
Authors
-------
diff --git a/dwm.suckless.org/patches/tag-previews/screenshot.png b/dwm.suckless.org/patches/tag-previews/screenshot.png
index 0f703373..231a5fc3 100644
Binary files a/dwm.suckless.org/patches/tag-previews/screenshot.png and b/dwm.suckless.org/patches/tag-previews/screenshot.png differ
Received on Tue Oct 12 2021 - 19:26:37 CEST