Simplify corner arcs in X11 code
This commit is contained in:
parent
d5fd674d2f
commit
aab9fef78c
61
src/x11/x.c
61
src/x11/x.c
@ -81,18 +81,18 @@ static void x_win_move(window_x11 *win, int x, int y, int width, int height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void x_win_round_corners(window_x11 *win, const int rad)
|
static void x_win_round_corners(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;
|
||||||
|
const int dia = 2 * rad;
|
||||||
|
const int degrees = 64; // the factor to convert degrees to XFillArc's angle param
|
||||||
|
|
||||||
Pixmap mask = XCreatePixmap(xctx.dpy, win->xwin, width, height, 1);
|
Pixmap mask = XCreatePixmap(xctx.dpy, win->xwin, width, height, 1);
|
||||||
XGCValues xgcv;
|
XGCValues xgcv;
|
||||||
|
|
||||||
GC shape_gc = XCreateGC(xctx.dpy, mask, 0, &xgcv);
|
GC shape_gc = XCreateGC(xctx.dpy, mask, 0, &xgcv);
|
||||||
|
|
||||||
const int dia = 2 * rad;
|
|
||||||
|
|
||||||
XSetForeground(xctx.dpy, shape_gc, 0);
|
XSetForeground(xctx.dpy, shape_gc, 0);
|
||||||
XFillRectangle(xctx.dpy,
|
XFillRectangle(xctx.dpy,
|
||||||
mask,
|
mask,
|
||||||
@ -104,43 +104,26 @@ void x_win_round_corners(window_x11 *win, const int rad)
|
|||||||
|
|
||||||
XSetForeground(xctx.dpy, shape_gc, 1);
|
XSetForeground(xctx.dpy, shape_gc, 1);
|
||||||
|
|
||||||
XFillArc(xctx.dpy,
|
/* To mark all pixels, which should get exposed, we
|
||||||
mask,
|
* use a circle for every corner and two overlapping rectangles */
|
||||||
shape_gc,
|
unsigned const int centercoords[] = {
|
||||||
0,
|
0, 0,
|
||||||
0,
|
width - dia - 1, 0,
|
||||||
dia,
|
0, height - dia - 1,
|
||||||
dia,
|
width - dia - 1, height - dia - 1,
|
||||||
0,
|
};
|
||||||
360 * 64);
|
|
||||||
XFillArc(xctx.dpy,
|
|
||||||
mask,
|
|
||||||
shape_gc,
|
|
||||||
width - dia - 1,
|
|
||||||
0,
|
|
||||||
dia,
|
|
||||||
dia,
|
|
||||||
0,
|
|
||||||
360 * 64);
|
|
||||||
XFillArc(xctx.dpy,
|
|
||||||
mask,
|
|
||||||
shape_gc,
|
|
||||||
0,
|
|
||||||
height - dia - 1,
|
|
||||||
dia,
|
|
||||||
dia,
|
|
||||||
0,
|
|
||||||
360 * 64);
|
|
||||||
XFillArc(xctx.dpy,
|
|
||||||
mask,
|
|
||||||
shape_gc,
|
|
||||||
width - dia - 1,
|
|
||||||
height - dia - 1,
|
|
||||||
dia,
|
|
||||||
dia,
|
|
||||||
0,
|
|
||||||
360 * 64);
|
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(centercoords)/sizeof(unsigned int); i = i+2) {
|
||||||
|
XFillArc(xctx.dpy,
|
||||||
|
mask,
|
||||||
|
shape_gc,
|
||||||
|
centercoords[i],
|
||||||
|
centercoords[i+1],
|
||||||
|
dia,
|
||||||
|
dia,
|
||||||
|
degrees * 0,
|
||||||
|
degrees * 360);
|
||||||
|
}
|
||||||
XFillRectangle(xctx.dpy,
|
XFillRectangle(xctx.dpy,
|
||||||
mask,
|
mask,
|
||||||
shape_gc,
|
shape_gc,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user