[hackers] [dwm] [PATCH] don't purge tagset of alternative view on _NET_ACTIVE_WINDOW event

2016-10-27 Thread Markus Teich
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.
---


Heyho Anselm,

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. :)

--Markus


 dwm.c | 37 +
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/dwm.c b/dwm.c
index 1d57971..0afd630 100644
--- a/dwm.c
+++ b/dwm.c
@@ -154,7 +154,6 @@ static void buttonpress(XEvent *e);
 static void checkotherwm(void);
 static void cleanup(void);
 static void cleanupmon(Monitor *mon);
-static void clearurgent(Client *c);
 static void clientmessage(XEvent *e);
 static void configure(Client *c);
 static void configurenotify(XEvent *e);
@@ -205,6 +204,7 @@ static void setfullscreen(Client *c, int fullscreen);
 static void setlayout(const Arg *arg);
 static void setmfact(const Arg *arg);
 static void setup(void);
+static void seturgent(Client *c, int urg);
 static void showhide(Client *c);
 static void sigchld(int unused);
 static void spawn(const Arg *arg);
@@ -510,19 +510,6 @@ cleanupmon(Monitor *mon)
 }
 
 void
-clearurgent(Client *c)
-{
-   XWMHints *wmh;
-
-   c->isurgent = 0;
-   if (!(wmh = XGetWMHints(dpy, c->win)))
-   return;
-   wmh->flags &= ~XUrgencyHint;
-   XSetWMHints(dpy, c->win, wmh);
-   XFree(wmh);
-}
-
-void
 clientmessage(XEvent *e)
 {
XClientMessageEvent *cme = &e->xclient;
@@ -535,11 +522,8 @@ clientmessage(XEvent *e)
setfullscreen(c, (cme->data.l[0] == 1 /* 
_NET_WM_STATE_ADD*/
  || (cme->data.l[0] == 2 /* 
_NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
} else if (cme->message_type == netatom[NetActiveWindow]) {
-   if (!ISVISIBLE(c)) {
-   c->mon->seltags ^= 1;
-   c->mon->tagset[c->mon->seltags] = c->tags;
-   }
-   pop(c);
+   if (c != selmon->sel && !c->isurgent)
+   seturgent(c, 1);
}
 }
 
@@ -807,7 +791,7 @@ focus(Client *c)
if (c->mon != selmon)
selmon = c->mon;
if (c->isurgent)
-   clearurgent(c);
+   seturgent(c, 0);
detachstack(c);
attachstack(c);
grabbuttons(c, 1);
@@ -1607,6 +1591,19 @@ setup(void)
 }
 
 void
+seturgent(Client *c, int urg)
+{
+   XWMHints *wmh;
+
+   c->isurgent = urg;
+   if (!(wmh = XGetWMHints(dpy, c->win)))
+   return;
+   wmh->flags = urg ? (wmh->flags | XUrgencyHint) : (wmh->flags & 
~XUrgencyHint);
+   XSetWMHints(dpy, c->win, wmh);
+   XFree(wmh);
+}
+
+void
 showhide(Client *c)
 {
if (!c)
-- 
2.7.3




[hackers] [dwm] [PATCH] per client resizehints

2016-10-27 Thread Markus Teich
---


Heyho Anselm,

here you go. 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.

--Markus


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

diff --git a/config.def.h b/config.def.h
index deb1584..175ab7f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,15 +26,14 @@ static const Rule rules[] = {
 *  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 },
+   /* class  instancetitle   tags mask isfloating   
resizehints   monitor */
+   { "Gimp", NULL,   NULL,   0,1,   1, 
   -1 },
+   { "Firefox",  NULL,   NULL,   1 << 8,   0,   1, 
   -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 = 1;/* 1 means respect size hints in tiled 
resizals */
 
 static const Layout layouts[] = {
/* symbol arrange function */
diff --git a/dwm.c b/dwm.c
index ab448a3..5cd7609 100644
--- a/dwm.c
+++ b/dwm.c
@@ -93,7 +93,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
-   int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+   int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, 
resizehints;
Client *next;
Client *snext;
Monitor *mon;
@@ -139,6 +139,7 @@ typedef struct {
const char *title;
unsigned int tags;
int isfloating;
+   int resizehints;
int monitor;
 } Rule;
 
@@ -299,6 +300,7 @@ applyrules(Client *c)
&& (!r->instance || strstr(instance, r->instance)))
{
c->isfloating = r->isfloating;
+   c->resizehints = r->resizehints;
c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
@@ -344,7 +346,7 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, 
int interact)
*h = bh;
if (*w < bh)
*w = bh;
-   if (resizehints || c->isfloating || 
!c->mon->lt[c->mon->sellt]->arrange) {
+   if (c->resizehints || c->isfloating || 
!c->mon->lt[c->mon->sellt]->arrange) {
/* see last two sentences in ICCCM 4.1.2.3 */
baseismin = c->basew == c->minw && c->baseh == c->minh;
if (!baseismin) { /* temporarily remove base dimensions */
-- 
2.7.3




Re: [hackers] More dwm patches

2016-10-27 Thread Martin Kühne
Run conway's game of life as your wallpaper [0].
make; ./life2d -r --conway

cheers!
mar77i

[0] https://github.com/mar77i/xdemos



Re: [hackers] More dwm patches

2016-10-27 Thread ssd
> A wallpaper can help change your mood.

to better and worse.



Re: [hackers] [dwm] [PATCH] don't purge tagset of alternative view on _NET_ACTIVE_WINDOW event

2016-10-27 Thread Anselm R Garbe
On 27 October 2016 at 13:29, Markus Teich  wrote:
> I just came up with an even less intrusive behavior: Instead of additionally
> selecting the respective tag, just set the urgency hint on the client and let
> the user decide when to handle it. This approach goes in the direction that 
> the
> user might not want clients to control window management.

I prefer this suggestion, if it doesn't introduce extra code.

Cheers,
Anselm



Re: [hackers] More dwm patches

2016-10-27 Thread Ali H. Fardan

On 2016-10-27 11:54, Anselm R Garbe wrote:

Doesn't sound useful to me. Wallpaper fetishists should keep using OSX.

-Anselm


A wallpaper can help change your mood.

---
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments



Re: [hackers] [dwm] [PATCH] get rid of unnecessary ternary operator

2016-10-27 Thread Anselm R Garbe
On 27 October 2016 at 12:46, Markus Teich  wrote:
> Anselm R Garbe wrote:
>> To me ! is logical NOT and your suggestion relies on the fact that
>> XUrgencyHint is a single bit flag? no?
>>
>> I prefer the original code, as it doesn't use side effects of logical NOTs.
>
> The `(wmh->flags & XUrgencyHint)` is used as a bool value regardless. 
> Basically
> `test_exp ? 1 : 0` seemed stupid to me. The double negation achieves the same
> thing as having the `? 1 : 0` (normalizing the output). However your argument
> with using the side effects of ! are valid, so leave it as it is.

Exactly, I prefer the original version.

Cheers,
Anselm



Re: [hackers] [dwm] [PATCH] clarify status text padding

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

On 27 October 2016 at 12:26, Markus Teich  wrote:
> now I have. As expected an like before the patch the status bar text gets
> overwritten by the tag names. This patch should not introduce new behavior at
> all.

OK, I will accept this patch.

-Anselm



Re: [hackers] More dwm patches

2016-10-27 Thread Anselm R Garbe
On 27 October 2016 at 13:24, Markus Teich  wrote:
> - resizehints per client (+1 SLoC): Some old version of mplayer "forced" me to
>   write this. I don't know if this is still a problem, but the patch might be
>   usefull regardless.

Show me.

> - allow no tags to be selected (approx +1 SLoC): This one might be confusing 
> to
>   new users because there is no tag selected on startup and even after 
> opening a
>   terminal window they still have to select the tag that it is opened on. 
> Might
>   be useful for wallpaper fetishists who don't want to have a designated
>   wallpaper tag where they never open any window.

Doesn't sound useful to me. Wallpaper fetishists should keep using OSX.

-Anselm



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] don't purge tagset of alternative view on _NET_ACTIVE_WINDOW event

2016-10-27 Thread Markus Teich
Markus Teich wrote:
> After this patch the tags of the event sending window get just added to the
> current view directly leading to views [1,2,3] and [4,5,6,7] without any
> further user interaction.

Heyho,

I just came up with an even less intrusive behavior: Instead of additionally
selecting the respective tag, just set the urgency hint on the client and let
the user decide when to handle it. This approach goes in the direction that the
user might not want clients to control window management.

--Markus



[hackers] More dwm patches

2016-10-27 Thread Markus Teich
Heyho,

I am currently updating my patch queue and I have some more patches in there
which might be considered for mainline dwm. If they are not accepted, I'll just
push them to the wiki when done.

- resizehints per client (+1 SLoC): Some old version of mplayer "forced" me to
  write this. I don't know if this is still a problem, but the patch might be
  usefull regardless.

- allow no tags to be selected (approx +1 SLoC): This one might be confusing to
  new users because there is no tag selected on startup and even after opening a
  terminal window they still have to select the tag that it is opened on. Might
  be useful for wallpaper fetishists who don't want to have a designated
  wallpaper tag where they never open any window.

Let me know what you think.

--Markus



[hackers] [dwm] [PATCH] don't purge tagset of alternative view on _NET_ACTIVE_WINDOW event

2016-10-27 Thread Markus Teich
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 tags of the event sending window get just added to the
current view directly leading to views [1,2,3] and [4,5,6,7] without any further
user interaction.
---
 dwm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/dwm.c b/dwm.c
index 85ec75e..ab448a3 100644
--- a/dwm.c
+++ b/dwm.c
@@ -534,8 +534,7 @@ clientmessage(XEvent *e)
  || (cme->data.l[0] == 2 /* 
_NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
} else if (cme->message_type == netatom[NetActiveWindow]) {
if (!ISVISIBLE(c)) {
-   c->mon->seltags ^= 1;
-   c->mon->tagset[c->mon->seltags] = c->tags;
+   c->mon->tagset[c->mon->seltags] |= c->tags;
}
pop(c);
}
-- 
2.7.3




Re: [hackers] [dwm] [PATCH] break up long config line

2016-10-27 Thread Markus Teich
Anselm R Garbe wrote:
> Why, are you entering command line options also on separate lines?

Heyho Anselm,

Nope, but my command line input mostly is way shorter, because I don't have to
enter a declaration in front of it and if I have such a special case like color
schemes, I tend to put them away in a "config" file, e.g. creating an alias in
`.mkshrc`. In the rare cases where I have complex and long arguments, yes indeed
I enter them on the same line, and that's a mess. ;)

--Markus



Re: [hackers] [dwm] [PATCH] get rid of unnecessary ternary operator

2016-10-27 Thread Markus Teich
Anselm R Garbe wrote:
> To me ! is logical NOT and your suggestion relies on the fact that
> XUrgencyHint is a single bit flag? no?
> 
> I prefer the original code, as it doesn't use side effects of logical NOTs.

Heyho Anselm,

The `(wmh->flags & XUrgencyHint)` is used as a bool value regardless. Basically
`test_exp ? 1 : 0` seemed stupid to me. The double negation achieves the same
thing as having the `? 1 : 0` (normalizing the output). However your argument
with using the side effects of ! are valid, so leave it as it is.

--Markus



Re: [hackers] [dwm] [PATCH] get rid of unnecessary ternary operator

2016-10-27 Thread Laslo Hunhold
On Thu, 27 Oct 2016 10:02:32 +0200
Anselm R Garbe  wrote:

Hey Anselm,

> To me ! is logical NOT and your suggestion relies on the fact that
> XUrgencyHint is a single bit flag? no?
> I prefer the original code, as it doesn't use side effects of logical
> NOTs.

this is exactly what was checked with the ternary operator. The
bitmask-result is also "so to say" casted to a boolean value, and
!! is inverse-idempotent on booleans, which means that we are save
here. I prefer Markus' approach, but it's your decision as a maintainer.

Cheers

Laslo

-- 
Laslo Hunhold 



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] clarify status text padding

2016-10-27 Thread Markus Teich
Anselm R Garbe wrote:
> On 26 October 2016 at 22:42, Markus Teich  wrote:
> > This patch simplifies the status bar text padding and fixes the comment with
> > a wrong description.
> 
> Have you tested this with long tag names?

Heyho Anselm,

now I have. As expected an like before the patch the status bar text gets
overwritten by the tag names. This patch should not introduce new behavior at
all.

--Markus



Re: [hackers] [dwm] [PATCH] break up long config line

2016-10-27 Thread Anselm R Garbe
Why, are you entering command line options also on separate lines?

On 27 October 2016 at 01:42, Markus Teich  wrote:
> ---
>  config.def.h | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> 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
>
>



Re: [hackers] [dwm] [PATCH] get rid of unnecessary ternary operator

2016-10-27 Thread Anselm R Garbe
To me ! is logical NOT and your suggestion relies on the fact that
XUrgencyHint is a single bit flag? no?

I prefer the original code, as it doesn't use side effects of logical NOTs.

-Anselm

On 27 October 2016 at 01:40, Markus Teich  wrote:
> ---
>  dwm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/dwm.c b/dwm.c
> index 3d6cc28..85ec75e 100644
> --- a/dwm.c
> +++ b/dwm.c
> @@ -2020,7 +2020,7 @@ updatewmhints(Client *c)
> wmh->flags &= ~XUrgencyHint;
> XSetWMHints(dpy, c->win, wmh);
> } else
> -   c->isurgent = (wmh->flags & XUrgencyHint) ? 1 : 0;
> +   c->isurgent = !!(wmh->flags & XUrgencyHint);
> if (wmh->flags & InputHint)
> c->neverfocus = !wmh->input;
> else
> --
> 2.7.3
>
>



Re: [hackers] [dwm] [PATCH] clarify status text padding

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

On 26 October 2016 at 22:42, Markus Teich  wrote:
> This patch simplifies the status bar text padding and fixes the comment with a
> wrong description.

Have you tested this with long tag names?

-Anselm



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