Skip to content

Commit

Permalink
randr: allow geometry strings to include @n
Browse files Browse the repository at this point in the history
When geometry string contain @n, where n is a number from 0..INT_MAX,
treat that number as a monitor's assigned number to use.

This is similar to how fvwm used to handle these geometry strings with
Xinerama, except that the designation of monitor numbers is now derived
via a deterministic algorithm.  See 'RANDR SUPPORT' in "man fvwm3all"
  • Loading branch information
ThomasAdam committed Dec 25, 2023
1 parent ee5b79c commit 245648f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/fvwm3_manpage_source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,16 @@ the window's upper right hand corner 5 pixels above and to the left of
the upper left hand corner of the screen; others may do just plain
bizarre things.

There is a fvwm-specific extension to geometry strings which can also
enforce the geometry is relative to the given screen. For example:

....
xterm -geometry +0+0@n
....

Where 'n' can be one of a RandR monitor name, or an assigned monitor number.
For more details, see the RANDR SUPPORT section.

There are several ways to cause a window to map onto a desktop or page
other than the currently active one. The geometry technique mentioned
above (specifying x,y coordinates larger than the physical screen size),
Expand Down
20 changes: 20 additions & 0 deletions libs/FScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "FScreen.h"
#include "FEvent.h"
#include "queue.h"
#include "strtonum.h"

#define GLOBAL_SCREEN_NAME "_global"

Expand Down Expand Up @@ -217,11 +218,30 @@ struct monitor *
monitor_resolve_name(const char *scr)
{
struct monitor *m = NULL;
int pos = -1;
const char *errstr;

if (scr == NULL)
{
return NULL;
}

/* Try and look up the monitor as a number. If that succeeds,
* try and match that number as something valid in the monitor
* information we have.
*/
pos = strtonum(scr, 0, INT_MAX, &errstr);
if (errstr == NULL) {
/* We have a valid number. Look it up. */
struct monitor *m_loop;

RB_FOREACH(m_loop, monitors, &monitor_q) {
if (m_loop->number == pos)
return (m_loop);
}
return (NULL);
}

/* "@g" is for the global screen. */
if (strcmp(scr, "g") == 0) {
m = monitor_get_global();
Expand Down

0 comments on commit 245648f

Please sign in to comment.