[patch] cwm: tile only within active monitor

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] cwm: tile only within active monitor

Charles A Daniels
Hi all,

I'm new around here, so apologies in advance if I miss something
obvious.

I have written a patch to cwm so that the htile/vtile functionality
only affect windows within the same monitor as the active window. For
single monitor setups, this will have no effect. For multi-monitor
setups, this will allow multiple different monitors to have windows
tiled independently from one another (within the same group).

This is implemented by modifying the relevant checks to ignore any
clients (ci) where the client is outside of the area of the current
display as returned by screen_area() (ci->geom not within area).

Testing and feedback are welcome and appreciated!

Regards,

~ Charles

P.S. I would be curious to heard about others' development workflows
for window managers. I've been compiling cwm, copying it to
/usr/X11R6/bin, logging out, and logging back in. This is really un-
ergonomic, and I'd like to have a better setup, but I've never
developed a window manager before so I'm unsure how to improve.

diff --git a/client.c.orig b/client.c
index 27658e6..05e18ab 100644
--- a/client.c.orig
+++ b/client.c
@@ -986,19 +986,23 @@ client_htile(struct client_ctx *cc)
  return;
  i = n = 0;
 
+ area = screen_area(sc,
+    cc->geom.x + cc->geom.w / 2,
+    cc->geom.y + cc->geom.h / 2, CWM_GAP);
+
  TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
  if (ci->flags & CLIENT_HIDDEN ||
-    ci->flags & CLIENT_IGNORE || (ci == cc))
+    ci->flags & CLIENT_IGNORE || (ci == cc) ||
+    ci->geom.x < area.x ||
+    ci->geom.x > (area.x + area.w) ||
+    ci->geom.y < area.y ||
+    ci->geom.y > (area.y + area.h))
  continue;
  n++;
  }
  if (n == 0)
  return;
 
- area = screen_area(sc,
-    cc->geom.x + cc->geom.w / 2,
-    cc->geom.y + cc->geom.h / 2, CWM_GAP);
-
  if (cc->flags & CLIENT_VMAXIMIZED ||
     cc->geom.h + (cc->bwidth * 2) >= area.h)
  return;
@@ -1017,7 +1021,11 @@ client_htile(struct client_ctx *cc)
  h = area.h - mh;
  TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
  if (ci->flags & CLIENT_HIDDEN ||
-    ci->flags & CLIENT_IGNORE || (ci == cc))
+    ci->flags & CLIENT_IGNORE || (ci == cc) ||
+    ci->geom.x < area.x ||
+    ci->geom.x > (area.x + area.w) ||
+    ci->geom.y < area.y ||
+    ci->geom.y > (area.y + area.h))
  continue;
  ci->bwidth = Conf.bwidth;
  ci->geom.x = x;
@@ -1044,21 +1052,26 @@ client_vtile(struct client_ctx *cc)
 
  if (!gc)
  return;
+
+ area = screen_area(sc,
+    cc->geom.x + cc->geom.w / 2,
+    cc->geom.y + cc->geom.h / 2, CWM_GAP);
+
  i = n = 0;
 
  TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
  if (ci->flags & CLIENT_HIDDEN ||
-    ci->flags & CLIENT_IGNORE || (ci == cc))
+    ci->flags & CLIENT_IGNORE || (ci == cc) ||
+    ci->geom.x < area.x ||
+    ci->geom.x > (area.x + area.w) ||
+    ci->geom.y < area.y ||
+    ci->geom.y > (area.y + area.h))
  continue;
  n++;
  }
  if (n == 0)
  return;
 
- area = screen_area(sc,
-    cc->geom.x + cc->geom.w / 2,
-    cc->geom.y + cc->geom.h / 2, CWM_GAP);
-
  if (cc->flags & CLIENT_HMAXIMIZED ||
     cc->geom.w + (cc->bwidth * 2) >= area.w)
  return;
@@ -1077,7 +1090,11 @@ client_vtile(struct client_ctx *cc)
  w = area.w - mw;
  TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
  if (ci->flags & CLIENT_HIDDEN ||
-    ci->flags & CLIENT_IGNORE || (ci == cc))
+    ci->flags & CLIENT_IGNORE || (ci == cc) ||
+    ci->geom.x < area.x ||
+    ci->geom.x > (area.x + area.w) ||
+    ci->geom.y < area.y ||
+    ci->geom.y > (area.y + area.h))
  continue;
  ci->bwidth = Conf.bwidth;
  ci->geom.x = area.x + mw;

Reply | Threaded
Open this post in threaded view
|

Re: [patch] cwm: tile only within active monitor

Okan Demirmen
On Sun 2019.01.06 at 14:46 -0500, Charles A Daniels wrote:

> Hi all,
>
> I'm new around here, so apologies in advance if I miss something
> obvious.
>
> I have written a patch to cwm so that the htile/vtile functionality
> only affect windows within the same monitor as the active window. For
> single monitor setups, this will have no effect. For multi-monitor
> setups, this will allow multiple different monitors to have windows
> tiled independently from one another (within the same group).
>
> This is implemented by modifying the relevant checks to ignore any
> clients (ci) where the client is outside of the area of the current
> display as returned by screen_area() (ci->geom not within area).
>
> Testing and feedback are welcome and appreciated!

Hi,

I don't use vtile/htile, nor do I have anything but one monitor
(laptop), so I'm not opposed to this. However, for those with
multi-monitors, the current behavior will change - that is, the
vtile/htile's will only take affect per monitor.

That said, all other cwm-based client modifications operate within a
monitor, so this would be consistent.

Would a large number of cwm users have their work-flow disrupted by this
change?

> Regards,
>
> ~ Charles
>
> P.S. I would be curious to heard about others' development workflows
> for window managers. I've been compiling cwm, copying it to
> /usr/X11R6/bin, logging out, and logging back in. This is really un-
> ergonomic, and I'd like to have a better setup, but I've never
> developed a window manager before so I'm unsure how to improve.

cwm will re-exec itself so you don't need to; however I typically run
cwm out of an xterm when I really need.

Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: [patch] cwm: tile only within active monitor

Okan Demirmen
On Wed 2019.02.13 at 12:06 -0500, Okan Demirmen wrote:

> On Sun 2019.01.06 at 14:46 -0500, Charles A Daniels wrote:
> > Hi all,
> >
> > I'm new around here, so apologies in advance if I miss something
> > obvious.
> >
> > I have written a patch to cwm so that the htile/vtile functionality
> > only affect windows within the same monitor as the active window. For
> > single monitor setups, this will have no effect. For multi-monitor
> > setups, this will allow multiple different monitors to have windows
> > tiled independently from one another (within the same group).
> >
> > This is implemented by modifying the relevant checks to ignore any
> > clients (ci) where the client is outside of the area of the current
> > display as returned by screen_area() (ci->geom not within area).
> >
> > Testing and feedback are welcome and appreciated!
>
> Hi,
>
> I don't use vtile/htile, nor do I have anything but one monitor
> (laptop), so I'm not opposed to this. However, for those with
> multi-monitors, the current behavior will change - that is, the
> vtile/htile's will only take affect per monitor.
>
> That said, all other cwm-based client modifications operate within a
> monitor, so this would be consistent.
>
> Would a large number of cwm users have their work-flow disrupted by this
> change?

No objections from other vtile/vtile users, so I've applied your diff to
limit v/h tile actions to clients that exist fully within the screen of
the master client.

Thanks!

> > Regards,
> >
> > ~ Charles
> >
> > P.S. I would be curious to heard about others' development workflows
> > for window managers. I've been compiling cwm, copying it to
> > /usr/X11R6/bin, logging out, and logging back in. This is really un-
> > ergonomic, and I'd like to have a better setup, but I've never
> > developed a window manager before so I'm unsure how to improve.
>
> cwm will re-exec itself so you don't need to; however I typically run
> cwm out of an xterm when I really need.
>
> Thanks!
>