diff --git a/include/Mw/TypeDefs.h b/include/Mw/TypeDefs.h index fbc91fa..ad072a3 100644 --- a/include/Mw/TypeDefs.h +++ b/include/Mw/TypeDefs.h @@ -274,7 +274,7 @@ struct _MwClass { MwHandlerChildrenProp children_prop_change; MwHandlerClipboardReceived clipboard; MwHandlerProps props_change; - MwHandler drag_and_drop; + MwHandler drag_and_drop; void* reserved2; void* reserved3; }; diff --git a/src/backend/gdi.c b/src/backend/gdi.c index 7f4ae6d..2abc8b3 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -77,7 +77,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { switch(msg) { case WM_INITDIALOG: - return TRUE; + return TRUE; case WM_PAINT: { PAINTSTRUCT ps; @@ -168,25 +168,26 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { MwLLDispatch(u->ll, up, &p); break; } - case WM_DROPFILES: { - HDROP hDrop = (HDROP)wp; - UINT count; - UINT i, n; - HRESULT hr; + case WM_DROPFILES: + { + HDROP hDrop = (HDROP)wp; + UINT count; + UINT i, n; + HRESULT hr; - count = wsymtbl.DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0); + count = wsymtbl.DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0); - for(i = 0; i < count; i++) { - wchar_t wpath[MAX_PATH]; - char path[MAX_PATH]; - wsymtbl.DragQueryFileW(hDrop, i, wpath, MAX_PATH); + for(i = 0; i < count; i++) { + wchar_t wpath[MAX_PATH]; + char path[MAX_PATH]; + wsymtbl.DragQueryFileW(hDrop, i, wpath, MAX_PATH); - memset(path, 0, sizeof(path)); - WideCharToMultiByte(CP_UTF8, 0, wpath, -1, path, sizeof(path) - 1, NULL, NULL); + memset(path, 0, sizeof(path)); + WideCharToMultiByte(CP_UTF8, 0, wpath, -1, path, sizeof(path) - 1, NULL, NULL); MwLLDispatch(u->ll, drag_and_drop, path); - } - wsymtbl.DragFinish(hDrop); + } + wsymtbl.DragFinish(hDrop); break; } case WM_MOUSEMOVE: @@ -612,9 +613,9 @@ static void MwLLNextEventImpl(MwLL handle) { handle->gdi.get_darktheme = 0; } while(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - if(GetMessage(&msg, NULL, 0, 0)) { + if(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); - DispatchMessage(&msg); + DispatchMessage(&msg); } } } diff --git a/src/core.c b/src/core.c index eb81536..251d255 100644 --- a/src/core.c +++ b/src/core.c @@ -145,8 +145,9 @@ static void llclosehandler(MwLL handle, void* data) { } static void llmovehandler(MwLL handle, void* data) { - MwWidget h = (MwWidget)handle->common.user; - MwPoint* p = data; + MwWidget h = (MwWidget)handle->common.user; + MwPoint* p = data; + h->mouse_point.x = p->x; h->mouse_point.y = p->y; @@ -193,15 +194,13 @@ static void llclipboardhandler(MwLL handle, void* data) { } static void lldraganddrophandler(MwLL handle, void* data) { - MwWidget h = (MwWidget)handle->common.user; - const char * p = data; + MwWidget h = (MwWidget)handle->common.user; + const char* p = data; if(MwGetInteger(h, MwNdisabled) == 1) return; - printf("%s\n",p); MwDispatchUserHandler(h, MwNdragAndDropHandler, data); } - /* if both of them are true * 1. widget class is not NULL * 2. parent is NULL @@ -282,20 +281,20 @@ static MwWidget MwCreateWidget_Internal(MwClass widget_class, const char* name, if(parent == NULL) h->top_step = 1; if(h->lowlevel != NULL) { - h->lowlevel->common.user = h; - h->lowlevel->common.handler->draw = lldrawhandler; - h->lowlevel->common.handler->up = lluphandler; - h->lowlevel->common.handler->down = lldownhandler; - h->lowlevel->common.handler->resize = llresizehandler; - h->lowlevel->common.handler->close = llclosehandler; - h->lowlevel->common.handler->move = llmovehandler; - h->lowlevel->common.handler->key = llkeyhandler; - h->lowlevel->common.handler->key_released = llkeyrelhandler; - h->lowlevel->common.handler->focus_in = llfocusinhandler; - h->lowlevel->common.handler->focus_out = llfocusouthandler; - h->lowlevel->common.handler->clipboard = llclipboardhandler; - h->lowlevel->common.handler->dark_theme = lldarkthemehandler; - h->lowlevel->common.handler->drag_and_drop = lldraganddrophandler; + h->lowlevel->common.user = h; + h->lowlevel->common.handler->draw = lldrawhandler; + h->lowlevel->common.handler->up = lluphandler; + h->lowlevel->common.handler->down = lldownhandler; + h->lowlevel->common.handler->resize = llresizehandler; + h->lowlevel->common.handler->close = llclosehandler; + h->lowlevel->common.handler->move = llmovehandler; + h->lowlevel->common.handler->key = llkeyhandler; + h->lowlevel->common.handler->key_released = llkeyrelhandler; + h->lowlevel->common.handler->focus_in = llfocusinhandler; + h->lowlevel->common.handler->focus_out = llfocusouthandler; + h->lowlevel->common.handler->clipboard = llclipboardhandler; + h->lowlevel->common.handler->dark_theme = lldarkthemehandler; + h->lowlevel->common.handler->drag_and_drop = lldraganddrophandler; } if(parent != NULL) arrput(parent->children, h); @@ -573,6 +572,7 @@ int MwStep(MwWidget handle) { MwFreeWidget(handle); return 1; } + return 0; }