From: Christophe CURIS <christophe.cu...@free.fr> The flags were stored as 'char' but it is more logical to use int which is "the natural size for integer on the host" and may help future evolution if new flags are added;
The array is created with an initial size consistent with the number of element we feed it with in 'makeWindowFlagsArray', this avoids a bunch of realloc; Fixed the type conversion that was not right, as pointed by clang. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- src/switchpanel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/switchpanel.c b/src/switchpanel.c index 98a296d..1608365 100644 --- a/src/switchpanel.c +++ b/src/switchpanel.c @@ -109,8 +109,8 @@ static void changeImage(WSwitchPanel *panel, int idecks, int selected, Bool dim, { WMFrame *icon = NULL; RImage *image = NULL; - char flags = 0; - char desired = 0; + int flags; + int desired = 0; /* This whole function is a no-op if we aren't drawing the panel */ if (!wPreferences.swtileImage) @@ -118,7 +118,7 @@ static void changeImage(WSwitchPanel *panel, int idecks, int selected, Bool dim, icon = WMGetFromArray(panel->icons, idecks); image = WMGetFromArray(panel->images, idecks); - flags = (char) (uintptr_t) WMGetFromArray(panel->flags, idecks); + flags = (int) (uintptr_t) WMGetFromArray(panel->flags, idecks); if (selected) desired |= ICON_SELECTED; @@ -227,7 +227,7 @@ static void scrollIcons(WSwitchPanel *panel, int delta) for (i = panel->firstVisible; i < panel->firstVisible + panel->visibleCount; i++) { if (i == panel->current) continue; - dim = ((char) (uintptr_t) WMGetFromArray(panel->flags, i) & ICON_DIM); + dim = ((int) (uintptr_t) WMGetFromArray(panel->flags, i) & ICON_DIM); changeImage(panel, i, 0, dim, True); } } @@ -403,11 +403,11 @@ static WMArray *makeWindowListArray(WWindow *curwin, int include_unmapped, Bool static WMArray *makeWindowFlagsArray(int count) { - WMArray *flags = WMCreateArray(1); + WMArray *flags = WMCreateArray(count); int i; for (i = 0; i < count; i++) - WMAddToArray(flags, (char) 0); + WMAddToArray(flags, (void *) 0); return flags; } -- 1.9.2 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.