sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 7a4c19cc65824ae2c4a4d4cefb41626160cd6947
parent d6848f26c3e64673e308bacedac5534f4c97828c
Author: explosion-mental <explosion0mental@gmail.com>
Date:   Tue, 12 Oct 2021 12:24:11 -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.

Diffstat:
Mdwm.suckless.org/patches/tag-previews/dwm-tag-preview-6.2.diff | 101+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Mdwm.suckless.org/patches/tag-previews/index.md | 41++++-------------------------------------
Mdwm.suckless.org/patches/tag-previews/screenshot.png | 0
3 files changed, 61 insertions(+), 81 deletions(-)

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 @@ -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@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 @@ -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 @@ -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 @@ -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 @@ -40,6 +40,7 @@ @@ -101,10 +100,13 @@ index 4465af1..aafdccc 100644 static void updatewindowtype(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); -@@ -271,6 +254,31 @@ static Window root, wmcheckwin; +@@ -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; @@ -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; @@ -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]; +}; @@ -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]; }; -@@ -430,6 +438,10 @@ buttonpress(XEvent *e) +@@ -430,6 +443,10 @@ buttonpress(XEvent *e) focus(NULL); } if (ev->window == selmon->barwin) { @@ -144,11 +148,19 @@ index 4465af1..aafdccc 100644 i = x = 0; do x += TEXTW(tags[i]); -@@ -504,8 +516,13 @@ cleanupmon(Monitor *mon) +@@ -497,6 +514,7 @@ void + cleanupmon(Monitor *mon) + { + Monitor *m; ++ size_t i; + + if (mon == mons) + mons = mons->next; +@@ -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); @@ -158,7 +170,7 @@ index 4465af1..aafdccc 100644 free(mon); } -@@ -1121,7 +1138,31 @@ motionnotify(XEvent *e) +@@ -1121,7 +1144,30 @@ motionnotify(XEvent *e) static Monitor *mon = NULL; Monitor *m; XMotionEvent *ev = &e->xmotion; @@ -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) { -@@ -1573,6 +1614,7 @@ setup(void) +@@ -1573,6 +1619,7 @@ setup(void) /* init bars */ updatebars(); updatestatus(); @@ -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, -@@ -1628,6 +1670,23 @@ showhide(Client *c) +@@ -1628,6 +1675,23 @@ showhide(Client *c) } } @@ -222,14 +233,14 @@ index 4465af1..aafdccc 100644 void sigchld(int unused) { -@@ -1652,6 +1711,38 @@ spawn(const Arg *arg) +@@ -1652,6 +1716,40 @@ spawn(const Arg *arg) } } +void +switchtag(void) +{ -+ int i; ++ int i; + unsigned int occ = 0; + Client *c; + Imlib_Image image; @@ -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]); @@ -261,7 +274,7 @@ index 4465af1..aafdccc 100644 void tag(const Arg *arg) { -@@ -1740,6 +1831,7 @@ toggleview(const Arg *arg) +@@ -1740,6 +1838,7 @@ toggleview(const Arg *arg) unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK); if (newtagset) { @@ -269,7 +282,7 @@ index 4465af1..aafdccc 100644 selmon->tagset[selmon->seltags] = newtagset; focus(NULL); arrange(selmon); -@@ -1805,7 +1897,7 @@ updatebars(void) +@@ -1805,7 +1904,7 @@ updatebars(void) XSetWindowAttributes wa = { .override_redirect = True, .background_pixmap = ParentRelative, @@ -278,7 +291,7 @@ index 4465af1..aafdccc 100644 }; XClassHint ch = {"dwm", "dwm"}; for (m = mons; m; m = m->next) { -@@ -2001,6 +2093,26 @@ updatetitle(Client *c) +@@ -2001,6 +2100,26 @@ updatetitle(Client *c) strcpy(c->name, broken); } @@ -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); @@ -305,7 +318,7 @@ index 4465af1..aafdccc 100644 void updatewindowtype(Client *c) { -@@ -2037,6 +2149,7 @@ view(const Arg *arg) +@@ -2037,6 +2156,7 @@ view(const Arg *arg) { if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) return; @@ -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 @@ -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. - - - @@ -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 Binary files differ.