Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting delta for move/resize actions #23

Open
frolovia opened this issue Mar 23, 2021 · 2 comments
Open

Setting delta for move/resize actions #23

frolovia opened this issue Mar 23, 2021 · 2 comments

Comments

@frolovia
Copy link

Would you please tell me how to set delta for move/resize action, but not position. E.g.:
xdo move -x +1 #want to move +1 pixel from current to the right

Thanks!

@ryanerwin
Copy link

@frolovia

Looking through the code for:

ISRELA()

#define ISRELA(s)      (s[0] == '+' || s[0] == '-')

I believe that if the string begins with a "+" or a "-" then the string is considered relative and will be added or subtracted from the current window position.

window_move
void window_move(xcb_window_t win)
{
	xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, win), NULL);
	if (geo == NULL) {
		return;
	}
	uint32_t values[2] = {geo->x, geo->y};
	int i = 0;
	SETGEOM(x)
	SETGEOM(y)
	xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values);
}

and

SETGEOM(v)
#define SETGEOM(v) \
	if (cfg.v != NULL) { \
		uint32_t v = atoi(cfg.v); \
		if (ISRELA(cfg.v)) { \
			values[i] += v; \
		} else { \
			values[i] = v; \
		} \
	} \
	i++;

Perhaps the way X11 handles window move events has changed recently.
I'm on KDE Plasma on Ubuntu 21.04, and I wasn't able to get this to work for me.

It works fine (if your not counting window titles and borders) with an absolute value like:

xdo move -y 200 -x 200

I was unable to get this to work correctly on KDE with relative values though.

xdo move -x "+5"
xdo move -x "-5"

I presume the author wrote this to work with bspwm and the window move logic isn't necessarily exactly compatible with other window managers.

I've had similar issues trying to handle relative window movement with xdotool and wmctrl

xdo move -x 200 -y 200
xdotool getactivewindow windowmove 200 200
wmctrl -r :ACTIVE -e "0,200,200,800,600"

So far the best way my research has turned up to do a window manager independent relative window move is the code in this post... Some testing shows it working for me, but I haven't wrapped it up in something useful yet.

https://unix.stackexchange.com/a/598706/286216

@ryanerwin
Copy link

ryanerwin commented Sep 1, 2021

You can get some windows to move relatively with xdotool. For example, move the active window 10px left:

	xdotool getactivewindow windowmove --sync --relative -- "-10" "0"

Unfortunately, this will not work on on all windows at least while running KDE.

Many windows have a Titlebar/Border visible area offset that doesn't match the rest of the window geometry, so moving a window horizontally actually moves it diagonally down the screen.

I'm looking into this in more detail, but it's a fairly complicated. Hopefully doesn't ultimately require integration with every window manager individually, because I would like to find a way do this only with XCB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants