git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@813 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
Nishi 2025-11-25 20:21:15 +00:00
commit f2bbadf62b
8 changed files with 41 additions and 3 deletions

View file

@ -323,6 +323,13 @@ MWDECL MwClass MwGetClass(MwWidget handle);
*/ */
MWDECL MwWidget* MwGetChildren(MwWidget handle); MWDECL MwWidget* MwGetChildren(MwWidget handle);
/*!
* @brief Gets the cursor coordinate
* @param handle Widget
* @param point Point
*/
MWDECL void MwGetCursorCoord(MwWidget handle, MwPoint* point);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -192,6 +192,8 @@ MWDECL void (*MwLLGrabPointer)(MwLL handle, int toggle);
MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text); MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text);
MWDECL char* (*MwLLGetClipboard)(MwLL handle); MWDECL char* (*MwLLGetClipboard)(MwLL handle);
MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -18,7 +18,7 @@ struct _MwLLGDI {
HWND hWnd; HWND hWnd;
HDC hDC; HDC hDC;
HCURSOR cursor; HCURSOR cursor;
HICON icon; HICON icon;
int grabbed; int grabbed;
}; };

View file

@ -52,6 +52,8 @@
\ \
MwLLSetClipboard = MwLLSetClipboardImpl; \ MwLLSetClipboard = MwLLSetClipboardImpl; \
MwLLGetClipboard = MwLLGetClipboardImpl; \ MwLLGetClipboard = MwLLGetClipboardImpl; \
\
MwLLGetCursorCoord = MwLLGetCursorCoordImpl; \
\ \
return 0; \ return 0; \
} }

View file

@ -240,7 +240,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
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);
r->gdi.hInstance = wc.hInstance; r->gdi.hInstance = wc.hInstance;
r->gdi.cursor = NULL; r->gdi.cursor = NULL;
r->gdi.icon = NULL; r->gdi.icon = NULL;
u->ll = r; u->ll = r;
u->min_set = 0; u->min_set = 0;
@ -716,13 +716,23 @@ static void MwLLMakeToolWindowImpl(MwLL handle) {
SetWindowPos(handle->gdi.hWnd, NULL, 0, 0, w, h, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(handle->gdi.hWnd, NULL, 0, 0, w, h, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
} }
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
POINT p;
(void)handle;
GetCursorPos(&p);
point->x = p.x;
point->y = p.y;
}
static void MwLLBeginStateChangeImpl(MwLL handle) { static void MwLLBeginStateChangeImpl(MwLL handle) {
(void)handle; (void)handle;
} }
static void MwLLEndStateChangeImpl(MwLL handle) { static void MwLLEndStateChangeImpl(MwLL handle) {
(void)handle; (void)handle;
;
} }
static int MwLLGDICallInitImpl(void) { static int MwLLGDICallInitImpl(void) {

View file

@ -990,6 +990,17 @@ static void MwLLMakeToolWindowImpl(MwLL handle) {
XChangeProperty(handle->x11.display, handle->x11.window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmenu, 1); XChangeProperty(handle->x11.display, handle->x11.window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmenu, 1);
} }
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
Window root, child;
int rx, ry, wx, wy;
unsigned int m;
XQueryPointer(handle->x11.display, DefaultRootWindow(handle->x11.display), &root, &child, &rx, &ry, &wx, &wy, &m);
point->x = rx;
point->y = ry;
}
static void MwLLBeginStateChangeImpl(MwLL handle) { static void MwLLBeginStateChangeImpl(MwLL handle) {
MwLLShow(handle, 0); MwLLShow(handle, 0);
} }

View file

@ -705,3 +705,7 @@ MwWidget* MwGetChildren(MwWidget handle) {
return c; return c;
} }
void MwGetCursorCoord(MwWidget handle, MwPoint* point) {
MwLLGetCursorCoord(handle->lowlevel, point);
}

View file

@ -48,6 +48,8 @@ void (*MwLLGrabPointer)(MwLL handle, int toggle);
void (*MwLLSetClipboard)(MwLL handle, const char* text); void (*MwLLSetClipboard)(MwLL handle, const char* text);
char* (*MwLLGetClipboard)(MwLL handle); char* (*MwLLGetClipboard)(MwLL handle);
void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
void MwLLCreateCommon(MwLL handle) { void MwLLCreateCommon(MwLL handle) {
handle->common.handler = malloc(sizeof(*handle->common.handler)); handle->common.handler = malloc(sizeof(*handle->common.handler));
memset(handle->common.handler, 0, sizeof(*handle->common.handler)); memset(handle->common.handler, 0, sizeof(*handle->common.handler));