Commit 67b10761 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winemac.drv: Use NtCallbackReturn to send back app's icons to unixlib.

parent b4b39bfb
......@@ -243,16 +243,16 @@ static BOOL CALLBACK get_first_resource(HMODULE module, LPCWSTR type, LPWSTR nam
*/
static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
{
struct app_icon_params *params = arg;
struct app_icon_result *result = param_ptr(params->result);
struct app_icon_entry entries[64];
HRSRC res_info;
HGLOBAL res_data;
GRPICONDIR *icon_dir;
unsigned count;
int i;
TRACE("()\n");
result->count = 0;
count = 0;
res_info = NULL;
EnumResourceNamesW(NULL, (LPCWSTR)RT_GROUP_ICON, get_first_resource, (LONG_PTR)&res_info);
......@@ -274,9 +274,9 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
goto cleanup;
}
for (i = 0; i < icon_dir->idCount && result->count < ARRAYSIZE(result->entries); i++)
for (i = 0; i < icon_dir->idCount && count < ARRAYSIZE(entries); i++)
{
struct app_icon_entry *entry = &result->entries[result->count];
struct app_icon_entry *entry = &entries[count];
int width = icon_dir->idEntries[i].bWidth;
int height = icon_dir->idEntries[i].bHeight;
BOOL found_better_bpp = FALSE;
......@@ -338,7 +338,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
{
entry->png = (UINT_PTR)icon_bits;
entry->icon = 0;
result->count++;
count++;
}
else
{
......@@ -348,7 +348,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
{
entry->icon = HandleToUlong(icon);
entry->png = 0;
result->count++;
count++;
}
else
WARN("failed to create icon %d from resource with ID %hd\n", i, icon_dir->idEntries[i].nID);
......@@ -363,7 +363,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size)
cleanup:
FreeResource(res_data);
return 0;
return NtCallbackReturn(entries, count * sizeof(entries[0]), 0);
}
typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size);
......
......@@ -249,27 +249,33 @@ cleanup:
*/
CFArrayRef create_app_icon_images(void)
{
struct app_icon_result icons;
struct app_icon_params params = { .result = (UINT_PTR)&icons };
CFMutableArrayRef images = NULL;
struct app_icon_entry *entries;
ULONG ret_len;
unsigned count;
int i;
TRACE("()\n");
macdrv_client_func(client_func_app_icon, &params, sizeof(params));
if (!icons.count) return NULL;
if (KeUserModeCallback(client_func_app_icon, NULL, 0, (void**)&entries, &ret_len) ||
(ret_len % sizeof(*entries)))
{
WARN("incorrect callback result\n");
return NULL;
}
count = ret_len / sizeof(*entries);
if (!count || !entries) return NULL;
images = CFArrayCreateMutable(NULL, icons.count, &kCFTypeArrayCallBacks);
images = CFArrayCreateMutable(NULL, count, &kCFTypeArrayCallBacks);
if (!images)
{
WARN("failed to create images array\n");
return NULL;
}
for (i = 0; i < icons.count; i++)
for (i = 0; i < count; i++)
{
struct app_icon_entry *icon = &icons.entries[i];
struct app_icon_entry *icon = &entries[i];
CGImageRef cgimage = NULL;
if (icon->png)
......
......@@ -104,18 +104,6 @@ struct app_icon_entry
UINT64 png;
};
struct app_icon_result
{
UINT32 count;
struct app_icon_entry entries[64];
};
/* macdrv_app_icon params */
struct app_icon_params
{
UINT64 result; /* FIXME: Use NtCallbackReturn instead */
};
/* macdrv_app_quit_request params */
struct app_quit_request_params
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment