Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.

Commit 9c9452c

Browse files
committed
use -r in shodc to set relative size or position
1 parent 073a7d7 commit 9c9452c

File tree

3 files changed

+14
-53
lines changed

3 files changed

+14
-53
lines changed

shod.1

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -215,36 +215,20 @@ is provided, move window to position 0,0 (top left corner).
215215
.PP
216216
The options are as follows:
217217
.TP
218-
.B \-X \fIN\fP
219-
Relative X position.
220-
Set the position on the X axis to N plus the current X position of the container.
218+
.B \-r
219+
Relative.
220+
All position and size values are relative to the container's current position and size.
221221
.TP
222222
.B \-x \fIN\fP
223-
Absolute X position.
224223
Set the position on the X axis to N.
225224
.TP
226-
.B \-Y \fIN\fP
227-
Relative Y position.
228-
Set the position on the Y axis to N plus the current Y position of the container.
229-
.TP
230225
.B \-y \fIN\fP
231-
Absolute Y position.
232226
Set the position on the Y axis to N.
233227
.TP
234-
.B \-W \fIN\fP
235-
Relative width.
236-
Set the width of the contianer to N plus its current width.
237-
.TP
238228
.B \-w \fIN\fP
239-
Absolute width.
240229
Set the width of the contianer to N.
241230
.TP
242-
.B \-H \fIN\fP
243-
Relative height.
244-
Set the height of the contianer to N plus its current height.
245-
.TP
246231
.B \-h \fIN\fP
247-
Absolute height.
248232
Set the height of the contianer to N.
249233
.SS Go To Desktop
250234
The

shod.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@
3030
#define DROPPIXELS 30 /* number of pixels from the border where a tab can be dropped in */
3131
#define RESIZETIME 64 /* time to redraw containers during resizing */
3232

33-
#define _SHOD_RELATIVE_X ((long)(1 << 16))
34-
#define _SHOD_RELATIVE_Y ((long)(1 << 17))
35-
#define _SHOD_RELATIVE_WIDTH ((long)(1 << 18))
36-
#define _SHOD_RELATIVE_HEIGHT ((long)(1 << 19))
33+
#define _SHOD_MOVERESIZE_RELATIVE ((long)(1 << 16))
3734

3835
/* window type */
3936
enum {
@@ -4831,10 +4828,10 @@ xeventclientmessage(XEvent *e)
48314828
if (res.c == NULL)
48324829
return;
48334830
value_mask = CWX | CWY | CWWidth | CWHeight;
4834-
wc.x = (ev->data.l[0] & _SHOD_RELATIVE_X) ? res.c->x + res.c->b + ev->data.l[1] : ev->data.l[1];
4835-
wc.y = (ev->data.l[0] & _SHOD_RELATIVE_Y) ? res.c->y + res.c->b + ev->data.l[2] : ev->data.l[2];
4836-
wc.width = (ev->data.l[0] & _SHOD_RELATIVE_WIDTH) ? res.c->w + ev->data.l[3] - 2 * res.c->b : ev->data.l[3];
4837-
wc.height = (ev->data.l[0] & _SHOD_RELATIVE_HEIGHT) ? res.c->h + ev->data.l[4] - 2 * res.c->b : ev->data.l[4];
4831+
wc.x = (ev->data.l[0] & _SHOD_MOVERESIZE_RELATIVE) ? res.c->x + ev->data.l[1] : ev->data.l[1];
4832+
wc.y = (ev->data.l[0] & _SHOD_MOVERESIZE_RELATIVE) ? res.c->y + ev->data.l[2] : ev->data.l[2];
4833+
wc.width = (ev->data.l[0] & _SHOD_MOVERESIZE_RELATIVE) ? res.c->w + ev->data.l[3] : ev->data.l[3];
4834+
wc.height = (ev->data.l[0] & _SHOD_MOVERESIZE_RELATIVE) ? res.c->h + ev->data.l[4] : ev->data.l[4];
48384835
if (res.d != NULL) {
48394836
dialogconfigure(res.d, value_mask, &wc);
48404837
} else {

shodc.c

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
#include <X11/Xatom.h>
88
#include <X11/Xutil.h>
99

10-
#define NAMEMAXLEN 128
11-
#define DIRECT_ACTION 2
12-
#define _SHOD_RELATIVE_X ((long)(1 << 16))
13-
#define _SHOD_RELATIVE_Y ((long)(1 << 17))
14-
#define _SHOD_RELATIVE_WIDTH ((long)(1 << 18))
15-
#define _SHOD_RELATIVE_HEIGHT ((long)(1 << 19))
10+
#define NAMEMAXLEN 128
11+
#define DIRECT_ACTION 2
12+
#define _SHOD_MOVERESIZE_RELATIVE ((long)(1 << 16))
1613

1714
/* state action */
1815
enum {
@@ -418,38 +415,21 @@ setgeom(int argc, char *argv[])
418415

419416
rel = 0;
420417
x = y = w = h = 0;
421-
while ((c = getopt(argc, argv, "X:Y:W:H:x:y:w:h:")) != -1) {
418+
while ((c = getopt(argc, argv, "rx:y:w:h:")) != -1) {
422419
switch (c) {
423-
case 'X':
424-
rel |= _SHOD_RELATIVE_X;
425-
x = strtol(optarg, NULL, 10);
426-
break;
427-
case 'Y':
428-
rel |= _SHOD_RELATIVE_Y;
429-
y = strtol(optarg, NULL, 10);
430-
break;
431-
case 'W':
432-
rel |= _SHOD_RELATIVE_WIDTH;
433-
w = strtol(optarg, NULL, 10);
434-
break;
435-
case 'H':
436-
rel |= _SHOD_RELATIVE_HEIGHT;
437-
h = strtol(optarg, NULL, 10);
420+
case 'r':
421+
rel |= _SHOD_MOVERESIZE_RELATIVE;
438422
break;
439423
case 'x':
440-
rel &= ~_SHOD_RELATIVE_X;
441424
x = strtol(optarg, NULL, 10);
442425
break;
443426
case 'y':
444-
rel &= ~_SHOD_RELATIVE_Y;
445427
y = strtol(optarg, NULL, 10);
446428
break;
447429
case 'w':
448-
rel &= ~_SHOD_RELATIVE_WIDTH;
449430
w = strtol(optarg, NULL, 10);
450431
break;
451432
case 'h':
452-
rel &= ~_SHOD_RELATIVE_HEIGHT;
453433
h = strtol(optarg, NULL, 10);
454434
break;
455435
default:

0 commit comments

Comments
 (0)