From 9b175458805db0614b54ba6484ac4198d6e64a85 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Thu, 16 Oct 2025 07:38:43 +0000 Subject: [PATCH] gdi backend has bugs git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@351 b9cfdab3-6d41-4d17-bbe4-086880011989 --- src/backend/gdi.c | 18 +++++++++++++----- src/backend/x11.c | 2 +- src/widget/image.c | 6 +++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/backend/gdi.c b/src/backend/gdi.c index a39a2ce..869825f 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -337,8 +337,12 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei BITMAPINFOHEADER bmih; RGBQUAD* quad; int y, x; - int w = (width + (16 - (width % 16))) / 8; - WORD* words = malloc(w * height); + int w = (width + (16 - (width % 16))) / 8; + WORD* words; + + if(16 * (width / 16) == width) w -= 2; + + words = malloc(w * height); r->width = width; r->height = height; @@ -478,18 +482,22 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) { } void MwLLDetach(MwLL handle, MwPoint* point) { - RECT rc, rc2; + RECT rc, rc2; + LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE); + + lp &= WS_VISIBLE; + GetWindowRect(GetParent(handle->hWnd), &rc); GetClientRect(handle->hWnd, &rc2); - SetWindowLongPtr(handle->hWnd, GWL_STYLE, (LPARAM)WS_OVERLAPPEDWINDOW); + SetWindowLongPtr(handle->hWnd, GWL_STYLE, (LPARAM)WS_OVERLAPPEDWINDOW | lp); SetParent(handle->hWnd, NULL); rc.left += point->x; rc.top += point->y; - AdjustWindowRect(&rc2, WS_OVERLAPPEDWINDOW, FALSE); + AdjustWindowRect(&rc2, WS_OVERLAPPEDWINDOW | lp, FALSE); rc2.right -= rc2.left; rc2.bottom -= rc2.top; diff --git a/src/backend/x11.c b/src/backend/x11.c index e403b10..30660bd 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -373,7 +373,7 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei r->use_render = XRenderQueryExtension(handle->display, &evbase, &erbase) ? 1 : 0; r->image = XCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), r->depth, ZPixmap, 0, di, width, height, 32, width * 4); - r->mask = XCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), r->depth, ZPixmap, 0, dm, width, height, 32, width * 4); + r->mask = XCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), 1, ZPixmap, 0, dm, width, height, 32, width * 4); for(y = 0; y < height; y++) { for(x = 0; x < width; x++) { diff --git a/src/widget/image.c b/src/widget/image.c index b7df424..89636cd 100644 --- a/src/widget/image.c +++ b/src/widget/image.c @@ -9,15 +9,19 @@ static int create(MwWidget handle) { static void draw(MwWidget handle) { MwRect r; - MwLLPixmap px = MwGetVoid(handle, MwNpixmap); + MwLLPixmap px = MwGetVoid(handle, MwNpixmap); + MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground)); r.x = 0; r.y = 0; r.width = MwGetInteger(handle, MwNwidth); r.height = MwGetInteger(handle, MwNheight); + MwDrawRect(handle, &r, base); if(px != NULL) { MwLLDrawPixmap(handle->lowlevel, &r, px); } + + MwLLFreeColor(base); } static void prop_change(MwWidget handle, const char* key) {