aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2016-01-25 16:06:46 -0500
committerDrew DeVault <sir@cmpwn.com>2016-01-25 16:06:46 -0500
commitf1e1ba0a5689966984f71a00572b89ea2d26f06b (patch)
tree7d7319859fdfa90ac7e6803b634f38a5418bb180
parentd2af1f33951220c2a9fc691034084d7276aafbc5 (diff)
parenta5345e807e229ee9e0e2f4bcb148aab0e7216e22 (diff)
Merge pull request #476 from christophgysin/cairo_set_source_u32
extract cairo_set_source_u32()
-rw-r--r--include/client/cairo.h5
-rw-r--r--swaybar/CMakeLists.txt6
-rw-r--r--swaybar/render.c9
-rw-r--r--swaylock/main.c8
-rw-r--r--wayland/cairo.c9
5 files changed, 20 insertions, 17 deletions
diff --git a/include/client/cairo.h b/include/client/cairo.h
index ad8390c4..46c53566 100644
--- a/include/client/cairo.h
+++ b/include/client/cairo.h
@@ -1,6 +1,11 @@
#ifndef _SWAY_CAIRO_H
#define _SWAY_CAIRO_H
+#include <stdint.h>
+#include <cairo/cairo.h>
+
+void cairo_set_source_u32(cairo_t *cairo, uint32_t color);
+
#ifdef WITH_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>
diff --git a/swaybar/CMakeLists.txt b/swaybar/CMakeLists.txt
index 60975f40..5b865083 100644
--- a/swaybar/CMakeLists.txt
+++ b/swaybar/CMakeLists.txt
@@ -25,6 +25,12 @@ target_link_libraries(swaybar
${JSONC_LIBRARIES}
)
+if (WITH_GDK_PIXBUF)
+ include_directories(
+ ${GDK_PIXBUF_INCLUDE_DIRS}
+ )
+endif()
+
install(
TARGETS swaybar
RUNTIME
diff --git a/swaybar/render.c b/swaybar/render.c
index ce5d10b4..1573a373 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -2,6 +2,7 @@
#include <stdint.h>
#include <string.h>
+#include "client/cairo.h"
#include "client/pango.h"
#include "client/window.h"
#include "bar/config.h"
@@ -15,14 +16,6 @@ static int ws_horizontal_padding = 5;
static double ws_vertical_padding = 1.5;
static int ws_spacing = 1;
-static void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
- cairo_set_source_rgba(cairo,
- ((color & 0xFF000000) >> 24) / 255.0,
- ((color & 0xFF0000) >> 16) / 255.0,
- ((color & 0xFF00) >> 8) / 255.0,
- (color & 0xFF) / 255.0);
-}
-
/**
* Renders a sharp line of any width and height.
*
diff --git a/swaylock/main.c b/swaylock/main.c
index 98e26839..f0fe1d00 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -115,14 +115,6 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod
}
}
-static void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
- cairo_set_source_rgba(cairo,
- (color >> (3*8) & 0xFF) / 255.0,
- (color >> (2*8) & 0xFF) / 255.0,
- (color >> (1*8) & 0xFF) / 255.0,
- (color >> (0*8) & 0xFF) / 255.0);
-}
-
void render_color(struct window *window, uint32_t color) {
cairo_set_source_u32(window->cairo, color);
cairo_paint(window->cairo);
diff --git a/wayland/cairo.c b/wayland/cairo.c
index 7462b10a..ba439d9d 100644
--- a/wayland/cairo.c
+++ b/wayland/cairo.c
@@ -1,6 +1,13 @@
-#include <cairo/cairo.h>
#include "client/cairo.h"
+void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
+ cairo_set_source_rgba(cairo,
+ (color >> (3*8) & 0xFF) / 255.0,
+ (color >> (2*8) & 0xFF) / 255.0,
+ (color >> (1*8) & 0xFF) / 255.0,
+ (color >> (0*8) & 0xFF) / 255.0);
+}
+
#ifdef WITH_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>