Skip to content

Commit

Permalink
IconBox: reference screen correctly
Browse files Browse the repository at this point in the history
When the IconBox style is used to specify a particular screen, use the
existing API to reference that screen.

Fixes #40
  • Loading branch information
ThomasAdam committed Sep 4, 2022
1 parent bc12d21 commit 8c17284
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
13 changes: 12 additions & 1 deletion fvwm/icons.c
Original file line number Diff line number Diff line change
Expand Up @@ -1791,8 +1791,19 @@ void AutoPlaceIcon(
break;
}
/* get the screen dimensions for the icon box */
FScreenGetScrRect(fscr, FSCREEN_CURRENT,
if (icon_boxes_ptr->IconScreen == NULL ||
strcmp(icon_boxes_ptr->IconScreen, "global") == 0) {
ref.x = 0;
ref.y = 0;
ref.width = monitor_get_all_widths();
ref.height = monitor_get_all_heights();
fvwm_debug(__func__, "using global screen");
} else {
fscr->name = icon_boxes_ptr->IconScreen;
FScreenGetScrRect(fscr, FSCREEN_BY_NAME,
&ref.x, &ref.y, &ref.width, &ref.height);
fvwm_debug(__func__, "using screen %s ", fscr->name);
}
dim[1].screen_offset = ref.y;
dim[1].screen_dimension = ref.height;
dim[2].screen_offset = ref.x;
Expand Down
17 changes: 9 additions & 8 deletions fvwm/style.c
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ static char *style_parse_icon_box_style(

/* otherwise try to parse the icon box */
IconBoxes = fxcalloc(1, sizeof(icon_boxes));
IconBoxes->IconScreen = "global";
IconBoxes->IconScreen = fxstrdup("global");
/* init grid x */
IconBoxes->IconGrid[0] = 3;
/* init grid y */
Expand All @@ -1838,7 +1838,10 @@ static char *style_parse_icon_box_style(
is_screen_given = True;
option = PeekToken(rest, &rest); /* skip screen */
option = PeekToken(rest, &rest); /* get the screen spec */
IconBoxes->IconScreen = option;
free(IconBoxes->IconScreen);
IconBoxes->IconScreen = fxstrdup(option);

fvwm_debug(__func__, "screen set: %s", option);
}

/* try for 4 numbers x y x y */
Expand Down Expand Up @@ -1892,16 +1895,19 @@ static char *style_parse_icon_box_style(
option = PeekToken(rest, NULL);
if (!option)
{
fvwm_debug(__func__, "No option set, returning: <<%s>>", rest);
return rest;
}
l = strlen(option);
if (l > 0 && l < 24)
{
char *scr;

fvwm_debug(__func__, "option 1: %s", option);
/* advance */
option = PeekToken(rest, &rest);
/* if word found, not too long */
fvwm_debug(__func__, "option 2: %s", option);
geom_flags = FScreenParseGeometryWithScreen(
option, &IconBoxes->IconBox[0],
&IconBoxes->IconBox[1], (unsigned int*)&width,
Expand Down Expand Up @@ -4810,12 +4816,7 @@ void free_icon_boxes(icon_boxes *ib)
temp = ib->next;
if (ib->use_count == 0)
{
if (ib->do_free_screen)
{
free(ib->IconScreen);
ib->IconScreen = NULL;
ib->do_free_screen = 0;
}
free(ib->IconScreen);
free(ib);
}
else
Expand Down

0 comments on commit 8c17284

Please sign in to comment.