add MwLibraryInit

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@680 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-11-13 01:30:10 +00:00
parent a5db4f8eac
commit b0ea597d62
27 changed files with 263 additions and 350 deletions

View File

@@ -210,7 +210,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
return 0;
}
MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
MwLL r = malloc(sizeof(*r));
userdata_t* u = malloc(sizeof(*u));
WNDCLASSEX wc;
@@ -263,7 +263,7 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
return r;
}
void MwLLDestroy(MwLL handle) {
static void MwLLDestroyImpl(MwLL handle) {
MwLLDestroyCommon(handle);
/* for safety */
@@ -275,7 +275,7 @@ void MwLLDestroy(MwLL handle) {
free(handle);
}
void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
POINT* p = malloc(sizeof(*p) * points_count);
HPEN pen = CreatePen(PS_NULL, 0, RGB(0, 0, 0));
int i;
@@ -294,7 +294,7 @@ void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color
free(p);
}
void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color) {
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
HPEN pen = CreatePen(PS_SOLID, 1, RGB(color->red, color->green, color->blue));
SelectObject(handle->hDC, pen);
@@ -304,7 +304,7 @@ void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color) {
DeleteObject(pen);
}
MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) {
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
MwLLColor c = malloc(sizeof(*c));
c->brush = NULL;
@@ -314,7 +314,7 @@ MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) {
return c;
}
void MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b) {
static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
HDC dc = GetDC(handle->hWnd);
if(r > 255) r = 255;
@@ -333,18 +333,18 @@ void MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b) {
ReleaseDC(handle->hWnd, dc);
}
void MwLLFreeColor(MwLLColor color) {
static void MwLLFreeColorImpl(MwLLColor color) {
DeleteObject(color->brush);
free(color);
}
void MwLLSetBackground(MwLL handle, MwLLColor color) {
static void MwLLSetBackgroundImpl(MwLL handle, MwLLColor color) {
(void)handle;
(void)color;
}
void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
RECT rc;
GetClientRect(handle->hWnd, &rc);
@@ -356,21 +356,21 @@ void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h)
*h = rc.bottom - rc.top;
}
void MwLLSetXY(MwLL handle, int x, int y) {
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
SetWindowPos(handle->hWnd, NULL, x, y, 0, 0, SWP_NOSIZE);
InvalidateRect(handle->hWnd, NULL, FALSE);
}
void MwLLSetWH(MwLL handle, int w, int h) {
static void MwLLSetWHImpl(MwLL handle, int w, int h) {
SetWindowPos(handle->hWnd, NULL, 0, 0, w, h, SWP_NOMOVE);
InvalidateRect(handle->hWnd, NULL, FALSE);
}
void MwLLSetTitle(MwLL handle, const char* title) {
static void MwLLSetTitleImpl(MwLL handle, const char* title) {
SetWindowText(handle->hWnd, title);
}
int MwLLPending(MwLL handle) {
static int MwLLPendingImpl(MwLL handle) {
MSG msg;
(void)handle;
@@ -378,7 +378,7 @@ int MwLLPending(MwLL handle) {
return PeekMessage(&msg, handle->hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0;
}
void MwLLNextEvent(MwLL handle) {
static void MwLLNextEventImpl(MwLL handle) {
MSG msg;
(void)handle;
@@ -390,7 +390,7 @@ void MwLLNextEvent(MwLL handle) {
}
}
MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int height) {
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
MwLLPixmap r = malloc(sizeof(*r));
HDC dc = GetDC(handle->hWnd);
BITMAPINFOHEADER bmih;
@@ -425,7 +425,7 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei
return r;
}
void MwLLPixmapUpdate(MwLLPixmap r) {
static void MwLLPixmapUpdateImpl(MwLLPixmap r) {
int y, x;
int w = (r->width + (16 - (r->width % 16))) / 8;
WORD* words;
@@ -466,7 +466,7 @@ void MwLLPixmapUpdate(MwLLPixmap r) {
free(words2);
}
void MwLLDestroyPixmap(MwLLPixmap pixmap) {
static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
free(pixmap->raw);
DeleteObject(pixmap->hMask);
DeleteObject(pixmap->hMask2);
@@ -475,7 +475,7 @@ void MwLLDestroyPixmap(MwLLPixmap pixmap) {
free(pixmap);
}
void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
HDC hmdc = CreateCompatibleDC(handle->hDC);
POINT p[3];
@@ -496,7 +496,7 @@ void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
DeleteDC(hmdc);
}
void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
ICONINFO ii;
HICON ico;
@@ -514,11 +514,11 @@ void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
DestroyIcon(ico);
}
void MwLLForceRender(MwLL handle) {
static void MwLLForceRenderImpl(MwLL handle) {
PostMessage(handle->hWnd, WM_USER, 0, 0);
}
void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
HCURSOR cursor;
BYTE* dmask = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight);
BYTE* dimage = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight);
@@ -566,7 +566,7 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
free(dmask);
}
void MwLLDetach(MwLL handle, MwPoint* point) {
static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
RECT rc, rc2;
LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE);
@@ -589,18 +589,18 @@ void MwLLDetach(MwLL handle, MwPoint* point) {
SetWindowPos(handle->hWnd, HWND_TOPMOST, rc.left, rc.top, rc2.right == 0 ? 1 : rc2.right, rc2.bottom == 0 ? 1 : rc2.bottom, SWP_FRAMECHANGED | SWP_NOACTIVATE);
}
void MwLLShow(MwLL handle, int show) {
static void MwLLShowImpl(MwLL handle, int show) {
ShowWindow(handle->hWnd, show ? SW_NORMAL : SW_HIDE);
if(show) SetFocus(handle->hWnd);
}
void MwLLMakePopup(MwLL handle, MwLL parent) {
static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
(void)handle;
(void)parent;
/* TODO */
}
void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
userdata_t* u = (userdata_t*)GetWindowLongPtr(handle->hWnd, GWLP_USERDATA);
u->min_set = u->max_set = 1;
@@ -610,7 +610,7 @@ void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
u->max.y = maxy;
}
void MwLLMakeBorderless(MwLL handle, int toggle) {
static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE);
if(toggle) {
@@ -624,11 +624,11 @@ void MwLLMakeBorderless(MwLL handle, int toggle) {
SetWindowPos(handle->hWnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
}
void MwLLFocus(MwLL handle) {
static void MwLLFocusImpl(MwLL handle) {
SetFocus(handle->hWnd);
}
void MwLLGrabPointer(MwLL handle, int toggle) {
static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
if(toggle) {
POINT p;
RECT rc;
@@ -657,7 +657,7 @@ void MwLLGrabPointer(MwLL handle, int toggle) {
}
}
void MwLLSetClipboard(MwLL handle, const char* text) {
static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
HGLOBAL hg;
if(OpenClipboard(handle->hWnd) != 0) {
char* lock;
@@ -675,7 +675,7 @@ void MwLLSetClipboard(MwLL handle, const char* text) {
}
}
char* MwLLGetClipboard(MwLL handle) {
static char* MwLLGetClipboardImpl(MwLL handle) {
HGLOBAL hg;
char* r = NULL;
if(OpenClipboard(handle->hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) {
@@ -692,7 +692,7 @@ char* MwLLGetClipboard(MwLL handle) {
return r;
}
void MwLLMakeToolWindow(MwLL handle) {
static void MwLLMakeToolWindowImpl(MwLL handle) {
LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE) & WS_VISIBLE;
RECT rc;
@@ -703,3 +703,11 @@ void MwLLMakeToolWindow(MwLL handle) {
SetWindowPos(handle->hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
}
static int MwLLGDICallInitImpl(void) {
/* TODO: check properly */
return 0;
}
#include "call.c"
CALL(GDI);

View File

@@ -1,76 +0,0 @@
/* $Id: carbon.c 154 2025-10-04 12:33:26Z nishi $ */
#include "mac.h"
#include "carbon.h"
#include <dlfcn.h>
void carbonBackendUserDataInit(mac_backend_userdata ud) {
}
static MwLL carbon_create(MwLL parent, int x, int y, int width, int height) {
return NULL;
};
static void carbon_destroy(MwLL handle) {
return;
};
static void carbon_polygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
return;
};
static MwLLColor carbon_allocColor(MwLL handle, int r, int g, int b) {
return NULL;
};
static void carbon_freeColor(MwLLColor color) {
return;
};
static void carbon_getXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
return;
};
static void carbon_setXY(MwLL handle, int x, int y) {
return;
};
static void carbon_setWH(MwLL handle, int w, int h) {
return;
};
static void carbon_setTitle(MwLL handle, const char* title) {
return;
};
static int carbon_pending(MwLL handle) {
return 0;
};
static void carbon_nextEvent(MwLL handle) {
return;
};
static MwLLPixmap carbon_createPixmap(MwLL handle, unsigned char* data, int width, int height) {
return NULL;
};
static void carbon_drawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
return;
};
static void carbon_setIcon(MwLL handle, MwLLPixmap pixmap) {
return;
};
static void carbon_forceRender(MwLL handle) {
return;
};
static mac_backend carbon_backend = {
.create = carbon_create,
.destroy = carbon_destroy,
.polygon = carbon_polygon,
.allocColor = carbon_allocColor,
.freeColor = carbon_freeColor,
.getXYWH = carbon_getXYWH,
.setXY = carbon_setXY,
.setWH = carbon_setWH,
.setTitle = carbon_setTitle,
.pending = carbon_pending,
.nextEvent = carbon_nextEvent,
.createPixmap = carbon_createPixmap,
.drawPixmap = carbon_drawPixmap,
.setIcon = carbon_setIcon,
.forceRender = carbon_forceRender,
};
mac_backend getCarbonBackend(void) {
return carbon_backend;
};

View File

@@ -1,12 +0,0 @@
#ifndef __QUICKDRAW_H__
#define __QUICKDRAW_H__
#include "mac.h"
struct mac_backend_userdata_t {
};
void carbonBackendUserDataInit(mac_backend_userdata);
mac_backend getCarbonBackend(void);
#endif

View File

@@ -1,83 +0,0 @@
/* $Id$ */
#include <Mw/Milsko.h>
#include "mac.h"
#include "carbon.h"
MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
// void* library;
// MwLL r = malloc(sizeof(*r));
// MwLLCreateCommon(r);
//
// library = dlopen("CarbonLib", RTLD_NOW);
// if(library != NULL) {
// dlclose(library);
// r->backend = getQuickDrawBackend();
// quickDrawBackendUserDataInit(r->userdata);
// return r;
// }
//
// printf("ERROR: No supported UI library found. (Searched for: CarbonLib)\n");
// getchar();
// raise(SIGTRAP);
return NULL;
};
void MwLLSleep(int ms) {
usleep(ms * 1000);
}
void MwLLFreeColor(MwLLColor color) {
free(color);
}
void MwLLDestroyPixmap(MwLLPixmap pixmap) {
free(pixmap);
}
void MwLLDestroy(MwLL handle) {
handle->backend.destroy(handle);
};
void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
handle->backend.polygon(handle, points, points_count, color);
};
MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) {
return handle->backend.allocColor(handle, r, g, b);
};
void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
return handle->backend.getXYWH(handle, x, y, w, h);
};
void MwLLSetXY(MwLL handle, int x, int y) {
return handle->backend.setXY(handle, x, y);
};
void MwLLSetWH(MwLL handle, int w, int h) {
return handle->backend.setWH(handle, w, h);
};
void MwLLSetTitle(MwLL handle, const char* title) {
return handle->backend.setTitle(handle, title);
};
int MwLLPending(MwLL handle) {
return handle->backend.pending(handle);
};
void MwLLNextEvent(MwLL handle) {
return handle->backend.nextEvent(handle);
};
MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int height) {
return handle->backend.createPixmap(handle, data, width, height);
};
void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
return handle->backend.drawPixmap(handle, rect, pixmap);
};
void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
return handle->backend.setIcon(handle, pixmap);
};
void MwLLForceRender(MwLL handle) {
return handle->backend.forceRender(handle);
};
void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
return handle->backend.setCursor(handle, image, mask);
};
void MwLLDetach(MwLL handle, MwPoint* point) {
return handle->backend.detach(handle, point);
};

View File

@@ -1,54 +0,0 @@
/* $Id$ */
#ifndef __MAC_H__
#define __MAC_H__
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
#include <Mw/LowLevel.h>
typedef enum {
PLATFORM_QUICKDRAW = 0,
PLATFORM_QUARTZ,
} macPlatform;
typedef struct mac_backend_t {
MwLL (*create)(MwLL parent, int x, int y, int width, int height);
void (*destroy)(MwLL handle);
void (*polygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
MwLLColor (*allocColor)(MwLL handle, int r, int g, int b);
void (*freeColor)(MwLLColor color);
void (*getXYWH)(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
void (*setXY)(MwLL handle, int x, int y);
void (*setWH)(MwLL handle, int w, int h);
void (*setTitle)(MwLL handle, const char* title);
int (*pending)(MwLL handle);
void (*nextEvent)(MwLL handle);
MwLLPixmap (*createPixmap)(MwLL handle, unsigned char* data, int width, int height);
void (*drawPixmap)(MwLL handle, MwRect* rect, MwLLPixmap pixmap);
void (*setIcon)(MwLL handle, MwLLPixmap pixmap);
void (*forceRender)(MwLL handle);
void (*setCursor)(MwLL handle, MwCursor* image, MwCursor* mask);
void (*detach)(MwLL handle, MwPoint* point);
} mac_backend;
typedef struct mac_backend_userdata_t* mac_backend_userdata;
struct _MwLL {
mac_backend backend;
mac_backend_userdata userdata;
int copy_buffer;
unsigned int width;
unsigned int height;
MwLLHandler handler;
};
struct _MwLLPixmap {
unsigned int width;
unsigned int height;
};
#endif

View File

@@ -121,7 +121,7 @@ static XVisualInfo* get_visual_info(Display* display) {
return XGetVisualInfo(display, VisualIDMask, &xvi, &n);
}
MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
MwLL r;
Window p;
XVisualInfo* xvi;
@@ -225,7 +225,7 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
return r;
}
void MwLLDestroy(MwLL handle) {
static void MwLLDestroyImpl(MwLL handle) {
MwLLDestroyCommon(handle);
if(handle->xic) XDestroyIC(handle->xic);
@@ -241,7 +241,7 @@ void MwLLDestroy(MwLL handle) {
free(handle);
}
void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
int i;
XPoint* p = malloc(sizeof(*p) * points_count);
@@ -256,19 +256,19 @@ void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color
free(p);
}
void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color) {
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
XSetForeground(handle->display, handle->gc, color->pixel);
XDrawLine(handle->display, handle->pixmap, handle->gc, points[0].x, points[0].y, points[1].x, points[1].y);
}
MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) {
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
MwLLColor c = malloc(sizeof(*c));
MwLLColorUpdate(handle, c, r, g, b);
return c;
}
void MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b) {
static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
XColor xc;
if(handle->red_mask == 0) {
@@ -292,7 +292,8 @@ void MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b) {
c->green = g;
c->blue = b;
}
void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
Window root;
unsigned int border, depth;
@@ -308,7 +309,7 @@ void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h)
}
}
void MwLLSetXY(MwLL handle, int x, int y) {
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
XSizeHints sh;
long r;
@@ -325,7 +326,7 @@ void MwLLSetXY(MwLL handle, int x, int y) {
XSync(handle->display, False);
}
void MwLLSetWH(MwLL handle, int w, int h) {
static void MwLLSetWHImpl(MwLL handle, int w, int h) {
XSizeHints sh;
long r;
@@ -353,15 +354,15 @@ void MwLLSetWH(MwLL handle, int w, int h) {
MwLLForceRender(handle);
}
void MwLLFreeColor(MwLLColor color) {
static void MwLLFreeColorImpl(MwLLColor color) {
free(color);
}
void MwLLSetBackground(MwLL handle, MwLLColor color) {
static void MwLLSetBackgroundImpl(MwLL handle, MwLLColor color) {
XSetWindowBackground(handle->display, handle->window, color->pixel);
}
int MwLLPending(MwLL handle) {
static int MwLLPendingImpl(MwLL handle) {
XEvent ev;
if(XCheckTypedWindowEvent(handle->display, handle->window, ClientMessage, &ev) || XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
XPutBackEvent(handle->display, &ev);
@@ -370,7 +371,7 @@ int MwLLPending(MwLL handle) {
return 0;
}
void MwLLNextEvent(MwLL handle) {
static void MwLLNextEventImpl(MwLL handle) {
XEvent ev;
while(XCheckTypedWindowEvent(handle->display, handle->window, ClientMessage, &ev) || XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
int render = 0;
@@ -526,11 +527,11 @@ void MwLLNextEvent(MwLL handle) {
}
}
void MwLLSetTitle(MwLL handle, const char* title) {
static void MwLLSetTitleImpl(MwLL handle, const char* title) {
XSetStandardProperties(handle->display, handle->window, title, title, None, (char**)NULL, 0, NULL);
}
MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int height) {
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
MwLLPixmap r = malloc(sizeof(*r));
char* di = malloc(4 * width * height);
char* dm = malloc(4 * width * height);
@@ -560,7 +561,7 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei
return r;
}
void MwLLPixmapUpdate(MwLLPixmap r) {
static void MwLLPixmapUpdateImpl(MwLLPixmap r) {
int y, x;
for(y = 0; y < r->height; y++) {
for(x = 0; x < r->width; x++) {
@@ -588,7 +589,7 @@ void MwLLPixmapUpdate(MwLLPixmap r) {
}
}
void MwLLDestroyPixmap(MwLLPixmap pixmap) {
static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
free(pixmap->raw);
XDestroyImage(pixmap->image);
XDestroyImage(pixmap->mask);
@@ -597,7 +598,7 @@ void MwLLDestroyPixmap(MwLLPixmap pixmap) {
free(pixmap);
}
void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
if(rect->width == 0 || rect->height == 0) return;
#ifdef USE_XRENDER
if(pixmap->image != NULL && pixmap->use_xrender) {
@@ -712,7 +713,7 @@ void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
}
}
void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
unsigned long* icon = malloc((2 + pixmap->width * pixmap->height) * sizeof(*icon));
int i;
Atom atom = XInternAtom(handle->display, "_NET_WM_ICON", False);
@@ -729,7 +730,7 @@ void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
free(icon);
}
void MwLLForceRender(MwLL handle) {
static void MwLLForceRenderImpl(MwLL handle) {
XEvent ev;
memset(&ev, 0, sizeof(ev));
@@ -738,7 +739,7 @@ void MwLLForceRender(MwLL handle) {
XSendEvent(handle->display, handle->window, False, ExposureMask, &ev);
}
void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
Cursor cur;
int y, x, ys, xs;
char* di = malloc(MwCursorDataHeight * MwCursorDataHeight * 4);
@@ -801,7 +802,7 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
XDestroyImage(cmask);
}
void MwLLDetach(MwLL handle, MwPoint* point) {
static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
int x = 0, y = 0;
Window child, root, parent;
Window* children;
@@ -824,7 +825,7 @@ void MwLLDetach(MwLL handle, MwPoint* point) {
if(xwa.map_state == IsViewable) wait_map(handle, 0, 0);
}
void MwLLShow(MwLL handle, int show) {
static void MwLLShowImpl(MwLL handle, int show) {
if(show) {
wait_map(handle, 0, 0);
@@ -834,7 +835,7 @@ void MwLLShow(MwLL handle, int show) {
}
}
void MwLLMakePopup(MwLL handle, MwLL parent) {
static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
Atom wndtype = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE", False);
Atom wnddlg = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE_DIALOG", False);
Atom wndstate = XInternAtom(handle->display, "_NET_WM_STATE", False);
@@ -849,7 +850,7 @@ void MwLLMakePopup(MwLL handle, MwLL parent) {
wait_map(handle, 1, 0);
}
void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
XSizeHints* hints = XAllocSizeHints();
long ret;
@@ -868,7 +869,7 @@ void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
wait_map(handle, 1, 0);
}
void MwLLMakeBorderless(MwLL handle, int toggle) {
static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
Atom atom = XInternAtom(handle->display, "_MOTIF_WM_HINTS", 0);
mwm_hints_t hints;
@@ -881,11 +882,11 @@ void MwLLMakeBorderless(MwLL handle, int toggle) {
wait_map(handle, 1, 0);
}
void MwLLFocus(MwLL handle) {
static void MwLLFocusImpl(MwLL handle) {
XSetInputFocus(handle->display, handle->window, RevertToNone, CurrentTime);
}
void MwLLGrabPointer(MwLL handle, int toggle) {
static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
XWindowAttributes attr;
XGetWindowAttributes(handle->display, handle->window, &attr);
@@ -899,14 +900,14 @@ void MwLLGrabPointer(MwLL handle, int toggle) {
}
}
void MwLLSetClipboard(MwLL handle, const char* text) {
static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
/* TODO */
(void)handle;
(void)text;
}
char* MwLLGetClipboard(MwLL handle) {
static char* MwLLGetClipboardImpl(MwLL handle) {
Atom clip, target, prop;
XEvent ev;
XEvent* queue = NULL;
@@ -947,7 +948,7 @@ char* MwLLGetClipboard(MwLL handle) {
return r;
}
void MwLLMakeToolWindow(MwLL handle) {
static void MwLLMakeToolWindowImpl(MwLL handle) {
XSetWindowAttributes xswa;
Atom wndtype = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE", False);
Atom wndmenu = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE_MENU", False);
@@ -957,3 +958,11 @@ void MwLLMakeToolWindow(MwLL handle) {
XChangeWindowAttributes(handle->display, handle->window, CWOverrideRedirect, &xswa);
XChangeProperty(handle->display, handle->window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmenu, 1);
}
static int MwLLX11CallInitImpl(void) {
/* TODO: check properly */
return 0;
}
#include "call.c"
CALL(X11);