add MwLLSetDarkTheme
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-04-16 09:35:53 +09:00
commit a2c1489ffb
8 changed files with 57 additions and 1 deletions

View file

@ -277,6 +277,8 @@ MWDECL void (*MwLLGetClipboard)(MwLL handle);
MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
MWDECL void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
MWDECL void (*MwLLSetDarkTheme)(MwLL handle, int toggle);
/* font renderer */
MWDECL void MwFLSetup(void);

View file

@ -54,6 +54,8 @@
\
MwLLGetCursorCoord = MwLLGetCursorCoordImpl; \
MwLLGetScreenSize = MwLLGetScreenSizeImpl; \
\
MwLLSetDarkTheme = MwLLSetDarkThemeImpl; \
\
return 0; \
}

View file

@ -1082,6 +1082,11 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
MwLLShow(handle, 1);
}
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle){
(void)handle;
(void)toggle;
}
static int MwLLCocoaCallInitImpl(void) {
#ifndef __APPLE__
printf("Using GNUStep Backend\n");

View file

@ -8,6 +8,14 @@ typedef struct userdata {
int max_set;
} userdata_t;
static struct symtbl {
void* lib_dwmapi;
HRESULT (WINAPI *DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
} wsymtbl;
#define DwmSetWindowAttribute wsymtbl.DwmSetWindowAttribute
static void detect_darktheme(MwLL handle) {
DWORD dw;
DWORD sz = sizeof(dw);
@ -26,6 +34,12 @@ static void detect_darktheme(MwLL handle) {
t = dw ? 0 : 1;
if(t && DwmSetWindowAttribute != NULL){
LPARAM style = GetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE);
BOOL v = TRUE;
if(!(style & WS_CHILD)) DwmSetWindowAttribute(handle->gdi.hWnd, 20, &v, sizeof(v));
}
MwLLDispatch(handle, dark_theme, &t);
}
@ -804,7 +818,20 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
(void)handle;
}
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle){
BOOL v = toggle ? TRUE : FALSE;
DwmSetWindowAttribute(handle->gdi.hWnd, 20, &v, sizeof(v));
}
static int MwLLGDICallInitImpl(void) {
memset(&wsymtbl, 0, sizeof(wsymtbl));
wsymtbl.lib_dwmapi = MwDynamicOpen("dwmapi.dll");
if(wsymtbl.lib_dwmapi != NULL) DwmSetWindowAttribute = MwDynamicSymbol(wsymtbl.lib_dwmapi, "DwmSetWindowAttribute");
/* TODO: check properly */
return 0;
}

View file

@ -2620,6 +2620,11 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
}
}
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle){
(void)handle;
(void)toggle;
}
static int MwLLWaylandCallInitImpl(void) {
#ifdef __linux__
MwBool loadWayland = MwFALSE;

View file

@ -4,7 +4,7 @@
#define ClipboardTimeout 100
static struct {
static struct symtbl {
void* lib_xlib;
void* lib_xrender;
MwBool has_xrender;
@ -1308,6 +1308,11 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
MwLLShow(handle, 1);
}
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle){
(void)handle;
(void)toggle;
}
static int MwLLX11CallInitImpl(void) {
MwBool loadX11 = MwFALSE;
if(getenv("MILSKO_BACKEND")) {

View file

@ -532,6 +532,14 @@ void MwSetInteger(MwWidget handle, const char* key, int n) {
if(strcmp(key, MwNmodernLook) == 0 || strcmp(key, MwNdarkTheme) == 0 || strcmp(key, MwNbitmapFont) == 0) {
force_render_all(handle);
}
if(strcmp(key, MwNdarkTheme) == 0){
MwWidget h = handle;
while(h->parent != NULL && h->parent->widget_class != NULL) h = h->parent;
MwLLSetDarkTheme(h->lowlevel, n);
}
}
void MwSetText(MwWidget handle, const char* key, const char* value) {

View file

@ -51,6 +51,8 @@ void (*MwLLGetClipboard)(MwLL handle) = NULL;
void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point) = NULL;
void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect) = NULL;
void (*MwLLSetDarkTheme)(MwLL handle, int toggle) = NULL;
void MwLLCreateCommon(MwLL handle) {
handle->common.handler = malloc(sizeof(*handle->common.handler));
memset(handle->common.handler, 0, sizeof(*handle->common.handler));