Skip to content

Commit 8c17284

Browse files
committed
IconBox: reference screen correctly
When the IconBox style is used to specify a particular screen, use the existing API to reference that screen. Fixes #40
1 parent bc12d21 commit 8c17284

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

fvwm/icons.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1791,8 +1791,19 @@ void AutoPlaceIcon(
17911791
break;
17921792
}
17931793
/* get the screen dimensions for the icon box */
1794-
FScreenGetScrRect(fscr, FSCREEN_CURRENT,
1794+
if (icon_boxes_ptr->IconScreen == NULL ||
1795+
strcmp(icon_boxes_ptr->IconScreen, "global") == 0) {
1796+
ref.x = 0;
1797+
ref.y = 0;
1798+
ref.width = monitor_get_all_widths();
1799+
ref.height = monitor_get_all_heights();
1800+
fvwm_debug(__func__, "using global screen");
1801+
} else {
1802+
fscr->name = icon_boxes_ptr->IconScreen;
1803+
FScreenGetScrRect(fscr, FSCREEN_BY_NAME,
17951804
&ref.x, &ref.y, &ref.width, &ref.height);
1805+
fvwm_debug(__func__, "using screen %s ", fscr->name);
1806+
}
17961807
dim[1].screen_offset = ref.y;
17971808
dim[1].screen_dimension = ref.height;
17981809
dim[2].screen_offset = ref.x;

fvwm/style.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ static char *style_parse_icon_box_style(
18261826

18271827
/* otherwise try to parse the icon box */
18281828
IconBoxes = fxcalloc(1, sizeof(icon_boxes));
1829-
IconBoxes->IconScreen = "global";
1829+
IconBoxes->IconScreen = fxstrdup("global");
18301830
/* init grid x */
18311831
IconBoxes->IconGrid[0] = 3;
18321832
/* init grid y */
@@ -1838,7 +1838,10 @@ static char *style_parse_icon_box_style(
18381838
is_screen_given = True;
18391839
option = PeekToken(rest, &rest); /* skip screen */
18401840
option = PeekToken(rest, &rest); /* get the screen spec */
1841-
IconBoxes->IconScreen = option;
1841+
free(IconBoxes->IconScreen);
1842+
IconBoxes->IconScreen = fxstrdup(option);
1843+
1844+
fvwm_debug(__func__, "screen set: %s", option);
18421845
}
18431846

18441847
/* try for 4 numbers x y x y */
@@ -1892,16 +1895,19 @@ static char *style_parse_icon_box_style(
18921895
option = PeekToken(rest, NULL);
18931896
if (!option)
18941897
{
1898+
fvwm_debug(__func__, "No option set, returning: <<%s>>", rest);
18951899
return rest;
18961900
}
18971901
l = strlen(option);
18981902
if (l > 0 && l < 24)
18991903
{
19001904
char *scr;
19011905

1906+
fvwm_debug(__func__, "option 1: %s", option);
19021907
/* advance */
19031908
option = PeekToken(rest, &rest);
19041909
/* if word found, not too long */
1910+
fvwm_debug(__func__, "option 2: %s", option);
19051911
geom_flags = FScreenParseGeometryWithScreen(
19061912
option, &IconBoxes->IconBox[0],
19071913
&IconBoxes->IconBox[1], (unsigned int*)&width,
@@ -4810,12 +4816,7 @@ void free_icon_boxes(icon_boxes *ib)
48104816
temp = ib->next;
48114817
if (ib->use_count == 0)
48124818
{
4813-
if (ib->do_free_screen)
4814-
{
4815-
free(ib->IconScreen);
4816-
ib->IconScreen = NULL;
4817-
ib->do_free_screen = 0;
4818-
}
4819+
free(ib->IconScreen);
48194820
free(ib);
48204821
}
48214822
else

0 commit comments

Comments
 (0)