From 416c6ecb99f90a7c84cce0b106401652692a4681 Mon Sep 17 00:00:00 2001 From: Ian Fan Date: Thu, 28 Feb 2019 12:02:14 +0000 Subject: tray: fix pixmap colors by converting from network byte order to host byte order --- swaybar/tray/item.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/swaybar/tray/item.c b/swaybar/tray/item.c index 4fa6c97b..027b3001 100644 --- a/swaybar/tray/item.c +++ b/swaybar/tray/item.c @@ -1,4 +1,5 @@ #define _POSIX_C_SOURCE 200809L +#include #include #include #include @@ -76,7 +77,12 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni, struct swaybar_pixmap *pixmap = malloc(sizeof(struct swaybar_pixmap) + npixels); pixmap->size = height; - memcpy(pixmap->pixels, pixels, npixels); + + // convert from network byte order to host byte order + for (int i = 0; i < height * width; ++i) { + ((uint32_t *)pixmap->pixels)[i] = ntohl(((uint32_t *)pixels)[i]); + } + list_add(pixmaps, pixmap); } else { sway_log(SWAY_DEBUG, "%s %s: discard invalid icon w:%d h:%d", sni->watcher_id, prop, width, height); -- cgit v1.2.3