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

randr: allow geometry strings to include @n #940

Merged
merged 4 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 1 addition & 19 deletions fvwm/expand.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "libs/ColorUtils.h"
#include "libs/safemalloc.h"
#include "libs/FEvent.h"
#include "libs/strtonum.h"
#include "fvwm.h"
#include "externs.h"
#include "cursor.h"
Expand Down Expand Up @@ -543,12 +542,10 @@ static signed int expand_vars_extended(

/* We could be left with "<NAME>.?" */
char *m_name = NULL;
struct monitor *mon2 = NULL, *m_loop;
struct monitor *mon2 = NULL;
char *rest_s;
const char *errstr;
char *p_free;
int got_string;
int pos = -1;

/* The first word is the monitor name:
*
Expand All @@ -560,22 +557,7 @@ static signed int expand_vars_extended(
p_free = rest_s;
got_string = 0;
while ((m_name = strsep(&rest_s, ".")) != NULL) {
/* Try parsing the name as a number. If that fails,
* then treat it as a valid name.
*/
pos = strtonum(m_name, 0, INT_MAX, &errstr);
if (errstr != NULL)
pos = -1;

RB_FOREACH(m_loop, monitors, &monitor_q) {
if (m_loop->number == pos) {
mon2 = m_loop;
goto rest;
}
}

mon2 = monitor_resolve_name(m_name);
rest:
if (mon2 == NULL)
{
free(p_free);
Expand Down
24 changes: 24 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 @@ -114,6 +115,18 @@ monitor_scan_edges(struct monitor *m)
}
}

struct monitor *
monitor_by_number(int n)
{
struct monitor *m_loop;

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

void
monitor_refresh_global(void)
{
Expand Down Expand Up @@ -217,11 +230,22 @@ 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)
return (monitor_by_number(pos));

/* "@g" is for the global screen. */
if (strcmp(scr, "g") == 0) {
m = monitor_get_global();
Expand Down
1 change: 1 addition & 0 deletions libs/FScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ RB_PROTOTYPE(monitors, monitor, entry, monitor_compare);
struct monitor *monitor_resolve_name(const char *);
struct monitor *monitor_by_xy(int, int);
struct monitor *monitor_by_output(int);
struct monitor *monitor_by_number(int);
struct monitor *monitor_by_primary(void);
struct monitor *monitor_by_last_primary(void);
struct monitor *monitor_get_current(void);
Expand Down
Loading