about summary refs log tree commit diff stats
path: root/src/wrapped32/wrappedlibxcursor.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-12-03 18:45:46 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-12-03 18:45:46 +0100
commitfb276bdc6bf02cc1781da2eaf1b60e824d840b8b (patch)
treebebc487e28c45d1977476f11a562cf87bb6024e2 /src/wrapped32/wrappedlibxcursor.c
parent1c1a26626ba1ceda224757ccaf8483534885cbe3 (diff)
downloadbox64-fb276bdc6bf02cc1781da2eaf1b60e824d840b8b.tar.gz
box64-fb276bdc6bf02cc1781da2eaf1b60e824d840b8b.zip
[BOX32][WRAPER] Fixed Xcursor wrapping
Diffstat (limited to 'src/wrapped32/wrappedlibxcursor.c')
-rw-r--r--src/wrapped32/wrappedlibxcursor.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/wrapped32/wrappedlibxcursor.c b/src/wrapped32/wrappedlibxcursor.c
index 655484ee..2e0ece0f 100644
--- a/src/wrapped32/wrappedlibxcursor.c
+++ b/src/wrapped32/wrappedlibxcursor.c
@@ -64,6 +64,67 @@ void inplace_XcursorCursors_enlarge(void* a)
 	dst->dpy = FindDisplay(from_ptrv(src->dpy));
 }
 
+void inplace_XcursorImage_shrink(void* a)
+{
+	if(!a) return;
+	my_XcursorImage_t* src = a;
+	my_XcursorImage_32_t* dst = a;
+
+	dst->version = src->version;
+	dst->size = src->size;
+	dst->width = src->width;
+	dst->height = src->height;
+	dst->xhot = src->xhot;
+	dst->yhot = src->yhot;
+	dst->delay = src->delay;
+	dst->pixels = to_ptrv(src->pixels);
+}
+void inplace_XcursorImage_enlarge(void* a)
+{
+	if(!a) return;
+	my_XcursorImage_32_t* src = a;
+	my_XcursorImage_t* dst = a;
+
+	dst->pixels = from_ptrv(src->pixels);
+	dst->delay = src->delay;
+	dst->yhot = src->yhot;
+	dst->xhot = src->xhot;
+	dst->height = src->height;
+	dst->width = src->width;
+	dst->size = src->size;
+	dst->version = src->version;
+}
+
+void inplace_XcursorImages_shrink(void* a)
+{
+	if(!a) return;
+	my_XcursorImages_t* src = a;
+	my_XcursorImages_32_t* dst = a;
+
+	for(int i=0; i<src->nimage; ++i)
+		inplace_XcursorCursors_shrink(src->images[i]);
+	for(int i=0; i<src->nimage; ++i)
+		((ptr_t*)src->images)[i] = to_ptrv(src->images[i]);
+	dst->nimage = src->nimage;
+	dst->images = to_ptrv(src->images);
+	dst->name = to_ptrv(src->name);
+}
+
+void inplace_XcursorImages_enlarge(void* a)
+{
+	if(!a) return;
+	my_XcursorImages_32_t* src = a;
+	my_XcursorImages_t* dst = a;
+
+	dst->name = from_ptrv(src->name);
+	dst->images = from_ptrv(src->images);
+	dst->nimage = src->nimage;
+	for(int i=dst->nimage-1; i>=0; --i)
+		dst->images[i] = from_ptrv(((ptr_t*)dst->images)[i]);
+	for(int i=dst->nimage-1; i>=0; --i)
+		inplace_XcursorCursors_enlarge(dst->images[i]);
+}
+
 EXPORT void* my32_XcursorCursorsCreate(x64emu_t* emu, void* dpy, int n)
 {
 	void* ret = my->XcursorCursorsCreate(dpy, n);
@@ -77,5 +138,55 @@ EXPORT void my32_XcursorCursorsDestroy(x64emu_t* emu, void* a)
 	my->XcursorCursorsDestroy(a);
 }
 
+EXPORT void* my32_XcursorImageCreate(x64emu_t* emu, int w, int h)
+{
+	void* ret = my->XcursorImageCreate(w, h);
+	inplace_XcursorImage_shrink(ret);
+	return ret;
+}
+
+EXPORT void my32_XcursorImageDestroy(x64emu_t* emu, void* image)
+{
+	inplace_XcursorImage_enlarge(image);
+	my->XcursorImageDestroy(image);
+}
+
+EXPORT unsigned long my32_XcursorImageLoadCursor(x64emu_t*, void* dpy, void* image)
+{
+	inplace_XcursorImage_enlarge(image);
+	unsigned long ret = my->XcursorImageLoadCursor(dpy, image);
+	inplace_XcursorImage_shrink(image);
+}
+
+EXPORT void* my_XcursorImagesCreate(x64emu_t* emu, int n)
+{
+	void* ret = my->XcursorImagesCreate(n);
+	inplace_XcursorImages_shrink(ret);
+	return ret;
+}
+
+EXPORT void my_XcursorImagesDestroy(x64emu_t* emu, void* images)
+{
+	inplace_XcursorCursors_enlarge(images);
+	my->XcursorImagesDestroy(images);
+}
+
+EXPORT unsigned long my_XcursorImagesLoadCursors(x64emu_t* emu, void* dpy, void* images)
+{
+	inplace_XcursorImages_enlarge(images);
+	unsigned long ret = my->XcursorImagesLoadCursor(dpy, images);
+	inplace_XcursorImages_shrink(images);
+	return ret;
+}
+
+EXPORT void* my_XcursorImagesLoadCursor(x64emu_t* emu, void* dpy, void* images)
+{
+	inplace_XcursorImages_enlarge(images);
+	void* ret = my->XcursorImagesLoadCursors(dpy, images);
+	inplace_XcursorImages_shrink(images);
+	inplace_XcursorCursors_shrink(ret);
+	return ret;
+}
+
 #include "wrappedlib_init32.h"