From 183e2b0e042f0ee0d06b2ea835ab79b8e6249dc6 Mon Sep 17 00:00:00 2001 From: Nishi Date: Fri, 24 Apr 2026 02:02:44 +0900 Subject: [PATCH 1/3] WOW --- src/backend/wayland.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/backend/wayland.c b/src/backend/wayland.c index c2a5ebd..823f941 100644 --- a/src/backend/wayland.c +++ b/src/backend/wayland.c @@ -1735,6 +1735,7 @@ static void clip(MwLL handle) { if(toplevel) { #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) + /* i seriously have no fucking idea how this works, do not ask me how this really works (nishi) */ x = 0; y = 0; cx = 0; @@ -1744,11 +1745,22 @@ static void clip(MwLL handle) { // ws is traversed result // ws[ws.length - 1] is ignored bc it's toplevel for(i = arrlen(ws) - 2; i >= 0; i--) { + int j; + int l = 0; + x += ws[i]->wayland.x; y += ws[i]->wayland.y; - cx = MAX(cx, ws[i]->wayland.x); - cy = MAX(cy, ws[i]->wayland.y); + for(j = i - 1; j >= 0; j--){ + if(ws[j]->wayland.x > cx) l = 1; + if(ws[j]->wayland.y > cy) l = 1; + if(l) break; + } + + if(!l){ + cx = MAX(cx, ws[i]->wayland.x); + cy = MAX(cy, ws[i]->wayland.y); + } mx = MIN(mx, x + ws[i]->wayland.ww); my = MIN(my, y + ws[i]->wayland.wh); From d225f7cb722a5c04280cdd80b4c5cb1368154315 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Fri, 24 Apr 2026 02:23:25 +0900 Subject: [PATCH 2/3] add widgets to periodic table --- examples/basic/periodic.c | 29 +++++++++++++--- examples/basic/viewport.c | 8 ++--- src/abstract/charset.c | 36 +++++++++---------- src/backend/wayland.c | 4 +-- src/cursor/arrow.c | 73 ++++++++++++++++++--------------------- src/cursor/default.c | 73 ++++++++++++++++++--------------------- src/cursor/text.c | 73 ++++++++++++++++++--------------------- src/dialog/filechooser.c | 8 ++--- src/widget/listbox.c | 14 ++++---- 9 files changed, 158 insertions(+), 160 deletions(-) diff --git a/examples/basic/periodic.c b/examples/basic/periodic.c index 2f4e4a5..7403ca7 100644 --- a/examples/basic/periodic.c +++ b/examples/basic/periodic.c @@ -145,11 +145,12 @@ static void MWAPI menu_handler(MwWidget handle, void* user, void* call) { } int main() { - int i, j; - MwWidget f, w, b; - int index; - MwMenu m, m2; - void* v; + int i, j; + MwWidget f, w, b; + MwLLPixmap px; + int index; + MwMenu m, m2; + void* v; MwLibraryInit(); @@ -157,6 +158,8 @@ int main() { MwNtitle, "Milsko Periodic Table", NULL); + px = MwLoadIcon(window, MwIconError); + menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0); m = MwMenuAdd(menu, NULL, "File"); @@ -256,6 +259,12 @@ int main() { f = frame("Entry", -PaddingContent, 24, MwEntryClass, NULL); add(f); + f = frame("Image", -PaddingContent, -PaddingContent, MwImageClass, + MwNpixmap, px, + NULL); + w = child(f); + add(f); + f = frame("Label", -PaddingContent, -PaddingContent, MwLabelClass, MwNtext, "Epic text", NULL); @@ -292,6 +301,14 @@ int main() { v = MwTreeViewAdd(w, v, NULL, "ghi"); add(f); + f = frame("Viewport", -PaddingContent, -PaddingContent, MwViewportClass, NULL); + w = child(f); + MwViewportSetSize(w, 256, 256); + MwVaCreateWidget(MwButtonClass, "btn", MwViewportGetViewport(w), 64, 64, 128, 128, + MwNtext, "Thing", + NULL); + add(f); + if(n != 0) newrow(); if(n == 0) MwDestroyWidget(boxes[row]); @@ -300,4 +317,6 @@ int main() { resize(window, NULL, NULL); MwLoop(window); + + MwLLDestroyPixmap(px); } diff --git a/examples/basic/viewport.c b/examples/basic/viewport.c index 30be60c..75524c4 100644 --- a/examples/basic/viewport.c +++ b/examples/basic/viewport.c @@ -31,12 +31,12 @@ int main() { if(px == NULL) px = MwLoadImage(vp, "picture.png"); -// MwVaCreateWidget(MwImageClass, "image", MwViewportGetViewport(vp), 0, 0, 1024, 1024, -// MwNpixmap, px, -// NULL); + // MwVaCreateWidget(MwImageClass, "image", MwViewportGetViewport(vp), 0, 0, 1024, 1024, + // MwNpixmap, px, + // NULL); MwViewportSetSize(vp, 1024, 1024); MwWidget f = MwCreateWidget(MwFrameClass, "fr", MwViewportGetViewport(vp), 256, 256, 128, 128); - f = MwCreateWidget(MwFrameClass, "fr", f, 0, 0, 128, 128); + f = MwCreateWidget(MwFrameClass, "fr", f, 0, 0, 128, 128); MwCreateWidget(MwButtonClass, "btn", f, 64, 64, 128, 128); MwAddUserHandler(w, MwNresizeHandler, resize, NULL); diff --git a/src/abstract/charset.c b/src/abstract/charset.c index 971496d..c0cf539 100644 --- a/src/abstract/charset.c +++ b/src/abstract/charset.c @@ -4,36 +4,36 @@ #define CP_UTF8 65001 #endif -char* MwACPToUTF8(const char* input){ +char* MwACPToUTF8(const char* input) { #if defined(_WIN32) && defined(MW_HAS_WCHAR) int mbbytes = (strlen(input) + 1) * 4; - int wbytes = 0; + int wbytes = 0; int len; wchar_t* wout; - char* mbout = malloc(mbbytes); + char* mbout = malloc(mbbytes); wbytes = MultiByteToWideChar(CP_ACP, 0, input, strlen(input), NULL, 0) * sizeof(wchar_t); - if(wbytes == 0){ + if(wbytes == 0) { free(mbout); return MwStringDuplicate(input); } wout = malloc(wbytes); - len = wbytes / sizeof(wchar_t); + len = wbytes / sizeof(wchar_t); memset(wout, 0, wbytes); memset(mbout, 0, mbbytes); len = MultiByteToWideChar(CP_ACP, 0, input, strlen(input), wout, len); - if(len == 0){ + if(len == 0) { free(mbout); free(wout); return MwStringDuplicate(input); } - + len = WideCharToMultiByte(CP_UTF8, 0, wout, len, mbout, mbbytes, 0, 0); - if(len == 0){ + if(len == 0) { free(mbout); free(wout); return MwStringDuplicate(input); @@ -46,39 +46,39 @@ char* MwACPToUTF8(const char* input){ return mbout; #else return MwStringDuplicate(input); -#endif +#endif } -char* MwUTF8ToACP(const char* input){ +char* MwUTF8ToACP(const char* input) { #if defined(_WIN32) && defined(MW_HAS_WCHAR) int mbbytes = (strlen(input) + 1) * 4; - int wbytes = 0; + int wbytes = 0; int len; wchar_t* wout; - char* mbout = malloc(mbbytes); + char* mbout = malloc(mbbytes); wbytes = MultiByteToWideChar(CP_UTF8, 0, input, strlen(input), NULL, 0) * sizeof(wchar_t); - if(wbytes == 0){ + if(wbytes == 0) { free(mbout); return MwStringDuplicate(input); } wout = malloc(wbytes); - len = wbytes / sizeof(wchar_t); + len = wbytes / sizeof(wchar_t); memset(wout, 0, wbytes); memset(mbout, 0, mbbytes); len = MultiByteToWideChar(CP_UTF8, 0, input, strlen(input), wout, len); - if(len == 0){ + if(len == 0) { free(mbout); free(wout); return MwStringDuplicate(input); } - + len = WideCharToMultiByte(CP_ACP, 0, wout, len, mbout, mbbytes, 0, 0); - if(len == 0){ + if(len == 0) { free(mbout); free(wout); return MwStringDuplicate(input); @@ -91,5 +91,5 @@ char* MwUTF8ToACP(const char* input){ return mbout; #else return MwStringDuplicate(input); -#endif +#endif } diff --git a/src/backend/wayland.c b/src/backend/wayland.c index 823f941..9987364 100644 --- a/src/backend/wayland.c +++ b/src/backend/wayland.c @@ -1751,13 +1751,13 @@ static void clip(MwLL handle) { x += ws[i]->wayland.x; y += ws[i]->wayland.y; - for(j = i - 1; j >= 0; j--){ + for(j = i - 1; j >= 0; j--) { if(ws[j]->wayland.x > cx) l = 1; if(ws[j]->wayland.y > cy) l = 1; if(l) break; } - if(!l){ + if(!l) { cx = MAX(cx, ws[i]->wayland.x); cy = MAX(cy, ws[i]->wayland.y); } diff --git a/src/cursor/arrow.c b/src/cursor/arrow.c index fab8af1..5a1d9bf 100644 --- a/src/cursor/arrow.c +++ b/src/cursor/arrow.c @@ -7,44 +7,37 @@ * These ""glyphs"" are unencumbered */ MwCursor MwCursorArrow = { - 14, 14, -13, -14, - { - 3, /* ............## */ - 15, /* ..........#### */ - 62, /* ........#####. */ - 254, /* ......#######. */ - 1020, /* ....########.. */ - 4092, /* ..##########.. */ - 248, /* ......#####... */ - 504, /* .....######... */ - 944, /* ....###.##.... */ - 1840, /* ...###..##.... */ - 3616, /* ..###...#..... */ - 7200, /* .###....#..... */ - 14336, /* ###........... */ - 4096, /* .#............ */ - 0, - 0 - } -}; + 14, 14, -13, -14, {3, /* ............## */ + 15, /* ..........#### */ + 62, /* ........#####. */ + 254, /* ......#######. */ + 1020, /* ....########.. */ + 4092, /* ..##########.. */ + 248, /* ......#####... */ + 504, /* .....######... */ + 944, /* ....###.##.... */ + 1840, /* ...###..##.... */ + 3616, /* ..###...#..... */ + 7200, /* .###....#..... */ + 14336, /* ###........... */ + 4096, /* .#............ */ + 0, 0}}; MwCursor MwCursorArrowMask = { - 16, 16, -14, -15, - { - 7, /* .............### */ - 31, /* ...........##### */ - 127, /* .........####### */ - 510, /* .......########. */ - 2046, /* .....##########. */ - 8188, /* ...###########.. */ - 16380, /* ..############.. */ - 16376, /* ..###########... */ - 2040, /* .....########... */ - 4080, /* ....########.... */ - 8176, /* ...#########.... */ - 16096, /* ..#####.###..... */ - 31968, /* .#####..###..... */ - 63552, /* #####....#...... */ - 28672, /* .###............ */ - 8192 /* ..#............. */ - } -}; + 16, 16, -14, -15, { + 7, /* .............### */ + 31, /* ...........##### */ + 127, /* .........####### */ + 510, /* .......########. */ + 2046, /* .....##########. */ + 8188, /* ...###########.. */ + 16380, /* ..############.. */ + 16376, /* ..###########... */ + 2040, /* .....########... */ + 4080, /* ....########.... */ + 8176, /* ...#########.... */ + 16096, /* ..#####.###..... */ + 31968, /* .#####..###..... */ + 63552, /* #####....#...... */ + 28672, /* .###............ */ + 8192 /* ..#............. */ + }}; diff --git a/src/cursor/default.c b/src/cursor/default.c index 9f1f146..d4bda3c 100644 --- a/src/cursor/default.c +++ b/src/cursor/default.c @@ -7,44 +7,37 @@ * These ""glyphs"" are unencumbered */ MwCursor MwCursorDefault = { - 8, 14, 0, -14, - { - 128, /* #....... */ - 192, /* ##...... */ - 224, /* ###..... */ - 240, /* ####.... */ - 248, /* #####... */ - 252, /* ######.. */ - 254, /* #######. */ - 255, /* ######## */ - 248, /* #####... */ - 216, /* ##.##... */ - 140, /* #...##.. */ - 12, /* ....##.. */ - 6, /* .....##. */ - 6, /* .....##. */ - 0, - 0 - } -}; + 8, 14, 0, -14, {128, /* #....... */ + 192, /* ##...... */ + 224, /* ###..... */ + 240, /* ####.... */ + 248, /* #####... */ + 252, /* ######.. */ + 254, /* #######. */ + 255, /* ######## */ + 248, /* #####... */ + 216, /* ##.##... */ + 140, /* #...##.. */ + 12, /* ....##.. */ + 6, /* .....##. */ + 6, /* .....##. */ + 0, 0}}; MwCursor MwCursorDefaultMask = { - 10, 16, -1, -15, - { - 768, /* ##........ */ - 896, /* ###....... */ - 960, /* ####...... */ - 992, /* #####..... */ - 1008, /* ######.... */ - 1016, /* #######... */ - 1020, /* ########.. */ - 1022, /* #########. */ - 1023, /* ########## */ - 1023, /* ########## */ - 1016, /* #######... */ - 956, /* ###.####.. */ - 828, /* ##..####.. */ - 30, /* .....####. */ - 30, /* .....####. */ - 12 /* ......##.. */ - } -}; + 10, 16, -1, -15, { + 768, /* ##........ */ + 896, /* ###....... */ + 960, /* ####...... */ + 992, /* #####..... */ + 1008, /* ######.... */ + 1016, /* #######... */ + 1020, /* ########.. */ + 1022, /* #########. */ + 1023, /* ########## */ + 1023, /* ########## */ + 1016, /* #######... */ + 956, /* ###.####.. */ + 828, /* ##..####.. */ + 30, /* .....####. */ + 30, /* .....####. */ + 12 /* ......##.. */ + }}; diff --git a/src/cursor/text.c b/src/cursor/text.c index fa2c372..855f01a 100644 --- a/src/cursor/text.c +++ b/src/cursor/text.c @@ -7,44 +7,37 @@ * These ""glyphs"" are unencumbered */ MwCursor MwCursorText = { - 7, 14, -3, -7, - { - 119, /* ###.### */ - 28, /* ..###.. */ - 8, /* ...#... */ - 8, /* ...#... */ - 8, /* ...#... */ - 8, /* ...#... */ - 8, /* ...#... */ - 8, /* ...#... */ - 8, /* ...#... */ - 8, /* ...#... */ - 8, /* ...#... */ - 8, /* ...#... */ - 28, /* ..###.. */ - 119, /* ###.### */ - 0, - 0 - } -}; + 7, 14, -3, -7, {119, /* ###.### */ + 28, /* ..###.. */ + 8, /* ...#... */ + 8, /* ...#... */ + 8, /* ...#... */ + 8, /* ...#... */ + 8, /* ...#... */ + 8, /* ...#... */ + 8, /* ...#... */ + 8, /* ...#... */ + 8, /* ...#... */ + 8, /* ...#... */ + 28, /* ..###.. */ + 119, /* ###.### */ + 0, 0}}; MwCursor MwCursorTextMask = { - 9, 16, -4, -8, - { - 495, /* ####.#### */ - 511, /* ######### */ - 511, /* ######### */ - 124, /* ..#####.. */ - 56, /* ...###... */ - 56, /* ...###... */ - 56, /* ...###... */ - 56, /* ...###... */ - 56, /* ...###... */ - 56, /* ...###... */ - 56, /* ...###... */ - 56, /* ...###... */ - 124, /* ..#####.. */ - 511, /* ######### */ - 511, /* ######### */ - 495 /* ####.#### */ - } -}; + 9, 16, -4, -8, { + 495, /* ####.#### */ + 511, /* ######### */ + 511, /* ######### */ + 124, /* ..#####.. */ + 56, /* ...###... */ + 56, /* ...###... */ + 56, /* ...###... */ + 56, /* ...###... */ + 56, /* ...###... */ + 56, /* ...###... */ + 56, /* ...###... */ + 56, /* ...###... */ + 124, /* ..#####.. */ + 511, /* ######### */ + 511, /* ######### */ + 495 /* ####.#### */ + }}; diff --git a/src/dialog/filechooser.c b/src/dialog/filechooser.c index edd2eaf..0c4d1b8 100644 --- a/src/dialog/filechooser.c +++ b/src/dialog/filechooser.c @@ -468,7 +468,7 @@ static void scan(MwWidget handle, const char* path, int record) { for(i = 0; i < arrlen(fc->entries); i++) { if(strcmp(fc->entries[i]->name, ".") == 0 || strcmp(fc->entries[i]->name, "..") == 0) continue; if(fc->entries[i]->type == MwDIRECTORY_DIRECTORY) { - char date[128]; + char date[128]; char* n = MwACPToUTF8(fc->entries[i]->name); MwStringTime(date, fc->entries[i]->mtime); @@ -477,7 +477,7 @@ static void scan(MwWidget handle, const char* path, int record) { MwListBoxSet(fc->files, index, -1, date); MwListBoxSet(fc->files, index, -1, NULL); MwListBoxSetIcon(fc->files, index, fc->dir); - + free(n); arrput(fc->sorted_entries, fc->entries[i]); @@ -485,8 +485,8 @@ static void scan(MwWidget handle, const char* path, int record) { } for(i = 0; i < arrlen(fc->entries); i++) { if(fc->entries[i]->type == MwDIRECTORY_FILE && !fc->dir_only) { - char date[128]; - char size[128]; + char date[128]; + char size[128]; char* n = MwACPToUTF8(fc->entries[i]->name); MwStringTime(date, fc->entries[i]->mtime); diff --git a/src/widget/listbox.c b/src/widget/listbox.c index 209bb8e..fbfb514 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -189,9 +189,9 @@ static void frame_draw(MwWidget handle) { } p.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding); for(j = 0; j < arrlen(lb->list[i].name); j++) { - char* t = lb->list[i].name[j]; - char* str; - int l = (j == 0 ? MwGetInteger(handle->parent, MwNleftPadding) : 0); + char* t = lb->list[i].name[j]; + char* str; + int l = (j == 0 ? MwGetInteger(handle->parent, MwNleftPadding) : 0); MwPoint p2 = p; p2.y += (MwTextHeight(handle, Font, "M") + Padding) / 2; @@ -200,11 +200,11 @@ static void frame_draw(MwWidget handle) { str = MwStringDuplicate(t); if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M")) { - int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M"); + int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M"); int seek = 0; - int l = 0; + int l = 0; - while(str[seek] != 0){ + while(str[seek] != 0) { int cp; seek += MwUTF8ToUTF32(str + seek, &cp); @@ -411,7 +411,7 @@ static int mwListBoxSetImpl(MwWidget handle, int row, int col, const char* text) MwListBox lb = handle->internal; MwListBoxEntry entry; char* t = text == NULL ? NULL : MwStringDuplicate(text); - int new = 0; + int new = 0; if(row == -1) row = arrlen(lb->list); entry.name = NULL; From 0c793d6832c5e4bfabf9180e4b8c9368aa4b44ec Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Fri, 24 Apr 2026 02:42:29 +0900 Subject: [PATCH 3/3] improve xrender output --- src/backend/x11.c | 73 +++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/src/backend/x11.c b/src/backend/x11.c index 67489cd..7cae9e1 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -962,38 +962,43 @@ static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) { free(pixmap); } +#define DO_XRENDER(dest_px, src, format, bpp) \ + { \ + Picture src_pic, dest_pic; \ + XRenderPictFormat* fmt = XRenderFindStandardFormat(handle->x11.display, format); \ + Pixmap src_px = XCreatePixmap(handle->x11.display, handle->x11.window, pixmap->common.width, pixmap->common.height, bpp); \ + GC gc = XCreateGC(handle->x11.display, src_px, 0, NULL); \ +\ + dest_px = XCreatePixmap(handle->x11.display, handle->x11.window, rect->width, rect->height, bpp); \ +\ + XPutImage(handle->x11.display, src_px, gc, src, 0, 0, 0, 0, pixmap->common.width, pixmap->common.height); \ +\ + src_pic = XRenderCreatePicture(handle->x11.display, src_px, fmt, 0, &attr); \ + dest_pic = XRenderCreatePicture(handle->x11.display, dest_px, fmt, 0, &attr); \ +\ + XRenderSetPictureTransform(handle->x11.display, src_pic, &m); \ + XRenderComposite(handle->x11.display, PictOpSrc, src_pic, 0, dest_pic, 0, 0, 0, 0, 0, 0, rect->width, rect->height); \ +\ + XRenderFreePicture(handle->x11.display, src_pic); \ + XRenderFreePicture(handle->x11.display, dest_pic); \ + XFreePixmap(handle->x11.display, src_px); \ + } + static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { if(rect->width <= 0 || rect->height <= 0 || pixmap->common.width <= 0 || pixmap->common.height <= 0) return; #ifdef USE_XRENDER if(pixmap->x11.image != NULL && pixmap->x11.use_xrender) { - Pixmap px = XCreatePixmap(handle->x11.display, handle->x11.window, pixmap->common.width, pixmap->common.height, pixmap->x11.depth); - Pixmap mask = XCreatePixmap(handle->x11.display, handle->x11.window, rect->width, rect->height, 1); - Pixmap pxsrc = XCreatePixmap(handle->x11.display, handle->x11.window, rect->width, rect->height, pixmap->x11.depth); - GC maskgc = XCreateGC(handle->x11.display, mask, 0, NULL); - XRenderPictFormat* format = XRenderFindStandardFormat(handle->x11.display, PictStandardRGB24); + Pixmap px; + Pixmap mask; XRenderPictureAttributes attr; - Picture src, dest; XTransform m; - double xsc = (double)pixmap->common.width / rect->width; - double ysc = (double)pixmap->common.height / rect->height; - char* dm = malloc(rect->width * rect->height * 4); - XImage* destmask; - int y, x; + double xsc; + double ysc; - destmask = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), 1, ZPixmap, 0, dm, rect->width, rect->height, 32, rect->width * 4); + memset(&attr, 0, sizeof(attr)); - for(y = 0; y < (int)rect->height; y++) { - for(x = 0; x < (int)rect->width; x++) { - int sy = y * pixmap->common.height / rect->height; - int sx = x * pixmap->common.width / rect->width; - sy = (int)sy; - sx = (int)sx; - - XPutPixel(destmask, x, y, XGetPixel(pixmap->x11.mask, sx, sy)); - } - } - - XPutImage(handle->x11.display, mask, maskgc, destmask, 0, 0, 0, 0, rect->width, rect->height); + xsc = (double)pixmap->common.width / rect->width; + ysc = (double)pixmap->common.height / rect->height; m.matrix[0][0] = XDoubleToFixed(xsc); m.matrix[0][1] = XDoubleToFixed(0); @@ -1007,30 +1012,16 @@ static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { m.matrix[2][1] = XDoubleToFixed(0); m.matrix[2][2] = XDoubleToFixed(1.0); - memset(&attr, 0, sizeof(attr)); - - XPutImage(handle->x11.display, px, handle->x11.gc, pixmap->x11.image, 0, 0, 0, 0, pixmap->common.width, pixmap->common.height); - - src = XRenderCreatePicture(handle->x11.display, px, format, 0, &attr); - dest = XRenderCreatePicture(handle->x11.display, pxsrc, format, 0, &attr); - - XRenderSetPictureTransform(handle->x11.display, src, &m); - XRenderComposite(handle->x11.display, PictOpSrc, src, 0, dest, 0, 0, 0, 0, 0, 0, rect->width, rect->height); - - XRenderFreePicture(handle->x11.display, src); - XRenderFreePicture(handle->x11.display, dest); + DO_XRENDER(px, pixmap->x11.image, PictStandardRGB24, pixmap->x11.depth); + DO_XRENDER(mask, pixmap->x11.mask, PictStandardA1, 1); XSetClipMask(handle->x11.display, handle->x11.gc, mask); XSetClipOrigin(handle->x11.display, handle->x11.gc, rect->x, rect->y); - XCopyArea(handle->x11.display, pxsrc, handle->x11.pixmap, handle->x11.gc, 0, 0, rect->width, rect->height, rect->x, rect->y); + XCopyArea(handle->x11.display, px, handle->x11.pixmap, handle->x11.gc, 0, 0, rect->width, rect->height, rect->x, rect->y); XSetClipMask(handle->x11.display, handle->x11.gc, None); - XDestroyImage(destmask); - - XFreeGC(handle->x11.display, maskgc); XFreePixmap(handle->x11.display, mask); XFreePixmap(handle->x11.display, px); - XFreePixmap(handle->x11.display, pxsrc); } else #endif if(pixmap->x11.image != NULL) {