aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2019-02-28 12:02:14 +0000
committerLibravatar emersion <contact@emersion.fr>2019-02-28 18:31:52 +0100
commit416c6ecb99f90a7c84cce0b106401652692a4681 (patch)
treead40376c5c9369948d493729a68cea2c68cd3b1f /swaybar
parentMerge pull request #3790 from RedSoxFan/sway-ipc-clarify-window-rect (diff)
downloadsway-416c6ecb99f90a7c84cce0b106401652692a4681.tar.gz
sway-416c6ecb99f90a7c84cce0b106401652692a4681.tar.zst
sway-416c6ecb99f90a7c84cce0b106401652692a4681.zip
tray: fix pixmap colors
by converting from network byte order to host byte order
Diffstat (limited to 'swaybar')
-rw-r--r--swaybar/tray/item.c8
1 files changed, 7 insertions, 1 deletions
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 @@
1#define _POSIX_C_SOURCE 200809L 1#define _POSIX_C_SOURCE 200809L
2#include <arpa/inet.h>
2#include <cairo.h> 3#include <cairo.h>
3#include <stdbool.h> 4#include <stdbool.h>
4#include <stdlib.h> 5#include <stdlib.h>
@@ -76,7 +77,12 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
76 struct swaybar_pixmap *pixmap = 77 struct swaybar_pixmap *pixmap =
77 malloc(sizeof(struct swaybar_pixmap) + npixels); 78 malloc(sizeof(struct swaybar_pixmap) + npixels);
78 pixmap->size = height; 79 pixmap->size = height;
79 memcpy(pixmap->pixels, pixels, npixels); 80
81 // convert from network byte order to host byte order
82 for (int i = 0; i < height * width; ++i) {
83 ((uint32_t *)pixmap->pixels)[i] = ntohl(((uint32_t *)pixels)[i]);
84 }
85
80 list_add(pixmaps, pixmap); 86 list_add(pixmaps, pixmap);
81 } else { 87 } else {
82 sway_log(SWAY_DEBUG, "%s %s: discard invalid icon w:%d h:%d", sni->watcher_id, prop, width, height); 88 sway_log(SWAY_DEBUG, "%s %s: discard invalid icon w:%d h:%d", sni->watcher_id, prop, width, height);