On Thu 2017.11.30 at 13:41 -0500, Okan Demirmen wrote:
> Hi,
>
> On Wed, Nov 22, 2017 at 3:27 PM, Julien Steinhauser <[email protected]> wrote:
>
> > A long time ago sent Dimitris Papastamos a patch to misc which
> > let one send X clients to corners.[0]
> >
> > I think it is useful so thank you Dimitris!
> > With some minor editing it still builds on current.
> >
> > I have no use of window-move-{up,down,right,left}{,-big} but X client
> > corner warping is done on a regular basis.
> >
> > At the time it did not receive the attention it (IMO) deserves.
> > Maybe was it because "feature" was written on the first line? ;)
> > I know featuritis is considered a disease around here and
> > I'm happy it is but here is an updated version anyway.
> > ??????
> >
> >
> ???I'm not opposed to this completely...I would in fact consider implementing
> this on-top of the snapping we already have allow snap'ing to an edge,
> regardless if one wants to snap to one or two edges.
> ???
A rough cut (no manpage bits yet) would be something like the below; it
allows one to "snap" to any edge or corner.
Incidentally, I dislike we used up/down/left/right from the beginning,
not sure of the trouble changing to all to cardinal directions or not...
Index: calmwm.h
===================================================================
RCS file: /home/open/cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.341
diff -u -p -r1.341 calmwm.h
--- calmwm.h 14 Jul 2017 17:23:38 -0000 1.341
+++ calmwm.h 30 Nov 2017 20:58:32 -0000
@@ -461,6 +461,7 @@ void
screen_assert_clients_within(str
void kbfunc_cwm_status(void *, struct cargs *);
void kbfunc_ptrmove(void *, struct cargs *);
+void kbfunc_client_snap(void *, struct cargs *);
void kbfunc_client_move(void *, struct cargs *);
void kbfunc_client_resize(void *, struct cargs *);
void kbfunc_client_delete(void *, struct cargs *);
Index: conf.c
===================================================================
RCS file: /home/open/cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.233
diff -u -p -r1.233 conf.c
--- conf.c 14 Jul 2017 17:23:38 -0000 1.233
+++ conf.c 30 Nov 2017 20:58:17 -0000
@@ -92,6 +92,24 @@ static const struct {
{ "window-movetogroup-8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 8
},
{ "window-movetogroup-9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 9
},
+ { "window-snap-up", kbfunc_client_snap, CWM_CONTEXT_CC,
+ (CWM_UP) },
+ { "window-snap-down", kbfunc_client_snap, CWM_CONTEXT_CC,
+ (CWM_DOWN) },
+ { "window-snap-left", kbfunc_client_snap, CWM_CONTEXT_CC,
+ (CWM_LEFT) },
+ { "window-snap-right", kbfunc_client_snap, CWM_CONTEXT_CC,
+ (CWM_RIGHT) },
+
+ { "window-snap-up-right", kbfunc_client_snap, CWM_CONTEXT_CC,
+ (CWM_UP|CWM_RIGHT) },
+ { "window-snap-up-left", kbfunc_client_snap, CWM_CONTEXT_CC,
+ (CWM_UP|CWM_LEFT) },
+ { "window-snap-down-right", kbfunc_client_snap, CWM_CONTEXT_CC,
+ (CWM_DOWN|CWM_RIGHT) },
+ { "window-snap-down-left", kbfunc_client_snap, CWM_CONTEXT_CC,
+ (CWM_DOWN|CWM_LEFT) },
+
{ "window-move", kbfunc_client_move, CWM_CONTEXT_CC, 0 },
{ "window-move-up", kbfunc_client_move, CWM_CONTEXT_CC,
(CWM_UP) },
Index: kbfunc.c
===================================================================
RCS file: /home/open/cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.149
diff -u -p -r1.149 kbfunc.c
--- kbfunc.c 14 Jul 2017 18:01:46 -0000 1.149
+++ kbfunc.c 30 Nov 2017 21:01:12 -0000
@@ -287,6 +287,42 @@ kbfunc_client_resize_mb(void *ctx, struc
}
void
+kbfunc_client_snap(void *ctx, struct cargs *cargs)
+{
+ struct client_ctx *cc = ctx;
+ struct screen_ctx *sc = cc->sc;
+ struct geom area;
+ int flags;
+
+ area = screen_area(sc,
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2, CWM_GAP);
+
+ flags = cargs->flag;
+ while (flags) {
+ if (flags & CWM_UP) {
+ cc->geom.y = area.y;
+ flags &= ~CWM_UP;
+ }
+ if (flags & CWM_LEFT) {
+ cc->geom.x = area.x;
+ flags &= ~CWM_LEFT;
+ }
+ if (flags & CWM_RIGHT) {
+ cc->geom.x = area.x + area.w - cc->geom.w -
+ (cc->bwidth * 2);
+ flags &= ~CWM_RIGHT;
+ }
+ if (flags & CWM_DOWN) {
+ cc->geom.y = area.y + area.h - cc->geom.h -
+ (cc->bwidth * 2);
+ flags &= ~CWM_DOWN;
+ }
+ }
+ client_move(cc);
+}
+
+void
kbfunc_client_delete(void *ctx, struct cargs *cargs)
{
client_send_delete(ctx);