[PATCH v2 0/10] MR9503: Draft: winemac: Allow Wine logging functions to be used from ObjC and non-Wine threads.
The goal of this MR is to allow the use of Wine’s logging functions by ObjC code (including from the main thread or other non-Wine threads). winemac’s ObjC code has almost no logging; often the first task when working on an issue is to add temporary logging traces to the ObjC code. By making the full ERR/WARN/TRACE/FIXME and debug channel functionality available, we can add TRACEs to delegate methods, etc. and put them in the right channels. Including Wine and Win32 headers in ObjC code does need a workaround for BOOL, which is both an ObjC and Win32 type. Part of the solution is to use the C99 ‘bool’ type wherever possible. Otherwise, BOOL is #defined to WINBOOL while Win32 headers are #included, and must be used in function signatures if a Win32 BOOL is needed. Creating a debug_info for non-Wine threads was straightforward, though with the limitation that timestamp/pid/tid are not supported. Note that previously macdrv_cocoa.h was included by both C and ObjC files, but macdrv.h was only included by C files. macdrv.h is now included by ObjC files as well, and merging the two header files can be done next. -- v2: winemac: Improve debugstr_cf(). winemac.drv: Remove winemac-specific logging functions. winemac.drv: Add default debug channels to ObjC files. winemac.drv: Include config.h and macdrv.h in all ObjC files. winemac.drv: Include OpenGL in macdrv.h. winemac: Avoid RIID redefinition errors with CFPlugIn.h. winemac: Replace Win32 BOOL usage in macdrv.h with WINBOOL. winemac: Move all Windows includes (by Unix files) to macdrv.h. winemac: Use C99 bool for internal functions/variables in macdrv.h. winemac: Use C string format strings in the ObjC-only ERR(). https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/winemac.drv/cocoa_app.h | 4 ++-- dlls/winemac.drv/cocoa_app.m | 6 +++--- dlls/winemac.drv/cocoa_clipboard.m | 8 ++++---- dlls/winemac.drv/cocoa_event.m | 10 +++++----- dlls/winemac.drv/cocoa_window.m | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h index e2f25c6cc41..d64b528e9f5 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -151,5 +151,5 @@ @interface WineApplication : NSApplication void OnMainThreadAsync(dispatch_block_t block); -void LogError(const char* func, NSString* format, ...); -void LogErrorv(const char* func, NSString* format, va_list args); +void LogError(const char* func, const char* format, ...); +void LogErrorv(const char* func, const char* format, va_list args); diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 102a5b70702..f8933b82233 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -2388,7 +2388,7 @@ void OnMainThreadAsync(dispatch_block_t block) /*********************************************************************** * LogError */ -void LogError(const char* func, NSString* format, ...) +void LogError(const char* func, const char* format, ...) { va_list args; va_start(args, format); @@ -2399,11 +2399,11 @@ void LogError(const char* func, NSString* format, ...) /*********************************************************************** * LogErrorv */ -void LogErrorv(const char* func, NSString* format, va_list args) +void LogErrorv(const char* func, const char* format, va_list args) { @autoreleasepool { - NSString* message = [[NSString alloc] initWithFormat:format arguments:args]; + NSString* message = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args]; fprintf(stderr, "err:%s:%s", func, [message UTF8String]); [message release]; } diff --git a/dlls/winemac.drv/cocoa_clipboard.m b/dlls/winemac.drv/cocoa_clipboard.m index 1eb9995b4eb..8fc14c5329a 100644 --- a/dlls/winemac.drv/cocoa_clipboard.m +++ b/dlls/winemac.drv/cocoa_clipboard.m @@ -132,7 +132,7 @@ CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) } @catch (id e) { - ERR(@"Exception discarded while copying pasteboard types: %@\n", e); + ERR("Exception discarded while copying pasteboard types: %@\n", e); } }); @@ -175,7 +175,7 @@ CFDataRef macdrv_copy_pasteboard_data(CFTypeRef pasteboard, CFStringRef type) } @catch (id e) { - ERR(@"Exception discarded while copying pasteboard types: %@\n", e); + ERR("Exception discarded while copying pasteboard types: %@\n", e); } }); @@ -203,7 +203,7 @@ void macdrv_clear_pasteboard(macdrv_window w) } @catch (id e) { - ERR(@"Exception discarded while clearing pasteboard: %@\n", e); + ERR("Exception discarded while clearing pasteboard: %@\n", e); } }); } @@ -240,7 +240,7 @@ int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w } @catch (id e) { - ERR(@"Exception discarded while copying pasteboard types: %@\n", e); + ERR("Exception discarded while copying pasteboard types: %@\n", e); } }); diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m index d3fc4e8f22c..aaa31ea302b 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -189,7 +189,7 @@ - (void) signalEventAvailable } while (rc < 0 && errno == EINTR); if (rc < 0 && errno != EAGAIN) - ERR(@"%@: got error writing to event queue signaling pipe: %s\n", self, strerror(errno)); + ERR("%@: got error writing to event queue signaling pipe: %s\n", self, strerror(errno)); } - (void) postEventObject:(MacDrvEvent*)event @@ -258,9 +258,9 @@ - (MacDrvEvent*) getEventMatchingMask:(macdrv_event_mask)mask if (rc == 0 || (rc < 0 && errno != EAGAIN)) { if (rc == 0) - ERR(@"%@: event queue signaling pipe unexpectedly closed\n", self); + ERR("%@: event queue signaling pipe unexpectedly closed\n", self); else - ERR(@"%@: got error reading from event queue signaling pipe: %s\n", self, strerror(errno)); + ERR("%@: got error reading from event queue signaling pipe: %s\n", self, strerror(errno)); return nil; } @@ -437,7 +437,7 @@ - (int) registerHotKey:(UInt32)keyCode modifiers:(UInt32)modifiers vkey:(unsigne status = InstallApplicationEventHandler(HotKeyHandler, 1, &eventType, self, &handler); if (status != noErr) { - ERR(@"InstallApplicationEventHandler() failed: %d\n", status); + ERR("InstallApplicationEventHandler() failed: %d\n", status); handler = NULL; return MACDRV_HOTKEY_FAILURE; } @@ -461,7 +461,7 @@ - (int) registerHotKey:(UInt32)keyCode modifiers:(UInt32)modifiers vkey:(unsigne return MACDRV_HOTKEY_ALREADY_REGISTERED; if (status != noErr) { - ERR(@"RegisterEventHotKey() failed: %d\n", status); + ERR("RegisterEventHotKey() failed: %d\n", status); return MACDRV_HOTKEY_FAILURE; } diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 8ca5dd76635..23ea24ec0fc 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -1595,7 +1595,7 @@ - (BOOL) becameEligibleParentOrChild reordered = TRUE; } else - ERR(@"shouldn't happen: %@ thinks %@ is a latent child, but it doesn't agree\n", self, child); + ERR("shouldn't happen: %@ thinks %@ is a latent child, but it doesn't agree\n", self, child); [indexesToRemove addIndex:i]; } } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/winemac.drv/clipboard.c | 8 ++++---- dlls/winemac.drv/cocoa_clipboard.m | 8 ++++---- dlls/winemac.drv/macdrv.h | 22 +++++++++++----------- dlls/winemac.drv/macdrv_cocoa.h | 2 +- dlls/winemac.drv/macdrv_main.c | 12 ++++++------ dlls/winemac.drv/window.c | 26 +++++++++++++------------- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 061e10ff3b3..d7039ec76cf 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -1464,21 +1464,21 @@ void macdrv_UpdateClipboard(void) /************************************************************************** * query_pasteboard_data */ -BOOL query_pasteboard_data(HWND hwnd, CFStringRef type) +bool query_pasteboard_data(HWND hwnd, CFStringRef type) { struct get_clipboard_params params = { .data_only = TRUE, .size = 1024 }; WINE_CLIPFORMAT *format; - BOOL ret = FALSE; + bool ret = false; TRACE("win %p/%p type %s\n", hwnd, clipboard_cocoa_window, debugstr_cf(type)); format = format_for_type(type); - if (!format) return FALSE; + if (!format) return false; if (!NtUserOpenClipboard(clipboard_hwnd, 0)) { ERR("failed to open clipboard for %s\n", debugstr_cf(type)); - return FALSE; + return false; } for (;;) diff --git a/dlls/winemac.drv/cocoa_clipboard.m b/dlls/winemac.drv/cocoa_clipboard.m index 8fc14c5329a..e0a83778b44 100644 --- a/dlls/winemac.drv/cocoa_clipboard.m +++ b/dlls/winemac.drv/cocoa_clipboard.m @@ -216,11 +216,11 @@ void macdrv_clear_pasteboard(macdrv_window w) * that type already on the pasteboard. If data is NULL, promises the * type. * - * Returns 0 on error, non-zero on success. + * Returns false on error, true on success. */ -int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w) +bool macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w) { - __block int ret = 0; + __block bool ret = false; WineWindow* window = (WineWindow*)w; OnMainThread(^{ @@ -235,7 +235,7 @@ int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w if (data) ret = [pb setData:(NSData*)data forType:(NSString*)type]; else - ret = 1; + ret = true; } } @catch (id e) diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index aeeadae122e..1572531e21e 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -38,9 +38,9 @@ #include "unixlib.h" -extern BOOL allow_vsync; -extern BOOL allow_set_gamma; -extern BOOL allow_software_rendering; +extern bool allow_vsync; +extern bool allow_set_gamma; +extern bool allow_software_rendering; extern UINT64 app_icon_callback; extern UINT64 app_quit_request_callback; @@ -202,12 +202,12 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p }; extern struct macdrv_client_surface *impl_from_client_surface(struct client_surface *client); -extern BOOL macdrv_client_surface_acquire_metal_swapchain(struct macdrv_client_surface *surface); +extern bool macdrv_client_surface_acquire_metal_swapchain(struct macdrv_client_surface *surface); extern struct macdrv_win_data *get_win_data(HWND hwnd); extern void release_win_data(struct macdrv_win_data *data); extern void init_win_context(void); -extern macdrv_window macdrv_get_cocoa_window(HWND hwnd, BOOL require_on_screen); +extern macdrv_window macdrv_get_cocoa_window(HWND hwnd, bool require_on_screen); extern RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp); extern void activate_on_following_focus(void); @@ -230,9 +230,9 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p extern void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event); extern void macdrv_window_drag_end(HWND hwnd); extern void macdrv_reassert_window_position(HWND hwnd); -extern BOOL query_resize_size(HWND hwnd, macdrv_query *query); -extern BOOL query_resize_start(HWND hwnd); -extern BOOL query_min_max_info(HWND hwnd); +extern bool query_resize_size(HWND hwnd, macdrv_query *query); +extern bool query_resize_start(HWND hwnd); +extern bool query_min_max_info(HWND hwnd); extern void macdrv_mouse_button(HWND hwnd, const macdrv_event *event); extern void macdrv_mouse_moved(HWND hwnd, const macdrv_event *event); @@ -248,7 +248,7 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p extern void macdrv_displays_changed(const macdrv_event *event); extern void macdrv_UpdateClipboard(void); -extern BOOL query_pasteboard_data(HWND hwnd, CFStringRef type); +extern bool query_pasteboard_data(HWND hwnd, CFStringRef type); extern void macdrv_lost_pasteboard_ownership(HWND hwnd); extern UINT macdrv_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs); @@ -307,7 +307,7 @@ static inline HWND get_focus(void) return NtUserGetGUIThreadInfo(GetCurrentThreadId(), &info) ? info.hwndFocus : 0; } -static inline BOOL intersect_rect( RECT *dst, const RECT *src1, const RECT *src2 ) +static inline bool intersect_rect( RECT *dst, const RECT *src1, const RECT *src2 ) { dst->left = max(src1->left, src2->left); dst->top = max(src1->top, src2->top); @@ -325,7 +325,7 @@ extern HKEY reg_create_ascii_key(HKEY root, const char *name, DWORD options, DWORD *disposition); extern HKEY reg_create_key(HKEY root, const WCHAR *name, ULONG name_len, DWORD options, DWORD *disposition); -extern BOOL reg_delete_tree(HKEY parent, const WCHAR *name, ULONG name_len); +extern bool reg_delete_tree(HKEY parent, const WCHAR *name, ULONG name_len); extern HKEY reg_open_key(HKEY root, const WCHAR *name, ULONG name_len); /* string helpers */ diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 9a91edbe8e3..49097d6d3c7 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -560,7 +560,7 @@ extern void macdrv_get_input_source_info(CFDataRef* uchr,CGEventSourceKeyboardTy extern bool macdrv_is_pasteboard_owner(macdrv_window w); extern bool macdrv_has_pasteboard_changed(void); extern void macdrv_clear_pasteboard(macdrv_window w); -extern int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w); +extern bool macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w); /* opengl */ diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 96168242cc2..b8e3eafebb6 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -43,13 +43,13 @@ C_ASSERT(NUM_EVENT_TYPES <= sizeof(macdrv_event_mask) * 8); int topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN; bool capture_displays_for_fullscreen = false; -BOOL allow_vsync = TRUE; -BOOL allow_set_gamma = TRUE; +bool allow_vsync = true; +bool allow_set_gamma = true; bool left_option_is_alt = false; bool right_option_is_alt = false; bool left_command_is_ctrl = false; bool right_command_is_ctrl = false; -BOOL allow_software_rendering = FALSE; +bool allow_software_rendering = false; bool allow_immovable_windows = true; bool use_confinement_cursor_clipping = true; bool cursor_clipping_locks_windows = true; @@ -206,15 +206,15 @@ HKEY reg_create_ascii_key(HKEY root, const char *name, DWORD options, DWORD *dis } -BOOL reg_delete_tree(HKEY parent, const WCHAR *name, ULONG name_len) +bool reg_delete_tree(HKEY parent, const WCHAR *name, ULONG name_len) { char buffer[4096]; KEY_NODE_INFORMATION *key_info = (KEY_NODE_INFORMATION *)buffer; DWORD size; HKEY key; - BOOL ret = TRUE; + bool ret = true; - if (!(key = reg_open_key(parent, name, name_len))) return FALSE; + if (!(key = reg_open_key(parent, name, name_len))) return false; while (ret && !NtEnumerateKey(key, 0, KeyNodeInformation, key_info, sizeof(buffer), &size)) ret = reg_delete_tree(key, key_info->Name, key_info->NameLength); diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index c23142de722..b76e100da55 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -220,7 +220,7 @@ void release_win_data(struct macdrv_win_data *data) * * Return the Mac window associated with the full area of a window */ -macdrv_window macdrv_get_cocoa_window(HWND hwnd, BOOL require_on_screen) +macdrv_window macdrv_get_cocoa_window(HWND hwnd, bool require_on_screen) { struct macdrv_win_data *data = get_win_data(hwnd); macdrv_window ret = NULL; @@ -1162,12 +1162,12 @@ struct client_surface *macdrv_CreateClientSurface(HWND hwnd, int pixel_format) return &surface->client; } -BOOL macdrv_client_surface_acquire_metal_swapchain(struct macdrv_client_surface *surface) +bool macdrv_client_surface_acquire_metal_swapchain(struct macdrv_client_surface *surface) { HWND hwnd = surface->client.hwnd; struct macdrv_win_data *data; - if (surface->metal_swapchain) return TRUE; + if (surface->metal_swapchain) return true; if ((data = get_win_data(hwnd))) { @@ -1181,10 +1181,10 @@ BOOL macdrv_client_surface_acquire_metal_swapchain(struct macdrv_client_surface if (NtUserGetAncestor(hwnd, GA_ROOT) != hwnd) { FIXME("Cross-process child window Metal swapchains are not implemented\n"); - return FALSE; + return false; } - if (!NtUserGetClientRect(hwnd, &rect, NtUserGetWinMonitorDpi(hwnd, MDT_RAW_DPI))) return FALSE; + if (!NtUserGetClientRect(hwnd, &rect, NtUserGetWinMonitorDpi(hwnd, MDT_RAW_DPI))) return false; surface->metal_swapchain = macdrv_create_offscreen_swapchain(hwnd, cgrect_from_rect(rect)); } @@ -2135,14 +2135,14 @@ void macdrv_app_quit_requested(const macdrv_event *event) * * Handler for QUERY_RESIZE_SIZE query. */ -BOOL query_resize_size(HWND hwnd, macdrv_query *query) +bool query_resize_size(HWND hwnd, macdrv_query *query) { struct macdrv_win_data *data = get_win_data(hwnd); RECT rect; int corner; - BOOL ret = FALSE; + bool ret = false; - if (!data) return FALSE; + if (!data) return false; rect = rect_from_cgrect(query->resize_size.rect); rect = window_rect_from_visible(&data->rects, rect); @@ -2163,7 +2163,7 @@ BOOL query_resize_size(HWND hwnd, macdrv_query *query) { rect = visible_rect_from_window(&data->rects, rect); query->resize_size.rect = cgrect_from_rect(rect); - ret = TRUE; + ret = true; } release_win_data(data); @@ -2176,7 +2176,7 @@ BOOL query_resize_size(HWND hwnd, macdrv_query *query) * * Handler for QUERY_RESIZE_START query. */ -BOOL query_resize_start(HWND hwnd) +bool query_resize_start(HWND hwnd) { TRACE("hwnd %p\n", hwnd); @@ -2185,7 +2185,7 @@ BOOL query_resize_start(HWND hwnd) sync_window_min_max_info(hwnd); send_message(hwnd, WM_ENTERSIZEMOVE, 0, 0); - return TRUE; + return true; } @@ -2194,11 +2194,11 @@ BOOL query_resize_start(HWND hwnd) * * Handler for QUERY_MIN_MAX_INFO query. */ -BOOL query_min_max_info(HWND hwnd) +bool query_min_max_info(HWND hwnd) { TRACE("hwnd %p\n", hwnd); sync_window_min_max_info(hwnd); - return TRUE; + return true; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/winemac.drv/clipboard.c | 7 ------- dlls/winemac.drv/display.c | 5 ----- dlls/winemac.drv/event.c | 5 +---- dlls/winemac.drv/gdi.c | 2 -- dlls/winemac.drv/image.c | 2 -- dlls/winemac.drv/keyboard.c | 3 --- dlls/winemac.drv/macdrv.h | 15 ++++++++++++++- dlls/winemac.drv/macdrv_main.c | 6 +----- dlls/winemac.drv/mouse.c | 2 -- dlls/winemac.drv/opengl.c | 7 ------- dlls/winemac.drv/surface.c | 2 -- dlls/winemac.drv/systray.c | 8 -------- dlls/winemac.drv/vulkan.c | 8 +------- dlls/winemac.drv/window.c | 9 +-------- 14 files changed, 18 insertions(+), 63 deletions(-) diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index d7039ec76cf..71be4940559 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -27,14 +27,7 @@ #endif #include "config.h" - -#include "ntstatus.h" #include "macdrv.h" -#include "winuser.h" -#include "shellapi.h" -#include "shlobj.h" -#include "wine/list.h" -#include "wine/server.h" WINE_DEFAULT_DEBUG_CHANNEL(clipboard); diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 2b2c55d9da8..055cfb4fb33 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -24,12 +24,7 @@ #endif #include "config.h" - #include "macdrv.h" -#include "winuser.h" -#include "winreg.h" -#include "ddrawi.h" -#include "winternl.h" WINE_DEFAULT_DEBUG_CHANNEL(display); diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index c7e5fb1c7a8..f7288b8d1b6 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -25,13 +25,10 @@ #endif #include "config.h" +#include "macdrv.h" #include <poll.h> -#include "ntstatus.h" -#include "macdrv.h" -#include "oleidl.h" - WINE_DEFAULT_DEBUG_CHANNEL(event); WINE_DECLARE_DEBUG_CHANNEL(imm); diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c index 906bb4d09e6..69a0aa7faf0 100644 --- a/dlls/winemac.drv/gdi.c +++ b/dlls/winemac.drv/gdi.c @@ -24,9 +24,7 @@ #endif #include "config.h" - #include "macdrv.h" -#include "winreg.h" WINE_DEFAULT_DEBUG_CHANNEL(macdrv); diff --git a/dlls/winemac.drv/image.c b/dlls/winemac.drv/image.c index cf927ce7d1a..7fb45f357a0 100644 --- a/dlls/winemac.drv/image.c +++ b/dlls/winemac.drv/image.c @@ -23,9 +23,7 @@ #endif #include "config.h" - #include "macdrv.h" -#include "winuser.h" WINE_DEFAULT_DEBUG_CHANNEL(image); diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 38bb2a7ad69..dfc02eaf191 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -29,10 +29,7 @@ #endif #include "config.h" - #include "macdrv.h" -#include "winuser.h" -#include "wine/server.h" WINE_DEFAULT_DEBUG_CHANNEL(keyboard); WINE_DECLARE_DEBUG_CHANNEL(key); diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 1572531e21e..ad858579906 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -29,13 +29,26 @@ #include "macdrv_cocoa.h" +/* All Windows headers needed by Unix C/ObjC files must be included here. */ #include "ntstatus.h" #include "windef.h" #include "winbase.h" #include "ntgdi.h" +#include "ddrawi.h" +#include "oleidl.h" +#include "shellapi.h" +#include "shlobj.h" +#include "unixlib.h" +#include "winnt.h" +#include "winternl.h" +#include "winuser.h" #include "wine/debug.h" #include "wine/gdi_driver.h" -#include "unixlib.h" +#include "wine/list.h" +#include "wine/server.h" +#include "wine/opengl_driver.h" +#include "wine/vulkan.h" +#include "wine/vulkan_driver.h" extern bool allow_vsync; diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index b8e3eafebb6..18d4395b31c 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -25,15 +25,11 @@ #endif #include "config.h" +#include "macdrv.h" #include <Security/AuthSession.h> #include <IOKit/pwr_mgt/IOPMLib.h> -#include "ntstatus.h" -#include "macdrv.h" -#include "shellapi.h" -#include "wine/server.h" - WINE_DEFAULT_DEBUG_CHANNEL(macdrv); #define IS_OPTION_TRUE(ch) \ diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index 51ae29ae84e..8a147321ae6 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -25,10 +25,8 @@ #endif #include "config.h" - #define OEMRESOURCE #include "macdrv.h" -#include "wine/server.h" WINE_DEFAULT_DEBUG_CHANNEL(cursor); diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 6b2ec0bc9d4..5c8b09ec176 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -24,15 +24,8 @@ #endif #include "config.h" - #include "macdrv.h" -#include "winuser.h" -#include "winternl.h" -#include "winnt.h" -#include "wine/debug.h" -#include "wine/opengl_driver.h" - #define GL_SILENCE_DEPRECATION #define __gl_h_ #define __gltypes_h_ diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 39481149121..d7925d9518e 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -25,9 +25,7 @@ #endif #include "config.h" - #include "macdrv.h" -#include "winuser.h" WINE_DEFAULT_DEBUG_CHANNEL(bitblt); diff --git a/dlls/winemac.drv/systray.c b/dlls/winemac.drv/systray.c index 0231e08e82b..d341b2b27d0 100644 --- a/dlls/winemac.drv/systray.c +++ b/dlls/winemac.drv/systray.c @@ -26,16 +26,8 @@ #endif #include "config.h" - #include "macdrv.h" -#include "windef.h" -#include "winuser.h" -#include "shellapi.h" - -#include "wine/list.h" -#include "wine/debug.h" - WINE_DEFAULT_DEBUG_CHANNEL(systray); diff --git a/dlls/winemac.drv/vulkan.c b/dlls/winemac.drv/vulkan.c index 532f792ed46..19515ee6229 100644 --- a/dlls/winemac.drv/vulkan.c +++ b/dlls/winemac.drv/vulkan.c @@ -26,15 +26,9 @@ #endif #include "config.h" - -#include <dlfcn.h> - -#include "ntstatus.h" #include "macdrv.h" -#include "wine/debug.h" -#include "wine/vulkan.h" -#include "wine/vulkan_driver.h" +#include <dlfcn.h> WINE_DEFAULT_DEBUG_CHANNEL(vulkan); diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index b76e100da55..2229ca01ef0 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -26,16 +26,9 @@ #endif #include "config.h" +#include "macdrv.h" #include <IOKit/pwr_mgt/IOPMLib.h> -#define GetCurrentThread Mac_GetCurrentThread -#define LoadResource Mac_LoadResource -#include <CoreServices/CoreServices.h> -#undef GetCurrentThread -#undef LoadResource - -#include "macdrv.h" -#include "wine/server.h" WINE_DEFAULT_DEBUG_CHANNEL(macdrv); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/winemac.drv/macdrv.h | 49 +++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index ad858579906..20c86385b65 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -29,6 +29,10 @@ #include "macdrv_cocoa.h" +#ifdef __OBJC__ +# define BOOL WINBOOL +#endif + /* All Windows headers needed by Unix C/ObjC files must be included here. */ #include "ntstatus.h" #include "windef.h" @@ -50,6 +54,18 @@ #include "wine/vulkan.h" #include "wine/vulkan_driver.h" +#ifdef __OBJC__ +# undef BOOL +# undef interface /* objbase defines 'interface' to 'struct' */ +#else + typedef BOOL WINBOOL; +#endif + +/* This file is included by C and ObjC, and BOOL could mean either Win32 BOOL or ObjC BOOL. + * Use the C 'bool' type instead, or use 'WINBOOL' if you need a Win32 BOOL. + */ +#define BOOL DoNotUseBOOLInThisFile + extern bool allow_vsync; extern bool allow_set_gamma; @@ -96,8 +112,6 @@ static inline RECT rect_from_cgrect(CGRect cgrect) extern CGRect macdrv_get_desktop_rect(void); extern void macdrv_reset_device_metrics(void); -extern BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp); -extern BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp); /************************************************************************** @@ -137,14 +151,14 @@ static inline RECT rect_from_cgrect(CGRect cgrect) } -extern BOOL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags); +extern WINBOOL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags); extern void macdrv_Beep(void); extern LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, LPCWSTR primary_name, HWND hwnd, DWORD flags, LPVOID lpvoid); extern LRESULT macdrv_ClipboardWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp); extern UINT macdrv_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, void *param); -extern BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp); -extern BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp); -extern BOOL macdrv_ClipCursor(const RECT *clip, BOOL reset); +extern WINBOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp); +extern WINBOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp); +extern WINBOOL macdrv_ClipCursor(const RECT *clip, WINBOOL reset); extern LRESULT macdrv_NotifyIcon(HWND hwnd, UINT msg, NOTIFYICONDATAW *data); extern void macdrv_CleanupIcons(HWND hwnd); extern LRESULT macdrv_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); @@ -154,25 +168,25 @@ static inline RECT rect_from_cgrect(CGRect cgrect) extern void macdrv_SetLayeredWindowAttributes(HWND hwnd, COLORREF key, BYTE alpha, DWORD flags); extern void macdrv_SetParent(HWND hwnd, HWND parent, HWND old_parent); -extern void macdrv_SetWindowRgn(HWND hwnd, HRGN hrgn, BOOL redraw); +extern void macdrv_SetWindowRgn(HWND hwnd, HRGN hrgn, WINBOOL redraw); extern void macdrv_SetWindowStyle(HWND hwnd, INT offset, STYLESTRUCT *style); extern void macdrv_SetWindowText(HWND hwnd, LPCWSTR text); extern UINT macdrv_ShowWindow(HWND hwnd, INT cmd, RECT *rect, UINT swp); extern LRESULT macdrv_SysCommand(HWND hwnd, WPARAM wparam, LPARAM lparam, const POINT *pos); extern void macdrv_UpdateLayeredWindow(HWND hwnd, BYTE alpha, UINT flags); extern LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp); -extern BOOL macdrv_WindowPosChanging(HWND hwnd, UINT swp_flags, BOOL shaped, const struct window_rects *rects); -extern BOOL macdrv_GetWindowStyleMasks(HWND hwnd, UINT style, UINT ex_style, UINT *style_mask, UINT *ex_style_mask); +extern WINBOOL macdrv_WindowPosChanging(HWND hwnd, UINT swp_flags, WINBOOL shaped, const struct window_rects *rects); +extern WINBOOL macdrv_GetWindowStyleMasks(HWND hwnd, UINT style, UINT ex_style, UINT *style_mask, UINT *ex_style_mask); extern struct client_surface *macdrv_CreateClientSurface(HWND hwnd, int pixel_format); -extern BOOL macdrv_CreateWindowSurface(HWND hwnd, BOOL layered, const RECT *surface_rect, struct window_surface **surface); +extern WINBOOL macdrv_CreateWindowSurface(HWND hwnd, WINBOOL layered, const RECT *surface_rect, struct window_surface **surface); extern void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, HWND owner_hint, UINT swp_flags, const struct window_rects *new_rects, struct window_surface *surface); extern void macdrv_DestroyCursorIcon(HCURSOR cursor); -extern BOOL macdrv_GetCursorPos(LPPOINT pos); +extern WINBOOL macdrv_GetCursorPos(LPPOINT pos); extern void macdrv_SetCapture(HWND hwnd, UINT flags, HWND previous); extern void macdrv_SetCursor(HWND hwnd, HCURSOR cursor); -extern BOOL macdrv_SetCursorPos(INT x, INT y); -extern BOOL macdrv_RegisterHotKey(HWND hwnd, UINT mod_flags, UINT vkey); +extern WINBOOL macdrv_SetCursorPos(INT x, INT y); +extern WINBOOL macdrv_RegisterHotKey(HWND hwnd, UINT mod_flags, UINT vkey); extern void macdrv_UnregisterHotKey(HWND hwnd, UINT modifiers, UINT vkey); extern SHORT macdrv_VkKeyScanEx(WCHAR wChar, HKL hkl); extern UINT macdrv_ImeToAsciiEx(UINT vkey, UINT vsc, const BYTE *state, HIMC himc); @@ -182,10 +196,10 @@ extern INT macdrv_ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyStat extern UINT macdrv_GetKeyboardLayoutList(INT size, HKL *list); extern INT macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size); extern void macdrv_NotifyIMEStatus(HWND hwnd, UINT status); -extern BOOL macdrv_SetIMECompositionRect(HWND hwnd, RECT rect); -extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_param, - UINT flags); -extern BOOL macdrv_ProcessEvents(DWORD mask); +extern WINBOOL macdrv_SetIMECompositionRect(HWND hwnd, RECT rect); +extern WINBOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_param, + UINT flags); +extern WINBOOL macdrv_ProcessEvents(DWORD mask); extern void macdrv_ThreadDetach(void); @@ -355,4 +369,5 @@ static inline UINT asciiz_to_unicode(WCHAR *dst, const char *src) return (p - dst) * sizeof(WCHAR); } +#undef BOOL #endif /* __WINE_MACDRV_H */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/winemac.drv/cocoa_display.m | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m index d22ada8c804..bc1b11c1909 100644 --- a/dlls/winemac.drv/cocoa_display.m +++ b/dlls/winemac.drv/cocoa_display.m @@ -21,6 +21,7 @@ #include "config.h" #import <AppKit/AppKit.h> +#define NO_CFPLUGIN #import <IOKit/graphics/IOGraphicsLib.h> #ifdef HAVE_MTLDEVICE_REGISTRYID #import <Metal/Metal.h> -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/winemac.drv/macdrv.h | 10 ++++++++++ dlls/winemac.drv/opengl.c | 6 ------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 20c86385b65..ba4204b937d 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -66,6 +66,16 @@ */ #define BOOL DoNotUseBOOLInThisFile +/* Include OpenGL here to avoid typedef conflicts between Windows wgl and OpenGL.framework */ +#define GL_SILENCE_DEPRECATION +#define __gl_h_ +#define __gltypes_h_ +#include <OpenGL/OpenGL.h> +#include <OpenGL/gl.h> +#include <OpenGL/glext.h> +#include <OpenGL/glu.h> +#include <OpenGL/CGLRenderers.h> + extern bool allow_vsync; extern bool allow_set_gamma; diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 5c8b09ec176..c1aaa449cbe 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -26,12 +26,6 @@ #include "config.h" #include "macdrv.h" -#define GL_SILENCE_DEPRECATION -#define __gl_h_ -#define __gltypes_h_ -#include <OpenGL/OpenGL.h> -#include <OpenGL/glu.h> -#include <OpenGL/CGLRenderers.h> #include <dlfcn.h> WINE_DEFAULT_DEBUG_CHANNEL(wgl); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> In place of macdrv_cocoa.h. Also move ObjC-only ERR() macro to macdrv.h. --- dlls/winemac.drv/cocoa_app.h | 3 --- dlls/winemac.drv/cocoa_app.m | 3 +++ dlls/winemac.drv/cocoa_clipboard.m | 4 +++- dlls/winemac.drv/cocoa_cursorclipping.m | 3 +++ dlls/winemac.drv/cocoa_display.m | 4 ++-- dlls/winemac.drv/cocoa_event.m | 4 +++- dlls/winemac.drv/cocoa_main.m | 4 +++- dlls/winemac.drv/cocoa_opengl.m | 6 +++--- dlls/winemac.drv/cocoa_status_item.m | 4 +++- dlls/winemac.drv/cocoa_window.m | 5 ++--- dlls/winemac.drv/macdrv.h | 5 +++++ dlls/winemac.drv/macdrv_cocoa.h | 6 ++---- 12 files changed, 32 insertions(+), 19 deletions(-) diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h index d64b528e9f5..ff44a73234c 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -150,6 +150,3 @@ @interface WineApplication : NSApplication void OnMainThreadAsync(dispatch_block_t block); - -void LogError(const char* func, const char* format, ...); -void LogErrorv(const char* func, const char* format, va_list args); diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index f8933b82233..09f7ea6dbe8 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#import "config.h" +#import "macdrv.h" + #import "cocoa_app.h" #import "cocoa_cursorclipping.h" #import "cocoa_event.h" diff --git a/dlls/winemac.drv/cocoa_clipboard.m b/dlls/winemac.drv/cocoa_clipboard.m index e0a83778b44..8820474342c 100644 --- a/dlls/winemac.drv/cocoa_clipboard.m +++ b/dlls/winemac.drv/cocoa_clipboard.m @@ -18,7 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "macdrv_cocoa.h" +#import "config.h" +#import "macdrv.h" + #import "cocoa_app.h" #import "cocoa_event.h" #import "cocoa_window.h" diff --git a/dlls/winemac.drv/cocoa_cursorclipping.m b/dlls/winemac.drv/cocoa_cursorclipping.m index b6151a2c8c4..2563111ec6c 100644 --- a/dlls/winemac.drv/cocoa_cursorclipping.m +++ b/dlls/winemac.drv/cocoa_cursorclipping.m @@ -19,6 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#import "config.h" +#import "macdrv.h" + #import "cocoa_app.h" #import "cocoa_cursorclipping.h" #import "cocoa_window.h" diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m index bc1b11c1909..c9be1ec8baa 100644 --- a/dlls/winemac.drv/cocoa_display.m +++ b/dlls/winemac.drv/cocoa_display.m @@ -18,7 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" +#import "config.h" +#import "macdrv.h" #import <AppKit/AppKit.h> #define NO_CFPLUGIN @@ -27,7 +28,6 @@ #import <Metal/Metal.h> #endif #include <dlfcn.h> -#include "macdrv_cocoa.h" #pragma GCC diagnostic ignored "-Wdeclaration-after-statement" diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m index aaa31ea302b..1d90c1a454f 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -18,11 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#import "config.h" +#import "macdrv.h" + #include <sys/types.h> #include <sys/event.h> #include <sys/time.h> -#include "macdrv_cocoa.h" #import "cocoa_event.h" #import "cocoa_app.h" #import "cocoa_window.h" diff --git a/dlls/winemac.drv/cocoa_main.m b/dlls/winemac.drv/cocoa_main.m index 8c9507a75b1..e80aa93473c 100644 --- a/dlls/winemac.drv/cocoa_main.m +++ b/dlls/winemac.drv/cocoa_main.m @@ -18,11 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#import "config.h" +#import "macdrv.h" + #import <AppKit/AppKit.h> #include <mach/mach.h> #include <mach/mach_time.h> -#include "macdrv_cocoa.h" #import "cocoa_app.h" #pragma GCC diagnostic ignored "-Wdeclaration-after-statement" diff --git a/dlls/winemac.drv/cocoa_opengl.m b/dlls/winemac.drv/cocoa_opengl.m index 2801834e825..adaf085d62f 100644 --- a/dlls/winemac.drv/cocoa_opengl.m +++ b/dlls/winemac.drv/cocoa_opengl.m @@ -18,11 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define GL_SILENCE_DEPRECATION -#include <OpenGL/gl.h> +#import "config.h" +#import "macdrv.h" + #import "cocoa_opengl.h" -#include "macdrv_cocoa.h" #include "cocoa_app.h" #include "cocoa_event.h" diff --git a/dlls/winemac.drv/cocoa_status_item.m b/dlls/winemac.drv/cocoa_status_item.m index 31f8a668d81..71c358ce3b3 100644 --- a/dlls/winemac.drv/cocoa_status_item.m +++ b/dlls/winemac.drv/cocoa_status_item.m @@ -18,8 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#import "config.h" +#import "macdrv.h" + #import <Cocoa/Cocoa.h> -#include "macdrv_cocoa.h" #import "cocoa_app.h" #import "cocoa_event.h" diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 23ea24ec0fc..beaf5c7ced2 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -18,9 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" +#import "config.h" +#import "macdrv.h" -#define GL_SILENCE_DEPRECATION #import <CoreVideo/CoreVideo.h> #import <Metal/Metal.h> #import <QuartzCore/QuartzCore.h> @@ -28,7 +28,6 @@ #import "cocoa_window.h" -#include "macdrv_cocoa.h" #import "cocoa_app.h" #import "cocoa_event.h" #import "cocoa_opengl.h" diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index ba4204b937d..905e9abe615 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -76,6 +76,11 @@ #include <OpenGL/glu.h> #include <OpenGL/CGLRenderers.h> +#ifdef __OBJC__ +#undef ERR +#define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false) +#endif + extern bool allow_vsync; extern bool allow_set_gamma; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 49097d6d3c7..19e5444696f 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -209,6 +209,8 @@ static inline CGPoint cgpoint_win_from_mac(CGPoint point) extern void macdrv_set_mouse_capture_window(macdrv_window window); extern void macdrv_set_cocoa_retina_mode(bool new_mode); +extern void LogError(const char* func, const char* format, ...); +extern void LogErrorv(const char* func, const char* format, va_list args); /* cursor */ extern void macdrv_set_cursor(CFStringRef name, CFArrayRef frames); @@ -219,10 +221,6 @@ static inline CGPoint cgpoint_win_from_mac(CGPoint point) /* display */ -/* Used DISPLAY_DEVICE.StateFlags for adapters */ -#define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 0x00000001 -#define DISPLAY_DEVICE_PRIMARY_DEVICE 0x00000004 - /* Represent a physical GPU in the PCI slots */ struct macdrv_gpu { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/winemac.drv/cocoa_clipboard.m | 2 ++ dlls/winemac.drv/cocoa_event.m | 2 ++ dlls/winemac.drv/cocoa_window.m | 1 + 3 files changed, 5 insertions(+) diff --git a/dlls/winemac.drv/cocoa_clipboard.m b/dlls/winemac.drv/cocoa_clipboard.m index 8820474342c..0d305f85bdf 100644 --- a/dlls/winemac.drv/cocoa_clipboard.m +++ b/dlls/winemac.drv/cocoa_clipboard.m @@ -36,6 +36,8 @@ #define NSBitmapImageFileTypeTIFF NSTIFFFileType #endif +WINE_DEFAULT_DEBUG_CHANNEL(clipboard); + static int owned_change_count = -1; static int change_count = -1; diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m index 1d90c1a454f..4a3e62a1988 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -31,6 +31,8 @@ #pragma GCC diagnostic ignored "-Wdeclaration-after-statement" +WINE_DEFAULT_DEBUG_CHANNEL(event); + static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThreadDictionaryKey"; diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index beaf5c7ced2..b74eae1f708 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -34,6 +34,7 @@ #pragma GCC diagnostic ignored "-Wdeclaration-after-statement" +WINE_DEFAULT_DEBUG_CHANNEL(macdrv); @interface NSWindow (PrivatePreventsActivation) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> Wine's logging functions now work from a non-Wine thread and are usable from ObjC. --- dlls/winemac.drv/cocoa_app.h | 2 -- dlls/winemac.drv/cocoa_app.m | 27 --------------------------- dlls/winemac.drv/cocoa_clipboard.m | 8 ++++---- dlls/winemac.drv/cocoa_event.m | 6 +++--- dlls/winemac.drv/cocoa_window.m | 2 +- dlls/winemac.drv/macdrv.h | 5 ----- dlls/winemac.drv/macdrv_cocoa.h | 3 --- dlls/winemac.drv/macdrv_main.c | 1 - 8 files changed, 8 insertions(+), 46 deletions(-) diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h index ff44a73234c..11325456ed3 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -22,8 +22,6 @@ #include "macdrv_cocoa.h" -#define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false) - /* Internal notification sent on NSApp for display configuration changes. The userInfo contains the two keys, NSNumbers for the effected CGDirectDisplayID and the CGDisplayChangeSummaryFlags from the underlying CG callback. */ diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 09f7ea6dbe8..a1532fdbcdb 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -44,9 +44,6 @@ static NSString* const WineActivatingAppConfigDirKey = @"ActivatingAppConfigDir"; -bool macdrv_err_on; - - #if !defined(MAC_OS_VERSION_14_0) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_14_0 @interface NSApplication (CooperativeActivationSelectorsForOldSDKs) @@ -2388,30 +2385,6 @@ void OnMainThreadAsync(dispatch_block_t block) @end -/*********************************************************************** - * LogError - */ -void LogError(const char* func, const char* format, ...) -{ - va_list args; - va_start(args, format); - LogErrorv(func, format, args); - va_end(args); -} - -/*********************************************************************** - * LogErrorv - */ -void LogErrorv(const char* func, const char* format, va_list args) -{ -@autoreleasepool -{ - NSString* message = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args]; - fprintf(stderr, "err:%s:%s", func, [message UTF8String]); - [message release]; -} -} - /*********************************************************************** * macdrv_window_rejected_focus * diff --git a/dlls/winemac.drv/cocoa_clipboard.m b/dlls/winemac.drv/cocoa_clipboard.m index 0d305f85bdf..de0f6dc768c 100644 --- a/dlls/winemac.drv/cocoa_clipboard.m +++ b/dlls/winemac.drv/cocoa_clipboard.m @@ -136,7 +136,7 @@ CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) } @catch (id e) { - ERR("Exception discarded while copying pasteboard types: %@\n", e); + ERR("Exception discarded while copying pasteboard types: %s\n", debugstr_cf(e)); } }); @@ -179,7 +179,7 @@ CFDataRef macdrv_copy_pasteboard_data(CFTypeRef pasteboard, CFStringRef type) } @catch (id e) { - ERR("Exception discarded while copying pasteboard types: %@\n", e); + ERR("Exception discarded while copying pasteboard types: %s\n", debugstr_cf(e)); } }); @@ -207,7 +207,7 @@ void macdrv_clear_pasteboard(macdrv_window w) } @catch (id e) { - ERR("Exception discarded while clearing pasteboard: %@\n", e); + ERR("Exception discarded while clearing pasteboard: %s\n", debugstr_cf(e)); } }); } @@ -244,7 +244,7 @@ bool macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window } @catch (id e) { - ERR("Exception discarded while copying pasteboard types: %@\n", e); + ERR("Exception discarded while copying pasteboard types: %s\n", debugstr_cf(e)); } }); diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m index 4a3e62a1988..16b1ca59d6e 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -193,7 +193,7 @@ - (void) signalEventAvailable } while (rc < 0 && errno == EINTR); if (rc < 0 && errno != EAGAIN) - ERR("%@: got error writing to event queue signaling pipe: %s\n", self, strerror(errno)); + ERR("%s: got error writing to event queue signaling pipe: %s\n", debugstr_cf(self), strerror(errno)); } - (void) postEventObject:(MacDrvEvent*)event @@ -262,9 +262,9 @@ - (MacDrvEvent*) getEventMatchingMask:(macdrv_event_mask)mask if (rc == 0 || (rc < 0 && errno != EAGAIN)) { if (rc == 0) - ERR("%@: event queue signaling pipe unexpectedly closed\n", self); + ERR("%s: event queue signaling pipe unexpectedly closed\n", debugstr_cf(self)); else - ERR("%@: got error reading from event queue signaling pipe: %s\n", self, strerror(errno)); + ERR("%s: got error reading from event queue signaling pipe: %s\n", debugstr_cf(self), strerror(errno)); return nil; } diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index b74eae1f708..f1e7da54cb8 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -1595,7 +1595,7 @@ - (BOOL) becameEligibleParentOrChild reordered = TRUE; } else - ERR("shouldn't happen: %@ thinks %@ is a latent child, but it doesn't agree\n", self, child); + ERR("shouldn't happen: %s thinks %s is a latent child, but it doesn't agree\n", debugstr_cf(self), debugstr_cf(child)); [indexesToRemove addIndex:i]; } } diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 905e9abe615..ba4204b937d 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -76,11 +76,6 @@ #include <OpenGL/glu.h> #include <OpenGL/CGLRenderers.h> -#ifdef __OBJC__ -#undef ERR -#define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false) -#endif - extern bool allow_vsync; extern bool allow_set_gamma; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 19e5444696f..540e4a625e0 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -113,7 +113,6 @@ /* main */ -extern bool macdrv_err_on; extern int topmost_float_inactive; extern bool capture_displays_for_fullscreen; extern bool left_option_is_alt; @@ -209,8 +208,6 @@ static inline CGPoint cgpoint_win_from_mac(CGPoint point) extern void macdrv_set_mouse_capture_window(macdrv_window window); extern void macdrv_set_cocoa_retina_mode(bool new_mode); -extern void LogError(const char* func, const char* format, ...); -extern void LogErrorv(const char* func, const char* format, va_list args); /* cursor */ extern void macdrv_set_cursor(CFStringRef name, CFArrayRef frames); diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 18d4395b31c..8c2f977b125 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -438,7 +438,6 @@ static NTSTATUS macdrv_init(void *arg) setup_options(); load_strings(params->strings); - macdrv_err_on = ERR_ON(macdrv); if (macdrv_start_cocoa_app(NtGetTickCount())) { ERR("Failed to start Cocoa app main loop\n"); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
From: Brendan Shanks <bshanks@codeweavers.com> Use __wine_dbg_strdup() to avoid quotes or 'L' being added to every string. --- dlls/winemac.drv/macdrv_main.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 8c2f977b125..b50068bc50e 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -72,25 +72,18 @@ const char* debugstr_cf(CFTypeRef t) if (!t) return "(null)"; if (CFGetTypeID(t) == CFStringGetTypeID()) - s = t; + s = CFStringCreateWithFormat(NULL, NULL, CFSTR("\"%@\""), t); else s = CFCopyDescription(t); ret = CFStringGetCStringPtr(s, kCFStringEncodingUTF8); - if (ret) ret = debugstr_a(ret); + if (ret) ret = __wine_dbg_strdup(ret); if (!ret) { - const UniChar* u = CFStringGetCharactersPtr(s); - if (u) - ret = debugstr_wn((const WCHAR*)u, CFStringGetLength(s)); + char buf[300]; + CFStringGetCString(s, buf, sizeof(buf), kCFStringEncodingUTF8); + ret = __wine_dbg_strdup(buf); } - if (!ret) - { - UniChar buf[200]; - int len = min(CFStringGetLength(s), ARRAY_SIZE(buf)); - CFStringGetCharacters(s, CFRangeMake(0, len), buf); - ret = debugstr_wn(buf, len); - } - if (s != t) CFRelease(s); + CFRelease(s); return ret; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9503
I've rebased this and removed the `debug_info` change, the intention is this will be used on top of !9579 which turns the main thread into a Wine system thread. Still a WIP, and the intention is to replace `BOOL` with `bool` in the user funcs so that `WINBOOL` is an implementation detail rather than something developers need to be aware of. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9503#note_149795
participants (2)
-
Brendan Shanks -
Brendan Shanks (@bshanks)