Skip to content

Commit

Permalink
clipping on Xlib
Browse files Browse the repository at this point in the history
  • Loading branch information
notsecure committed Jun 11, 2014
1 parent 93ffca0 commit 21c8efd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
5 changes: 5 additions & 0 deletions icons/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ bm_plus_bits[] = {

#undef B

#ifdef __WIN32__
#define F(r, g, b, a) (((b * a) / 0xFF) | ((g * a) / 0xFF) << 8 | ((r * a) / 0xFF) << 16 | a << 24)
#else
#define F(r, g, b, a) ((b) | ((g) << 8) | ((r) << 16) | ((a) << 24))
#endif

#define G(x) F(107, 194, 96, x)
uint32_t
bm_online_bits[] = {
Expand Down
2 changes: 1 addition & 1 deletion main.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ enum
BM_RESTORE,
BM_MAXIMIZE,
BM_EXIT,
BM_CORNER,
BM_PLUS,
BM_CORNER,
BM_ONLINE,
BM_AWAY,
BM_BUSY,
Expand Down
21 changes: 12 additions & 9 deletions xlib/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ void drawvline(int x, int y, int y2, uint32_t color)
void fillrect(RECT *r, uint32_t color)
{
XSetForeground(display, gc, color);
XFillRectangle(display, drawbuf, gc, r->left, r->top, r->right - r->left + 1, r->bottom - r->top + 1);
XFillRectangle(display, drawbuf, gc, r->left, r->top, r->right - r->left, r->bottom - r->top);
}

void framerect(RECT *r, uint32_t color)
{
XSetForeground(display, gc, color);
XDrawRectangle(display, drawbuf, gc, r->left, r->top, r->right - r->left, r->bottom - r->top);
XDrawRectangle(display, drawbuf, gc, r->left, r->top, r->right - r->left - 1, r->bottom - r->top - 1);
}

void setfont(int id)
Expand Down Expand Up @@ -230,13 +230,13 @@ void setbgcolor(uint32_t color)
XSetBackground(display, gc, color);
}

//XRectangle clip[16];
//static int clipk;
static XRectangle clip[16];
static int clipk;

void pushclip(int left, int top, int width, int height)
{
/*if(!clipk) {
XSetClipMask(display, gc, drawbuf);
if(!clipk) {
//XSetClipMask(display, gc, drawbuf);
}

XRectangle *r = &clip[clipk++];
Expand All @@ -245,20 +245,23 @@ void pushclip(int left, int top, int width, int height)
r->width = width;
r->height = height;

XSetClipRectangles(display, gc, 0, 0, r, 1, Unsorted);*/
XSetClipRectangles(display, gc, 0, 0, r, 1, Unsorted);
XftDrawSetClipRectangles(xftdraw, 0, 0, r, 1);
}

void popclip(void)
{
/*clipk--;
clipk--;
if(!clipk) {
XSetClipMask(display, gc, None);
XftDrawSetClip(xftdraw, None);
return;
}

XRectangle *r = &clip[clipk - 1];

XSetClipRectangles(display, gc, 0, 0, r, 1, Unsorted);*/
XSetClipRectangles(display, gc, 0, 0, r, 1, Unsorted);
XftDrawSetClipRectangles(xftdraw, 0, 0, r, 1);
}

void enddraw(int x, int y, int width, int height)
Expand Down

0 comments on commit 21c8efd

Please sign in to comment.