diff --git a/include/Mw/Core.h b/include/Mw/Core.h index c8866e2..28df4d4 100644 --- a/include/Mw/Core.h +++ b/include/Mw/Core.h @@ -330,6 +330,13 @@ MWDECL MwWidget* MwGetChildren(MwWidget handle); */ MWDECL void MwGetCursorCoord(MwWidget handle, MwPoint* point); +/*! + * @brief Gets the screen size + * @param handle Widget + * @param rect Rectangle + */ +MWDECL void MwGetScreenSize(MwWidget handle, MwRect* rect); + #ifdef __cplusplus } #endif diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index a2e55df..cb9c1e6 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -193,6 +193,7 @@ MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text); MWDECL char* (*MwLLGetClipboard)(MwLL handle); MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point); +MWDECL void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect); #ifdef __cplusplus } diff --git a/src/backend/call.c b/src/backend/call.c index f29e48d..bace30c 100644 --- a/src/backend/call.c +++ b/src/backend/call.c @@ -54,6 +54,7 @@ MwLLGetClipboard = MwLLGetClipboardImpl; \ \ MwLLGetCursorCoord = MwLLGetCursorCoordImpl; \ + MwLLGetScreenSize = MwLLGetScreenSizeImpl; \ \ return 0; \ } diff --git a/src/backend/gdi.c b/src/backend/gdi.c index 426d21e..f466dfd 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -727,6 +727,15 @@ static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) { point->y = p.y; } +static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { + RECT rc; + GetClientRect(GetDesktopWindow(), &rc); + + rect->x = rect->y = 0; + rect->width = rc.right - rc.left; + rect->height = rc.bottom - rc.top; +} + static void MwLLBeginStateChangeImpl(MwLL handle) { (void)handle; } diff --git a/src/backend/x11.c b/src/backend/x11.c index 3fdd775..f75adfb 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -1001,6 +1001,15 @@ static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) { point->y = ry; } +static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { + XWindowAttributes xwa; + XGetWindowAttributes(handle->x11.display, handle->x11.window, &xwa); + + rect->x = rect->y = 0; + rect->width = xwa.width; + rect->height = xwa.height; +} + static void MwLLBeginStateChangeImpl(MwLL handle) { MwLLShow(handle, 0); } diff --git a/src/core.c b/src/core.c index 2746215..85c7b5c 100644 --- a/src/core.c +++ b/src/core.c @@ -738,3 +738,7 @@ MwWidget* MwGetChildren(MwWidget handle) { void MwGetCursorCoord(MwWidget handle, MwPoint* point) { MwLLGetCursorCoord(handle->lowlevel, point); } + +void MwGetScreenSize(MwWidget handle, MwRect* rect) { + MwLLGetScreenSize(handle->lowlevel, rect); +} diff --git a/src/lowlevel.c b/src/lowlevel.c index cef29f3..70dd50f 100644 --- a/src/lowlevel.c +++ b/src/lowlevel.c @@ -49,6 +49,7 @@ void (*MwLLSetClipboard)(MwLL handle, const char* text); char* (*MwLLGetClipboard)(MwLL handle); void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point); +void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect); void MwLLCreateCommon(MwLL handle) { handle->common.handler = malloc(sizeof(*handle->common.handler));