aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2016-04-02 16:29:48 -0400
committerDrew DeVault <sir@cmpwn.com>2016-04-02 16:29:48 -0400
commitef45bac131c2197e2d4e60ffe72f9575c88a42a0 (patch)
tree367199f99b000db7110292ef81a89e4de60d545a /sway
parent4885a6c423b9bcf4a60e57b32f528b9c90d09cd8 (diff)
parent3953b064f54965e70eb9ddef6d5569201efd0690 (diff)
Merge pull request #562 from fluxchief/border-endian
improve endianess handeling
Diffstat (limited to 'sway')
-rw-r--r--sway/border.c23
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 @@
#include "config.h"
#include "client/pango.h"
+#include <arpa/inet.h>
+
void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
- int endian = 1;
- if (*(char *)&endian == 1) { // little endian
- cairo_set_source_rgba(cairo,
- (color >> (1*8) & 0xFF) / 255.0,
- (color >> (2*8) & 0xFF) / 255.0,
- (color >> (3*8) & 0xFF) / 255.0,
- (color >> (0*8) & 0xFF) / 255.0);
- } else { // big endian
- cairo_set_source_rgba(cairo,
- (color >> (0*8) & 0xFF) / 255.0,
- (color >> (3*8) & 0xFF) / 255.0,
- (color >> (2*8) & 0xFF) / 255.0,
- (color >> (1*8) & 0xFF) / 255.0);
- }
+ color = htonl(color);
+
+ cairo_set_source_rgba(cairo,
+ (color >> (2*8) & 0xFF) / 255.0,
+ (color >> (1*8) & 0xFF) / 255.0,
+ (color >> (0*8) & 0xFF) / 255.0,
+ (color >> (3*8) & 0xFF) / 255.0);
}
static cairo_t *create_border_buffer(swayc_t *view, struct wlc_geometry geo, cairo_surface_t **surface) {