diff options
author | 2016-01-28 19:41:03 -0500 | |
---|---|---|
committer | 2016-03-30 00:47:58 +0200 | |
commit | a8e084433d57609398fd1b72b72d3d7e71925d44 (patch) | |
tree | 6e5bee5dc73245cde72a0124bbc5888006384c82 /sway | |
parent | Initial setup of window border rendering (diff) | |
download | sway-a8e084433d57609398fd1b72b72d3d7e71925d44.tar.gz sway-a8e084433d57609398fd1b72b72d3d7e71925d44.tar.zst sway-a8e084433d57609398fd1b72b72d3d7e71925d44.zip |
Window borders proof of concept
Diffstat (limited to 'sway')
-rw-r--r-- | sway/render.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/sway/render.c b/sway/render.c index 66d2e5f0..a5ba2f4c 100644 --- a/sway/render.c +++ b/sway/render.c | |||
@@ -1,7 +1,16 @@ | |||
1 | #include "render.h" | 1 | #include "render.h" |
2 | #include <cairo.h> | 2 | #include <wlc/wlc-render.h> |
3 | #include <cairo/cairo.h> | ||
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
4 | 5 | ||
6 | void cairo_set_source_u32(cairo_t *cairo, uint32_t color) { | ||
7 | cairo_set_source_rgba(cairo, | ||
8 | (color >> (3*8) & 0xFF) / 255.0, | ||
9 | (color >> (2*8) & 0xFF) / 255.0, | ||
10 | (color >> (1*8) & 0xFF) / 255.0, | ||
11 | (color >> (0*8) & 0xFF) / 255.0); | ||
12 | } | ||
13 | |||
5 | cairo_t *create_cairo_context(int width, int height, int channels, | 14 | cairo_t *create_cairo_context(int width, int height, int channels, |
6 | cairo_surface_t **surf, unsigned char **buf) { | 15 | cairo_surface_t **surf, unsigned char **buf) { |
7 | cairo_t *cr; | 16 | cairo_t *cr; |
@@ -24,12 +33,18 @@ cairo_t *create_cairo_context(int width, int height, int channels, | |||
24 | } | 33 | } |
25 | 34 | ||
26 | void render_view_borders(wlc_handle view) { | 35 | void render_view_borders(wlc_handle view) { |
36 | const int bw = 2; | ||
27 | unsigned char *surf_data; | 37 | unsigned char *surf_data; |
28 | cairo_surface_t *surf; | 38 | cairo_surface_t *surf; |
29 | int texture_id; | 39 | struct wlc_geometry geo = *wlc_view_get_geometry(view); |
30 | const struct wlc_geometry *geo = wlc_view_get_geometry(view); | 40 | cairo_t *cr = create_cairo_context(geo.size.w + bw * 2, geo.size.h + bw * 2, 4, &surf, &surf_data); |
31 | cairo_t *cr = create_cairo_context(geo->size.w, geo->size.h, 4, &surf, &surf_data); | 41 | cairo_set_source_u32(cr, 0x0000FFFF); |
32 | // TODO | 42 | cairo_paint(cr); |
43 | geo.origin.x -= bw; | ||
44 | geo.origin.y -= bw; | ||
45 | geo.size.w += bw * 2; | ||
46 | geo.size.h += bw * 2; | ||
47 | wlc_pixels_write(WLC_RGBA8888, &geo, surf_data); | ||
33 | cairo_destroy(cr); | 48 | cairo_destroy(cr); |
34 | free(surf_data); | 49 | free(surf_data); |
35 | } | 50 | } |