summaryrefslogtreecommitdiffstats
path: root/wayland
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-28 22:22:46 +0200
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-30 00:47:58 +0200
commitcefcce48aad4e452be9d081b1cd1521e2b042e97 (patch)
treea1baadb89b2d94f63175f61c2459d77cd2819ab4 /wayland
parentMake pango: prefix optional for font config (diff)
downloadsway-cefcce48aad4e452be9d081b1cd1521e2b042e97.tar.gz
sway-cefcce48aad4e452be9d081b1cd1521e2b042e97.tar.zst
sway-cefcce48aad4e452be9d081b1cd1521e2b042e97.zip
Make client/pango.h not depend on client/window.h
Diffstat (limited to 'wayland')
-rw-r--r--wayland/pango.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/wayland/pango.c b/wayland/pango.c
index 9766be6a..d79d89b3 100644
--- a/wayland/pango.c
+++ b/wayland/pango.c
@@ -4,21 +4,19 @@
4#include <stdlib.h> 4#include <stdlib.h>
5#include <string.h> 5#include <string.h>
6#include <stdio.h> 6#include <stdio.h>
7#include "client/window.h"
8#include "client/buffer.h"
9#include "log.h" 7#include "log.h"
10 8
11PangoLayout *get_pango_layout(struct window *window, const char *text) { 9PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text) {
12 PangoLayout *layout = pango_cairo_create_layout(window->cairo); 10 PangoLayout *layout = pango_cairo_create_layout(cairo);
13 pango_layout_set_text(layout, text, -1); 11 pango_layout_set_text(layout, text, -1);
14 PangoFontDescription *desc = pango_font_description_from_string(window->font); 12 PangoFontDescription *desc = pango_font_description_from_string(font);
15 pango_layout_set_font_description(layout, desc); 13 pango_layout_set_font_description(layout, desc);
16 pango_layout_set_single_paragraph_mode(layout, 1); 14 pango_layout_set_single_paragraph_mode(layout, 1);
17 pango_font_description_free(desc); 15 pango_font_description_free(desc);
18 return layout; 16 return layout;
19} 17}
20 18
21void get_text_size(struct window *window, int *width, int *height, const char *fmt, ...) { 19void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, const char *fmt, ...) {
22 char *buf = malloc(2048); 20 char *buf = malloc(2048);
23 21
24 va_list args; 22 va_list args;
@@ -28,8 +26,8 @@ void get_text_size(struct window *window, int *width, int *height, const char *f
28 } 26 }
29 va_end(args); 27 va_end(args);
30 28
31 PangoLayout *layout = get_pango_layout(window, buf); 29 PangoLayout *layout = get_pango_layout(cairo, font, buf);
32 pango_cairo_update_layout(window->cairo, layout); 30 pango_cairo_update_layout(cairo, layout);
33 31
34 pango_layout_get_pixel_size(layout, width, height); 32 pango_layout_get_pixel_size(layout, width, height);
35 33
@@ -38,7 +36,7 @@ void get_text_size(struct window *window, int *width, int *height, const char *f
38 free(buf); 36 free(buf);
39} 37}
40 38
41void pango_printf(struct window *window, const char *fmt, ...) { 39void pango_printf(cairo_t *cairo, const char *font, const char *fmt, ...) {
42 char *buf = malloc(2048); 40 char *buf = malloc(2048);
43 41
44 va_list args; 42 va_list args;
@@ -48,10 +46,10 @@ void pango_printf(struct window *window, const char *fmt, ...) {
48 } 46 }
49 va_end(args); 47 va_end(args);
50 48
51 PangoLayout *layout = get_pango_layout(window, buf); 49 PangoLayout *layout = get_pango_layout(cairo, font, buf);
52 pango_cairo_update_layout(window->cairo, layout); 50 pango_cairo_update_layout(cairo, layout);
53 51
54 pango_cairo_show_layout(window->cairo, layout); 52 pango_cairo_show_layout(cairo, layout);
55 53
56 g_object_unref(layout); 54 g_object_unref(layout);
57 55