Skip to content

Commit 7fbba48

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 7fbba48

File tree

4 files changed

+47
-12
lines changed

4 files changed

+47
-12
lines changed

fvwm/icons.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,13 +1786,19 @@ void AutoPlaceIcon(
17861786
icon_boxes_ptr = NULL; /* init */
17871787
while(do_all_iconboxes(t, &icon_boxes_ptr))
17881788
{
1789+
fscreen_scr_t screen;
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+
screen = FSCREEN_CURRENT;
1797+
if (icon_boxes_ptr->IconScreen)
1798+
screen = ScreenToFScreen(icon_boxes_ptr->IconScreen);
1799+
if (screen == FSCREEN_BY_NAME)
1800+
fscr->name = icon_boxes_ptr->IconScreen;
1801+
FScreenGetScrRect(fscr, screen,
17961802
&ref.x, &ref.y, &ref.width, &ref.height);
17971803
dim[1].screen_offset = ref.y;
17981804
dim[1].screen_dimension = ref.height;
@@ -1940,7 +1946,7 @@ void AutoPlaceIcon(
19401946
}
19411947

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.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ monitor_resolve_name(const char *scr)
241241
struct monitor *m = NULL;
242242
int pos = -1;
243243
const char *errstr;
244+
fscreen_scr_t fscreen;
244245

245246
if (scr == NULL)
246247
{
@@ -255,20 +256,25 @@ monitor_resolve_name(const char *scr)
255256
if (errstr == NULL)
256257
return (monitor_by_number(pos));
257258

258-
/* "@g" is for the global screen. */
259-
if (strcmp(scr, "g") == 0) {
259+
fscreen = ScreenToFScreen(scr);
260+
261+
switch (fscreen) {
262+
case FSCREEN_GLOBAL:
260263
m = monitor_get_global();
261-
}
262-
/* "@c" is for the current screen. */
263-
else if (strcmp(scr, "c") == 0)
264+
break;
265+
case FSCREEN_CURRENT: FSCREEN_XYPOS:
264266
m = monitor_get_current();
265-
/* "@p" is for the primary screen. */
266-
else if (strcmp(scr, "p") == 0)
267+
break;
268+
case FSCREEN_PRIMARY:
267269
m = monitor_by_primary();
268-
else
270+
break;
271+
case FSCREEN_BY_NAME:
272+
default:
269273
/* Assume the monitor name is a literal RandR name (such as
270274
* HDMI2). */
271275
m = monitor_by_name(scr);
276+
break;
277+
}
272278

273279
return (m);
274280
}

libs/FScreen.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,25 @@ 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+
if (*scr == '@')
208+
scr++;
209+
switch (*scr) {
210+
case 'g':
211+
return FSCREEN_GLOBAL;
212+
case 'p':
213+
return FSCREEN_PRIMARY;
214+
case 'c':
215+
return FSCREEN_CURRENT;
216+
case 'w':
217+
return FSCREEN_XYPOS;
218+
}
219+
return FSCREEN_BY_NAME;
220+
}
221+
203222
/* Clipping/positioning */
204223
int FScreenClipToScreen(fscreen_scr_arg *, fscreen_scr_t,
205224
int *x, int *y, int w, int h);

0 commit comments

Comments
 (0)