Reuse draw_rounded_rect() for xshape drawing

This commit is contained in:
Nikita Zlobin 2020-05-20 21:15:01 +05:00
parent 85ea8b8aa8
commit 73b7176e0b
3 changed files with 7 additions and 12 deletions

View File

@ -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. * The top corners will get rounded by `corner_radius`, if `first` is set.
* Respectably the same for `last` with the bottom corners. * 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; const float degrees = M_PI / 180.0;

View File

@ -8,6 +8,8 @@ void draw_setup(void);
void draw(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); void draw_deinit(void);
#endif #endif

View File

@ -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 width = win->dim.w;
const int height = win->dim.h; const int height = win->dim.h;
unsigned const int coords[] = {
0 + rad,
width - rad,
height - rad,
};
Pixmap mask; Pixmap mask;
cairo_surface_t * cxbm; 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_paint(cr);
cairo_set_source_rgba(cr, 1, 1, 1, 1); cairo_set_source_rgba(cr, 1, 1, 1, 1);
cairo_new_path(cr); draw_rounded_rect(cr, 0, 0,
cairo_arc(cr, coords[0], coords[0], rad, M_PI, -M_PI_2); width, height,
cairo_arc(cr, coords[1], coords[0], rad, -M_PI_2, 0); rad,
cairo_arc(cr, coords[1], coords[2], rad, 0, M_PI_2); true, true);
cairo_arc(cr, coords[0], coords[2], rad, M_PI_2, M_PI);
cairo_close_path(cr);
cairo_fill(cr); cairo_fill(cr);
cairo_show_page(cr); cairo_show_page(cr);