mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-28 16:17:09 +08:00
handlers for requests REQID_LOADCURSOR_PNG and REQID_LOADCURSOR_PNG_MEM
This commit is contained in:
@@ -226,6 +226,57 @@ static int load_cursor (int cli, int clifd, void* buff, size_t len)
|
|||||||
return ServerSendReply (clifd, &hcsr, sizeof (HCURSOR));
|
return ServerSendReply (clifd, &hcsr, sizeof (HCURSOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IS_COMPOSITING_SCHEMA
|
||||||
|
static int load_cursor_png_file (int cli, int clifd, void* buff, size_t len)
|
||||||
|
{
|
||||||
|
int hotspot[2];
|
||||||
|
HCURSOR hcsr = 0;
|
||||||
|
|
||||||
|
if (len <= (sizeof (hotspot) + 1)) // length of file name is 0.
|
||||||
|
goto ret;
|
||||||
|
|
||||||
|
memcpy (hotspot, buff, sizeof(hotspot));
|
||||||
|
hcsr = LoadCursorFromPNGFile (buff + sizeof(hotspot), hotspot[0], hotspot[1]);
|
||||||
|
|
||||||
|
#ifdef _MGHAVE_CURSOR
|
||||||
|
if (hcsr) {
|
||||||
|
add_global_res (cli, (void*) hcsr,
|
||||||
|
(void*)hcsr, (ReleaseProc)DestroyCursor);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret:
|
||||||
|
return ServerSendReply (clifd, &hcsr, sizeof (HCURSOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int load_cursor_png_mem (int cli, int clifd, void* buff, size_t len)
|
||||||
|
{
|
||||||
|
int hotspot[2];
|
||||||
|
HCURSOR hcsr;
|
||||||
|
|
||||||
|
/* check wheter has enough PNG data.
|
||||||
|
* see: https://garethrees.org/2007/11/14/pngcrush/
|
||||||
|
*/
|
||||||
|
if (len < (sizeof (hotspot) + 67))
|
||||||
|
goto ret;
|
||||||
|
|
||||||
|
memcpy (hotspot, buff, sizeof(hotspot));
|
||||||
|
hcsr = LoadCursorFromPNGMem (buff + sizeof(hotspot), len - sizeof (hotspot),
|
||||||
|
hotspot[0], hotspot[1]);
|
||||||
|
|
||||||
|
#ifdef _MGHAVE_CURSOR
|
||||||
|
if (hcsr) {
|
||||||
|
add_global_res (cli, (void*) hcsr,
|
||||||
|
(void*)hcsr, (ReleaseProc)DestroyCursor);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret:
|
||||||
|
return ServerSendReply (clifd, &hcsr, sizeof (HCURSOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* IS_COMPOSITING_SCHEMA */
|
||||||
|
|
||||||
static int create_cursor (int cli, int clifd, void* buff, size_t len)
|
static int create_cursor (int cli, int clifd, void* buff, size_t len)
|
||||||
{
|
{
|
||||||
HCURSOR hcsr;
|
HCURSOR hcsr;
|
||||||
@@ -709,8 +760,12 @@ static struct req_request {
|
|||||||
{ copy_cursor, 0 },
|
{ copy_cursor, 0 },
|
||||||
#if IS_COMPOSITING_SCHEMA
|
#if IS_COMPOSITING_SCHEMA
|
||||||
{ get_wp_surface, 0 },
|
{ get_wp_surface, 0 },
|
||||||
|
{ load_cursor_png_file, 0 },
|
||||||
|
{ load_cursor_png_mem, 0 },
|
||||||
#else
|
#else
|
||||||
{ NULL, 0 },
|
{ NULL, 0 },
|
||||||
|
{ NULL, 0 },
|
||||||
|
{ NULL, 0 },
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user