add MwLLSetDarkTheme
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
0fb9c45ea4
commit
a2c1489ffb
8 changed files with 57 additions and 1 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@
|
|||
\
|
||||
MwLLGetCursorCoord = MwLLGetCursorCoordImpl; \
|
||||
MwLLGetScreenSize = MwLLGetScreenSizeImpl; \
|
||||
\
|
||||
MwLLSetDarkTheme = MwLLSetDarkThemeImpl; \
|
||||
\
|
||||
return 0; \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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")) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue