Skip to content

Commit

Permalink
use -r in shodc to set relative size or position
Browse files Browse the repository at this point in the history
  • Loading branch information
phillbush committed Sep 28, 2021
1 parent 073a7d7 commit 9c9452c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 53 deletions.
22 changes: 3 additions & 19 deletions shod.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 5 additions & 8 deletions shod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
32 changes: 6 additions & 26 deletions shodc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9c9452c

Please sign in to comment.