Skip to content

Commit

Permalink
FParseGeoemtry: fix negative offsets
Browse files Browse the repository at this point in the history
When parsing geometry strings, ensure the "global" screen is taken in to
account.  Prior to this, the individual monitor was assumed.

This should fix GH issue #28.
  • Loading branch information
ThomasAdam committed May 2, 2020
1 parent 5b9a891 commit 80117c5
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions libs/FScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,21 +760,25 @@ int FScreenParseGeometryWithScreen(
int ret;

/* Safety net */
if (parsestring == NULL || *parsestring == '\0')
if (parsestring == NULL || *parsestring == '\0') {
*screen_return = NULL;
return 0;
}

/* If the geometry specification contains an '@' symbol, assume the
* screen is specified. This must be the name of the monitor in
* question!
*/
/* No screen specified; parse geometry as standard. */
if (strchr(parsestring, '@') == NULL) {
*screen_return = NULL;
copy = fxstrdup(parsestring);
goto parse_geometry;
}

/* If the geometry specification contains an '@' symbol, assume the
* screen is specified. This must be the name of the monitor in
* question!
*/
copy = fxstrdup(parsestring);
copy = strsep(&parsestring, "@");
*screen_return = parsestring;
*screen_return = fxstrdup(parsestring);
geom_str = strsep(&copy, "@");
copy = geom_str;

Expand All @@ -800,23 +804,24 @@ int FScreenParseGeometry(
parsestring, x_return, y_return, width_return, height_return,
&scr);

if (scr != NULL)
if (scr != NULL) {
m = monitor_by_name(scr);
else
free(scr);
} else
m = monitor_get_current();

/* adapt geometry to selected screen */
if (rc & XValue)
{
if (rc & XNegative)
*x_return -= (m->si->w - m->si->x);
*x_return -= (m->virtual_scr.MyDisplayWidth - m->si->w - m->si->x);
else
*x_return += m->si->x;
}
if (rc & YValue)
{
if (rc & YNegative)
*y_return -= (m->si->h - m->si->y);
*y_return -= (m->virtual_scr.MyDisplayHeight - m->si->h - m->si->y);
else
*y_return += m->si->y;
}
Expand Down

0 comments on commit 80117c5

Please sign in to comment.