Discussion:
PATCH: cwm move window to {top,bottom}{left,right} corners
Add Reply
Julien Steinhauser
2017-11-22 20:27:34 UTC
Reply
Permalink
Raw Message
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.

This version lacks the keybindings from the initial patch,
it also lacks for now a change in the man pages.
I use it with the following in ~/.cwmrc:

bind-key 4S-Left window-movebottomleft
bind-key 4S-Right window-movebottomright
bind-key 4S-XF86Back window-movetopleft
bind-key 4S-XF86Forward window-movetopright

I know these are not standards keys found on every keyboard,
but Thinkpads are not exotic beasts in this land so it might
be an helpful start to some of you and every declinaison of h j k l
was already in use in the default config.

OK?

[0] https://marc.info/?l=openbsd-misc&m=140344759017419&w=2

Index: calmwm.h
===================================================================
RCS file: /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 22 Nov 2017 19:21:47 -0000
@@ -54,6 +54,10 @@
#define CWM_DOWN 0x0002
#define CWM_LEFT 0x0004
#define CWM_RIGHT 0x0008
+#define CWM_TOP_LEFT 0x0100
+#define CWM_BOTTOM_LEFT 0x0200
+#define CWM_TOP_RIGHT 0x0400
+#define CWM_BOTTOM_RIGHT 0x0800
#define CWM_BIGAMOUNT 0x0010
#define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)

@@ -476,6 +480,7 @@ void kbfunc_client_toggle_hmaximize(v
void kbfunc_client_toggle_vmaximize(void *, struct cargs *);
void kbfunc_client_htile(void *, struct cargs *);
void kbfunc_client_vtile(void *, struct cargs *);
+void kbfunc_client_move_edge(void *, struct cargs *);
void kbfunc_client_cycle(void *, struct cargs *);
void kbfunc_client_toggle_group(void *, struct cargs *);
void kbfunc_client_movetogroup(void *, struct cargs *);
Index: conf.c
===================================================================
RCS file: /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 22 Nov 2017 19:21:48 -0000
@@ -67,6 +67,14 @@ static const struct {
{ "window-delete", kbfunc_client_delete, CWM_CONTEXT_CC, 0 },
{ "window-htile", kbfunc_client_htile, CWM_CONTEXT_CC, 0 },
{ "window-vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, 0 },
+ { "window-movetopleft", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_TOP_LEFT) },
+ { "window-movebottomleft", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_BOTTOM_LEFT) },
+ { "window-movetopright", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_TOP_RIGHT) },
+ { "window-movebottomright", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_BOTTOM_RIGHT) },
{ "window-stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, 0 },
{ "window-fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, 0 },
{ "window-maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, 0 },
@@ -666,6 +674,51 @@ conf_grab_mouse(Window win)
BUTTONMASK, GrabModeAsync, GrabModeSync,
None, None);
}
+ }
+}
+
+void
+kbfunc_client_move_edge(void *ctx, struct cargs *cargs)
+{
+ struct client_ctx *cc = ctx;
+ struct screen_ctx *sc = cc->sc;
+ struct geom xine;
+ int flags;
+
+ /*
+ * pick screen that the middle of the window is on.
+ * that's probably more fair than if just the origin of
+ * a window is poking over a boundary
+ */
+ xine = screen_area(sc,
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2, CWM_GAP);
+
+ flags = cargs->flag;
+
+ switch (flags) {
+ case CWM_TOP_LEFT:
+ cc->geom.x = xine.x;
+ cc->geom.y = xine.y;
+ client_move(cc);
+ break;
+ case CWM_BOTTOM_LEFT:
+ cc->geom.x = xine.x;
+ cc->geom.y = xine.y + xine.h - cc->geom.h - cc->bwidth * 2;
+ client_move(cc);
+ break;
+ case CWM_TOP_RIGHT:
+ cc->geom.x = xine.x + xine.w - cc->geom.w - cc->bwidth * 2;
+ cc->geom.y = xine.y;
+ client_move(cc);
+ break;
+ case CWM_BOTTOM_RIGHT:
+ cc->geom.x = xine.x + xine.w - cc->geom.w - cc->bwidth * 2;
+ cc->geom.y = xine.y + xine.h - cc->geom.h - cc->bwidth * 2;
+ client_move(cc);
+ break;
+ default:
+ warnx("invalid flags passed to kbfunc_client_move_edge");
}
}
Okan Demirmen
2017-11-30 18:41:05 UTC
Reply
Permalink
Raw Message
Hi,
Post by Julien Steinhauser
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.

Post by Julien Steinhauser
This version lacks the keybindings from the initial patch,
it also lacks for now a change in the man pages.
bind-key 4S-Left window-movebottomleft
bind-key 4S-Right window-movebottomright
bind-key 4S-XF86Back window-movetopleft
bind-key 4S-XF86Forward window-movetopright
I know these are not standards keys found on every keyboard,
but Thinkpads are not exotic beasts in this land so it might
be an helpful start to some of you and every declinaison of h j k l
was already in use in the default config.
OK?
[0] https://marc.info/?l=openbsd-misc&m=140344759017419&w=2
Index: calmwm.h
===================================================================
RCS file: /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 22 Nov 2017 19:21:47 -0000
@@ -54,6 +54,10 @@
#define CWM_DOWN 0x0002
#define CWM_LEFT 0x0004
#define CWM_RIGHT 0x0008
+#define CWM_TOP_LEFT 0x0100
+#define CWM_BOTTOM_LEFT 0x0200
+#define CWM_TOP_RIGHT 0x0400
+#define CWM_BOTTOM_RIGHT 0x0800
#define CWM_BIGAMOUNT 0x0010
#define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
@@ -476,6 +480,7 @@ void kbfunc_client_toggle_
hmaximize(v
void kbfunc_client_toggle_vmaximize(void *, struct
cargs *);
void kbfunc_client_htile(void *, struct cargs *);
void kbfunc_client_vtile(void *, struct cargs *);
+void kbfunc_client_move_edge(void *, struct cargs *);
void kbfunc_client_cycle(void *, struct cargs *);
void kbfunc_client_toggle_group(void *, struct cargs
*);
void kbfunc_client_movetogroup(void *, struct cargs *);
Index: conf.c
===================================================================
RCS file: /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 22 Nov 2017 19:21:48 -0000
@@ -67,6 +67,14 @@ static const struct {
{ "window-delete", kbfunc_client_delete, CWM_CONTEXT_CC, 0 },
{ "window-htile", kbfunc_client_htile, CWM_CONTEXT_CC, 0 },
{ "window-vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, 0 },
+ { "window-movetopleft", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_TOP_LEFT) },
+ { "window-movebottomleft", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_BOTTOM_LEFT) },
+ { "window-movetopright", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_TOP_RIGHT) },
+ { "window-movebottomright", kbfunc_client_move_edge,
CWM_CONTEXT_CC,
+ (CWM_BOTTOM_RIGHT) },
{ "window-stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, 0 },
{ "window-fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, 0 },
{ "window-maximize", kbfunc_client_toggle_maximize,
CWM_CONTEXT_CC, 0 },
@@ -666,6 +674,51 @@ conf_grab_mouse(Window win)
BUTTONMASK, GrabModeAsync, GrabModeSync,
None, None);
}
+ }
+}
+
+void
+kbfunc_client_move_edge(void *ctx, struct cargs *cargs)
+{
+ struct client_ctx *cc = ctx;
+ struct screen_ctx *sc = cc->sc;
+ struct geom xine;
+ int flags;
+
+ /*
+ * pick screen that the middle of the window is on.
+ * that's probably more fair than if just the origin of
+ * a window is poking over a boundary
+ */
+ xine = screen_area(sc,
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2, CWM_GAP);
+
+ flags = cargs->flag;
+
+ switch (flags) {
+ cc->geom.x = xine.x;
+ cc->geom.y = xine.y;
+ client_move(cc);
+ break;
+ cc->geom.x = xine.x;
+ cc->geom.y = xine.y + xine.h - cc->geom.h - cc->bwidth *
2;
+ client_move(cc);
+ break;
+ cc->geom.x = xine.x + xine.w - cc->geom.w - cc->bwidth *
2;
+ cc->geom.y = xine.y;
+ client_move(cc);
+ break;
+ cc->geom.x = xine.x + xine.w - cc->geom.w - cc->bwidth *
2;
+ cc->geom.y = xine.y + xine.h - cc->geom.h - cc->bwidth *
2;
+ client_move(cc);
+ break;
+ warnx("invalid flags passed to kbfunc_client_move_edge");
}
}
Okan Demirmen
2017-11-30 21:10:25 UTC
Reply
Permalink
Raw Message
Hi,
Post by Julien Steinhauser
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);
Julien Steinhauser
2017-12-04 20:27:30 UTC
Reply
Permalink
Raw Message
Post by Okan Demirmen
A rough cut (no manpage bits yet) would be something like the below; it
allows one to "snap" to any edge or corner.
Tested and approved, thanks.
See a proposal for cwmrc.5 below.
I don't have idea for default keybindings so I didn't touch cwm.1
Post by Okan Demirmen
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...
Well, it depends on how much you dislike it …
It would break everyone's ~/.cwmrc all of a sudden.

Index: cwmrc.5
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.68
diff -u -p -r1.68 cwmrc.5
--- cwmrc.5 6 Jul 2017 17:09:17 -0000 1.68
+++ cwmrc.5 4 Dec 2017 20:08:50 -0000
@@ -334,6 +334,8 @@ Other windows in its group share remaini
Move current window.
.It window-resize
Resize current window.
+.It window-snap
+Snap current window to edge or corner of the screen
.It window-move-up
Move window
.Ar moveamount
@@ -398,6 +400,22 @@ pixels right.
Resize window 10 times
.Ar moveamount
pixels left.
+.It window-snap-up
+Snap window to top edge
+.It window-snap-down
+Snap window to bottom edge
+.It window-snap-right
+Snap window to right edge
+.It window-snap-left
+Snap window to left edge
+.It window-snap-up-right
+Snap window to top-right corner
+.It window-snap-up-left
+Snap window to top-left corner
+.It window-snap-down-right
+Snap window to bottom-right corner
+.It window-snap-down-left
+Snap window to bottom-left corner
.It pointer-move-up
Move pointer
.Ar moveamount
Okan Demirmen
2017-12-07 16:31:26 UTC
Reply
Permalink
Raw Message
Post by Julien Steinhauser
Post by Okan Demirmen
A rough cut (no manpage bits yet) would be something like the below; it
allows one to "snap" to any edge or corner.
Tested and approved, thanks.
See a proposal for cwmrc.5 below.
I don't have idea for default keybindings so I didn't touch cwm.1
No default bindings - kept it simple.

Fixed up the cwmrc(5) bits and committed.

Thanks everyone.

Thuban
2017-11-30 20:09:40 UTC
Reply
Permalink
Raw Message
This feature sounds very useful to me.
Post by Julien Steinhauser
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.
This version lacks the keybindings from the initial patch,
it also lacks for now a change in the man pages.
bind-key 4S-Left window-movebottomleft
bind-key 4S-Right window-movebottomright
bind-key 4S-XF86Back window-movetopleft
bind-key 4S-XF86Forward window-movetopright
I know these are not standards keys found on every keyboard,
but Thinkpads are not exotic beasts in this land so it might
be an helpful start to some of you and every declinaison of h j k l
was already in use in the default config.
OK?
[0] https://marc.info/?l=openbsd-misc&m=140344759017419&w=2
Index: calmwm.h
===================================================================
RCS file: /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 22 Nov 2017 19:21:47 -0000
@@ -54,6 +54,10 @@
#define CWM_DOWN 0x0002
#define CWM_LEFT 0x0004
#define CWM_RIGHT 0x0008
+#define CWM_TOP_LEFT 0x0100
+#define CWM_BOTTOM_LEFT 0x0200
+#define CWM_TOP_RIGHT 0x0400
+#define CWM_BOTTOM_RIGHT 0x0800
#define CWM_BIGAMOUNT 0x0010
#define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
@@ -476,6 +480,7 @@ void kbfunc_client_toggle_hmaximize(v
void kbfunc_client_toggle_vmaximize(void *, struct cargs *);
void kbfunc_client_htile(void *, struct cargs *);
void kbfunc_client_vtile(void *, struct cargs *);
+void kbfunc_client_move_edge(void *, struct cargs *);
void kbfunc_client_cycle(void *, struct cargs *);
void kbfunc_client_toggle_group(void *, struct cargs *);
void kbfunc_client_movetogroup(void *, struct cargs *);
Index: conf.c
===================================================================
RCS file: /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 22 Nov 2017 19:21:48 -0000
@@ -67,6 +67,14 @@ static const struct {
{ "window-delete", kbfunc_client_delete, CWM_CONTEXT_CC, 0 },
{ "window-htile", kbfunc_client_htile, CWM_CONTEXT_CC, 0 },
{ "window-vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, 0 },
+ { "window-movetopleft", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_TOP_LEFT) },
+ { "window-movebottomleft", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_BOTTOM_LEFT) },
+ { "window-movetopright", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_TOP_RIGHT) },
+ { "window-movebottomright", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_BOTTOM_RIGHT) },
{ "window-stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, 0 },
{ "window-fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, 0 },
{ "window-maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, 0 },
@@ -666,6 +674,51 @@ conf_grab_mouse(Window win)
BUTTONMASK, GrabModeAsync, GrabModeSync,
None, None);
}
+ }
+}
+
+void
+kbfunc_client_move_edge(void *ctx, struct cargs *cargs)
+{
+ struct client_ctx *cc = ctx;
+ struct screen_ctx *sc = cc->sc;
+ struct geom xine;
+ int flags;
+
+ /*
+ * pick screen that the middle of the window is on.
+ * that's probably more fair than if just the origin of
+ * a window is poking over a boundary
+ */
+ xine = screen_area(sc,
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2, CWM_GAP);
+
+ flags = cargs->flag;
+
+ switch (flags) {
+ cc->geom.x = xine.x;
+ cc->geom.y = xine.y;
+ client_move(cc);
+ break;
+ cc->geom.x = xine.x;
+ cc->geom.y = xine.y + xine.h - cc->geom.h - cc->bwidth * 2;
+ client_move(cc);
+ break;
+ cc->geom.x = xine.x + xine.w - cc->geom.w - cc->bwidth * 2;
+ cc->geom.y = xine.y;
+ client_move(cc);
+ break;
+ cc->geom.x = xine.x + xine.w - cc->geom.w - cc->bwidth * 2;
+ cc->geom.y = xine.y + xine.h - cc->geom.h - cc->bwidth * 2;
+ client_move(cc);
+ break;
+ warnx("invalid flags passed to kbfunc_client_move_edge");
}
}
--
thuban
Артур Истомин
2017-12-01 02:37:19 UTC
Reply
Permalink
Raw Message
Post by Thuban
This feature sounds very useful to me.
This feature was in original calmwm and was very useful for me too.
Post by Thuban
Post by Julien Steinhauser
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.
This version lacks the keybindings from the initial patch,
it also lacks for now a change in the man pages.
bind-key 4S-Left window-movebottomleft
bind-key 4S-Right window-movebottomright
bind-key 4S-XF86Back window-movetopleft
bind-key 4S-XF86Forward window-movetopright
I know these are not standards keys found on every keyboard,
but Thinkpads are not exotic beasts in this land so it might
be an helpful start to some of you and every declinaison of h j k l
was already in use in the default config.
OK?
[0] https://marc.info/?l=openbsd-misc&m=140344759017419&w=2
Index: calmwm.h
===================================================================
RCS file: /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 22 Nov 2017 19:21:47 -0000
@@ -54,6 +54,10 @@
#define CWM_DOWN 0x0002
#define CWM_LEFT 0x0004
#define CWM_RIGHT 0x0008
+#define CWM_TOP_LEFT 0x0100
+#define CWM_BOTTOM_LEFT 0x0200
+#define CWM_TOP_RIGHT 0x0400
+#define CWM_BOTTOM_RIGHT 0x0800
#define CWM_BIGAMOUNT 0x0010
#define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
@@ -476,6 +480,7 @@ void kbfunc_client_toggle_hmaximize(v
void kbfunc_client_toggle_vmaximize(void *, struct cargs *);
void kbfunc_client_htile(void *, struct cargs *);
void kbfunc_client_vtile(void *, struct cargs *);
+void kbfunc_client_move_edge(void *, struct cargs *);
void kbfunc_client_cycle(void *, struct cargs *);
void kbfunc_client_toggle_group(void *, struct cargs *);
void kbfunc_client_movetogroup(void *, struct cargs *);
Index: conf.c
===================================================================
RCS file: /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 22 Nov 2017 19:21:48 -0000
@@ -67,6 +67,14 @@ static const struct {
{ "window-delete", kbfunc_client_delete, CWM_CONTEXT_CC, 0 },
{ "window-htile", kbfunc_client_htile, CWM_CONTEXT_CC, 0 },
{ "window-vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, 0 },
+ { "window-movetopleft", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_TOP_LEFT) },
+ { "window-movebottomleft", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_BOTTOM_LEFT) },
+ { "window-movetopright", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_TOP_RIGHT) },
+ { "window-movebottomright", kbfunc_client_move_edge, CWM_CONTEXT_CC,
+ (CWM_BOTTOM_RIGHT) },
{ "window-stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, 0 },
{ "window-fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, 0 },
{ "window-maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, 0 },
@@ -666,6 +674,51 @@ conf_grab_mouse(Window win)
BUTTONMASK, GrabModeAsync, GrabModeSync,
None, None);
}
+ }
+}
+
+void
+kbfunc_client_move_edge(void *ctx, struct cargs *cargs)
+{
+ struct client_ctx *cc = ctx;
+ struct screen_ctx *sc = cc->sc;
+ struct geom xine;
+ int flags;
+
+ /*
+ * pick screen that the middle of the window is on.
+ * that's probably more fair than if just the origin of
+ * a window is poking over a boundary
+ */
+ xine = screen_area(sc,
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2, CWM_GAP);
+
+ flags = cargs->flag;
+
+ switch (flags) {
+ cc->geom.x = xine.x;
+ cc->geom.y = xine.y;
+ client_move(cc);
+ break;
+ cc->geom.x = xine.x;
+ cc->geom.y = xine.y + xine.h - cc->geom.h - cc->bwidth * 2;
+ client_move(cc);
+ break;
+ cc->geom.x = xine.x + xine.w - cc->geom.w - cc->bwidth * 2;
+ cc->geom.y = xine.y;
+ client_move(cc);
+ break;
+ cc->geom.x = xine.x + xine.w - cc->geom.w - cc->bwidth * 2;
+ cc->geom.y = xine.y + xine.h - cc->geom.h - cc->bwidth * 2;
+ client_move(cc);
+ break;
+ warnx("invalid flags passed to kbfunc_client_move_edge");
}
}
--
thuban
Loading...