From 73b7176e0bb074c10f50f67d7f088041632cc153 Mon Sep 17 00:00:00 2001 From: Nikita Zlobin Date: Wed, 20 May 2020 21:15:01 +0500 Subject: [PATCH] Reuse draw_rounded_rect() for xshape drawing --- src/draw.c | 2 +- src/draw.h | 2 ++ src/x11/x.c | 15 ++++----------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/draw.c b/src/draw.c index ada575d..14dfd8b 100644 --- a/src/draw.c +++ b/src/draw.c @@ -416,7 +416,7 @@ static int frame_internal_radius (int r, int w, int h) * The top corners will get rounded by `corner_radius`, if `first` is set. * Respectably the same for `last` with the bottom corners. */ -static void draw_rounded_rect(cairo_t *c, int x, int y, int width, int height, int corner_radius, bool first, bool last) +void draw_rounded_rect(cairo_t *c, int x, int y, int width, int height, int corner_radius, bool first, bool last) { const float degrees = M_PI / 180.0; diff --git a/src/draw.h b/src/draw.h index d646dc2..be7a467 100644 --- a/src/draw.h +++ b/src/draw.h @@ -8,6 +8,8 @@ void draw_setup(void); void draw(void); +void draw_rounded_rect(cairo_t *c, int x, int y, int width, int height, int corner_radius, bool first, bool last); + void draw_deinit(void); #endif diff --git a/src/x11/x.c b/src/x11/x.c index b6eb819..b82f481 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -89,11 +89,6 @@ static void x_win_round_corners(struct window_x11 *win, const int rad) { const int width = win->dim.w; const int height = win->dim.h; - unsigned const int coords[] = { - 0 + rad, - width - rad, - height - rad, - }; Pixmap mask; cairo_surface_t * cxbm; @@ -112,12 +107,10 @@ static void x_win_round_corners(struct window_x11 *win, const int rad) cairo_paint(cr); cairo_set_source_rgba(cr, 1, 1, 1, 1); - cairo_new_path(cr); - cairo_arc(cr, coords[0], coords[0], rad, M_PI, -M_PI_2); - cairo_arc(cr, coords[1], coords[0], rad, -M_PI_2, 0); - cairo_arc(cr, coords[1], coords[2], rad, 0, M_PI_2); - cairo_arc(cr, coords[0], coords[2], rad, M_PI_2, M_PI); - cairo_close_path(cr); + draw_rounded_rect(cr, 0, 0, + width, height, + rad, + true, true); cairo_fill(cr); cairo_show_page(cr);