]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/{common/font,theme}.c: Switch to cairo helpers
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 26 Aug 2022 02:50:54 +0000 (04:50 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 26 Aug 2022 05:54:12 +0000 (06:54 +0100)
src/common/font.c
src/theme.c

index 9fd49b50113922183ab477f80648628eb1a9e97c..ff1b84da7fe155113d4ad0040df0db5f0c9aca0c 100644 (file)
@@ -7,6 +7,7 @@
 #include <wlr/util/box.h>
 #include <wlr/util/log.h>
 #include "common/font.h"
+#include "common/graphic-helpers.h"
 #include "labwc.h"
 #include "buffer.h"
 
@@ -99,7 +100,7 @@ font_buffer_create(struct lab_data_buffer **buffer, int max_width,
        cairo_t *cairo = (*buffer)->cairo;
        cairo_surface_t *surf = cairo_get_target(cairo);
 
-       cairo_set_source_rgba(cairo, color[0], color[1], color[2], color[3]);
+       set_cairo_color(cairo, color);
        cairo_move_to(cairo, 0, 0);
 
        PangoLayout *layout = pango_cairo_create_layout(cairo);
index a0c3e99edb828384a1b57749b795bb4f64cb0cc0..bdd6a21a79d870ea0d2e04441d8cbe5ba1da1302 100644 (file)
@@ -20,6 +20,7 @@
 #include <strings.h>
 #include "common/dir.h"
 #include "common/font.h"
+#include "common/graphic-helpers.h"
 #include "common/string-helpers.h"
 #include "common/zfree.h"
 #include "config/rcxml.h"
@@ -358,12 +359,6 @@ struct rounded_corner_ctx {
        } corner;
 };
 
-static void
-set_source(cairo_t *cairo, float *c)
-{
-       cairo_set_source_rgba(cairo, c[0], c[1], c[2], c[3]);
-}
-
 static struct lab_data_buffer *
 rounded_rect(struct rounded_corner_ctx *ctx)
 {
@@ -410,13 +405,13 @@ rounded_rect(struct rounded_corner_ctx *ctx)
        }
        cairo_close_path(cairo);
        cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
-       set_source(cairo, ctx->fill_color);
+       set_cairo_color(cairo, ctx->fill_color);
        cairo_fill_preserve(cairo);
        cairo_stroke(cairo);
 
        /* border */
        cairo_set_line_cap(cairo, CAIRO_LINE_CAP_ROUND);
-       set_source(cairo, ctx->border_color);
+       set_cairo_color(cairo, ctx->border_color);
        cairo_set_line_width(cairo, ctx->line_width);
        double half_line_width = ctx->line_width / 2.0;
        switch (ctx->corner) {