Re: [hackers] [dwm] [PATCH] decouple color-scheme count from dwm.c

2016-11-11 Thread Markus Teich
Heyho Anselm,

Markus Teich wrote:
> this patch allows for a flexible amount of different colorschemes in config.h
> without having to edit dwm.c as well.

> This patch simplifies the status bar text padding and fixes the comment with a
> wrong description.

I think enough time has passed for others to review those patches. :)

> diff --git a/config.def.h b/config.def.h
> index ba9a240..deb1584 100644
> --- a/config.def.h
> +++ b/config.def.h
> @@ -56,7 +56,13 @@ static const Layout layouts[] = {
>  
>  /* commands */
>  static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in 
> spawn() */
> -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", 
> dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", 
> col_gray4, NULL };
> +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon,
> +   "-fn", dmenufont,
> +   "-nb", col_gray1,
> +   "-nf", col_gray3,
> +   "-sb", col_cyan,
> +   "-sf", col_gray4,
> +   NULL };
>  static const char *termcmd[]  = { "st", NULL };
>  
>  static Key keys[] = {
> -- 
> 2.7.3

> Before this patch when receiving a _NET_ACTIVE_WINDOW event from a window
> which is out of view one of the two altenative views/tagsets gets purged and
> replaced with just the tags where the respective window is visible. For
> example if you have tags [1,2,3] selected in the first view and tags [4,5,6]
> on the second view and are currently on the second one, then when a window on
> tag 7 sends the _NET_ACTIVE_WINDOW event the first view is purged and replaced
> by just tags [7].  To get back to your previous setup you have to re-select
> tags 1-3 and then have the views [1,2,3,7] and [4,5,6] where the new window is
> still on the view you were not using previously, but on the other one.
> 
> After this patch the event sending window just gets set to urgent leaving the
> user the choice when to handle the event. The patch also removes the behavior
> of such windows getting popped to the top of the master area.
> 
> ---
> 
> Here is the version which sets the urgency hint on receiving
> _NET_ACTIVE_WINDOW messages. There is no real "extra code", but a small
> refactoring was needed to stay sane: clearurgent() was renamed to seturgent()
> which takes the value to set the urgency hint to as an extra parameter.
> 
> Also after the patch the window does not get popped to the top of the master
> area anymore, since I thought that was in the same line of intrusiveness.
> 
> This patch even saves 3 SLoC. :)

> Per client resize hints. Since the client struct is always initialized with
> zeroes to preserve behaviour either the meaning has to be reversed
> ("ignorehints"?) or a default rule with class, instance and title set to NULL
> has to be added.

Did you make up your oppinion about these three yet? Please reply in the
original thread if you have more feedback. I just collected all the pending
patches in this one mail to not spam the list by creating a ping for every
single one of them.

--Markus



Re: [hackers] [dwm] [PATCH] decouple color-scheme count from dwm.c

2016-10-27 Thread Anselm R Garbe
On 27 October 2016 at 12:34, Markus Teich  wrote:
> Anselm R Garbe wrote:
>> Why wouldn't dwm just work fine without this change, if editing config.h 
>> would
>> incorporate assigning SchemeLast with a value instead?  Then all the nasty
>> heap allocation would become unnecessary.
>
> that would be the other option I considered. I choose the heap one to reduce
> config.h complexity. You would have to make sure SchemeLast and the size of
> `colors` stay the same manually which is more error prone than letting the 
> code
> figure it out. However if you think that is a better option, I'd adapt the 
> patch
> accordingly.

I prefer requiring SchemeLast = N.

-Anselm



Re: [hackers] [dwm] [PATCH] decouple color-scheme count from dwm.c

2016-10-27 Thread Markus Teich
Anselm R Garbe wrote:
> On 26 October 2016 at 20:30, Markus Teich  wrote:
> > this patch allows for a flexible amount of different colorschemes in
> > config.h without having to edit dwm.c as well. Applying this upstream would
> > help patches like urgentborder and statuscolors with the new drw mechanics.
> > This patch has no benefit to core dwm at all, but since it's an improvement
> > for the ecosystem, you might want to consider merging it to the dwm source.
> 
> Why wouldn't dwm just work fine without this change, if editing config.h would
> incorporate assigning SchemeLast with a value instead?  Then all the nasty
> heap allocation would become unnecessary.

Heyho,

that would be the other option I considered. I choose the heap one to reduce
config.h complexity. You would have to make sure SchemeLast and the size of
`colors` stay the same manually which is more error prone than letting the code
figure it out. However if you think that is a better option, I'd adapt the patch
accordingly.

--Markus



Re: [hackers] [dwm] [PATCH] decouple color-scheme count from dwm.c

2016-10-27 Thread Anselm R Garbe
Hi Markus,

On 26 October 2016 at 20:30, Markus Teich  wrote:
> this patch allows for a flexible amount of different colorschemes in config.h
> without having to edit dwm.c as well. Applying this upstream would help 
> patches
> like urgentborder and statuscolors with the new drw mechanics. This patch has 
> no
> benefit to core dwm at all, but since it's an improvement for the ecosystem, 
> you
> might want to consider merging it to the dwm source.

Why wouldn't dwm just work fine without this change, if editing
config.h would incorporate assigning SchemeLast with a value instead?
Then all the nasty heap allocation would become unnecessary.

Cheers,
Anselm



[hackers] [dwm] [PATCH] decouple color-scheme count from dwm.c

2016-10-26 Thread Markus Teich
---


Heyho,

this patch allows for a flexible amount of different colorschemes in config.h
without having to edit dwm.c as well. Applying this upstream would help patches
like urgentborder and statuscolors with the new drw mechanics. This patch has no
benefit to core dwm at all, but since it's an improvement for the ecosystem, you
might want to consider merging it to the dwm source.

--Markus


 config.def.h |  2 +-
 dwm.c| 12 +++-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/config.def.h b/config.def.h
index fd77a07..ba9a240 100644
--- a/config.def.h
+++ b/config.def.h
@@ -12,7 +12,7 @@ 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]  = {
+static const char *colors[][3]  = {
/*   fg bg border   */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] =  { col_gray4, col_cyan,  col_cyan  },
diff --git a/dwm.c b/dwm.c
index 421bf27..25ef526 100644
--- a/dwm.c
+++ b/dwm.c
@@ -60,7 +60,7 @@
 
 /* enums */
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */
+enum { SchemeNorm, SchemeSel }; /* color schemes */
 enum { NetSupported, NetWMName, NetWMState,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -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[SchemeLast];
+static Scm *scheme;
 static Display *dpy;
 static Drw *drw;
 static Monitor *mons, *selmon;
@@ -483,7 +483,7 @@ cleanup(void)
cleanupmon(mons);
for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]);
-   for (i = 0; i < SchemeLast; i++)
+   for (i = 0; i < LENGTH(colors); i++)
free(scheme[i]);
drw_free(drw);
XSync(dpy, False);
@@ -1549,6 +1549,7 @@ setmfact(const Arg *arg)
 void
 setup(void)
 {
+   int i;
XSetWindowAttributes wa;
 
/* clean up any zombies immediately */
@@ -1583,8 +1584,9 @@ setup(void)
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
-   scheme[SchemeNorm] = drw_scm_create(drw, colors[SchemeNorm], 3);
-   scheme[SchemeSel] = drw_scm_create(drw, colors[SchemeSel], 3);
+   scheme = ecalloc(LENGTH(colors), sizeof(Scm));
+   for (i = 0; i < LENGTH(colors); i++)
+   scheme[i] = drw_scm_create(drw, colors[i], 3);
/* init bars */
updatebars();
updatestatus();
-- 
2.7.3