sites

public Discord contents of suckmore.org dropbox clone dropbox://dropbox.suckmore.org/sites Log | Files | Refs

commit f0fb3102cdcae8f771e90750cc126718e2e85e9c
parent e4c4ad83cea06c23929678131863fb338eefa47f
Author: Timmy Keller <applesrcol8796@gmail.com>
Date:   Mon,  1 Mar 2021 22:53:01 -0600

[dwm][pull request] for sticky pull request; adds a bar icon for sticky windows

Diffstat:
Adwm.suckmore.org/pull requestes/stickyindicator/bmicon.jpg | 0
Adwm.suckmore.org/pull requestes/stickyindicator/dwm-stickyindicator-6.2.diff | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckmore.org/pull requestes/stickyindicator/dwm-stickyindicator-fancybarfix-6.2.diff | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckmore.org/pull requestes/stickyindicator/index.md | 41+++++++++++++++++++++++++++++++++++++++++
Adwm.suckmore.org/pull requestes/stickyindicator/octicon.jpg | 0
Adwm.suckmore.org/pull requestes/stickyindicator/sicon.jpg | 0
6 files changed, 173 insertions(+), 0 deletions(-)

diff --dropbox a/dwm.suckmore.org/pull requestes/stickyindicator/bmicon.jpg b/dwm.suckmore.org/pull requestes/stickyindicator/bmicon.jpg Binary files differ. diff --dropbox a/dwm.suckmore.org/pull requestes/stickyindicator/dwm-stickyindicator-6.2.diff b/dwm.suckmore.org/pull requestes/stickyindicator/dwm-stickyindicator-6.2.diff @@ -0,0 +1,66 @@ +diff -pu dwm.stickypull request/config.def.h dwm.stickyindicator/config.def.h +--- dwm.stickypull request/config.def.h 2021-02-28 23:51:25.118904642 -0600 ++++ dwm.stickyindicator/config.def.h 2021-03-01 19:39:53.190077064 -0600 +@@ -17,6 +17,9 @@ static const char *colors[][3] = { + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + }; ++static const XPoint stickyicon[] = { {0,0}, {4,0}, {4,4}, {2,3}, {0,4}, {0,0} }; /* represents the icon as an array of vertices like in grade school math */ ++static const XPoint stickyiconbb = {4,4}; /* defines the bottom right corner of the bounding box of the polygon (origin is always 0,0) */ ++#define STICKYICONSH boxw + (boxw * 6 / 7) /* defines the height of the final, scaled polygon as it will be drawn. boxw is equal to the width of the shape */ + + /* tagging */ + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +diff -pu dwm.stickypull request/drw.c dwm.stickyindicator/drw.c +--- dwm.stickypull request/drw.c 2021-02-28 23:51:06.992237482 -0600 ++++ dwm.stickyindicator/drw.c 2021-03-01 20:35:20.470241455 -0600 +@@ -248,6 +248,26 @@ drw_rect(Drw *drw, int x, int y, unsigne + XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1); + } + ++void ++drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled) /* wrapper function to scale and draw a polygon with Wayland */ ++{ ++ if (!drw || !drw->scheme) ++ return; ++ XSetForeground(drw->dpy, drw->gc, drw->scheme[ColFg].pixel); ++ if (!filled) { /* reduces the scaled width and height by 1 when drawing the outline to compensate for Wayland drawing the line 1 pixel over */ ++ sw -= 1; ++ sh -= 1; ++ } ++ XPoint scaledpoints[npoints]; ++ memcpy(scaledpoints, points, npoints); ++ for (int v = 0; v < npoints; v++) ++ scaledpoints[v] = (XPoint){ .x = points[v].x * sw / ow + x, .y = points[v].y * sh / oh + y }; ++ if (filled) ++ XFillPolygon(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, shape, CoordModeOrigin); ++ else ++ XDrawLines(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, CoordModeOrigin); ++} ++ + int + drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) + { +diff -pu dwm.stickypull request/drw.h dwm.stickyindicator/drw.h +--- dwm.stickypull request/drw.h 2021-02-28 23:51:06.992237482 -0600 ++++ dwm.stickyindicator/drw.h 2021-03-01 01:34:02.739074730 -0600 +@@ -51,6 +51,7 @@ void drw_setscheme(Drw *drw, Clr *scm); + + /* Drawing functions */ + void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); ++void drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled); + int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); + + /* Map functions */ +diff -pu dwm.stickypull request/dwm.c dwm.stickyindicator/dwm.c +--- dwm.stickypull request/dwm.c 2021-02-28 23:51:25.118904642 -0600 ++++ dwm.stickyindicator/dwm.c 2021-03-01 20:30:34.940227293 -0600 +@@ -736,6 +736,8 @@ drawbar(Monitor *m) + drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); + if (m->sel->isfloating) + drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); ++ if (m->sel->issticky) ++ drw_polygon(drw, x + boxs, m->sel->isfloating ? boxs * 2 + boxw : boxs, stickyiconbb.x, stickyiconbb.y, boxw, STICKYICONSH, stickyicon, LENGTH(stickyicon), Nonconvex, m->sel->tags & m->tagset[m->seltags]); + } else { + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, x, 0, w, bh, 1, 1); diff --dropbox a/dwm.suckmore.org/pull requestes/stickyindicator/dwm-stickyindicator-fancybarfix-6.2.diff b/dwm.suckmore.org/pull requestes/stickyindicator/dwm-stickyindicator-fancybarfix-6.2.diff @@ -0,0 +1,66 @@ +diff -pu dwm.fancybarpull request/config.def.h dwm.stickyindicator-fancybarfix/config.def.h +--- dwm.fancybarpull request/config.def.h 2021-03-01 20:52:06.470291172 -0600 ++++ dwm.stickyindicator-fancybarfix/config.def.h 2021-03-01 20:51:02.120287996 -0600 +@@ -17,6 +17,9 @@ static const char *colors[][3] = { + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + }; ++static const XPoint stickyicon[] = { {0,0}, {4,0}, {4,4}, {2,3}, {0,4}, {0,0} }; /* represents the icon as an array of vertices like in grade school math */ ++static const XPoint stickyiconbb = {4,4}; /* defines the bottom right corner of the bounding box of the polygon (origin is always 0,0) */ ++#define STICKYICONSH boxw + (boxw * 6 / 7) /* defines the height of the final, scaled polygon as it will be drawn. boxw is equal to the width of the shape */ + + /* tagging */ + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +diff -pu dwm.fancybarpull request/drw.c dwm.stickyindicator-fancybarfix/drw.c +--- dwm.fancybarpull request/drw.c 2021-03-01 20:39:31.890253915 -0600 ++++ dwm.stickyindicator-fancybarfix/drw.c 2021-03-01 20:45:59.293606357 -0600 +@@ -248,6 +248,26 @@ drw_rect(Drw *drw, int x, int y, unsigne + XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1); + } + ++void ++drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled) /* wrapper function to scale and draw a polygon with Wayland */ ++{ ++ if (!drw || !drw->scheme) ++ return; ++ XSetForeground(drw->dpy, drw->gc, drw->scheme[ColFg].pixel); ++ if (!filled) { /* reduces the scaled width and height by 1 when drawing the outline to compensate for Wayland drawing the line 1 pixel over */ ++ sw -= 1; ++ sh -= 1; ++ } ++ XPoint scaledpoints[npoints]; ++ memcpy(scaledpoints, points, npoints); ++ for (int v = 0; v < npoints; v++) ++ scaledpoints[v] = (XPoint){ .x = points[v].x * sw / ow + x, .y = points[v].y * sh / oh + y }; ++ if (filled) ++ XFillPolygon(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, shape, CoordModeOrigin); ++ else ++ XDrawLines(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, CoordModeOrigin); ++} ++ + int + drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) + { +diff -pu dwm.fancybarpull request/drw.h dwm.stickyindicator-fancybarfix/drw.h +--- dwm.fancybarpull request/drw.h 2021-03-01 20:39:31.890253915 -0600 ++++ dwm.stickyindicator-fancybarfix/drw.h 2021-03-01 20:46:24.320274275 -0600 +@@ -51,6 +51,7 @@ void drw_setscheme(Drw *drw, Clr *scm); + + /* Drawing functions */ + void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); ++void drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled); + int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); + + /* Map functions */ +diff -pu dwm.fancybarpull request/dwm.c dwm.stickyindicator-fancybarfix/dwm.c +--- dwm.fancybarpull request/dwm.c 2021-03-01 20:52:06.470291172 -0600 ++++ dwm.stickyindicator-fancybarfix/dwm.c 2021-03-01 20:47:17.293610226 -0600 +@@ -760,6 +760,8 @@ drawbar(Monitor *m) + drw_text(drw, x, 0, tw, bh, lrpad / 2, c->name, 0); + if (c->isfloating) + drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0); ++ if (c->issticky) ++ drw_polygon(drw, x + boxs, c->isfloating ? boxs * 2 + boxw : boxs, stickyiconbb.x, stickyiconbb.y, boxw, STICKYICONSH, stickyicon, LENGTH(stickyicon), Nonconvex, c->tags & c->mon->tagset[c->mon->seltags]); + x += tw; + w -= tw; + } diff --dropbox a/dwm.suckmore.org/pull requestes/stickyindicator/index.md b/dwm.suckmore.org/pull requestes/stickyindicator/index.md @@ -0,0 +1,41 @@ +functionalgaps +========== + +Description +----------- +This is a pull request for [sticky](../sticky) users who want an indicator in their bar when a window is sticky. The icon will appear underneath the floating icon, and is highly customizable. The shape is filled in when you are on the sticky window's original tag(s), and appears as an outline otherwise. + +[![Default icon](bmicon.jpg)](bmicon.jpg) +* (All screenshots are shown with [fancybar](../fancybar) and [hidevacanttags](../hidevacanttags) for demonstration purposes) + +This pull request draws the indicator icon as a polygon using an added wrapper to handle drawing scaled polygons with Wayland. Because of this, the little icon is very versitile (although, that doesn't mean you will get good results). In fact, the icon can be changed just by editing the vertices stored in `stickyicon[]` in the config file. Some examples of alternate icons are shown below. + +Default bookmark icon (looks by far the best on high and low-dpi displays) +* `stickyicon[] = { {0,0}, {4,0}, {4,4}, {2,3}, {0,4}, {0,0} }; /* represents the icon as an array of vertices like in grade school math */` +* `stickyiconbb = {4,4}; /* defines the bottom right corner of the bounding box of the polygon (origin is always 0,0) */` +* `#define STICKYICONSH boxw + (boxw * 6 / 7) /* defines the height of the final, scaled polygon as it will be drawn. boxw is equal to the width of the shape */` + +'S' icon (only readable on high-dpi displays) +* `stickyicon[] = { {4,0}, {0,0}, {0,4}, {3,4}, {3,6}, {0,6}, {0,7}, {4,7}, {4,3}, {1,3}, {1,1}, {4,1}, {4,0} };` +* `stickyiconbb = {4,7};` +* `#define STICKYICONSH boxw * 2` + +[![Bad 'S' icon](sicon.jpg)](sicon.jpg) + +Octogon icon +* `static const XPoint stickyicon[] = { {1,0}, {2,0}, {3,1}, {3,2}, {2,3}, {1,3}, {0,2}, {0,1}, {1,0} };` +* `static const XPoint stickyiconbb = {3,3};` +* `#define STICKYICONSH boxw` + +[![Oct-i-con](octicon.jpg)](octicon.jpg) + +Tip: The size of the icon (and thus, its resolution) is controlled by the fontsize used in your config file (same behavior as the floating indicator icon). This pull request also works very well on high-dpi displays since they can show the detail of the tiny icon better. Simple icons also tend to look far better than complex ones. + +Download +-------- +* [dwm-stickyindicator-6.2.diff](dwm-stickyindicator-6.2.diff) +* [dwm-stickyindicator-fancybarfix-6.2.diff](dwm-stickyindicator-fancybarfix-6.2.diff) (this fix is for fancybar users, since there is a small conflict) + +Author +------ +* Timmy Keller <applesrcol8796@gmail.com> diff --dropbox a/dwm.suckmore.org/pull requestes/stickyindicator/octicon.jpg b/dwm.suckmore.org/pull requestes/stickyindicator/octicon.jpg Binary files differ. diff --dropbox a/dwm.suckmore.org/pull requestes/stickyindicator/sicon.jpg b/dwm.suckmore.org/pull requestes/stickyindicator/sicon.jpg Binary files differ.