From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/cocoa_app.m | 4 ++-- dlls/winemac.drv/cocoa_event.m | 6 +++--- dlls/winemac.drv/event.c | 6 +++--- dlls/winemac.drv/macdrv_cocoa.h | 2 +- dlls/winemac.drv/mouse.c | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index b5a3059382e..b13bc678c6d 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -1188,7 +1188,7 @@ static NSString* WineLocalizedString(unsigned int stringID) [eventQueuesLock lock]; for (queue in eventQueues) { - [queue discardEventsMatchingMask:event_mask_for_type(MOUSE_MOVED) | + [queue discardEventsMatchingMask:event_mask_for_type(MOUSE_MOVED_RELATIVE) | event_mask_for_type(MOUSE_MOVED_ABSOLUTE) forWindow:nil]; [queue resetMouseEventPositions:pos]; @@ -1444,7 +1444,7 @@ static NSString* WineLocalizedString(unsigned int stringID) mouseMoveDeltaX += [anEvent deltaX]; mouseMoveDeltaY += [anEvent deltaY];
- event = macdrv_create_event(MOUSE_MOVED, targetWindow); + event = macdrv_create_event(MOUSE_MOVED_RELATIVE, targetWindow); event->mouse_moved.x = mouseMoveDeltaX * scale; event->mouse_moved.y = mouseMoveDeltaY * scale;
diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m index 868ce5a7813..24f69b17a0a 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -204,17 +204,17 @@ static const OSType WineHotKeySignature = 'Wine'; }]; [events removeObjectsAtIndexes:indexes];
- if ((event->event->type == MOUSE_MOVED || + if ((event->event->type == MOUSE_MOVED_RELATIVE || event->event->type == MOUSE_MOVED_ABSOLUTE) && event->event->deliver == INT_MAX && (lastEvent = [events lastObject]) && - (lastEvent->event->type == MOUSE_MOVED || + (lastEvent->event->type == MOUSE_MOVED_RELATIVE || lastEvent->event->type == MOUSE_MOVED_ABSOLUTE) && lastEvent->event->deliver == INT_MAX && lastEvent->event->window == event->event->window && lastEvent->event->mouse_moved.drag == event->event->mouse_moved.drag) { - if (event->event->type == MOUSE_MOVED) + if (event->event->type == MOUSE_MOVED_RELATIVE) { lastEvent->event->mouse_moved.x += event->event->mouse_moved.x; lastEvent->event->mouse_moved.y += event->event->mouse_moved.y; diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 361709010c9..aed8f94076a 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -44,7 +44,7 @@ static const char *dbgstr_event(int type) "KEYBOARD_CHANGED", "LOST_PASTEBOARD_OWNERSHIP", "MOUSE_BUTTON", - "MOUSE_MOVED", + "MOUSE_MOVED_RELATIVE", "MOUSE_MOVED_ABSOLUTE", "MOUSE_SCROLL", "QUERY_EVENT", @@ -100,7 +100,7 @@ static macdrv_event_mask get_event_mask(DWORD mask)
if (mask & QS_MOUSEMOVE) { - event_mask |= event_mask_for_type(MOUSE_MOVED); + event_mask |= event_mask_for_type(MOUSE_MOVED_RELATIVE); event_mask |= event_mask_for_type(MOUSE_MOVED_ABSOLUTE); }
@@ -325,7 +325,7 @@ void macdrv_handle_event(const macdrv_event *event) case MOUSE_BUTTON: macdrv_mouse_button(hwnd, event); break; - case MOUSE_MOVED: + case MOUSE_MOVED_RELATIVE: case MOUSE_MOVED_ABSOLUTE: macdrv_mouse_moved(hwnd, event); break; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 94f9fbcfa17..27b130ca32e 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -328,7 +328,7 @@ enum { KEYBOARD_CHANGED, LOST_PASTEBOARD_OWNERSHIP, MOUSE_BUTTON, - MOUSE_MOVED, + MOUSE_MOVED_RELATIVE, MOUSE_MOVED_ABSOLUTE, MOUSE_SCROLL, QUERY_EVENT, diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index 078b674d7c0..00ec9a36c38 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -892,14 +892,14 @@ void macdrv_mouse_button(HWND hwnd, const macdrv_event *event) /*********************************************************************** * macdrv_mouse_moved * - * Handler for MOUSE_MOVED and MOUSE_MOVED_ABSOLUTE events. + * Handler for MOUSE_MOVED_RELATIVE and MOUSE_MOVED_ABSOLUTE events. */ void macdrv_mouse_moved(HWND hwnd, const macdrv_event *event) { UINT flags = MOUSEEVENTF_MOVE;
TRACE("win %p/%p %s (%d,%d) drag %d time %lu (%lu ticks ago)\n", hwnd, event->window, - (event->type == MOUSE_MOVED) ? "relative" : "absolute", + (event->type == MOUSE_MOVED_RELATIVE) ? "relative" : "absolute", event->mouse_moved.x, event->mouse_moved.y, event->mouse_moved.drag, event->mouse_moved.time_ms, (NtGetTickCount() - event->mouse_moved.time_ms));
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/dllmain.c | 1 + dlls/winemac.drv/dragdrop.c | 32 +++++++++++----------------- dlls/winemac.drv/event.c | 42 ++++++++++++++++++++++++++++++++++++- dlls/winemac.drv/macdrv.h | 2 +- dlls/winemac.drv/unixlib.h | 13 +++++++++++- 5 files changed, 67 insertions(+), 23 deletions(-)
diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index 493062521ad..69bc02e46c2 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -29,6 +29,7 @@ HMODULE macdrv_module = 0; typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); static const kernel_callback kernel_callbacks[] = { + macdrv_dnd_query_drop, macdrv_dnd_query_exited, macdrv_ime_query_char_rect, macdrv_ime_set_text, diff --git a/dlls/winemac.drv/dragdrop.c b/dlls/winemac.drv/dragdrop.c index 19a5c4794b5..a57caab423b 100644 --- a/dlls/winemac.drv/dragdrop.c +++ b/dlls/winemac.drv/dragdrop.c @@ -427,40 +427,32 @@ static IDropTarget* get_droptarget_pointer(HWND hwnd)
/************************************************************************** - * query_drag_drop + * macdrv_dnd_query_drop */ -BOOL query_drag_drop(macdrv_query* query) +NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) { + struct dnd_query_drop_params *params = arg; + IDropTarget *droptarget; BOOL ret = FALSE; - HWND hwnd = macdrv_get_window_hwnd(query->window); - struct macdrv_win_data *data = get_win_data(hwnd); POINT pt; - IDropTarget *droptarget; - - TRACE("win %p/%p x,y %d,%d op 0x%08x pasteboard %p\n", hwnd, query->window, - query->drag_drop.x, query->drag_drop.y, query->drag_drop.op, query->drag_drop.pasteboard);
- if (!data) - { - WARN("no win_data for win %p/%p\n", hwnd, query->window); - return FALSE; - } + TRACE("win %p x,y %d,%d effect %x pasteboard %s\n", params->hwnd, params->x, params->y, + params->effect, wine_dbgstr_longlong(params->handle));
- pt.x = query->drag_drop.x + data->whole_rect.left; - pt.y = query->drag_drop.y + data->whole_rect.top; - release_win_data(data); + pt.x = params->x; + pt.y = params->y;
droptarget = get_droptarget_pointer(last_droptarget_hwnd); if (droptarget) { HRESULT hr; POINTL pointl; - DWORD effect = drag_operations_to_dropeffects(query->drag_drop.op); + DWORD effect = params->effect;
if (!active_data_object) { WARN("shouldn't happen: no active IDataObject\n"); - active_data_object = create_data_object_for_pasteboard(query->drag_drop.pasteboard); + active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle); }
pointl.x = pt.x; @@ -484,12 +476,12 @@ BOOL query_drag_drop(macdrv_query* query) } else { - hwnd = WindowFromPoint(pt); + HWND hwnd = WindowFromPoint(pt); while (hwnd && !(GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_ACCEPTFILES)) hwnd = GetParent(hwnd); if (hwnd) { - HDROP hdrop = macdrv_get_pasteboard_data(query->drag_drop.pasteboard, CF_HDROP); + HDROP hdrop = macdrv_get_pasteboard_data((void *)(UINT_PTR)params->handle, CF_HDROP); DROPFILES *dropfiles = GlobalLock(hdrop); if (dropfiles) { diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index aed8f94076a..8432218d8d1 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -23,7 +23,7 @@ #include "config.h"
#include "macdrv.h" -#include "winuser.h" +#include "oleidl.h"
WINE_DEFAULT_DEBUG_CHANNEL(event); WINE_DECLARE_DEBUG_CHANNEL(imm); @@ -179,6 +179,46 @@ static void macdrv_sent_text_input(const macdrv_event *event) }
+/************************************************************************** + * drag_operations_to_dropeffects + */ +static DWORD drag_operations_to_dropeffects(uint32_t ops) +{ + DWORD effects = 0; + if (ops & (DRAG_OP_COPY | DRAG_OP_GENERIC)) + effects |= DROPEFFECT_COPY; + if (ops & DRAG_OP_MOVE) + effects |= DROPEFFECT_MOVE; + if (ops & (DRAG_OP_LINK | DRAG_OP_GENERIC)) + effects |= DROPEFFECT_LINK; + return effects; +} + + +/************************************************************************** + * query_drag_drop + */ +static BOOL query_drag_drop(macdrv_query *query) +{ + HWND hwnd = macdrv_get_window_hwnd(query->window); + struct macdrv_win_data *data = get_win_data(hwnd); + struct dnd_query_drop_params params; + + if (!data) + { + WARN("no win_data for win %p/%p\n", hwnd, query->window); + return FALSE; + } + + params.hwnd = hwnd; + params.effect = drag_operations_to_dropeffects(query->drag_drop.op); + params.x = query->drag_drop.x + data->whole_rect.left; + params.y = query->drag_drop.y + data->whole_rect.top; + params.handle = (UINT_PTR)query->drag_drop.pasteboard; + release_win_data(data); + return macdrv_client_func(client_func_dnd_query_drop, ¶ms, sizeof(params)); +} + /************************************************************************** * query_drag_exited */ diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 401ebab3bcc..a0ae0225423 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -260,7 +260,6 @@ extern BOOL macdrv_pasteboard_has_format(CFTypeRef pasteboard, UINT desired_form extern UINT* macdrv_get_pasteboard_formats(CFTypeRef pasteboard, UINT* num_formats) DECLSPEC_HIDDEN;
extern BOOL query_drag_operation(macdrv_query* query) DECLSPEC_HIDDEN; -extern BOOL query_drag_drop(macdrv_query* query) DECLSPEC_HIDDEN;
extern struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) DECLSPEC_HIDDEN; extern const struct vulkan_funcs *macdrv_wine_get_vulkan_driver(UINT version) DECLSPEC_HIDDEN; @@ -296,6 +295,7 @@ extern NTSTATUS macdrv_notify_icon(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_client_func(enum macdrv_client_funcs func, const void *params, ULONG size) DECLSPEC_HIDDEN;
+extern NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) DECLSPEC_HIDDEN;
/* user helpers */ diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index 067f46c8f5d..a858b29baaa 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -67,12 +67,23 @@ struct notify_icon_params /* driver client callbacks exposed with KernelCallbackTable interface */ enum macdrv_client_funcs { - client_func_dnd_query_exited = NtUserDriverCallbackFirst, + client_func_dnd_query_drop = NtUserDriverCallbackFirst, + client_func_dnd_query_exited, client_func_ime_query_char_rect, client_func_ime_set_text, client_func_last };
+/* macdrv_dnd_query_drop params */ +struct dnd_query_drop_params +{ + HWND hwnd; + UINT32 effect; + INT32 x; + INT32 y; + UINT64 handle; +}; + /* macdrv_dnd_query_exited params */ struct dnd_query_exited_params {
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/dllmain.c | 1 + dlls/winemac.drv/dragdrop.c | 72 ++++++++----------------------------- dlls/winemac.drv/event.c | 47 ++++++++++++++++++++++++ dlls/winemac.drv/macdrv.h | 3 +- dlls/winemac.drv/unixlib.h | 13 ++++++- 5 files changed, 75 insertions(+), 61 deletions(-)
diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index 69bc02e46c2..4bedb2aaf61 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -29,6 +29,7 @@ HMODULE macdrv_module = 0; typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); static const kernel_callback kernel_callbacks[] = { + macdrv_dnd_query_drag, macdrv_dnd_query_drop, macdrv_dnd_query_exited, macdrv_ime_query_char_rect, diff --git a/dlls/winemac.drv/dragdrop.c b/dlls/winemac.drv/dragdrop.c index a57caab423b..c3172a29467 100644 --- a/dlls/winemac.drv/dragdrop.c +++ b/dlls/winemac.drv/dragdrop.c @@ -325,37 +325,6 @@ static IDataObject *create_data_object_for_pasteboard(CFTypeRef pasteboard) }
-/************************************************************************** - * drag_operations_to_dropeffects - */ -static DWORD drag_operations_to_dropeffects(uint32_t ops) -{ - DWORD effects = DROPEFFECT_NONE; - if (ops & (DRAG_OP_COPY | DRAG_OP_GENERIC)) - effects |= DROPEFFECT_COPY; - if (ops & DRAG_OP_MOVE) - effects |= DROPEFFECT_MOVE; - if (ops & (DRAG_OP_LINK | DRAG_OP_GENERIC)) - effects |= DROPEFFECT_LINK; - return effects; -} - - -/************************************************************************** - * dropeffect_to_drag_operation - */ -static uint32_t dropeffect_to_drag_operation(DWORD effect, uint32_t ops) -{ - if (effect & DROPEFFECT_LINK && ops & DRAG_OP_LINK) return DRAG_OP_LINK; - if (effect & DROPEFFECT_COPY && ops & DRAG_OP_COPY) return DRAG_OP_COPY; - if (effect & DROPEFFECT_MOVE && ops & DRAG_OP_MOVE) return DRAG_OP_MOVE; - if (effect & DROPEFFECT_LINK && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC; - if (effect & DROPEFFECT_COPY && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC; - - return DRAG_OP_NONE; -} - - /* Based on functions in dlls/ole32/ole2.c */ static HANDLE get_droptarget_local_handle(HWND hwnd) { @@ -547,31 +516,22 @@ NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) /************************************************************************** * query_drag_operation */ -BOOL query_drag_operation(macdrv_query* query) +NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) { + struct dnd_query_drag_params *params = arg; + HWND hwnd = params->hwnd; BOOL ret = FALSE; - HWND hwnd = macdrv_get_window_hwnd(query->window); - struct macdrv_win_data *data = get_win_data(hwnd); POINT pt; DWORD effect; IDropTarget *droptarget; HRESULT hr;
- TRACE("win %p/%p x,y %d,%d offered_ops 0x%x pasteboard %p\n", hwnd, query->window, - query->drag_operation.x, query->drag_operation.y, query->drag_operation.offered_ops, - query->drag_operation.pasteboard); - - if (!data) - { - WARN("no win_data for win %p/%p\n", hwnd, query->window); - return FALSE; - } - - pt.x = query->drag_operation.x + data->whole_rect.left; - pt.y = query->drag_operation.y + data->whole_rect.top; - release_win_data(data); + TRACE("win %p x,y %d,%d effect %x pasteboard %s\n", hwnd, params->x, params->y, + params->effect, wine_dbgstr_longlong(params->handle));
- effect = drag_operations_to_dropeffects(query->drag_operation.offered_ops); + pt.x = params->x; + pt.y = params->y; + effect = params->effect;
/* Instead of the top-level window we got in the query, start with the deepest child under the cursor. Travel up the hierarchy looking for a window that @@ -604,16 +564,14 @@ BOOL query_drag_operation(macdrv_query* query) POINTL pointl = { pt.x, pt.y };
if (!active_data_object) - active_data_object = create_data_object_for_pasteboard(query->drag_operation.pasteboard); + active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle);
TRACE("DragEnter hwnd %p droptarget %p\n", hwnd, droptarget); hr = IDropTarget_DragEnter(droptarget, active_data_object, MK_LBUTTON, pointl, &effect); if (SUCCEEDED(hr)) { - query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect, - query->drag_operation.offered_ops); - TRACE(" effect %d accepted op %d\n", effect, query->drag_operation.accepted_op); + TRACE(" effect %d\n", effect); ret = TRUE; } else @@ -629,9 +587,7 @@ BOOL query_drag_operation(macdrv_query* query) hr = IDropTarget_DragOver(droptarget, MK_LBUTTON, pointl, &effect); if (SUCCEEDED(hr)) { - query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect, - query->drag_operation.offered_ops); - TRACE(" effect %d accepted op %d\n", effect, query->drag_operation.accepted_op); + TRACE(" effect %d\n", effect); ret = TRUE; } else @@ -649,7 +605,7 @@ BOOL query_drag_operation(macdrv_query* query) FORMATETC formatEtc;
if (!active_data_object) - active_data_object = create_data_object_for_pasteboard(query->drag_operation.pasteboard); + active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle);
formatEtc.cfFormat = CF_HDROP; formatEtc.ptd = NULL; @@ -659,12 +615,12 @@ BOOL query_drag_operation(macdrv_query* query) if (SUCCEEDED(IDataObject_QueryGetData(active_data_object, &formatEtc))) { TRACE("WS_EX_ACCEPTFILES hwnd %p\n", hwnd); - query->drag_operation.accepted_op = DRAG_OP_GENERIC; + effect = DROPEFFECT_COPY | DROPEFFECT_LINK; ret = TRUE; } } }
TRACE(" -> %s\n", ret ? "TRUE" : "FALSE"); - return ret; + return ret ? effect : 0; } diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 8432218d8d1..ce7f06b07dd 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -195,6 +195,21 @@ static DWORD drag_operations_to_dropeffects(uint32_t ops) }
+/************************************************************************** + * dropeffect_to_drag_operation + */ +static uint32_t dropeffect_to_drag_operation(DWORD effect, uint32_t ops) +{ + if (effect & DROPEFFECT_LINK && ops & DRAG_OP_LINK) return DRAG_OP_LINK; + if (effect & DROPEFFECT_COPY && ops & DRAG_OP_COPY) return DRAG_OP_COPY; + if (effect & DROPEFFECT_MOVE && ops & DRAG_OP_MOVE) return DRAG_OP_MOVE; + if (effect & DROPEFFECT_LINK && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC; + if (effect & DROPEFFECT_COPY && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC; + + return DRAG_OP_NONE; +} + + /************************************************************************** * query_drag_drop */ @@ -230,6 +245,38 @@ static BOOL query_drag_exited(macdrv_query *query) }
+/************************************************************************** + * query_drag_operation + */ +static BOOL query_drag_operation(macdrv_query *query) +{ + struct dnd_query_drag_params params; + HWND hwnd = macdrv_get_window_hwnd(query->window); + struct macdrv_win_data *data = get_win_data(hwnd); + DWORD effect; + + if (!data) + { + WARN("no win_data for win %p/%p\n", hwnd, query->window); + return FALSE; + } + + params.hwnd = hwnd; + params.effect = drag_operations_to_dropeffects(query->drag_operation.offered_ops); + params.x = query->drag_operation.x + data->whole_rect.left; + params.y = query->drag_operation.y + data->whole_rect.top; + params.handle = (UINT_PTR)query->drag_operation.pasteboard; + release_win_data(data); + + effect = macdrv_client_func(client_func_dnd_query_drag, ¶ms, sizeof(params)); + if (!effect) return FALSE; + + query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect, + query->drag_operation.offered_ops); + return TRUE; +} + + /************************************************************************** * query_ime_char_rect */ diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index a0ae0225423..ce71baa5735 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -259,8 +259,6 @@ extern HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_form extern BOOL macdrv_pasteboard_has_format(CFTypeRef pasteboard, UINT desired_format) DECLSPEC_HIDDEN; extern UINT* macdrv_get_pasteboard_formats(CFTypeRef pasteboard, UINT* num_formats) DECLSPEC_HIDDEN;
-extern BOOL query_drag_operation(macdrv_query* query) DECLSPEC_HIDDEN; - extern struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) DECLSPEC_HIDDEN; extern const struct vulkan_funcs *macdrv_wine_get_vulkan_driver(UINT version) DECLSPEC_HIDDEN; extern void sync_gl_view(struct macdrv_win_data* data, const RECT* old_whole_rect, const RECT* old_client_rect) DECLSPEC_HIDDEN; @@ -295,6 +293,7 @@ extern NTSTATUS macdrv_notify_icon(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_client_func(enum macdrv_client_funcs func, const void *params, ULONG size) DECLSPEC_HIDDEN;
+extern NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) DECLSPEC_HIDDEN;
diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index a858b29baaa..f4a8b7982f5 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -67,13 +67,24 @@ struct notify_icon_params /* driver client callbacks exposed with KernelCallbackTable interface */ enum macdrv_client_funcs { - client_func_dnd_query_drop = NtUserDriverCallbackFirst, + client_func_dnd_query_drag = NtUserDriverCallbackFirst, + client_func_dnd_query_drop, client_func_dnd_query_exited, client_func_ime_query_char_rect, client_func_ime_set_text, client_func_last };
+/* macdrv_dnd_query_drag params */ +struct dnd_query_drag_params +{ + HWND hwnd; + UINT32 effect; + INT32 x; + INT32 y; + UINT64 handle; +}; + /* macdrv_dnd_query_drop params */ struct dnd_query_drop_params {
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 61 +++++++++++++++++++++++----------- dlls/winemac.drv/dragdrop.c | 34 ++++++++++--------- dlls/winemac.drv/macdrv.h | 6 ++-- dlls/winemac.drv/macdrv_main.c | 4 +++ dlls/winemac.drv/unixlib.h | 18 ++++++++++ 5 files changed, 86 insertions(+), 37 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 16c44ddfde6..f46bb389cc9 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -248,6 +248,12 @@ static const char *debugstr_format(UINT id) }
+static CFTypeRef pasteboard_from_handle(UINT64 handle) +{ + return (CFTypeRef)(UINT_PTR)handle; +} + + /************************************************************************** * insert_clipboard_format */ @@ -1201,14 +1207,16 @@ HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) /************************************************************************** * macdrv_pasteboard_has_format */ -BOOL macdrv_pasteboard_has_format(CFTypeRef pasteboard, UINT desired_format) +NTSTATUS macdrv_dnd_have_format(void *arg) { + struct dnd_have_format_params *params = arg; + CFTypeRef pasteboard = pasteboard_from_handle(params->handle); CFArrayRef types; int count; UINT i; BOOL found = FALSE;
- TRACE("pasteboard %p, desired_format %s\n", pasteboard, debugstr_format(desired_format)); + TRACE("pasteboard %p, desired_format %s\n", pasteboard, debugstr_format(params->format));
types = macdrv_copy_pasteboard_types(pasteboard); if (!types) @@ -1229,7 +1237,7 @@ BOOL macdrv_pasteboard_has_format(CFTypeRef pasteboard, UINT desired_format) { TRACE("for type %s got format %s\n", debugstr_cf(type), debugstr_format(format->format_id));
- if (format->format_id == desired_format) + if (format->format_id == params->format) { found = TRUE; break; @@ -1365,33 +1373,24 @@ static WINE_CLIPFORMAT** get_formats_for_pasteboard(CFTypeRef pasteboard, UINT *
/************************************************************************** - * macdrv_get_pasteboard_formats + * macdrv_dnd_get_formats */ -UINT* macdrv_get_pasteboard_formats(CFTypeRef pasteboard, UINT* num_formats) +NTSTATUS macdrv_dnd_get_formats(void *arg) { + struct dnd_get_formats_params *params = arg; + CFTypeRef pasteboard = pasteboard_from_handle(params->handle); WINE_CLIPFORMAT** formats; UINT count, i; - UINT* format_ids;
formats = get_formats_for_pasteboard(pasteboard, &count); if (!formats) - return NULL; - - format_ids = malloc(count); - if (!format_ids) - { - WARN("Failed to allocate formats IDs array\n"); - free(formats); - return NULL; - } + return 0; + count = min(count, ARRAYSIZE(params->formats));
for (i = 0; i < count; i++) - format_ids[i] = formats[i]->format_id; - - free(formats); + params->formats[i] = formats[i]->format_id;
- *num_formats = count; - return format_ids; + return count; }
@@ -1746,3 +1745,25 @@ void macdrv_lost_pasteboard_ownership(HWND hwnd) if (!macdrv_is_pasteboard_owner(clipboard_cocoa_window)) grab_win32_clipboard(); } + + +/************************************************************************** + * macdrv_dnd_release + */ +NTSTATUS macdrv_dnd_release(void *arg) +{ + UINT64 handle = *(UINT64 *)arg; + CFRelease(pasteboard_from_handle(handle)); + return 0; +} + + +/************************************************************************** + * macdrv_dnd_retain + */ +NTSTATUS macdrv_dnd_retain(void *arg) +{ + UINT64 handle = *(UINT64 *)arg; + CFRetain(pasteboard_from_handle(handle)); + return 0; +} diff --git a/dlls/winemac.drv/dragdrop.c b/dlls/winemac.drv/dragdrop.c index c3172a29467..962a9d8c24b 100644 --- a/dlls/winemac.drv/dragdrop.c +++ b/dlls/winemac.drv/dragdrop.c @@ -42,7 +42,7 @@ typedef struct { IDataObject IDataObject_iface; LONG ref; - CFTypeRef pasteboard; + UINT64 pasteboard; } DragDropDataObject;
@@ -131,7 +131,7 @@ static ULONG WINAPI dddo_Release(IDataObject* iface) return refCount;
TRACE("-- destroying DragDropDataObject (%p)\n", This); - CFRelease(This->pasteboard); + MACDRV_CALL(dnd_release, &This->pasteboard); HeapFree(GetProcessHeap(), 0, This); return 0; } @@ -148,7 +148,7 @@ static HRESULT WINAPI dddo_GetData(IDataObject* iface, FORMATETC* formatEtc, STG if (SUCCEEDED(hr)) { medium->tymed = TYMED_HGLOBAL; - medium->u.hGlobal = macdrv_get_pasteboard_data(This->pasteboard, formatEtc->cfFormat); + medium->u.hGlobal = macdrv_get_pasteboard_data((void *)(UINT_PTR)This->pasteboard, formatEtc->cfFormat); medium->pUnkForRelease = NULL; hr = medium->u.hGlobal ? S_OK : E_OUTOFMEMORY; } @@ -168,6 +168,7 @@ static HRESULT WINAPI dddo_GetDataHere(IDataObject* iface, FORMATETC* formatEtc, static HRESULT WINAPI dddo_QueryGetData(IDataObject* iface, FORMATETC* formatEtc) { DragDropDataObject *This = impl_from_IDataObject(iface); + struct dnd_have_format_params params; HRESULT hr = DV_E_FORMATETC;
TRACE("This %p formatEtc %p={.tymed=0x%x, .dwAspect=%d, .cfFormat=%s}\n", @@ -185,7 +186,9 @@ static HRESULT WINAPI dddo_QueryGetData(IDataObject* iface, FORMATETC* formatEtc return E_NOTIMPL; }
- if (macdrv_pasteboard_has_format(This->pasteboard, formatEtc->cfFormat)) + params.handle = This->pasteboard; + params.format = formatEtc->cfFormat; + if (MACDRV_CALL(dnd_have_format, ¶ms)) hr = S_OK;
TRACE(" -> 0x%x\n", hr); @@ -225,7 +228,8 @@ static HRESULT WINAPI dddo_EnumFormatEtc(IDataObject* iface, DWORD direction, IEnumFORMATETC** enumFormatEtc) { DragDropDataObject *This = impl_from_IDataObject(iface); - UINT *formats, count; + struct dnd_get_formats_params params; + UINT count; HRESULT hr;
TRACE("This %p direction %u enumFormatEtc %p\n", This, direction, enumFormatEtc); @@ -236,8 +240,9 @@ static HRESULT WINAPI dddo_EnumFormatEtc(IDataObject* iface, DWORD direction, return E_NOTIMPL; }
- formats = macdrv_get_pasteboard_formats(This->pasteboard, &count); - if (formats) + params.handle = This->pasteboard; + count = MACDRV_CALL(dnd_get_formats, ¶ms); + if (count) { FORMATETC *formatEtcs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(FORMATETC)); if (formatEtcs) @@ -246,7 +251,7 @@ static HRESULT WINAPI dddo_EnumFormatEtc(IDataObject* iface, DWORD direction,
for (i = 0; i < count; i++) { - formatEtcs[i].cfFormat = formats[i]; + formatEtcs[i].cfFormat = params.formats[i]; formatEtcs[i].ptd = NULL; formatEtcs[i].dwAspect = DVASPECT_CONTENT; formatEtcs[i].lindex = -1; @@ -258,8 +263,6 @@ static HRESULT WINAPI dddo_EnumFormatEtc(IDataObject* iface, DWORD direction, } else hr = E_OUTOFMEMORY; - - HeapFree(GetProcessHeap(), 0, formats); } else hr = SHCreateStdEnumFmtEtc(0, NULL, enumFormatEtc); @@ -309,7 +312,7 @@ static const IDataObjectVtbl dovt = };
-static IDataObject *create_data_object_for_pasteboard(CFTypeRef pasteboard) +static IDataObject *create_data_object_for_pasteboard(UINT64 pasteboard) { DragDropDataObject *dddo;
@@ -319,7 +322,8 @@ static IDataObject *create_data_object_for_pasteboard(CFTypeRef pasteboard)
dddo->ref = 1; dddo->IDataObject_iface.lpVtbl = &dovt; - dddo->pasteboard = CFRetain(pasteboard); + dddo->pasteboard = pasteboard; + MACDRV_CALL(dnd_retain, &dddo->pasteboard);
return &dddo->IDataObject_iface; } @@ -421,7 +425,7 @@ NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) if (!active_data_object) { WARN("shouldn't happen: no active IDataObject\n"); - active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle); + active_data_object = create_data_object_for_pasteboard(params->handle); }
pointl.x = pt.x; @@ -564,7 +568,7 @@ NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) POINTL pointl = { pt.x, pt.y };
if (!active_data_object) - active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle); + active_data_object = create_data_object_for_pasteboard(params->handle);
TRACE("DragEnter hwnd %p droptarget %p\n", hwnd, droptarget); hr = IDropTarget_DragEnter(droptarget, active_data_object, MK_LBUTTON, @@ -605,7 +609,7 @@ NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) FORMATETC formatEtc;
if (!active_data_object) - active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle); + active_data_object = create_data_object_for_pasteboard(params->handle);
formatEtc.cfFormat = CF_HDROP; formatEtc.ptd = NULL; diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index ce71baa5735..4c1a21a3fe8 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -256,8 +256,6 @@ extern void macdrv_UpdateClipboard(void) DECLSPEC_HIDDEN; extern BOOL query_pasteboard_data(HWND hwnd, CFStringRef type) DECLSPEC_HIDDEN; extern void macdrv_lost_pasteboard_ownership(HWND hwnd) DECLSPEC_HIDDEN; extern HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) DECLSPEC_HIDDEN; -extern BOOL macdrv_pasteboard_has_format(CFTypeRef pasteboard, UINT desired_format) DECLSPEC_HIDDEN; -extern UINT* macdrv_get_pasteboard_formats(CFTypeRef pasteboard, UINT* num_formats) DECLSPEC_HIDDEN;
extern struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) DECLSPEC_HIDDEN; extern const struct vulkan_funcs *macdrv_wine_get_vulkan_driver(UINT version) DECLSPEC_HIDDEN; @@ -287,6 +285,10 @@ extern NTSTATUS WINAPI macdrv_ime_query_char_rect(void *params, ULONG size) DECL
/* unixlib interface */
+extern NTSTATUS macdrv_dnd_get_formats(void *arg) DECLSPEC_HIDDEN; +extern NTSTATUS macdrv_dnd_have_format(void *arg) DECLSPEC_HIDDEN; +extern NTSTATUS macdrv_dnd_release(void *arg) DECLSPEC_HIDDEN; +extern NTSTATUS macdrv_dnd_retain(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_ime_process_text_input(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_notify_icon(void *arg) DECLSPEC_HIDDEN;
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 4ef9060ea4b..a0b29604e62 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -630,6 +630,10 @@ static NTSTATUS macdrv_ime_using_input_method(void *arg)
const unixlib_entry_t __wine_unix_call_funcs[] = { + macdrv_dnd_get_formats, + macdrv_dnd_have_format, + macdrv_dnd_release, + macdrv_dnd_retain, macdrv_ime_clear, macdrv_ime_process_text_input, macdrv_ime_using_input_method, diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index f4a8b7982f5..b29bf99e7f4 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -21,6 +21,10 @@
enum macdrv_funcs { + unix_dnd_get_formats, + unix_dnd_have_format, + unix_dnd_release, + unix_dnd_retain, unix_ime_clear, unix_ime_process_text_input, unix_ime_using_input_method, @@ -33,6 +37,20 @@ enum macdrv_funcs extern NTSTATUS unix_call(enum macdrv_funcs code, void *params) DECLSPEC_HIDDEN; #define MACDRV_CALL(func, params) unix_call( unix_ ## func, params )
+/* macdrv_dnd_get_formats params */ +struct dnd_get_formats_params +{ + UINT64 handle; + UINT formats[64]; +}; + +/* macdrv_dnd_have_format params */ +struct dnd_have_format_params +{ + UINT64 handle; + UINT format; +}; + /* macdrv_ime_process_text_input params */ struct process_text_input_params {
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 29 ++++++++++++++--------------- dlls/winemac.drv/dragdrop.c | 24 ++++++++++++++++++++++-- dlls/winemac.drv/macdrv.h | 2 +- dlls/winemac.drv/macdrv_main.c | 1 + dlls/winemac.drv/unixlib.h | 10 ++++++++++ 5 files changed, 48 insertions(+), 18 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index f46bb389cc9..8a795e61724 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -1128,24 +1128,26 @@ static CFDataRef export_unicodetext_to_utf16(void *data, size_t size)
/************************************************************************** - * macdrv_get_pasteboard_data + * macdrv_dnd_get_data */ -HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) +NTSTATUS macdrv_dnd_get_data(void *arg) { + struct dnd_get_data_params *params = arg; + CFTypeRef pasteboard = pasteboard_from_handle(params->handle); CFArrayRef types; CFIndex count; CFIndex i; CFStringRef type, best_type; WINE_CLIPFORMAT* best_format = NULL; - HANDLE data = NULL; + NTSTATUS status = STATUS_SUCCESS;
- TRACE("pasteboard %p, desired_format %s\n", pasteboard, debugstr_format(desired_format)); + TRACE("pasteboard %p, desired_format %s\n", pasteboard, debugstr_format(params->format));
types = macdrv_copy_pasteboard_types(pasteboard); if (!types) { WARN("Failed to copy pasteboard types\n"); - return NULL; + return STATUS_NO_MEMORY; }
count = CFArrayGetCount(types); @@ -1161,7 +1163,7 @@ HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) { TRACE("for type %s got format %p/%s\n", debugstr_cf(type), format, debugstr_format(format->format_id));
- if (format->format_id == desired_format) + if (format->format_id == params->format) { /* The best format is the matching one which is not synthesized. Failing that, the best format is the first matching synthesized format. */ @@ -1183,15 +1185,12 @@ HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) if (pasteboard_data) { size_t size; - void *import = best_format->import_func(pasteboard_data, &size), *ptr; + void *import = best_format->import_func(pasteboard_data, &size); if (import) { - data = GlobalAlloc(GMEM_FIXED, size); - if (data && (ptr = GlobalLock(data))) - { - memcpy(ptr, import, size); - GlobalUnlock(data); - } + if (size > params->size) status = STATUS_BUFFER_OVERFLOW; + else memcpy(params->data, import, size); + params->size = size; free(import); } CFRelease(pasteboard_data); @@ -1199,8 +1198,8 @@ HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) }
CFRelease(types); - TRACE(" -> %p\n", data); - return data; + TRACE(" -> %#x\n", status); + return status; }
diff --git a/dlls/winemac.drv/dragdrop.c b/dlls/winemac.drv/dragdrop.c index 962a9d8c24b..aec8b1f4790 100644 --- a/dlls/winemac.drv/dragdrop.c +++ b/dlls/winemac.drv/dragdrop.c @@ -24,6 +24,8 @@
#define NONAMELESSUNION
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "macdrv.h"
#define COBJMACROS @@ -92,6 +94,24 @@ static inline DragDropDataObject *impl_from_IDataObject(IDataObject *iface) }
+static HANDLE get_pasteboard_data(UINT64 pasteboard, UINT desired_format) +{ + struct dnd_get_data_params params = { .handle = pasteboard, .format = desired_format, .size = 2048 }; + HANDLE handle; + NTSTATUS status; + + for (;;) + { + if (!(handle = GlobalAlloc(GMEM_FIXED, params.size))) return 0; + params.data = GlobalLock(handle); + status = MACDRV_CALL(dnd_get_data, ¶ms); + GlobalUnlock(handle); + if (!status) return GlobalReAlloc(handle, params.size, 0); + GlobalFree(handle); + if (status != STATUS_BUFFER_OVERFLOW) return 0; + } +} + static HRESULT WINAPI dddo_QueryInterface(IDataObject* iface, REFIID riid, LPVOID *ppvObj) { DragDropDataObject *This = impl_from_IDataObject(iface); @@ -148,7 +168,7 @@ static HRESULT WINAPI dddo_GetData(IDataObject* iface, FORMATETC* formatEtc, STG if (SUCCEEDED(hr)) { medium->tymed = TYMED_HGLOBAL; - medium->u.hGlobal = macdrv_get_pasteboard_data((void *)(UINT_PTR)This->pasteboard, formatEtc->cfFormat); + medium->u.hGlobal = get_pasteboard_data(This->pasteboard, formatEtc->cfFormat); medium->pUnkForRelease = NULL; hr = medium->u.hGlobal ? S_OK : E_OUTOFMEMORY; } @@ -454,7 +474,7 @@ NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) hwnd = GetParent(hwnd); if (hwnd) { - HDROP hdrop = macdrv_get_pasteboard_data((void *)(UINT_PTR)params->handle, CF_HDROP); + HDROP hdrop = get_pasteboard_data(params->handle, CF_HDROP); DROPFILES *dropfiles = GlobalLock(hdrop); if (dropfiles) { diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 4c1a21a3fe8..a841465486e 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -255,7 +255,6 @@ extern void macdrv_displays_changed(const macdrv_event *event) DECLSPEC_HIDDEN; extern void macdrv_UpdateClipboard(void) DECLSPEC_HIDDEN; extern BOOL query_pasteboard_data(HWND hwnd, CFStringRef type) DECLSPEC_HIDDEN; extern void macdrv_lost_pasteboard_ownership(HWND hwnd) DECLSPEC_HIDDEN; -extern HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) DECLSPEC_HIDDEN;
extern struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) DECLSPEC_HIDDEN; extern const struct vulkan_funcs *macdrv_wine_get_vulkan_driver(UINT version) DECLSPEC_HIDDEN; @@ -285,6 +284,7 @@ extern NTSTATUS WINAPI macdrv_ime_query_char_rect(void *params, ULONG size) DECL
/* unixlib interface */
+extern NTSTATUS macdrv_dnd_get_data(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_dnd_get_formats(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_dnd_have_format(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_dnd_release(void *arg) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index a0b29604e62..61195d408c8 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -630,6 +630,7 @@ static NTSTATUS macdrv_ime_using_input_method(void *arg)
const unixlib_entry_t __wine_unix_call_funcs[] = { + macdrv_dnd_get_data, macdrv_dnd_get_formats, macdrv_dnd_have_format, macdrv_dnd_release, diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index b29bf99e7f4..0bfc61321d0 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -21,6 +21,7 @@
enum macdrv_funcs { + unix_dnd_get_data, unix_dnd_get_formats, unix_dnd_have_format, unix_dnd_release, @@ -37,6 +38,15 @@ enum macdrv_funcs extern NTSTATUS unix_call(enum macdrv_funcs code, void *params) DECLSPEC_HIDDEN; #define MACDRV_CALL(func, params) unix_call( unix_ ## func, params )
+/* macdrv_dnd_get_data params */ +struct dnd_get_data_params +{ + UINT64 handle; + UINT format; + size_t size; + void *data; +}; + /* macdrv_dnd_get_formats params */ struct dnd_get_formats_params {
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/dllmain.c | 174 +++++++++++++++++++++++++++++++++ dlls/winemac.drv/macdrv_main.c | 9 ++ dlls/winemac.drv/unixlib.h | 16 ++- dlls/winemac.drv/window.c | 168 +------------------------------ 4 files changed, 202 insertions(+), 165 deletions(-)
diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index 4bedb2aaf61..675820b28cd 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -22,13 +22,187 @@ #include <stdarg.h> #include "macdrv.h" #include "shellapi.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
HMODULE macdrv_module = 0;
+struct quit_info { + HWND *wins; + UINT capacity; + UINT count; + UINT done; + DWORD flags; + BOOL result; + BOOL replied; +}; + + +static BOOL CALLBACK get_process_windows(HWND hwnd, LPARAM lp) +{ + struct quit_info *qi = (struct quit_info*)lp; + DWORD pid; + + NtUserGetWindowThread(hwnd, &pid); + if (pid == GetCurrentProcessId()) + { + if (qi->count >= qi->capacity) + { + UINT new_cap = qi->capacity * 2; + HWND *new_wins = HeapReAlloc(GetProcessHeap(), 0, qi->wins, new_cap * sizeof(*qi->wins)); + if (!new_wins) return FALSE; + qi->wins = new_wins; + qi->capacity = new_cap; + } + + qi->wins[qi->count++] = hwnd; + } + + return TRUE; +} + +static void quit_reply(int reply) +{ + struct quit_result_params params = { .result = reply }; + MACDRV_CALL(quit_result, ¶ms); +} + + +static void CALLBACK quit_callback(HWND hwnd, UINT msg, ULONG_PTR data, LRESULT result) +{ + struct quit_info *qi = (struct quit_info*)data; + + qi->done++; + + if (msg == WM_QUERYENDSESSION) + { + TRACE("got WM_QUERYENDSESSION result %ld from win %p (%u of %u done)\n", result, + hwnd, qi->done, qi->count); + + if (!result && !IsWindow(hwnd)) + { + TRACE("win %p no longer exists; ignoring apparent refusal\n", hwnd); + result = TRUE; + } + + if (!result && qi->result) + { + qi->result = FALSE; + + /* On the first FALSE from WM_QUERYENDSESSION, we already know the + ultimate reply. Might as well tell Cocoa now. */ + if (!qi->replied) + { + qi->replied = TRUE; + TRACE("giving quit reply %d\n", qi->result); + quit_reply(qi->result); + } + } + + if (qi->done >= qi->count) + { + UINT i; + + qi->done = 0; + for (i = 0; i < qi->count; i++) + { + TRACE("sending WM_ENDSESSION to win %p result %d flags 0x%08x\n", qi->wins[i], + qi->result, qi->flags); + if (!SendMessageCallbackW(qi->wins[i], WM_ENDSESSION, qi->result, qi->flags, + quit_callback, (ULONG_PTR)qi)) + { + WARN("failed to send WM_ENDSESSION to win %p; error 0x%08x\n", + qi->wins[i], GetLastError()); + quit_callback(qi->wins[i], WM_ENDSESSION, (ULONG_PTR)qi, 0); + } + } + } + } + else /* WM_ENDSESSION */ + { + TRACE("finished WM_ENDSESSION for win %p (%u of %u done)\n", hwnd, qi->done, qi->count); + + if (qi->done >= qi->count) + { + if (!qi->replied) + { + TRACE("giving quit reply %d\n", qi->result); + quit_reply(qi->result); + } + + TRACE("%sterminating process\n", qi->result ? "" : "not "); + if (qi->result) + TerminateProcess(GetCurrentProcess(), 0); + + HeapFree(GetProcessHeap(), 0, qi->wins); + HeapFree(GetProcessHeap(), 0, qi); + } + } +} + + +/*********************************************************************** + * macdrv_app_quit_request + */ +NTSTATUS WINAPI macdrv_app_quit_request(void *arg, ULONG size) +{ + struct app_quit_request_params *params = arg; + struct quit_info *qi; + UINT i; + + qi = HeapAlloc(GetProcessHeap(), 0, sizeof(*qi)); + if (!qi) + goto fail; + + qi->capacity = 32; + qi->wins = HeapAlloc(GetProcessHeap(), 0, qi->capacity * sizeof(*qi->wins)); + qi->count = qi->done = 0; + + if (!qi->wins || !EnumWindows(get_process_windows, (LPARAM)qi)) + goto fail; + + qi->flags = params->flags; + qi->result = TRUE; + qi->replied = FALSE; + + for (i = 0; i < qi->count; i++) + { + TRACE("sending WM_QUERYENDSESSION to win %p\n", qi->wins[i]); + if (!SendMessageCallbackW(qi->wins[i], WM_QUERYENDSESSION, 0, qi->flags, + quit_callback, (ULONG_PTR)qi)) + { + DWORD error = GetLastError(); + BOOL invalid = (error == ERROR_INVALID_WINDOW_HANDLE); + if (invalid) + TRACE("failed to send WM_QUERYENDSESSION to win %p because it's invalid; assuming success\n", + qi->wins[i]); + else + WARN("failed to send WM_QUERYENDSESSION to win %p; error 0x%08x; assuming refusal\n", + qi->wins[i], error); + quit_callback(qi->wins[i], WM_QUERYENDSESSION, (ULONG_PTR)qi, invalid); + } + } + + /* quit_callback() will clean up qi */ + return 0; + +fail: + WARN("failed to allocate window list\n"); + if (qi) + { + HeapFree(GetProcessHeap(), 0, qi->wins); + HeapFree(GetProcessHeap(), 0, qi); + } + quit_reply(FALSE); + return 0; +} + typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); static const kernel_callback kernel_callbacks[] = { + macdrv_app_quit_request, macdrv_dnd_query_drag, macdrv_dnd_query_drop, macdrv_dnd_query_exited, diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 61195d408c8..ddd4f03fd31 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -628,6 +628,14 @@ static NTSTATUS macdrv_ime_using_input_method(void *arg) }
+static NTSTATUS macdrv_quit_result(void *arg) +{ + struct quit_result_params *params = arg; + macdrv_quit_reply(params->result); + return 0; +} + + const unixlib_entry_t __wine_unix_call_funcs[] = { macdrv_dnd_get_data, @@ -640,6 +648,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] = macdrv_ime_using_input_method, macdrv_init, macdrv_notify_icon, + macdrv_quit_result, };
C_ASSERT( ARRAYSIZE(__wine_unix_call_funcs) == unix_funcs_count ); diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index 0bfc61321d0..894ab699c13 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -31,6 +31,7 @@ enum macdrv_funcs unix_ime_using_input_method, unix_init, unix_notify_icon, + unix_quit_result, unix_funcs_count };
@@ -92,10 +93,17 @@ struct notify_icon_params struct _NOTIFYICONDATAW *data; };
+/* macdrv_quit_result params */ +struct quit_result_params +{ + int result; +}; + /* driver client callbacks exposed with KernelCallbackTable interface */ enum macdrv_client_funcs { - client_func_dnd_query_drag = NtUserDriverCallbackFirst, + client_func_app_quit_request = NtUserDriverCallbackFirst, + client_func_dnd_query_drag, client_func_dnd_query_drop, client_func_dnd_query_exited, client_func_ime_query_char_rect, @@ -103,6 +111,12 @@ enum macdrv_client_funcs client_func_last };
+/* macdrv_app_quit_request params */ +struct app_quit_request_params +{ + UINT flags; +}; + /* macdrv_dnd_query_drag params */ struct dnd_query_drag_params { diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 2f473730b2f..072bdf606d4 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -2653,114 +2653,6 @@ void macdrv_reassert_window_position(HWND hwnd) }
-struct quit_info { - HWND *wins; - UINT capacity; - UINT count; - UINT done; - DWORD flags; - BOOL result; - BOOL replied; -}; - - -static BOOL CALLBACK get_process_windows(HWND hwnd, LPARAM lp) -{ - struct quit_info *qi = (struct quit_info*)lp; - DWORD pid; - - NtUserGetWindowThread(hwnd, &pid); - if (pid == GetCurrentProcessId()) - { - if (qi->count >= qi->capacity) - { - UINT new_cap = qi->capacity * 2; - HWND *new_wins = realloc(qi->wins, new_cap * sizeof(*qi->wins)); - if (!new_wins) return FALSE; - qi->wins = new_wins; - qi->capacity = new_cap; - } - - qi->wins[qi->count++] = hwnd; - } - - return TRUE; -} - - -static void CALLBACK quit_callback(HWND hwnd, UINT msg, ULONG_PTR data, LRESULT result) -{ - struct quit_info *qi = (struct quit_info*)data; - - qi->done++; - - if (msg == WM_QUERYENDSESSION) - { - TRACE("got WM_QUERYENDSESSION result %ld from win %p (%u of %u done)\n", result, - hwnd, qi->done, qi->count); - - if (!result && !IsWindow(hwnd)) - { - TRACE("win %p no longer exists; ignoring apparent refusal\n", hwnd); - result = TRUE; - } - - if (!result && qi->result) - { - qi->result = FALSE; - - /* On the first FALSE from WM_QUERYENDSESSION, we already know the - ultimate reply. Might as well tell Cocoa now. */ - if (!qi->replied) - { - qi->replied = TRUE; - TRACE("giving quit reply %d\n", qi->result); - macdrv_quit_reply(qi->result); - } - } - - if (qi->done >= qi->count) - { - UINT i; - - qi->done = 0; - for (i = 0; i < qi->count; i++) - { - TRACE("sending WM_ENDSESSION to win %p result %d flags 0x%08x\n", qi->wins[i], - qi->result, qi->flags); - if (!SendMessageCallbackW(qi->wins[i], WM_ENDSESSION, qi->result, qi->flags, - quit_callback, (ULONG_PTR)qi)) - { - WARN("failed to send WM_ENDSESSION to win %p; error 0x%08x\n", - qi->wins[i], GetLastError()); - quit_callback(qi->wins[i], WM_ENDSESSION, (ULONG_PTR)qi, 0); - } - } - } - } - else /* WM_ENDSESSION */ - { - TRACE("finished WM_ENDSESSION for win %p (%u of %u done)\n", hwnd, qi->done, qi->count); - - if (qi->done >= qi->count) - { - if (!qi->replied) - { - TRACE("giving quit reply %d\n", qi->result); - macdrv_quit_reply(qi->result); - } - - TRACE("%sterminating process\n", qi->result ? "" : "not "); - if (qi->result) - TerminateProcess(GetCurrentProcess(), 0); - - free(qi->wins); - free(qi); - } - } -} - - /*********************************************************************** * macdrv_app_quit_requested * @@ -2768,66 +2660,14 @@ static void CALLBACK quit_callback(HWND hwnd, UINT msg, ULONG_PTR data, LRESULT */ void macdrv_app_quit_requested(const macdrv_event *event) { - struct quit_info *qi; - UINT i; + struct app_quit_request_params params = { .flags = 0 };
TRACE("reason %d\n", event->app_quit_requested.reason);
- qi = malloc(sizeof(*qi)); - if (!qi) - goto fail; - - qi->capacity = 32; - qi->wins = malloc(qi->capacity * sizeof(*qi->wins)); - qi->count = qi->done = 0; - - if (!qi->wins || !EnumWindows(get_process_windows, (LPARAM)qi)) - goto fail; + if (event->app_quit_requested.reason == QUIT_REASON_LOGOUT) + params.flags = ENDSESSION_LOGOFF;
- switch (event->app_quit_requested.reason) - { - case QUIT_REASON_LOGOUT: - default: - qi->flags = ENDSESSION_LOGOFF; - break; - case QUIT_REASON_RESTART: - case QUIT_REASON_SHUTDOWN: - qi->flags = 0; - break; - } - - qi->result = TRUE; - qi->replied = FALSE; - - for (i = 0; i < qi->count; i++) - { - TRACE("sending WM_QUERYENDSESSION to win %p\n", qi->wins[i]); - if (!SendMessageCallbackW(qi->wins[i], WM_QUERYENDSESSION, 0, qi->flags, - quit_callback, (ULONG_PTR)qi)) - { - DWORD error = GetLastError(); - BOOL invalid = (error == ERROR_INVALID_WINDOW_HANDLE); - if (invalid) - TRACE("failed to send WM_QUERYENDSESSION to win %p because it's invalid; assuming success\n", - qi->wins[i]); - else - WARN("failed to send WM_QUERYENDSESSION to win %p; error 0x%08x; assuming refusal\n", - qi->wins[i], error); - quit_callback(qi->wins[i], WM_QUERYENDSESSION, (ULONG_PTR)qi, invalid); - } - } - - /* quit_callback() will clean up qi */ - return; - -fail: - WARN("failed to allocate window list\n"); - if (qi) - { - free(qi->wins); - free(qi); - } - macdrv_quit_reply(FALSE); + macdrv_client_func(client_func_app_quit_request, ¶ms, sizeof(params)); }
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/dllmain.c | 168 ++++++++++++++++++++++++++++++++++ dlls/winemac.drv/image.c | 178 ++++++------------------------------- dlls/winemac.drv/unixlib.h | 25 +++++- 3 files changed, 219 insertions(+), 152 deletions(-)
diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index 675820b28cd..e281a473e07 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -63,6 +63,30 @@ static BOOL CALLBACK get_process_windows(HWND hwnd, LPARAM lp) return TRUE; }
+#include "pshpack1.h" + +typedef struct +{ + BYTE bWidth; + BYTE bHeight; + BYTE bColorCount; + BYTE bReserved; + WORD wPlanes; + WORD wBitCount; + DWORD dwBytesInRes; + WORD nID; +} GRPICONDIRENTRY; + +typedef struct +{ + WORD idReserved; + WORD idType; + WORD idCount; + GRPICONDIRENTRY idEntries[1]; +} GRPICONDIR; + +#include "poppack.h" + static void quit_reply(int reply) { struct quit_result_params params = { .result = reply }; @@ -199,9 +223,153 @@ fail: return 0; }
+/*********************************************************************** + * get_first_resource + * + * Helper for create_app_icon_images(). Enum proc for EnumResourceNamesW() + * which just gets the handle for the first resource and stops further + * enumeration. + */ +static BOOL CALLBACK get_first_resource(HMODULE module, LPCWSTR type, LPWSTR name, LONG_PTR lparam) +{ + HRSRC *res_info = (HRSRC*)lparam; + + *res_info = FindResourceW(module, name, (LPCWSTR)RT_GROUP_ICON); + return FALSE; +} + + +/*********************************************************************** + * macdrv_app_icon + */ +static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) +{ + struct app_icon_params *params = arg; + struct app_icon_result *result = params->result; + HRSRC res_info; + HGLOBAL res_data; + GRPICONDIR *icon_dir; + int i; + + TRACE("()\n"); + + result->count = 0; + + res_info = NULL; + EnumResourceNamesW(NULL, (LPCWSTR)RT_GROUP_ICON, get_first_resource, (LONG_PTR)&res_info); + if (!res_info) + { + WARN("found no RT_GROUP_ICON resource\n"); + return 0; + } + + if (!(res_data = LoadResource(NULL, res_info))) + { + WARN("failed to load RT_GROUP_ICON resource\n"); + return 0; + } + + if (!(icon_dir = LockResource(res_data))) + { + WARN("failed to lock RT_GROUP_ICON resource\n"); + goto cleanup; + } + + for (i = 0; i < icon_dir->idCount && result->count < ARRAYSIZE(result->entries); i++) + { + struct app_icon_entry *entry = &result->entries[result->count]; + int width = icon_dir->idEntries[i].bWidth; + int height = icon_dir->idEntries[i].bHeight; + BOOL found_better_bpp = FALSE; + int j; + LPCWSTR name; + HGLOBAL icon_res_data; + BYTE *icon_bits; + + if (!width) width = 256; + if (!height) height = 256; + + /* If there's another icon at the same size but with better + color depth, skip this one. We end up making CGImages that + are all 32 bits per pixel, so Cocoa doesn't get the original + color depth info to pick the best representation itself. */ + for (j = 0; j < icon_dir->idCount; j++) + { + int jwidth = icon_dir->idEntries[j].bWidth; + int jheight = icon_dir->idEntries[j].bHeight; + + if (!jwidth) jwidth = 256; + if (!jheight) jheight = 256; + + if (j != i && jwidth == width && jheight == height && + icon_dir->idEntries[j].wBitCount > icon_dir->idEntries[i].wBitCount) + { + found_better_bpp = TRUE; + break; + } + } + + if (found_better_bpp) continue; + + name = MAKEINTRESOURCEW(icon_dir->idEntries[i].nID); + res_info = FindResourceW(NULL, name, (LPCWSTR)RT_ICON); + if (!res_info) + { + WARN("failed to find RT_ICON resource %d with ID %hd\n", i, icon_dir->idEntries[i].nID); + continue; + } + + icon_res_data = LoadResource(NULL, res_info); + if (!icon_res_data) + { + WARN("failed to load icon %d with ID %hd\n", i, icon_dir->idEntries[i].nID); + continue; + } + + icon_bits = LockResource(icon_res_data); + if (icon_bits) + { + static const BYTE png_magic[] = { 0x89, 0x50, 0x4e, 0x47 }; + + entry->width = width; + entry->height = height; + entry->size = icon_dir->idEntries[i].dwBytesInRes; + + if (!memcmp(icon_bits, png_magic, sizeof(png_magic))) + { + entry->png = icon_bits; + entry->icon = 0; + result->count++; + } + else + { + entry->icon = CreateIconFromResourceEx(icon_bits, icon_dir->idEntries[i].dwBytesInRes, + TRUE, 0x00030000, width, height, 0); + if (entry->icon) + { + entry->png = NULL; + result->count++; + } + else + WARN("failed to create icon %d from resource with ID %hd\n", i, icon_dir->idEntries[i].nID); + } + } + else + WARN("failed to lock RT_ICON resource %d with ID %hd\n", i, icon_dir->idEntries[i].nID); + + FreeResource(icon_res_data); + } + +cleanup: + FreeResource(res_data); + + return 0; +} + typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); static const kernel_callback kernel_callbacks[] = { + macdrv_app_icon, macdrv_app_quit_request, macdrv_dnd_query_drag, macdrv_dnd_query_drop, diff --git a/dlls/winemac.drv/image.c b/dlls/winemac.drv/image.c index 943ad97b749..f6423858136 100644 --- a/dlls/winemac.drv/image.c +++ b/dlls/winemac.drv/image.c @@ -25,30 +25,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(image);
-#include "pshpack1.h" - -typedef struct -{ - BYTE bWidth; - BYTE bHeight; - BYTE bColorCount; - BYTE bReserved; - WORD wPlanes; - WORD wBitCount; - DWORD dwBytesInRes; - WORD nID; -} GRPICONDIRENTRY; - -typedef struct -{ - WORD idReserved; - WORD idType; - WORD idCount; - GRPICONDIRENTRY idEntries[1]; -} GRPICONDIR; - -#include "poppack.h" -
/*********************************************************************** * create_cgimage_from_icon_bitmaps @@ -264,167 +240,67 @@ cleanup: }
-/*********************************************************************** - * get_first_resource - * - * Helper for create_app_icon_images(). Enum proc for EnumResourceNamesW() - * which just gets the handle for the first resource and stops further - * enumeration. - */ -static BOOL CALLBACK get_first_resource(HMODULE module, LPCWSTR type, LPWSTR name, LONG_PTR lparam) -{ - HRSRC *res_info = (HRSRC*)lparam; - - *res_info = FindResourceW(module, name, (LPCWSTR)RT_GROUP_ICON); - return FALSE; -} - - /*********************************************************************** * create_app_icon_images */ CFArrayRef create_app_icon_images(void) { - HRSRC res_info; - HGLOBAL res_data; - GRPICONDIR *icon_dir; + struct app_icon_result icons; + struct app_icon_params params = { .result = &icons }; CFMutableArrayRef images = NULL; int i;
TRACE("()\n");
- res_info = NULL; - EnumResourceNamesW(NULL, (LPCWSTR)RT_GROUP_ICON, get_first_resource, (LONG_PTR)&res_info); - if (!res_info) - { - WARN("found no RT_GROUP_ICON resource\n"); - return NULL; - } + macdrv_client_func(client_func_app_icon, ¶ms, sizeof(params));
- if (!(res_data = LoadResource(NULL, res_info))) - { - WARN("failed to load RT_GROUP_ICON resource\n"); - return NULL; - } + if (!icons.count) return NULL;
- if (!(icon_dir = LockResource(res_data))) - { - WARN("failed to lock RT_GROUP_ICON resource\n"); - goto cleanup; - } - - images = CFArrayCreateMutable(NULL, icon_dir->idCount, &kCFTypeArrayCallBacks); + images = CFArrayCreateMutable(NULL, icons.count, &kCFTypeArrayCallBacks); if (!images) { WARN("failed to create images array\n"); - goto cleanup; + return NULL; }
- for (i = 0; i < icon_dir->idCount; i++) + for (i = 0; i < icons.count; i++) { - int width = icon_dir->idEntries[i].bWidth; - int height = icon_dir->idEntries[i].bHeight; - BOOL found_better_bpp = FALSE; - int j; - LPCWSTR name; - HGLOBAL icon_res_data; - BYTE *icon_bits; - - if (!width) width = 256; - if (!height) height = 256; - - /* If there's another icon at the same size but with better - color depth, skip this one. We end up making CGImages that - are all 32 bits per pixel, so Cocoa doesn't get the original - color depth info to pick the best representation itself. */ - for (j = 0; j < icon_dir->idCount; j++) - { - int jwidth = icon_dir->idEntries[j].bWidth; - int jheight = icon_dir->idEntries[j].bHeight; - - if (!jwidth) jwidth = 256; - if (!jheight) jheight = 256; + struct app_icon_entry *icon = &icons.entries[i]; + CGImageRef cgimage = NULL;
- if (j != i && jwidth == width && jheight == height && - icon_dir->idEntries[j].wBitCount > icon_dir->idEntries[i].wBitCount) - { - found_better_bpp = TRUE; - break; - } - } - - if (found_better_bpp) continue; - - name = MAKEINTRESOURCEW(icon_dir->idEntries[i].nID); - res_info = FindResourceW(NULL, name, (LPCWSTR)RT_ICON); - if (!res_info) + if (icon->png) { - WARN("failed to find RT_ICON resource %d with ID %hd\n", i, icon_dir->idEntries[i].nID); - continue; - } - - icon_res_data = LoadResource(NULL, res_info); - if (!icon_res_data) - { - WARN("failed to load icon %d with ID %hd\n", i, icon_dir->idEntries[i].nID); - continue; - } - - icon_bits = LockResource(icon_res_data); - if (icon_bits) - { - static const BYTE png_magic[] = { 0x89, 0x50, 0x4e, 0x47 }; - CGImageRef cgimage = NULL; - - if (!memcmp(icon_bits, png_magic, sizeof(png_magic))) - { - CFDataRef data = CFDataCreate(NULL, (UInt8*)icon_bits, icon_dir->idEntries[i].dwBytesInRes); - if (data) - { - CGDataProviderRef provider = CGDataProviderCreateWithCFData(data); - CFRelease(data); - if (provider) - { - cgimage = CGImageCreateWithPNGDataProvider(provider, NULL, FALSE, - kCGRenderingIntentDefault); - CGDataProviderRelease(provider); - } - } - } - - if (!cgimage) + CFDataRef data = CFDataCreate(NULL, icon->png, icon->size); + if (data) { - HICON icon; - icon = CreateIconFromResourceEx(icon_bits, icon_dir->idEntries[i].dwBytesInRes, - TRUE, 0x00030000, width, height, 0); - if (icon) + CGDataProviderRef provider = CGDataProviderCreateWithCFData(data); + CFRelease(data); + if (provider) { - cgimage = create_cgimage_from_icon(icon, width, height); - DestroyIcon(icon); + cgimage = CGImageCreateWithPNGDataProvider(provider, NULL, FALSE, + kCGRenderingIntentDefault); + CGDataProviderRelease(provider); } - else - WARN("failed to create icon %d from resource with ID %hd\n", i, icon_dir->idEntries[i].nID); - } - - if (cgimage) - { - CFArrayAppendValue(images, cgimage); - CGImageRelease(cgimage); } } else - WARN("failed to lock RT_ICON resource %d with ID %hd\n", i, icon_dir->idEntries[i].nID); + { + cgimage = create_cgimage_from_icon(icon->icon, icon->width, icon->height); + NtUserDestroyCursor(icon->icon, 0); + }
- FreeResource(icon_res_data); + if (cgimage) + { + CFArrayAppendValue(images, cgimage); + CGImageRelease(cgimage); + } }
-cleanup: if (images && !CFArrayGetCount(images)) { CFRelease(images); images = NULL; } - FreeResource(res_data);
return images; } diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index 894ab699c13..fea59564b92 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -102,7 +102,8 @@ struct quit_result_params /* driver client callbacks exposed with KernelCallbackTable interface */ enum macdrv_client_funcs { - client_func_app_quit_request = NtUserDriverCallbackFirst, + client_func_app_icon = NtUserDriverCallbackFirst, + client_func_app_quit_request, client_func_dnd_query_drag, client_func_dnd_query_drop, client_func_dnd_query_exited, @@ -111,6 +112,28 @@ enum macdrv_client_funcs client_func_last };
+/* macdrv_app_icon result */ +struct app_icon_entry +{ + UINT32 width; + UINT32 height; + UINT32 size; + void *png; + HICON icon; +}; + +struct app_icon_result +{ + UINT32 count; + struct app_icon_entry entries[64]; +}; + +/* macdrv_app_icon params */ +struct app_icon_params +{ + struct app_icon_result *result; /* FIXME: Use NtCallbackReturn instead */ +}; + /* macdrv_app_quit_request params */ struct app_quit_request_params {
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/mouse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index 00ec9a36c38..18a98296a76 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -166,7 +166,6 @@ static void send_mouse_input(HWND hwnd, macdrv_window cocoa_window, UINT flags, */ CFStringRef copy_system_cursor_name(ICONINFOEXW *info) { - static const WCHAR idW[] = {'%','h','u',0}; const struct system_cursors *cursors; unsigned int i; CFStringRef cursor_name = NULL; @@ -184,7 +183,12 @@ CFStringRef copy_system_cursor_name(ICONINFOEXW *info) p = name + strlenW(name); *p++ = ','; if (info->szResName[0]) strcpyW(p, info->szResName); - else sprintfW(p, idW, info->wResID); + else + { + char buf[16]; + sprintf(buf, "%hu", info->wResID); + asciiz_to_unicode(p, buf); + }
/* @@ Wine registry key: HKCU\Software\Wine\Mac Driver\Cursors */ if (!(key = open_hkcu_key("Software\Wine\Mac Driver\Cursors")))
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/Makefile.in | 3 ++- dlls/winemac.drv/clipboard.c | 4 ++++ dlls/winemac.drv/display.c | 6 +++++- dlls/winemac.drv/dllmain.c | 10 +++++++++- dlls/winemac.drv/event.c | 12 ++++++++---- dlls/winemac.drv/gdi.c | 4 ++++ dlls/winemac.drv/image.c | 4 ++++ dlls/winemac.drv/keyboard.c | 4 ++++ dlls/winemac.drv/macdrv.h | 9 ++------- dlls/winemac.drv/macdrv_main.c | 30 +++++++++++++++++++++--------- dlls/winemac.drv/mouse.c | 4 ++++ dlls/winemac.drv/opengl.c | 4 ++++ dlls/winemac.drv/surface.c | 4 ++++ dlls/winemac.drv/systray.c | 4 ++++ dlls/winemac.drv/unixlib.h | 6 ++++-- dlls/winemac.drv/vulkan.c | 4 ++++ dlls/winemac.drv/window.c | 4 ++++ tools/makedep.c | 2 ++ 18 files changed, 93 insertions(+), 25 deletions(-)
diff --git a/dlls/winemac.drv/Makefile.in b/dlls/winemac.drv/Makefile.in index 06c654344d1..e3d3180b2d1 100644 --- a/dlls/winemac.drv/Makefile.in +++ b/dlls/winemac.drv/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DWINE_NO_LONG_TYPES MODULE = winemac.drv +UNIXLIB = winemac.so IMPORTS = uuid rpcrt4 user32 gdi32 win32u DELAYIMPORTS = ole32 shell32 imm32 -EXTRALIBS = -framework AppKit -framework Carbon -framework Security -framework OpenGL -framework IOKit -framework CoreVideo -framework QuartzCore $(METAL_LIBS) +EXTRALIBS = -lwin32u -framework AppKit -framework Carbon -framework Security -framework OpenGL -framework IOKit -framework CoreVideo -framework QuartzCore $(METAL_LIBS)
EXTRADLLFLAGS = -mcygwin
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 8a795e61724..0f7bace1050 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -22,6 +22,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include "ntstatus.h" diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 5dbfe9338ce..2e126b384d1 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -19,6 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include "macdrv.h" @@ -992,7 +996,7 @@ better: } else if (flags & (CDS_TEST | CDS_NORESET)) ret = DISP_CHANGE_SUCCESSFUL; - else if (lstrcmpiW(primary_adapter, devname)) + else if (wcsicmp(primary_adapter, devname)) { FIXME("Changing non-primary adapter settings is currently unsupported.\n"); ret = DISP_CHANGE_SUCCESSFUL; diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index e281a473e07..2ffbc12083d 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -28,6 +28,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
HMODULE macdrv_module = 0; +static unixlib_handle_t macdrv_handle; +NTSTATUS (CDECL *macdrv_unix_call)(enum macdrv_funcs code, void *params);
struct quit_info { HWND *wins; @@ -405,15 +407,21 @@ static BOOL process_attach(void) { .id = 0 } };
+ if (NtQueryVirtualMemory(GetCurrentProcess(), macdrv_module, MemoryWineUnixFuncs, + &macdrv_handle, sizeof(macdrv_handle), NULL)) + return FALSE; + for (str = strings; str->id; str++) str->len = LoadStringW(macdrv_module, str->id, (WCHAR *)&str->str, 0); params.strings = strings;
- if (MACDRV_CALL(init, ¶ms)) return FALSE; + params.pNtWaitForMultipleObjects = NtWaitForMultipleObjects; + if (__wine_unix_call(macdrv_handle, unix_init, ¶ms)) return FALSE;
callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; memcpy( callback_table + NtUserDriverCallbackFirst, kernel_callbacks, sizeof(kernel_callbacks) );
+ macdrv_unix_call = params.unix_call; return TRUE; }
diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index ce7f06b07dd..d76c6ee8edb 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -20,6 +20,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include "macdrv.h" @@ -521,8 +525,8 @@ NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, if (!data) { if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT; - return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), - !!(flags & MWMO_ALERTABLE), timeout ); + return pNtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), + !!(flags & MWMO_ALERTABLE), timeout ); }
if (data->current_event && data->current_event->type != QUERY_EVENT && @@ -534,8 +538,8 @@ NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, if (process_events(data->queue, event_mask)) ret = count - 1; else if (count || !timeout || timeout->QuadPart) { - ret = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), - !!(flags & MWMO_ALERTABLE), timeout ); + ret = pNtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), + !!(flags & MWMO_ALERTABLE), timeout ); if (ret == count - 1) process_events(data->queue, event_mask); } else ret = WAIT_TIMEOUT; diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c index 3f83436d97a..7114835677b 100644 --- a/dlls/winemac.drv/gdi.c +++ b/dlls/winemac.drv/gdi.c @@ -19,6 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include "macdrv.h" diff --git a/dlls/winemac.drv/image.c b/dlls/winemac.drv/image.c index f6423858136..a0ee8b04aa9 100644 --- a/dlls/winemac.drv/image.c +++ b/dlls/winemac.drv/image.c @@ -18,6 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include "macdrv.h" diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 181e86afd4a..102f945e79c 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -24,6 +24,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include "macdrv.h" diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index a841465486e..735cfc84d87 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -43,6 +43,8 @@ extern BOOL allow_software_rendering DECLSPEC_HIDDEN; extern BOOL disable_window_decorations DECLSPEC_HIDDEN; extern HMODULE macdrv_module DECLSPEC_HIDDEN;
+extern NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN, + BOOLEAN,const LARGE_INTEGER*) DECLSPEC_HIDDEN;
extern const char* debugstr_cf(CFTypeRef t) DECLSPEC_HIDDEN;
@@ -273,7 +275,6 @@ extern void macdrv_status_item_mouse_move(const macdrv_event *event) DECLSPEC_HI extern void check_retina_status(void) DECLSPEC_HIDDEN; extern void macdrv_init_display_devices(BOOL force) DECLSPEC_HIDDEN; extern void init_user_driver(void) DECLSPEC_HIDDEN; -extern NTSTATUS macdrv_init(void *arg) DECLSPEC_HIDDEN;
/************************************************************************** * Mac IME driver @@ -372,10 +373,4 @@ static inline UINT asciiz_to_unicode(WCHAR *dst, const char *src) return (p - dst) * sizeof(WCHAR); }
-/* FIXME: remove once we use unixlib */ -#define wcsicmp strcmpiW -#define wcsnicmp strncmpiW -#define wcsrchr strrchrW -#define wcstol strtolW - #endif /* __WINE_MACDRV_H */ diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index ddd4f03fd31..6ed0fdb7730 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -19,6 +19,11 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ + +#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include <Security/AuthSession.h> @@ -67,6 +72,8 @@ int enable_app_nap = FALSE;
CFDictionaryRef localized_strings;
+NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN, + BOOLEAN,const LARGE_INTEGER*);
/************************************************************************** * debugstr_cf @@ -313,9 +320,9 @@ static void setup_options(void) { static const WCHAR noneW[] = {'n','o','n','e',0}; static const WCHAR allW[] = {'a','l','l',0}; - if (!lstrcmpW(buffer, noneW)) + if (!wcscmp(buffer, noneW)) topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONE; - else if (!lstrcmpW(buffer, allW)) + else if (!wcscmp(buffer, allW)) topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_ALL; else topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN; @@ -371,9 +378,9 @@ static void setup_options(void) { static const WCHAR transparentW[] = {'t','r','a','n','s','p','a','r','e','n','t',0}; static const WCHAR behindW[] = {'b','e','h','i','n','d',0}; - if (!lstrcmpW(buffer, transparentW)) + if (!wcscmp(buffer, transparentW)) gl_surface_mode = GL_SURFACE_IN_FRONT_TRANSPARENT; - else if (!lstrcmpW(buffer, behindW)) + else if (!wcscmp(buffer, behindW)) gl_surface_mode = GL_SURFACE_BEHIND; else gl_surface_mode = GL_SURFACE_IN_FRONT_OPAQUE; @@ -427,10 +434,13 @@ static void load_strings(struct localized_string *str) }
+static NTSTATUS CDECL unix_call( enum macdrv_funcs code, void *params ); + + /*********************************************************************** * macdrv_init */ -NTSTATUS macdrv_init(void *arg) +static NTSTATUS macdrv_init(void *arg) { struct init_params *params = arg; SessionAttributeBits attributes; @@ -454,6 +464,8 @@ NTSTATUS macdrv_init(void *arg) init_user_driver(); macdrv_init_display_devices(FALSE);
+ pNtWaitForMultipleObjects = params->pNtWaitForMultipleObjects; + params->unix_call = unix_call; return STATUS_SUCCESS; }
@@ -609,9 +621,9 @@ BOOL macdrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param,
NTSTATUS macdrv_client_func(enum macdrv_client_funcs id, const void *params, ULONG size) { - /* FIXME: use KeUserModeCallback instead */ - NTSTATUS (WINAPI *func)(const void *, ULONG) = ((void **)NtCurrentTeb()->Peb->KernelCallbackTable)[id]; - return func(params, size); + void *ret_ptr; + ULONG ret_len; + return KeUserModeCallback(id, params, size, &ret_ptr, &ret_len); }
@@ -655,7 +667,7 @@ C_ASSERT( ARRAYSIZE(__wine_unix_call_funcs) == unix_funcs_count );
/* FIXME: Use __wine_unix_call instead */ -NTSTATUS unix_call(enum macdrv_funcs code, void *params) +static NTSTATUS CDECL unix_call(enum macdrv_funcs code, void *params) { return __wine_unix_call_funcs[code]( params ); } diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index 18a98296a76..fcdd1d1be1a 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -20,6 +20,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#define OEMRESOURCE diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index cf58588981f..63b24ee991d 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -19,6 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include "macdrv.h" diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index e8039b3b3aa..5306e3b619f 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -20,6 +20,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include "macdrv.h" diff --git a/dlls/winemac.drv/systray.c b/dlls/winemac.drv/systray.c index c1901ae0036..9d660d0287e 100644 --- a/dlls/winemac.drv/systray.c +++ b/dlls/winemac.drv/systray.c @@ -21,6 +21,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include "macdrv.h" diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index fea59564b92..284a3e26db9 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -36,8 +36,8 @@ enum macdrv_funcs };
/* FIXME: Use __wine_unix_call when the rest of the stack is ready */ -extern NTSTATUS unix_call(enum macdrv_funcs code, void *params) DECLSPEC_HIDDEN; -#define MACDRV_CALL(func, params) unix_call( unix_ ## func, params ) +extern NTSTATUS (CDECL *macdrv_unix_call)(enum macdrv_funcs code, void *params) DECLSPEC_HIDDEN; +#define MACDRV_CALL(func, params) macdrv_unix_call(unix_ ## func, params)
/* macdrv_dnd_get_data params */ struct dnd_get_data_params @@ -83,7 +83,9 @@ struct localized_string
struct init_params { + NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*); struct localized_string *strings; + NTSTATUS (CDECL *unix_call)(enum macdrv_funcs code, void *params); };
/* macdrv_notify_icon params */ diff --git a/dlls/winemac.drv/vulkan.c b/dlls/winemac.drv/vulkan.c index ddef551c3d7..00f5e8465ab 100644 --- a/dlls/winemac.drv/vulkan.c +++ b/dlls/winemac.drv/vulkan.c @@ -21,6 +21,10 @@ /* NOTE: If making changes here, consider whether they should be reflected in * the other drivers. */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include <stdarg.h> diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 072bdf606d4..f533f1d6310 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -21,6 +21,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include <IOKit/pwr_mgt/IOPMLib.h> diff --git a/tools/makedep.c b/tools/makedep.c index eaf7366da1a..83e4844050a 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -1506,6 +1506,8 @@ static void parse_file( struct makefile *make, struct incl_file *source, int src source->files_count = 0; source->files_size = file->deps_count; source->files = xmalloc( source->files_size * sizeof(*source->files) ); + + if (strendswith( file->name, ".m" )) file->flags |= FLAG_C_UNIX; if (file->flags & FLAG_C_UNIX) source->use_msvcrt = 0; else if (file->flags & FLAG_C_IMPLIB) source->use_msvcrt = 1;
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/Makefile.in | 2 -- dlls/winemac.drv/dllmain.c | 5 ++--- dlls/winemac.drv/dragdrop.c | 5 ++--- dlls/winemac.drv/ime.c | 8 ++----- dlls/winemac.drv/macdrv.h | 12 ----------- dlls/winemac.drv/macdrv_dll.h | 39 +++++++++++++++++++++++++++++++++++ 6 files changed, 45 insertions(+), 26 deletions(-) create mode 100644 dlls/winemac.drv/macdrv_dll.h
diff --git a/dlls/winemac.drv/Makefile.in b/dlls/winemac.drv/Makefile.in index e3d3180b2d1..19f3e834cec 100644 --- a/dlls/winemac.drv/Makefile.in +++ b/dlls/winemac.drv/Makefile.in @@ -5,8 +5,6 @@ IMPORTS = uuid rpcrt4 user32 gdi32 win32u DELAYIMPORTS = ole32 shell32 imm32 EXTRALIBS = -lwin32u -framework AppKit -framework Carbon -framework Security -framework OpenGL -framework IOKit -framework CoreVideo -framework QuartzCore $(METAL_LIBS)
-EXTRADLLFLAGS = -mcygwin - C_SRCS = \ clipboard.c \ display.c \ diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index 2ffbc12083d..0618ec83228 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -18,9 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "config.h" -#include <stdarg.h> -#include "macdrv.h" +#include "macdrv_dll.h" +#include "macdrv_res.h" #include "shellapi.h" #include "wine/debug.h"
diff --git a/dlls/winemac.drv/dragdrop.c b/dlls/winemac.drv/dragdrop.c index aec8b1f4790..afd4fb0a6d2 100644 --- a/dlls/winemac.drv/dragdrop.c +++ b/dlls/winemac.drv/dragdrop.c @@ -20,18 +20,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "config.h" - #define NONAMELESSUNION
#include "ntstatus.h" #define WIN32_NO_STATUS -#include "macdrv.h" +#include "macdrv_dll.h"
#define COBJMACROS #include "objidl.h" #include "shellapi.h" #include "shlobj.h" +#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dragdrop);
diff --git a/dlls/winemac.drv/ime.c b/dlls/winemac.drv/ime.c index 756e880c5a3..fd94591a2b8 100644 --- a/dlls/winemac.drv/ime.c +++ b/dlls/winemac.drv/ime.c @@ -34,14 +34,10 @@ * here the IMM level deals with if the application is IME aware or not. */
-#include "config.h" - -#include <stdarg.h> - -#include "macdrv.h" -#include "winuser.h" +#include "macdrv_dll.h" #include "imm.h" #include "ddk/imm.h" +#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(imm);
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 735cfc84d87..7c0f7127883 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -41,7 +41,6 @@ extern BOOL allow_vsync DECLSPEC_HIDDEN; extern BOOL allow_set_gamma DECLSPEC_HIDDEN; extern BOOL allow_software_rendering DECLSPEC_HIDDEN; extern BOOL disable_window_decorations DECLSPEC_HIDDEN; -extern HMODULE macdrv_module DECLSPEC_HIDDEN;
extern NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN, BOOLEAN,const LARGE_INTEGER*) DECLSPEC_HIDDEN; @@ -276,13 +275,6 @@ extern void check_retina_status(void) DECLSPEC_HIDDEN; extern void macdrv_init_display_devices(BOOL force) DECLSPEC_HIDDEN; extern void init_user_driver(void) DECLSPEC_HIDDEN;
-/************************************************************************** - * Mac IME driver - */ - -extern NTSTATUS WINAPI macdrv_ime_set_text(void *params, ULONG size) DECLSPEC_HIDDEN; -extern NTSTATUS WINAPI macdrv_ime_query_char_rect(void *params, ULONG size) DECLSPEC_HIDDEN; - /* unixlib interface */
extern NTSTATUS macdrv_dnd_get_data(void *arg) DECLSPEC_HIDDEN; @@ -296,10 +288,6 @@ extern NTSTATUS macdrv_notify_icon(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_client_func(enum macdrv_client_funcs func, const void *params, ULONG size) DECLSPEC_HIDDEN;
-extern NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) DECLSPEC_HIDDEN; -extern NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) DECLSPEC_HIDDEN; -extern NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) DECLSPEC_HIDDEN; - /* user helpers */
static inline LRESULT send_message(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) diff --git a/dlls/winemac.drv/macdrv_dll.h b/dlls/winemac.drv/macdrv_dll.h new file mode 100644 index 00000000000..3a11528eabc --- /dev/null +++ b/dlls/winemac.drv/macdrv_dll.h @@ -0,0 +1,39 @@ +/* + * MAC driver definitions + * + * Copyright 2022 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WINE_MACDRV_DLL_H +#define __WINE_MACDRV_DLL_H + +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "ntgdi.h" +#include "unixlib.h" + +extern NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) DECLSPEC_HIDDEN; + +extern NTSTATUS WINAPI macdrv_ime_set_text(void *params, ULONG size) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI macdrv_ime_query_char_rect(void *params, ULONG size) DECLSPEC_HIDDEN; + +extern HMODULE macdrv_module DECLSPEC_HIDDEN; + +#endif /* __WINE_MACDRV_DLL_H */
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 9 ++++----- dlls/winemac.drv/display.c | 1 - dlls/winemac.drv/keyboard.c | 7 +++---- dlls/winemac.drv/macdrv_main.c | 3 --- dlls/winemac.drv/mouse.c | 13 +++++-------- dlls/winemac.drv/window.c | 6 ++---- 6 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 0f7bace1050..af8d99b59a3 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -36,7 +36,6 @@ #include "shlobj.h" #include "wine/list.h" #include "wine/server.h" -#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(clipboard); @@ -766,7 +765,7 @@ static void *import_nsfilenames_to_hdrop(CFDataRef data, size_t *ret_size)
len = 1; /* for the terminating null */ for (i = 0; i < count; i++) - len += strlenW(paths[i]) + 1; + len += wcslen(paths[i]) + 1;
*ret_size = sizeof(*dropfiles) + len * sizeof(WCHAR); if (!(dropfiles = malloc(*ret_size))) @@ -784,8 +783,8 @@ static void *import_nsfilenames_to_hdrop(CFDataRef data, size_t *ret_size) p = (WCHAR*)(dropfiles + 1); for (i = 0; i < count; i++) { - strcpyW(p, paths[i]); - p += strlenW(p) + 1; + wcscpy(p, paths[i]); + p += wcslen(p) + 1; } *p = 0;
@@ -994,7 +993,7 @@ static CFDataRef export_hdrop_to_filenames(void *data, size_t size) }
if (dropfiles->fWide) - p = (WCHAR*)p + strlenW(p) + 1; + p = (WCHAR*)p + wcslen(p) + 1; else p = (char*)p + strlen(p) + 1;
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 2e126b384d1..19b9a9cdd9d 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -31,7 +31,6 @@ #include "ddrawi.h" #define WIN32_NO_STATUS #include "winternl.h" -#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(display);
diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 102f945e79c..824addad78b 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -32,7 +32,6 @@
#include "macdrv.h" #include "winuser.h" -#include "wine/unicode.h" #include "wine/server.h"
WINE_DEFAULT_DEBUG_CHANNEL(keyboard); @@ -403,7 +402,7 @@ static BOOL char_matches_string(WCHAR wchar, UniChar *string, BOOL ignore_diacri { BOOL ret; CFStringRef s1 = CFStringCreateWithCharactersNoCopy(NULL, (UniChar*)&wchar, 1, kCFAllocatorNull); - CFStringRef s2 = CFStringCreateWithCharactersNoCopy(NULL, string, strlenW(string), kCFAllocatorNull); + CFStringRef s2 = CFStringCreateWithCharactersNoCopy(NULL, string, wcslen(string), kCFAllocatorNull); CFStringCompareFlags flags = kCFCompareCaseInsensitive | kCFCompareNonliteral | kCFCompareWidthInsensitive; if (ignore_diacritics) flags |= kCFCompareDiacriticInsensitive; @@ -1366,7 +1365,7 @@ INT macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size) if (status == noErr && deadKeyState) { lstrcpynW(buffer + len, dead, size - len); - len = strlenW(buffer); + len = wcslen(buffer); }
TRACE("lparam 0x%08x -> %s\n", lparam, debugstr_w(buffer)); @@ -1526,7 +1525,7 @@ UINT macdrv_MapVirtualKeyEx(UINT wCode, UINT wMapType, HKL hkl) }
if (status == noErr && len) - ret = toupperW(s[0]) | (deadKey ? 0x80000000 : 0); + ret = RtlUpcaseUnicodeChar(s[0]) | (deadKey ? 0x80000000 : 0);
break; } diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 6ed0fdb7730..e1fd7b2d331 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -32,10 +32,7 @@ #include "ntstatus.h" #define WIN32_NO_STATUS #include "macdrv.h" -#include "winuser.h" -#include "winreg.h" #include "wine/server.h" -#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index fcdd1d1be1a..3f79dda2073 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -28,10 +28,7 @@
#define OEMRESOURCE #include "macdrv.h" -#include "winuser.h" -#include "winreg.h" #include "wine/server.h" -#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(cursor);
@@ -182,11 +179,11 @@ CFStringRef copy_system_cursor_name(ICONINFOEXW *info)
if (!info->szModName[0]) return NULL;
- p = strrchrW(info->szModName, '\'); - strcpyW(name, p ? p + 1 : info->szModName); - p = name + strlenW(name); + p = wcsrchr(info->szModName, '\'); + wcscpy(name, p ? p + 1 : info->szModName); + p = name + wcslen(name); *p++ = ','; - if (info->szResName[0]) strcpyW(p, info->szResName); + if (info->szResName[0]) wcscpy(p, info->szResName); else { char buf[16]; @@ -212,7 +209,7 @@ CFStringRef copy_system_cursor_name(ICONINFOEXW *info) return NULL; /* force standard cursor */ }
- cursor_name = CFStringCreateWithCharacters(NULL, value, strlenW(value)); + cursor_name = CFStringCreateWithCharacters(NULL, value, wcslen(value)); if (!cursor_name) { WARN("CFStringCreateWithCharacters failed for %s\n", debugstr_w(value)); diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index f533f1d6310..9d778f427b0 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -35,8 +35,6 @@ #undef LoadResource
#include "macdrv.h" -#include "winuser.h" -#include "wine/unicode.h" #include "wine/server.h"
WINE_DEFAULT_DEBUG_CHANNEL(macdrv); @@ -715,7 +713,7 @@ static void create_cocoa_window(struct macdrv_win_data *data)
/* set the window text */ if (!NtUserInternalGetWindowText(data->hwnd, text, ARRAY_SIZE(text))) text[0] = 0; - macdrv_set_cocoa_window_title(data->cocoa_window, text, strlenW(text)); + macdrv_set_cocoa_window_title(data->cocoa_window, text, wcslen(text));
/* set the window region */ if (win_rgn || IsRectEmpty(&data->window_rect)) sync_window_region(data, win_rgn); @@ -1773,7 +1771,7 @@ void macdrv_SetWindowText(HWND hwnd, LPCWSTR text) TRACE("%p, %s\n", hwnd, debugstr_w(text));
if ((win = macdrv_get_cocoa_window(hwnd, FALSE))) - macdrv_set_cocoa_window_title(win, text, strlenW(text)); + macdrv_set_cocoa_window_title(win, text, wcslen(text)); }
This merge request was approved by Huw Davies.