diff options
author | 2016-04-02 16:29:48 -0400 | |
---|---|---|
committer | 2016-04-02 16:29:48 -0400 | |
commit | ef45bac131c2197e2d4e60ffe72f9575c88a42a0 (patch) | |
tree | 367199f99b000db7110292ef81a89e4de60d545a /sway/border.c | |
parent | Merge pull request #569 from 1ace/master (diff) | |
parent | improve endianess handeling (diff) | |
download | sway-ef45bac131c2197e2d4e60ffe72f9575c88a42a0.tar.gz sway-ef45bac131c2197e2d4e60ffe72f9575c88a42a0.tar.zst sway-ef45bac131c2197e2d4e60ffe72f9575c88a42a0.zip |
Merge pull request #562 from fluxchief/border-endian
improve endianess handeling
Diffstat (limited to 'sway/border.c')
-rw-r--r-- | sway/border.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/sway/border.c b/sway/border.c index fa54ebe2..acabc8e0 100644 --- a/sway/border.c +++ b/sway/border.c | |||
@@ -8,21 +8,16 @@ | |||
8 | #include "config.h" | 8 | #include "config.h" |
9 | #include "client/pango.h" | 9 | #include "client/pango.h" |
10 | 10 | ||
11 | #include <arpa/inet.h> | ||
12 | |||
11 | void cairo_set_source_u32(cairo_t *cairo, uint32_t color) { | 13 | void cairo_set_source_u32(cairo_t *cairo, uint32_t color) { |
12 | int endian = 1; | 14 | color = htonl(color); |
13 | if (*(char *)&endian == 1) { // little endian | 15 | |
14 | cairo_set_source_rgba(cairo, | 16 | cairo_set_source_rgba(cairo, |
15 | (color >> (1*8) & 0xFF) / 255.0, | 17 | (color >> (2*8) & 0xFF) / 255.0, |
16 | (color >> (2*8) & 0xFF) / 255.0, | 18 | (color >> (1*8) & 0xFF) / 255.0, |
17 | (color >> (3*8) & 0xFF) / 255.0, | 19 | (color >> (0*8) & 0xFF) / 255.0, |
18 | (color >> (0*8) & 0xFF) / 255.0); | 20 | (color >> (3*8) & 0xFF) / 255.0); |
19 | } else { // big endian | ||
20 | cairo_set_source_rgba(cairo, | ||
21 | (color >> (0*8) & 0xFF) / 255.0, | ||
22 | (color >> (3*8) & 0xFF) / 255.0, | ||
23 | (color >> (2*8) & 0xFF) / 255.0, | ||
24 | (color >> (1*8) & 0xFF) / 255.0); | ||
25 | } | ||
26 | } | 21 | } |
27 | 22 | ||
28 | static cairo_t *create_border_buffer(swayc_t *view, struct wlc_geometry geo, cairo_surface_t **surface) { | 23 | static cairo_t *create_border_buffer(swayc_t *view, struct wlc_geometry geo, cairo_surface_t **surface) { |