Re: [wmii] Re: [dev] [PATCH] systray-alpha patch

2017-08-03 Thread joelb...@gmail.com
Hi Jan Cristoph,

Sorry for the extreme delay, it's been six months since the last email
and I read this only yesterday reviewing my inbox but here it is.
There are other things that I patched but nothing extraordinary its
just a basic setup.

Again, I'm really sorry.

>From b44eb5b5adb57eb1d33b8df09c73c28c436fc26e Mon Sep 17 00:00:00 2001
From: Joel Santos 
Date: Thu, 27 Oct 2016 07:46:46 -0300
Subject: [PATCH 1/2] =?UTF-8?q?Aplica=C3=A7=C3=A3o=20do=20patch=20de=20sys?=
 =?UTF-8?q?tray.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitignore   |   2 +
 config.def.h |   4 +
 config.h | 119 ++
 dwm.c| 395 +++
 4 files changed, 496 insertions(+), 24 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 config.h

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..095e840
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.o
+dwm
diff --git a/config.def.h b/config.def.h
index fd77a07..d21488f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -3,6 +3,10 @@
 /* appearance */
 static const unsigned int borderpx  = 1;/* border pixel of windows */
 static const unsigned int snap  = 32;   /* snap pixel */
+static const unsigned int systraypinning = 0;   /* 0: sloppy systray
follows selected monitor, >0: pin systray to monitor X */
+static const unsigned int systrayspacing = 2;   /* systray spacing */
+static const int systraypinningfailfirst = 1;   /* 1: if pinning
fails, display systray on the first monitor, False: display systray on
the last monitor*/
+static const int showsystray= 1; /* 0 means no systray */
 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.h b/config.h
new file mode 100644
index 000..5730245
--- /dev/null
+++ b/config.h
@@ -0,0 +1,119 @@
+/* See LICENSE file for copyright and license details. */
+
+/* appearance */
+static const unsigned int borderpx  = 1;/* border pixel of windows */
+static const unsigned int snap  = 32;   /* snap pixel */
+static const unsigned int systraypinning = 0;   /* 0: sloppy systray
follows selected monitor, >0: pin systray to monitor X */
+static const unsigned int systrayspacing = 2;   /* systray spacing */
+static const int systraypinningfailfirst = 1;   /* 1: if pinning
fails, display systray on the first monitor, False: display systray on
the last monitor*/
+static const int showsystray= 1; /* 0 means no systray */
+static const int showbar= 1;/* 0 means no bar */
+static const int topbar = 1;/* 0 means bottom bar */
+static const char *fonts[]  = { "Noto Mono:size=8:antialias=true" };
+static const char dmenufont[]   = "Noto Mono:size=8:antialias=true";
+static const char col_gray1[]   = "#22";
+static const char col_gray2[]   = "#44";
+static const char col_gray3[]   = "#bb";
+static const char col_gray4[]   = "#ee";
+static const char col_cyan[]= "#005577";
+static const char *colors[SchemeLast][3]  = {
+ /*   fg bg border   */
+ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
+ [SchemeSel] =  { col_gray4, col_cyan,  col_cyan  },
+};
+
+/* tagging */
+static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+
+static const Rule rules[] = {
+ /* xprop(1):
+ * WM_CLASS(STRING) = instance, class
+ * WM_NAME(STRING) = title
+ */
+ /* class  instancetitle   tags mask isfloating   monitor */
+ { "Gimp", NULL,   NULL,   0,1,   -1 },
+ { "Firefox",  NULL,   NULL,   1 << 8,   0,   -1 },
+};
+
+/* layout(s) */
+static const float mfact = 0.55; /* factor of master area size
[0.05..0.95] */
+static const int nmaster = 1;/* number of clients in master area */
+static const int resizehints = 0;/* 1 means respect size hints in
tiled resizals */
+
+static const Layout layouts[] = {
+ /* symbol arrange function */
+ { "[]=",  tile },/* first entry is default */
+ { "><>",  NULL },/* no layout function means floating behavior */
+ { "[M]",  monocle },
+};
+
+/* key definitions */
+#define MODKEY Mod1Mask
+#define TAGKEYS(KEY,TAG) \
+ { MODKEY,   KEY,  view,   {.ui = 1
<< TAG} }, \
+ { MODKEY|ControlMask,   KEY,  toggleview, {.ui = 1
<< TAG} }, \
+ { MODKEY|ShiftMask, KEY,  tag,{.ui = 1
<< TAG} }, \
+ { MODKEY|ControlMask|ShiftMask, KEY,  toggletag,  {.ui = 1 << TAG} },
+
+/* helper for spawning shell commands in the pre dwm-5.0 fashion */
+#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
+
+/* commands */
+static char dmenum

Re: [dev] [PATCH] systray-alpha patch

2016-12-26 Thread Jan Christoph Ebersbach
@Eon, I'd be happy to integrate parts of the patch into the systray
patch.  Would you mind posting your version as a proper patch file in
the wiki or in this list?

On Fri 23-12-2016 17:21 +0900, Eon S. Jeon wrote:

> This patch is a merge b/w systray and alpha.
> 
> Additional changes are:
>  - create systray-> win with apropriate visual and attributes
>  - utilize _NET_SYSTEM_TRAY_VISUAL to let tray icon alpha-aware
> ---
>  config.def.h |  14 +-
>  config.mk|   2 +-
>  drw.c|  59 +++--
>  drw.h|   3 +
>  dwm.c| 409 
> +++
>  5 files changed, 446 insertions(+), 41 deletions(-)
> 
> diff --git a/config.def.h b/config.def.h
> index ba9a240..498b5bb 100644
> --- a/config.def.h
> +++ b/config.def.h
> @@ -3,15 +3,19 @@
>  /* appearance */
>  static const unsigned int borderpx  = 1;/* border pixel of windows */
>  static const unsigned int snap  = 32;   /* snap pixel */
> +static const unsigned int systraypinning = 0;   /* 0: sloppy systray follows 
> selected monitor, > 0: pin systray to monitor X */
> +static const unsigned int systrayspacing = 2;   /* systray spacing */
> +static const int systraypinningfailfirst = 1;   /* 1: if pinning fails, 
> display systray on the first monitor, False: display systray on the last 
> monitor*/
> +static const int showsystray= 1; /* 0 means no systray */
>  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" };
>  static const char dmenufont[]   = "monospace:size=10";
> -static const char col_gray1[]   = "#22";
> -static const char col_gray2[]   = "#44";
> -static const char col_gray3[]   = "#bb";
> -static const char col_gray4[]   = "#ee";
> -static const char col_cyan[]= "#005577";
> +static const char col_gray1[]   = "#22A#dd";
> +static const char col_gray2[]   = "#44A#ff";
> +static const char col_gray3[]   = "#bbA#ff";
> +static const char col_gray4[]   = "#eeA#ff";
> +static const char col_cyan[]= "#005577A#dd";
>  static const char *colors[][3]  = {
>   /*   fg bg border   */
>   [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
> diff --git a/config.mk b/config.mk
> index 80dc936..2c62e89 100644
> --- a/config.mk
> +++ b/config.mk
> @@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2
>  
>  # includes and libs
>  INCS = -I${X11INC} -I${FREETYPEINC}
> -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
> +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender
>  
>  # flags
>  CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 
> -DVERSION="${VERSION}\" ${XINERAMAFLAGS}
> diff --git a/drw.c b/drw.c
> index 319eb6b..833e8d1 100644
> --- a/drw.c
> +++ b/drw.c
> @@ -60,6 +60,39 @@ utf8decode(const char *c, long *u, size_t clen)
>   return len;
>  }
>  
> +static void
> +drw_initvisual(Drw *drw, Display *dpy, int screen, Window root)
> +{
> + XVisualInfo *infos;
> + XRenderPictFormat *fmt;
> + int nitems;
> + int i;
> +
> + XVisualInfo tpl = {
> + .screen = screen,
> + .depth = 32,
> + .class = TrueColor
> + };
> + long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
> +
> + infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
> + for(i = 0; i < nitems; i ++) {
> + fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
> + if (fmt-> type == PictTypeDirect && fmt->direct.alphaMask)
> + goto found;
> + }
> +
> + drw-> visual = DefaultVisual(dpy, screen);
> + drw-> depth = DefaultDepth(dpy, screen);
> + drw-> cmap = DefaultColormap(dpy, screen);
> + return;
> +
> +found:
> + drw-> visual = infos[i].visual;
> + drw-> depth = infos[i].depth;
> + drw-> cmap = XCreateColormap(dpy, root, drw->visual, AllocNone);
> +}
> +
>  Drw *
>  drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned 
> int h)
>  {
> @@ -70,8 +103,9 @@ drw_create(Display *dpy, int screen, Window root, unsigned 
> int w, unsigned int h
>   drw-> root = root;
>   drw-> w = w;
>   drw-> h = h;
> - drw-> drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, 
> screen));
> - drw-> gc = XCreateGC(dpy, root, 0, NULL);
> + drw_initvisual(drw, dpy, screen, root);
> + drw-> drawable = XCreatePixmap(dpy, root, w, h, drw->depth);
> + drw-> gc = XCreateGC(dpy, drw->drawable, 0, NULL);
>   XSetLineAttributes(dpy, drw-> gc, 1, LineSolid, CapButt, JoinMiter);
>  
>   return drw;
> @@ -87,7 +121,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
>   drw-> h = h;
>   if (drw-> drawable)
>   XFreePixmap(drw-> dpy, drw->drawable);
> - drw-> drawabl

[dev] [PATCH] systray-alpha patch

2016-12-23 Thread Eon S. Jeon
This patch is a merge b/w systray and alpha.

Additional changes are:
 - create systray->win with apropriate visual and attributes
 - utilize _NET_SYSTEM_TRAY_VISUAL to let tray icon alpha-aware
---
 config.def.h |  14 +-
 config.mk|   2 +-
 drw.c|  59 +++--
 drw.h|   3 +
 dwm.c| 409 +++
 5 files changed, 446 insertions(+), 41 deletions(-)

diff --git a/config.def.h b/config.def.h
index ba9a240..498b5bb 100644
--- a/config.def.h
+++ b/config.def.h
@@ -3,15 +3,19 @@
 /* appearance */
 static const unsigned int borderpx  = 1;/* border pixel of windows */
 static const unsigned int snap  = 32;   /* snap pixel */
+static const unsigned int systraypinning = 0;   /* 0: sloppy systray follows 
selected monitor, >0: pin systray to monitor X */
+static const unsigned int systrayspacing = 2;   /* systray spacing */
+static const int systraypinningfailfirst = 1;   /* 1: if pinning fails, 
display systray on the first monitor, False: display systray on the last 
monitor*/
+static const int showsystray= 1; /* 0 means no systray */
 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" };
 static const char dmenufont[]   = "monospace:size=10";
-static const char col_gray1[]   = "#22";
-static const char col_gray2[]   = "#44";
-static const char col_gray3[]   = "#bb";
-static const char col_gray4[]   = "#ee";
-static const char col_cyan[]= "#005577";
+static const char col_gray1[]   = "#22\0A#dd";
+static const char col_gray2[]   = "#44\0A#ff";
+static const char col_gray3[]   = "#bb\0A#ff";
+static const char col_gray4[]   = "#ee\0A#ff";
+static const char col_cyan[]= "#005577\0A#dd";
 static const char *colors[][3]  = {
/*   fg bg border   */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
diff --git a/config.mk b/config.mk
index 80dc936..2c62e89 100644
--- a/config.mk
+++ b/config.mk
@@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2
 
 # includes and libs
 INCS = -I${X11INC} -I${FREETYPEINC}
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender
 
 # flags
 CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 
-DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff --git a/drw.c b/drw.c
index 319eb6b..833e8d1 100644
--- a/drw.c
+++ b/drw.c
@@ -60,6 +60,39 @@ utf8decode(const char *c, long *u, size_t clen)
return len;
 }
 
+static void
+drw_initvisual(Drw *drw, Display *dpy, int screen, Window root)
+{
+   XVisualInfo *infos;
+   XRenderPictFormat *fmt;
+   int nitems;
+   int i;
+
+   XVisualInfo tpl = {
+   .screen = screen,
+   .depth = 32,
+   .class = TrueColor
+   };
+   long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
+
+   infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
+   for(i = 0; i < nitems; i ++) {
+   fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
+   if (fmt->type == PictTypeDirect && fmt->direct.alphaMask)
+   goto found;
+   }
+
+   drw->visual = DefaultVisual(dpy, screen);
+   drw->depth = DefaultDepth(dpy, screen);
+   drw->cmap = DefaultColormap(dpy, screen);
+   return;
+
+found:
+   drw->visual = infos[i].visual;
+   drw->depth = infos[i].depth;
+   drw->cmap = XCreateColormap(dpy, root, drw->visual, AllocNone);
+}
+
 Drw *
 drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int 
h)
 {
@@ -70,8 +103,9 @@ drw_create(Display *dpy, int screen, Window root, unsigned 
int w, unsigned int h
drw->root = root;
drw->w = w;
drw->h = h;
-   drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, 
screen));
-   drw->gc = XCreateGC(dpy, root, 0, NULL);
+   drw_initvisual(drw, dpy, screen, root);
+   drw->drawable = XCreatePixmap(dpy, root, w, h, drw->depth);
+   drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
 
return drw;
@@ -87,7 +121,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
drw->h = h;
if (drw->drawable)
XFreePixmap(drw->dpy, drw->drawable);
-   drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, 
DefaultDepth(drw->dpy, drw->screen));
+   drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
 }
 
 void
@@ -182,13 +216,24 @@ drw_fontset_free(Fnt *font)
 void
 drw_clr_create(Drw *drw, XftColor *dest, const char *clrname)
 {
+   unsigned long alpha;
+   size_t i;
+
if (!drw || !dest || !clrname)