Skip to content

riodraw

bakkeby edited this page Jan 10, 2022 · 7 revisions

This patch allows the user to "draw" where a window is to be placed in a similar manner to the Plan 9 window system rio.

This solution is based on an external tool slop (Select Operation) that handles the drawing of the selected area where a client window is to be placed.

This can either be used when resizing (and repositioning) a client window or when spawning a new window.

As the riodraw shares a lot of the same code as the swallow patch this comes in a few variants - standalone, on top of swallow, full patch including both riodraw and swallow, and one that does no PID matching (i.e. the next window managed is assumed to be the one that was spawned via riospawn).

One room for improvement would be if one could pass the starting point for slop via command line arguments (as in the first click) - that way one could have a more seamless integration for button press bindings in dwm. Something to revisit if such a feature is added to slop.

Note that even if -t 0 is passed to slop it still ends up highlighting the window underneath the cursor for a fraction of a second on the first mouse click before you start dragging.

Configuration options

static const char slopspawnstyle[]  = "-t 0 -c 0.92,0.85,0.69,0.3 -o"; /* do NOT define -f (format) here */
static const char slopresizestyle[] = "-t 0 -c 0.92,0.85,0.69,0.3"; /* do NOT define -f (format) here */
static const int riodraw_borders    = 0; /* 0 or 1, indicates whether the area drawn using slop includes the window borders */
static const int riodraw_matchpid   = 1; /* 0 or 1, indicates whether to match the PID of the client that was spawned with riospawn */
static const int riodraw_spawnasync = 0; /* 0 means that the application is only spawned after a successful selection while
                                          * 1 means that the application is being initialised in the background while the selection is made */

The slopspawnstyle and slopresizestyle options allow you to use a different slop style when spawning and resizing clients. See slop --help for details.

The riodraw_borders option controls whether the drawn area represents the actual window size or the window size including the borders. This may not make much of a difference when the borders are thin, but it gives a different feel if thicker window borders are used.

The riodraw_matchpid option controls whether or not to try to match the PID of the rio spawned window. If this is set to 0 then simply the next window being managed is assumed to be the rio spawned window.

If riodraw_spawnasync is set to 0 then the client is only spawned following a successful selection. This means that if you happen to cancel the selection (or make a very small selection) then the spawn command is never executed.

If riodraw_spawnasync is set to 1 then the spawn command is executed first and the slop selection is made after that. The benefit of this is that if the application takes a while to start then the whole process will feel a bit snappier as the application has time to initialise in the background while the selection is made. One side effect of this is that if the selection is cancelled the application has to be killed behind the scenes when the mapping request comes through.

Note that if you have a need to use both ways of spawning clients then consider splitting the riodraw function into two separate functions and getting rid of the configuration item, e.g.

void
riospawnasync(const Arg *arg)
{
	riopid = spawncmd(arg);
	riodraw(NULL, slopspawnstyle);
}

void
riospawn(const Arg *arg)
{
	if (riodraw(NULL, slopspawnstyle))
		riopid = spawncmd(arg);
}

Showcase

Spawning clients:

riospawn.gif

Resizing clients:

rioresize.gif

Download