Skip to content

Commit

Permalink
Goto{Desk,Page,DeskAndPage}: use 'screen' keyword
Browse files Browse the repository at this point in the history
The GotoDesk, GotoPage, and GotoDeskAndPage commands have never followed
other conventions for commands which accept screen-specific
instructioons, by using the literal keyword "screen" to denote the
specific screen.

For example:

    EWMHBaseStruts screen HDMI-1 0 0 20 20

Change these commands so that this is the case.  This also includes
hard-coded references to commands used by modules, such as FvwmPager.

This is a breaking syntax change.

Fixes #965
  • Loading branch information
ThomasAdam committed Mar 20, 2024
1 parent 5440ca5 commit 068fe2c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 65 deletions.
97 changes: 37 additions & 60 deletions fvwm/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#define CMD_GOTO_DESK(m, d) \
do { \
char *cmd; \
xasprintf(&cmd, "GotoDesk %s 0 %d", (m)->si->name, (d)); \
xasprintf(&cmd, "GotoDesk screen %s 0 %d", (m)->si->name, (d)); \
execute_function_override_window( \
NULL, NULL, cmd, NULL, 0, NULL); \
free(cmd); \
Expand Down Expand Up @@ -1819,42 +1819,30 @@ Bool get_page_arguments(
int mw, mh;
char *token;
char *taction;
char *next;
int wrapx;
int wrapy;
int limitdeskx;
int limitdesky;
struct monitor *m;
struct monitor *m = NULL;

wrapx = 0;
wrapy = 0;
limitdeskx = 1;
limitdesky = 1;

/* We've received something like:
*
* GotoPage 0 0
*
* But no monitor token. Use the current monitor.
*/
if (GetIntegerArguments(action, NULL, val, 2) == 2) {
xasprintf(&action, "%s %d %d",
monitor_get_current()->si->name, val[0], val[1]);
token = PeekToken(action, NULL);
if (StrEquals(token, "screen")) {
/* Skip literal 'screen' */
token = PeekToken(action, &action);
/* Actually get the screen value. */
token = PeekToken(action, &action);

val[0] = -1;
val[1] = -1;
if ((m = monitor_resolve_name(token)) == NULL)
fvwm_debug(__func__, "Invalid screen: %s", token);
}

token = PeekToken(action, &next);
m = monitor_resolve_name(token);
if (m != NULL)
{
action = next;
}
else
{
m = (fw && fw->m) ? fw->m : monitor_get_current();
}
if (m == NULL)
monitor_get_current();
*mret = m;

mw = monitor_get_all_widths();
Expand Down Expand Up @@ -2358,7 +2346,7 @@ void CMD_DesktopConfiguration(F_CMD_ARGS)
RB_FOREACH(m_loop, monitors, &monitor_q) {
if (m_loop == m)
continue;
xasprintf(&cmd, "GotoDeskAndPage %s %d %d %d",
xasprintf(&cmd, "GotoDeskAndPage screen %s %d %d %d",
m_loop->si->name,
m->virtual_scr.CurrentDesk,
m->virtual_scr.Vx / monitor_get_all_widths(),
Expand Down Expand Up @@ -2561,23 +2549,24 @@ void CMD_DesktopSize(F_CMD_ARGS)
void CMD_GotoDesk(F_CMD_ARGS)
{
struct monitor *m, *m_loop;
char *next, *token;
char *token;
int new_desk;

/* We've received something like:
*
* GotoDesk 0 0
*
* But no monitor token. Use the current monitor.
*/
token = PeekToken(action, &next);
m = monitor_resolve_name(token);
if (m == NULL) {
m = monitor_get_current();
next = action;
token = PeekToken(action, NULL);
if (StrEquals(token, "screen")) {
/* Skip literal 'screen' */
token = PeekToken(action, &action);
/* Actually get the screen value. */
token = PeekToken(action, &action);

if ((m = monitor_resolve_name(token)) == NULL)
fvwm_debug(__func__, "Invalid screen: %s", token);
}

new_desk = GetDeskNumber(m, next, m->virtual_scr.CurrentDesk);
if (m == NULL)
m = monitor_get_current();

new_desk = GetDeskNumber(m, action, m->virtual_scr.CurrentDesk);

if (is_tracking_shared) {
/* Check to see if this monitor is requesting a desktop which
Expand Down Expand Up @@ -2633,34 +2622,22 @@ void CMD_GotoDeskAndPage(F_CMD_ARGS)
int val[3];
int current_desk;
Bool is_new_desk;
char *next;
char *token;
struct monitor *m;

/* We've received something like:
*
* GotoDeskAndPage 0 0
*
* But no monitor token. Use the current monitor.
*/
if (GetIntegerArguments(action, NULL, val, 2) == 2) {
xasprintf(&action, "%s %d %d",
monitor_get_current()->si->name, val[0], val[1]);
token = PeekToken(action, NULL);
if (StrEquals(token, "screen")) {
/* Skip literal 'screen' */
token = PeekToken(action, &action);
/* Actually get the screen value. */
token = PeekToken(action, &action);

val[0] = -1;
val[1] = -1;
}
token = PeekToken(action, &next);
m = monitor_resolve_name(token);
if (m != NULL)
{
action = next;
if ((m = monitor_resolve_name(token)) == NULL)
fvwm_debug(__func__, "Invalid screen: %s", token);
}
else
{

if (m == NULL)
m = monitor_get_current();
}
/* FIXME: monitor needs broadcast when global. */

if (MatchToken(action, "prev"))
{
Expand Down
10 changes: 5 additions & 5 deletions modules/FvwmPager/x_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ void MovePage(Bool is_new_desk)
sptr = Desks[fp->m->virtual_scr.CurrentDesk -desk1].label;
else
{
snprintf(str, sizeof(str), "GotoDesk %s %d", fp->m->si->name, fp->m->virtual_scr.CurrentDesk);
snprintf(str, sizeof(str), "GotoDesk screen %s %d", fp->m->si->name, fp->m->virtual_scr.CurrentDesk);
sptr = &str[0];
}

Expand Down Expand Up @@ -1935,7 +1935,7 @@ void SwitchToDesk(int Desk)
return;
}
snprintf(command, sizeof(command),
"GotoDesk %s 0 %d", fp->m->si->name, Desk + desk1);
"GotoDesk screen %s 0 %d", fp->m->si->name, Desk + desk1);
SendText(fd,command,0);
}

Expand Down Expand Up @@ -1964,7 +1964,7 @@ void SwitchToDeskAndPage(int Desk, XEvent *Event)
vy = Event->xbutton.y * fp->virtual_scr.VHeight / (desk_h * monitor_get_all_heights());
fp->m->virtual_scr.Vx = vx * monitor_get_all_widths();
fp->m->virtual_scr.Vy = vy * monitor_get_all_heights();
snprintf(command, sizeof(command), "GotoDeskAndPage %s %d %d %d",
snprintf(command, sizeof(command), "GotoDeskAndPage screen %s %d %d %d",
fp->m->si->name, Desk + desk1, vx, vy);
SendText(fd, command, 0);

Expand Down Expand Up @@ -1992,7 +1992,7 @@ void SwitchToDeskAndPage(int Desk, XEvent *Event)
x = fp->virtual_scr.VxMax / monitor_get_all_widths();
if (y * monitor_get_all_heights() > fp->virtual_scr.VyMax)
y = fp->virtual_scr.VyMax / monitor_get_all_heights();
snprintf(command, sizeof(command), "GotoPage %s %d %d", fp->m->si->name, x, y);
snprintf(command, sizeof(command), "GotoPage screen %s %d %d", fp->m->si->name, x, y);
SendText(fd, command, 0);
}
Wait = 1;
Expand All @@ -2008,7 +2008,7 @@ void IconSwitchPage(XEvent *Event)
return;
}

snprintf(command,sizeof(command),"GotoPage %s %d %d",
snprintf(command,sizeof(command),"GotoPage screen %s %d %d",
fp->m->si->name,
Event->xbutton.x * fp->virtual_scr.VWidth /
(icon.width * monitor_get_all_widths()),
Expand Down

0 comments on commit 068fe2c

Please sign in to comment.