commit 9c9452c7e7a5d9534cd94fc37fd5f185ac9666ae
parent 073a7d71e11c71eb728d01cd1750f056b0c1a16c
Author: phillbush <phillbush@cock.li>
Date: Tue, 28 Sep 2021 19:49:53 -0300
use -r in shodc to set relative size or position
Diffstat:
M | shod.1 | | | 22 | +++------------------- |
M | shod.c | | | 13 | +++++-------- |
M | shodc.c | | | 32 | ++++++-------------------------- |
3 files changed, 14 insertions(+), 53 deletions(-)
diff --git a/shod.1 b/shod.1
@@ -215,36 +215,20 @@ is provided, move window to position 0,0 (top left corner).
.PP
The options are as follows:
.TP
-.B \-X \fIN\fP
-Relative X position.
-Set the position on the X axis to N plus the current X position of the container.
+.B \-r
+Relative.
+All position and size values are relative to the container's current position and size.
.TP
.B \-x \fIN\fP
-Absolute X position.
Set the position on the X axis to N.
.TP
-.B \-Y \fIN\fP
-Relative Y position.
-Set the position on the Y axis to N plus the current Y position of the container.
-.TP
.B \-y \fIN\fP
-Absolute Y position.
Set the position on the Y axis to N.
.TP
-.B \-W \fIN\fP
-Relative width.
-Set the width of the contianer to N plus its current width.
-.TP
.B \-w \fIN\fP
-Absolute width.
Set the width of the contianer to N.
.TP
-.B \-H \fIN\fP
-Relative height.
-Set the height of the contianer to N plus its current height.
-.TP
.B \-h \fIN\fP
-Absolute height.
Set the height of the contianer to N.
.SS Go To Desktop
The
diff --git a/shod.c b/shod.c
@@ -30,10 +30,7 @@
#define DROPPIXELS 30 /* number of pixels from the border where a tab can be dropped in */
#define RESIZETIME 64 /* time to redraw containers during resizing */
-#define _SHOD_RELATIVE_X ((long)(1 << 16))
-#define _SHOD_RELATIVE_Y ((long)(1 << 17))
-#define _SHOD_RELATIVE_WIDTH ((long)(1 << 18))
-#define _SHOD_RELATIVE_HEIGHT ((long)(1 << 19))
+#define _SHOD_MOVERESIZE_RELATIVE ((long)(1 << 16))
/* window type */
enum {
@@ -4831,10 +4828,10 @@ xeventclientmessage(XEvent *e)
if (res.c == NULL)
return;
value_mask = CWX | CWY | CWWidth | CWHeight;
- wc.x = (ev->data.l[0] & _SHOD_RELATIVE_X) ? res.c->x + res.c->b + ev->data.l[1] : ev->data.l[1];
- wc.y = (ev->data.l[0] & _SHOD_RELATIVE_Y) ? res.c->y + res.c->b + ev->data.l[2] : ev->data.l[2];
- wc.width = (ev->data.l[0] & _SHOD_RELATIVE_WIDTH) ? res.c->w + ev->data.l[3] - 2 * res.c->b : ev->data.l[3];
- wc.height = (ev->data.l[0] & _SHOD_RELATIVE_HEIGHT) ? res.c->h + ev->data.l[4] - 2 * res.c->b : ev->data.l[4];
+ wc.x = (ev->data.l[0] & _SHOD_MOVERESIZE_RELATIVE) ? res.c->x + ev->data.l[1] : ev->data.l[1];
+ wc.y = (ev->data.l[0] & _SHOD_MOVERESIZE_RELATIVE) ? res.c->y + ev->data.l[2] : ev->data.l[2];
+ wc.width = (ev->data.l[0] & _SHOD_MOVERESIZE_RELATIVE) ? res.c->w + ev->data.l[3] : ev->data.l[3];
+ wc.height = (ev->data.l[0] & _SHOD_MOVERESIZE_RELATIVE) ? res.c->h + ev->data.l[4] : ev->data.l[4];
if (res.d != NULL) {
dialogconfigure(res.d, value_mask, &wc);
} else {
diff --git a/shodc.c b/shodc.c
@@ -7,12 +7,9 @@
#include <X11/Xatom.h>
#include <X11/Xutil.h>
-#define NAMEMAXLEN 128
-#define DIRECT_ACTION 2
-#define _SHOD_RELATIVE_X ((long)(1 << 16))
-#define _SHOD_RELATIVE_Y ((long)(1 << 17))
-#define _SHOD_RELATIVE_WIDTH ((long)(1 << 18))
-#define _SHOD_RELATIVE_HEIGHT ((long)(1 << 19))
+#define NAMEMAXLEN 128
+#define DIRECT_ACTION 2
+#define _SHOD_MOVERESIZE_RELATIVE ((long)(1 << 16))
/* state action */
enum {
@@ -418,38 +415,21 @@ setgeom(int argc, char *argv[])
rel = 0;
x = y = w = h = 0;
- while ((c = getopt(argc, argv, "X:Y:W:H:x:y:w:h:")) != -1) {
+ while ((c = getopt(argc, argv, "rx:y:w:h:")) != -1) {
switch (c) {
- case 'X':
- rel |= _SHOD_RELATIVE_X;
- x = strtol(optarg, NULL, 10);
- break;
- case 'Y':
- rel |= _SHOD_RELATIVE_Y;
- y = strtol(optarg, NULL, 10);
- break;
- case 'W':
- rel |= _SHOD_RELATIVE_WIDTH;
- w = strtol(optarg, NULL, 10);
- break;
- case 'H':
- rel |= _SHOD_RELATIVE_HEIGHT;
- h = strtol(optarg, NULL, 10);
+ case 'r':
+ rel |= _SHOD_MOVERESIZE_RELATIVE;
break;
case 'x':
- rel &= ~_SHOD_RELATIVE_X;
x = strtol(optarg, NULL, 10);
break;
case 'y':
- rel &= ~_SHOD_RELATIVE_Y;
y = strtol(optarg, NULL, 10);
break;
case 'w':
- rel &= ~_SHOD_RELATIVE_WIDTH;
w = strtol(optarg, NULL, 10);
break;
case 'h':
- rel &= ~_SHOD_RELATIVE_HEIGHT;
h = strtol(optarg, NULL, 10);
break;
default: