Re: [hackers] [dmenu] [PATCH] Set class name on menu window

2017-11-03 Thread Devin J. Pohly
On Thu, Nov 02, 2017 at 10:03:19PM -0700, Omar Sandoval wrote:
> On Fri, Nov 03, 2017 at 12:15:55AM +0100, Hiltjo Posthuma wrote:
> > 
> > Then it should be changed/fixed in (your local) compton. Then all 
> > applications
> > can benefit and all the applications don't need to be patched.
> > 
> > There are too many _NET_WM_CRAP already.
> 
> It's not a matter of changing compton. There's just no way to identify
> dmenu windows because dmenu doesn't set any window properties. WM_CLASS
> is a standard ICCCM property that almost every X application sets
> (including st). _NET_WM_PID is a red herring; I just pointed it out
> because it _could_ be used to find the process name like you suggested,
> but dmenu doesn't set it and WM_CLASS is the normal way to do it
> anyways.
> 

I'm inclined to agree with Omar here - WM_CLASS is a venerable X
standard, not late-coming cruft from the _NET_WM crowd.  I remember
having been surprised that dmenu didn't set it.

Other suckless and suckless-like programs set this hint (st, tabbed,
sent, dzen2) and process it (dwm).

If it makes things better, this could be reduced to two lines:

XClassHints ch = {"dmenu", "dmenu"};
XSetClassHint(dpy, win, &ch);

*dp

-- 
<><



[hackers] [dmenu][PATCH v2] Set class name on menu window

2017-11-03 Thread Omar Sandoval
WM_CLASS is a standard ICCCM property which is used to identify windows.
Window managers and compositors use it to allow per-application
configurable behavior.
---
Thanks, Devin, that's much cleaner.

 dmenu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/dmenu.c b/dmenu.c
index d605ab4..85e5060 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -545,6 +545,7 @@ setup(void)
XIM xim;
Window w, dw, *dws;
XWindowAttributes wa;
+   XClassHint ch = {"dmenu", "dmenu"};
 #ifdef XINERAMA
XineramaScreenInfo *info;
Window pw;
@@ -613,6 +614,7 @@ setup(void)
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
CopyFromParent, CopyFromParent, CopyFromParent,
CWOverrideRedirect | CWBackPixel | CWEventMask, 
&swa);
+   XSetClassHint(dpy, win, &ch);
 
/* open input methods */
xim = XOpenIM(dpy, NULL, NULL, NULL);
-- 
2.15.0




[hackers] [dwm] [PATCH v3] Set class name on status bar

2017-11-03 Thread Omar Sandoval
This is useful for configuring compositors to ignore the status bar
window.
---
As Devin pointed out in the dmenu thread, there's no reason to
dynamically allocate ch at all.

 dwm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/dwm.c b/dwm.c
index 4782343..b0d99c0 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1809,6 +1809,7 @@ updatebars(void)
.background_pixmap = ParentRelative,
.event_mask = ButtonPressMask|ExposureMask
};
+   XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) {
if (m->barwin)
continue;
@@ -1817,6 +1818,7 @@ updatebars(void)
CWOverrideRedirect|CWBackPixmap|CWEventMask, 
&wa);
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
XMapRaised(dpy, m->barwin);
+   XSetClassHint(dpy, m->barwin, &ch);
}
 }
 
-- 
2.15.0




Re: [hackers] [dwm] [PATCH v3] Set class name on status bar

2017-11-03 Thread Hiltjo Posthuma
On Fri, Nov 03, 2017 at 09:58:38AM -0700, Omar Sandoval wrote:
> This is useful for configuring compositors to ignore the status bar
> window.
> ---
> As Devin pointed out in the dmenu thread, there's no reason to
> dynamically allocate ch at all.
> 
>  dwm.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/dwm.c b/dwm.c
> index 4782343..b0d99c0 100644
> --- a/dwm.c
> +++ b/dwm.c
> @@ -1809,6 +1809,7 @@ updatebars(void)
>   .background_pixmap = ParentRelative,
>   .event_mask = ButtonPressMask|ExposureMask
>   };
> + XClassHint ch = {"dwm", "dwm"};
>   for (m = mons; m; m = m->next) {
>   if (m->barwin)
>   continue;
> @@ -1817,6 +1818,7 @@ updatebars(void)
>   CWOverrideRedirect|CWBackPixmap|CWEventMask, 
> &wa);
>   XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
>   XMapRaised(dpy, m->barwin);
> + XSetClassHint(dpy, m->barwin, &ch);
>   }
>  }
>  
> -- 
> 2.15.0
> 
> 

Thanks!, I'll apply it for dwm and dmenu soon :)

-- 
Kind regards,
Hiltjo



[hackers] [dwm] Set class name on status bar || Omar Sandoval

2017-11-03 Thread git
commit a9b6a312a77b9cc81ca8b08a95c09e9f7948d7a6
Author: Omar Sandoval 
AuthorDate: Fri Nov 3 09:58:38 2017 -0700
Commit: Hiltjo Posthuma 
CommitDate: Fri Nov 3 20:40:34 2017 +0100

Set class name on status bar

This is useful for configuring compositors to ignore the status bar
window.

diff --git a/dwm.c b/dwm.c
index 4782343..b0d99c0 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1809,6 +1809,7 @@ updatebars(void)
.background_pixmap = ParentRelative,
.event_mask = ButtonPressMask|ExposureMask
};
+   XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) {
if (m->barwin)
continue;
@@ -1817,6 +1818,7 @@ updatebars(void)
CWOverrideRedirect|CWBackPixmap|CWEventMask, 
&wa);
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
XMapRaised(dpy, m->barwin);
+   XSetClassHint(dpy, m->barwin, &ch);
}
 }
 



[hackers] [dmenu] Set class name on menu window || Omar Sandoval

2017-11-03 Thread git
commit 64ab2801fbbbcc028c359080ae4bd546fc871f67
Author: Omar Sandoval 
AuthorDate: Fri Nov 3 09:49:10 2017 -0700
Commit: Hiltjo Posthuma 
CommitDate: Fri Nov 3 20:41:03 2017 +0100

Set class name on menu window

WM_CLASS is a standard ICCCM property which is used to identify windows.
Window managers and compositors use it to allow per-application
configurable behavior.

diff --git a/dmenu.c b/dmenu.c
index d605ab4..85e5060 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -545,6 +545,7 @@ setup(void)
XIM xim;
Window w, dw, *dws;
XWindowAttributes wa;
+   XClassHint ch = {"dmenu", "dmenu"};
 #ifdef XINERAMA
XineramaScreenInfo *info;
Window pw;
@@ -613,6 +614,7 @@ setup(void)
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
CopyFromParent, CopyFromParent, CopyFromParent,
CWOverrideRedirect | CWBackPixel | CWEventMask, 
&swa);
+   XSetClassHint(dpy, win, &ch);
 
/* open input methods */
xim = XOpenIM(dpy, NULL, NULL, NULL);



Re: [hackers] [dmenu][PATCH v2] Set class name on menu window

2017-11-03 Thread Hiltjo Posthuma
On Fri, Nov 03, 2017 at 09:49:10AM -0700, Omar Sandoval wrote:
> WM_CLASS is a standard ICCCM property which is used to identify windows.
> Window managers and compositors use it to allow per-application
> configurable behavior.
> ---
> Thanks, Devin, that's much cleaner.
> 
>  dmenu.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/dmenu.c b/dmenu.c
> index d605ab4..85e5060 100644
> --- a/dmenu.c
> +++ b/dmenu.c
> @@ -545,6 +545,7 @@ setup(void)
>   XIM xim;
>   Window w, dw, *dws;
>   XWindowAttributes wa;
> + XClassHint ch = {"dmenu", "dmenu"};
>  #ifdef XINERAMA
>   XineramaScreenInfo *info;
>   Window pw;
> @@ -613,6 +614,7 @@ setup(void)
>   win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
>   CopyFromParent, CopyFromParent, CopyFromParent,
>   CWOverrideRedirect | CWBackPixel | CWEventMask, 
> &swa);
> + XSetClassHint(dpy, win, &ch);
>  
>   /* open input methods */
>   xim = XOpenIM(dpy, NULL, NULL, NULL);
> -- 
> 2.15.0
> 
> 

Awesome! Applied.

Thanks Omar and Devin!

-- 
Kind regards,
Hiltjo



[hackers] [dmenu] init colors using SchemeLast || Hiltjo Posthuma

2017-11-03 Thread git
commit 41379f7c39e6aa0a17d7807b22b49ea148f5b0fa
Author: Hiltjo Posthuma 
AuthorDate: Fri Nov 3 21:05:29 2017 +0100
Commit: Hiltjo Posthuma 
CommitDate: Fri Nov 3 21:05:29 2017 +0100

init colors using SchemeLast

this makes it slightly easier to add colors to schemes.

diff --git a/dmenu.c b/dmenu.c
index 85e5060..91330f1 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -553,9 +553,8 @@ setup(void)
 #endif
 
/* init appearance */
-   scheme[SchemeNorm] = drw_scm_create(drw, colors[SchemeNorm], 2);
-   scheme[SchemeSel] = drw_scm_create(drw, colors[SchemeSel], 2);
-   scheme[SchemeOut] = drw_scm_create(drw, colors[SchemeOut], 2);
+   for (j = 0; j < SchemeLast; j++)
+   scheme[j] = drw_scm_create(drw, colors[j], 2);
 
clip = XInternAtom(dpy, "CLIPBOARD",   False);
utf8 = XInternAtom(dpy, "UTF8_STRING", False);



[hackers] [dmenu] fix a possible free of a uninitialize variable in paste() || Hiltjo Posthuma

2017-11-03 Thread git
commit 1cabeda5505dcc35d4d2ca2a09151a7c449fb401
Author: Hiltjo Posthuma 
AuthorDate: Fri Nov 3 15:31:37 2017 +0100
Commit: Hiltjo Posthuma 
CommitDate: Fri Nov 3 21:07:02 2017 +0100

fix a possible free of a uninitialize variable in paste()

diff --git a/dmenu.c b/dmenu.c
index 91330f1..eae5685 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -467,10 +467,12 @@ paste(void)
Atom da;
 
/* we have been given the current selection, now insert it into input */
-   XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
-  utf8, &da, &di, &dl, &dl, (unsigned char **)&p);
-   insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
-   XFree(p);
+   if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
+  utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
+   == Success && p) {
+   insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
+   XFree(p);
+   }
drawmenu();
 }
 



[hackers] [dmenu] drw: drw_scm_create: use Clr type || Hiltjo Posthuma

2017-11-03 Thread git
commit f0a5b75d6a0d2a62da45e9f65d92ea4a6a2d5831
Author: Hiltjo Posthuma 
AuthorDate: Fri Nov 3 21:10:38 2017 +0100
Commit: Hiltjo Posthuma 
CommitDate: Fri Nov 3 21:10:38 2017 +0100

drw: drw_scm_create: use Clr type

in this context XftColor is a too low-level type.

diff --git a/drw.c b/drw.c
index c1582e7..c638323 100644
--- a/drw.c
+++ b/drw.c
@@ -200,7 +200,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t 
clrcount)
Clr *ret;
 
/* need at least two colors for a scheme */
-   if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, 
sizeof(XftColor
+   if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, 
sizeof(Clr
return NULL;
 
for (i = 0; i < clrcount; i++)



[hackers] [dwm] sync dmenu drw.{c,h} code: use Clr* (was Scm) || Hiltjo Posthuma

2017-11-03 Thread git
commit 3756f7f6b8dccf7a31789ffaf073a76fd1a87eb9
Author: Hiltjo Posthuma 
AuthorDate: Fri Nov 3 21:20:48 2017 +0100
Commit: Hiltjo Posthuma 
CommitDate: Fri Nov 3 21:20:48 2017 +0100

sync dmenu drw.{c,h} code: use Clr* (was Scm)

diff --git a/drw.c b/drw.c
index 319eb6b..c638323 100644
--- a/drw.c
+++ b/drw.c
@@ -180,7 +180,7 @@ drw_fontset_free(Fnt *font)
 }
 
 void
-drw_clr_create(Drw *drw, XftColor *dest, const char *clrname)
+drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
 {
if (!drw || !dest || !clrname)
return;
@@ -193,14 +193,14 @@ drw_clr_create(Drw *drw, XftColor *dest, const char 
*clrname)
 
 /* Wrapper to create color schemes. The caller has to call free(3) on the
  * returned color scheme when done using it. */
-Scm
+Clr *
 drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
 {
size_t i;
-   Scm ret;
+   Clr *ret;
 
/* need at least two colors for a scheme */
-   if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, 
sizeof(XftColor
+   if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, 
sizeof(Clr
return NULL;
 
for (i = 0; i < clrcount; i++)
@@ -216,7 +216,7 @@ drw_setfontset(Drw *drw, Fnt *set)
 }
 
 void
-drw_setscheme(Drw *drw, Scm scm)
+drw_setscheme(Drw *drw, Clr *scm)
 {
if (drw)
drw->scheme = scm;
diff --git a/drw.h b/drw.h
index ff4355b..4c67419 100644
--- a/drw.h
+++ b/drw.h
@@ -12,8 +12,8 @@ typedef struct Fnt {
struct Fnt *next;
 } Fnt;
 
-enum { ColFg, ColBg, ColCount }; /* Scm index */
-typedef XftColor *Scm;
+enum { ColFg, ColBg }; /* Clr scheme index */
+typedef XftColor Clr;
 
 typedef struct {
unsigned int w, h;
@@ -22,7 +22,7 @@ typedef struct {
Window root;
Drawable drawable;
GC gc;
-   Scm scheme;
+   Clr *scheme;
Fnt *fonts;
 } Drw;
 
@@ -38,8 +38,8 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
 void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned 
int *w, unsigned int *h);
 
 /* Colorscheme abstraction */
-void drw_clr_create(Drw *drw, XftColor *dest, const char *clrname);
-Scm drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
+void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
+Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
 
 /* Cursor abstraction */
 Cur *drw_cur_create(Drw *drw, int shape);
@@ -47,7 +47,7 @@ void drw_cur_free(Drw *drw, Cur *cursor);
 
 /* Drawing context manipulation */
 void drw_setfontset(Drw *drw, Fnt *set);
-void drw_setscheme(Drw *drw, Scm scm);
+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);
diff --git a/dwm.c b/dwm.c
index 650d19f..ff893df 100644
--- a/dwm.c
+++ b/dwm.c
@@ -263,7 +263,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
 static Atom wmatom[WMLast], netatom[NetLast];
 static int running = 1;
 static Cur *cursor[CurLast];
-static Scm *scheme;
+static Clr **scheme;
 static Display *dpy;
 static Drw *drw;
 static Monitor *mons, *selmon;
@@ -1568,7 +1568,7 @@ setup(void)
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
-   scheme = ecalloc(LENGTH(colors), sizeof(Scm));
+   scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i], 3);
/* init bars */



[hackers] [dwm] gettextprop: check result of XGetTextProperty (undefined behaviour for XFree) || Hiltjo Posthuma

2017-11-03 Thread git
commit 99f78fa553f9ddb23fab73e47a408d66ca7f974c
Author: Hiltjo Posthuma 
AuthorDate: Fri Nov 3 16:36:32 2017 +0100
Commit: Hiltjo Posthuma 
CommitDate: Fri Nov 3 21:14:58 2017 +0100

gettextprop: check result of XGetTextProperty (undefined behaviour for 
XFree)

diff --git a/dwm.c b/dwm.c
index b0d99c0..650d19f 100644
--- a/dwm.c
+++ b/dwm.c
@@ -910,8 +910,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int 
size)
if (!text || size == 0)
return 0;
text[0] = '\0';
-   XGetTextProperty(dpy, w, &name, atom);
-   if (!name.nitems)
+   if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems)
return 0;
if (name.encoding == XA_STRING)
strncpy(text, (char *)name.value, size - 1);



Re: [hackers] [dmenu][PATCH v2] Set class name on menu window

2017-11-03 Thread Omar Sandoval
On Fri, Nov 03, 2017 at 08:44:14PM +0100, Hiltjo Posthuma wrote:
> On Fri, Nov 03, 2017 at 09:49:10AM -0700, Omar Sandoval wrote:
> > WM_CLASS is a standard ICCCM property which is used to identify windows.
> > Window managers and compositors use it to allow per-application
> > configurable behavior.
> > ---
> > Thanks, Devin, that's much cleaner.
> > 
> >  dmenu.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/dmenu.c b/dmenu.c
> > index d605ab4..85e5060 100644
> > --- a/dmenu.c
> > +++ b/dmenu.c
> > @@ -545,6 +545,7 @@ setup(void)
> > XIM xim;
> > Window w, dw, *dws;
> > XWindowAttributes wa;
> > +   XClassHint ch = {"dmenu", "dmenu"};
> >  #ifdef XINERAMA
> > XineramaScreenInfo *info;
> > Window pw;
> > @@ -613,6 +614,7 @@ setup(void)
> > win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
> > CopyFromParent, CopyFromParent, CopyFromParent,
> > CWOverrideRedirect | CWBackPixel | CWEventMask, 
> > &swa);
> > +   XSetClassHint(dpy, win, &ch);
> >  
> > /* open input methods */
> > xim = XOpenIM(dpy, NULL, NULL, NULL);
> > -- 
> > 2.15.0
> > 
> > 
> 
> Awesome! Applied.
> 
> Thanks Omar and Devin!

Thanks, Hiltjo, I appreciate it!



Re: [hackers] [st][PATCH] in bracketed paste mode, filter escapes from pasted data

2017-11-03 Thread Eric Pruitt
On Fri, Nov 03, 2017 at 12:14:46AM +0100, Laslo Hunhold wrote:
> However, as it has already been laid out numerous times, we can not
> accept companies to be in the list of contributors, only people. If
> you are interested in the reasons, I can lay them out again, but
> admittedly I think they are pretty obvious.

I think most open source projects are happy to accept contributions from
corporate entities, so I doubt this is obvious especially if you don't
regularly read the suckless.org mailing lists. Rather than rehashing the
issue "numerous times", you should update the website. The community
page (https://suckless.org/community) is probably the right place.

Eric