Skip to content

Commit eb8cc43

Browse files
committed
Make screen option of icon boxes work again
Make IconBox screen option working again even with several monitors. Signed-off-by: Werner Fink <werner@suse.de>
1 parent a15c008 commit eb8cc43

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

fvwm/icons.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,18 +1786,18 @@ void AutoPlaceIcon(
17861786
icon_boxes_ptr = NULL; /* init */
17871787
while(do_all_iconboxes(t, &icon_boxes_ptr))
17881788
{
1789+
struct monitor *m;
17891790
if (loc_ok == True)
17901791
{
17911792
/* leave for loop */
17921793
break;
17931794
}
17941795
/* get the screen dimensions for the icon box */
1795-
FScreenGetScrRect(fscr, FSCREEN_CURRENT,
1796-
&ref.x, &ref.y, &ref.width, &ref.height);
1797-
dim[1].screen_offset = ref.y;
1798-
dim[1].screen_dimension = ref.height;
1799-
dim[2].screen_offset = ref.x;
1800-
dim[2].screen_dimension = ref.width;
1796+
m = monitor_resolve_name(icon_boxes_ptr->IconScreen);
1797+
dim[1].screen_offset = ref.y = m->si->y;
1798+
dim[1].screen_dimension = ref.height = m->si->h;
1799+
dim[2].screen_offset = ref.x = m->si->x;
1800+
dim[2].screen_dimension = ref.width = m->si->w;
18011801
/* y amount */
18021802
dim[1].step = icon_boxes_ptr->IconGrid[1];
18031803
/* init start from */
@@ -1939,8 +1939,14 @@ void AutoPlaceIcon(
19391939
real_y = dim[1].real_start;
19401940
}
19411941

1942+
/* get real location of screen */
1943+
fscreen_scr_t screen = ScreenToFScreen(icon_boxes_ptr->IconScreen);
1944+
if (screen == FSCREEN_BY_NAME)
1945+
{
1946+
fscr->name = icon_boxes_ptr->IconScreen;
1947+
}
19421948
/* this may be a good location */
1943-
if (FScreenIsRectangleOnScreen(fscr, FSCREEN_XYPOS, &ref))
1949+
if (FScreenIsRectangleOnScreen(fscr, screen, &ref))
19441950
{
19451951
loc_ok = True;
19461952
}
@@ -2035,6 +2041,8 @@ do_all_iconboxes(FvwmWindow *t, icon_boxes **icon_boxes_ptr)
20352041
global_icon_box_ptr->IconGrid[0] = 80;
20362042
global_icon_box_ptr->IconGrid[1] = 80;
20372043
global_icon_box_ptr->IconFlags = ICONFILLHRZ;
2044+
global_icon_box_ptr->IconScreen = "p";
2045+
global_icon_box_ptr->do_free_screen = 0;
20382046
}
20392047
if (*icon_boxes_ptr == NULL)
20402048
{

fvwm/style.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ static char *style_parse_icon_box_style(
19641964

19651965
/* otherwise try to parse the icon box */
19661966
IconBoxes = fxcalloc(1, sizeof(icon_boxes));
1967-
IconBoxes->IconScreen = "global";
1967+
IconBoxes->IconScreen = "g";
19681968
/* init grid x */
19691969
IconBoxes->IconGrid[0] = 3;
19701970
/* init grid y */
@@ -1976,7 +1976,9 @@ static char *style_parse_icon_box_style(
19761976
is_screen_given = True;
19771977
option = PeekToken(rest, &rest); /* skip screen */
19781978
option = PeekToken(rest, &rest); /* get the screen spec */
1979-
IconBoxes->IconScreen = option;
1979+
/* GetIntegerArguments() below removes screen */
1980+
IconBoxes->IconScreen = fxstrdup(option);
1981+
IconBoxes->do_free_screen = 1;
19801982
}
19811983

19821984
/* try for 4 numbers x y x y */

libs/FScreen.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,23 @@ const char *FScreenOfPointerXY(int, int);
200200
int monitor_get_count(void);
201201
struct monitor *FindScreenOfXY(int, int);
202202

203+
inline int ScreenToFScreen(const char *scr)
204+
{
205+
if (!scr)
206+
return FSCREEN_CURRENT;
207+
switch (*scr) {
208+
case 'g':
209+
return FSCREEN_GLOBAL;
210+
case 'p':
211+
return FSCREEN_PRIMARY;
212+
case 'c':
213+
return FSCREEN_CURRENT;
214+
case 'w':
215+
return FSCREEN_XYPOS;
216+
}
217+
return FSCREEN_BY_NAME;
218+
}
219+
203220
/* Clipping/positioning */
204221
int FScreenClipToScreen(fscreen_scr_arg *, fscreen_scr_t,
205222
int *x, int *y, int w, int h);

0 commit comments

Comments
 (0)