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

IconBox: reference screen correctly #129

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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