mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-02-06 07:13:13 +00:00
might be functional
This commit is contained in:
@@ -163,6 +163,7 @@ struct _MwLLHandler {
|
|||||||
void (*focus_in)(MwLL handle, void* data);
|
void (*focus_in)(MwLL handle, void* data);
|
||||||
void (*focus_out)(MwLL handle, void* data);
|
void (*focus_out)(MwLL handle, void* data);
|
||||||
void (*clipboard)(MwLL handle, void* data);
|
void (*clipboard)(MwLL handle, void* data);
|
||||||
|
void (*dark_theme)(MwLL handle, void* data);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ struct _MwLLGDI {
|
|||||||
int grabbed;
|
int grabbed;
|
||||||
int force_render;
|
int force_render;
|
||||||
int get_clipboard;
|
int get_clipboard;
|
||||||
|
int get_darktheme;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLGDIColor {
|
struct _MwLLGDIColor {
|
||||||
|
|||||||
@@ -8,6 +8,17 @@ typedef struct userdata {
|
|||||||
int max_set;
|
int max_set;
|
||||||
} userdata_t;
|
} userdata_t;
|
||||||
|
|
||||||
|
static void detect_darktheme(MwLL handle){
|
||||||
|
DWORD dw;
|
||||||
|
DWORD sz = sizeof(dw);
|
||||||
|
|
||||||
|
if(RegGetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme", RRF_RT_REG_DWORD, NULL, &dw, &sz) == ERROR_SUCCESS){
|
||||||
|
int t = dw ? 0 : 1;
|
||||||
|
|
||||||
|
MwLLDispatch(handle, dark_theme, &t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
||||||
userdata_t* u = (userdata_t*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
userdata_t* u = (userdata_t*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
||||||
|
|
||||||
@@ -205,6 +216,10 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
|||||||
} else if(msg == WM_USER) {
|
} else if(msg == WM_USER) {
|
||||||
InvalidateRect(hWnd, NULL, FALSE);
|
InvalidateRect(hWnd, NULL, FALSE);
|
||||||
UpdateWindow(hWnd);
|
UpdateWindow(hWnd);
|
||||||
|
} else if(msg == WM_WININICHANGE){
|
||||||
|
char* s = (char*)lp;
|
||||||
|
|
||||||
|
if(s != NULL && strcmp(s, "ImmersiveColorSet") == 0) detect_darktheme(u->ll);
|
||||||
} else {
|
} else {
|
||||||
return DefWindowProc(hWnd, msg, wp, lp);
|
return DefWindowProc(hWnd, msg, wp, lp);
|
||||||
}
|
}
|
||||||
@@ -238,6 +253,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||||||
r->common.type = MwLLBackendGDI;
|
r->common.type = MwLLBackendGDI;
|
||||||
|
|
||||||
r->gdi.get_clipboard = 1;
|
r->gdi.get_clipboard = 1;
|
||||||
|
r->gdi.get_darktheme = 1;
|
||||||
r->gdi.force_render = 0;
|
r->gdi.force_render = 0;
|
||||||
r->gdi.grabbed = 0;
|
r->gdi.grabbed = 0;
|
||||||
r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL);
|
r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL);
|
||||||
@@ -384,7 +400,7 @@ static int MwLLPendingImpl(MwLL handle) {
|
|||||||
|
|
||||||
(void)handle;
|
(void)handle;
|
||||||
|
|
||||||
if(handle->gdi.get_clipboard) return 1;
|
if(handle->gdi.get_clipboard || handle->gdi.get_darktheme) return 1;
|
||||||
return PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0;
|
return PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,6 +427,11 @@ static void MwLLNextEventImpl(MwLL handle) {
|
|||||||
|
|
||||||
handle->gdi.get_clipboard = 0;
|
handle->gdi.get_clipboard = 0;
|
||||||
}
|
}
|
||||||
|
if(handle->gdi.get_darktheme){
|
||||||
|
detect_darktheme(handle);
|
||||||
|
|
||||||
|
handle->gdi.get_clipboard = 0;
|
||||||
|
}
|
||||||
while(PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE)) {
|
while(PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE)) {
|
||||||
GetMessage(&msg, handle->gdi.hWnd, 0, 0);
|
GetMessage(&msg, handle->gdi.hWnd, 0, 0);
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
|
|||||||
@@ -127,6 +127,13 @@ static void llclipboardhandler(MwLL handle, void* data) {
|
|||||||
*/
|
*/
|
||||||
#define IsFirstVisible(handle) ((handle)->widget_class != NULL && ((handle)->parent == NULL || (handle)->parent->widget_class == NULL))
|
#define IsFirstVisible(handle) ((handle)->widget_class != NULL && ((handle)->parent == NULL || (handle)->parent->widget_class == NULL))
|
||||||
|
|
||||||
|
static void lldarkthemehandler(MwLL handle, void* data){
|
||||||
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
|
int* ptr = data;
|
||||||
|
|
||||||
|
if(IsFirstVisible(h)) MwToggleDarkTheme(h, *ptr);
|
||||||
|
}
|
||||||
|
|
||||||
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||||
MwWidget h = malloc(sizeof(*h));
|
MwWidget h = malloc(sizeof(*h));
|
||||||
|
|
||||||
@@ -171,6 +178,7 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||||||
h->lowlevel->common.handler->focus_in = llfocusinhandler;
|
h->lowlevel->common.handler->focus_in = llfocusinhandler;
|
||||||
h->lowlevel->common.handler->focus_out = llfocusouthandler;
|
h->lowlevel->common.handler->focus_out = llfocusouthandler;
|
||||||
h->lowlevel->common.handler->clipboard = llclipboardhandler;
|
h->lowlevel->common.handler->clipboard = llclipboardhandler;
|
||||||
|
h->lowlevel->common.handler->dark_theme = lldarkthemehandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(parent != NULL) arrput(parent->children, h);
|
if(parent != NULL) arrput(parent->children, h);
|
||||||
|
|||||||
Reference in New Issue
Block a user