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.
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 85d252abb7e..f6ba2b4414e 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -145,5 +145,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 2a9dab26989..b0b5120718d 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -2357,7 +2357,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); @@ -2368,11 +2368,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 7c86fc1d5ff..cc120e4c7dc 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -190,7 +190,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 @@ -259,9 +259,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; }
@@ -438,7 +438,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; } @@ -462,7 +462,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 19c8fef4246..ac42db124e9 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -1543,7 +1543,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]; } }
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/clipboard.c | 8 ++++---- dlls/winemac.drv/cocoa_clipboard.m | 8 ++++---- dlls/winemac.drv/macdrv.h | 20 ++++++++++---------- dlls/winemac.drv/macdrv_cocoa.h | 2 +- dlls/winemac.drv/macdrv_main.c | 12 ++++++------ dlls/winemac.drv/window.c | 18 +++++++++--------- 6 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index c1e6ebb6d5b..c745be73484 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -1465,21 +1465,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 ac2a7853652..54c1278bc2f 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -39,9 +39,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; @@ -209,7 +209,7 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p 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);
@@ -232,9 +232,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); @@ -251,7 +251,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); @@ -310,7 +310,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); @@ -328,7 +328,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 954acb0fc67..71cc0bae04d 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -548,7 +548,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 ed913834255..9780d350246 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -44,13 +44,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 26ea212043d..a511641e3c7 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; @@ -2085,14 +2085,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); @@ -2113,7 +2113,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); @@ -2126,7 +2126,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);
@@ -2135,7 +2135,7 @@ BOOL query_resize_start(HWND hwnd) sync_window_min_max_info(hwnd); send_message(hwnd, WM_ENTERSIZEMOVE, 0, 0);
- return TRUE; + return true; }
@@ -2144,11 +2144,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; }
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/clipboard.c | 8 -------- dlls/winemac.drv/display.c | 7 +------ dlls/winemac.drv/event.c | 6 +----- 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 | 7 +------ 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 | 9 +-------- dlls/winemac.drv/window.c | 9 +-------- 14 files changed, 19 insertions(+), 68 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index c745be73484..2094558bb41 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -27,15 +27,7 @@ #endif
#include "config.h" - -#include "ntstatus.h" -#define WIN32_NO_STATUS #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 8b012379b2e..e07b0fac0b5 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -24,13 +24,8 @@ #endif
#include "config.h" - #include "macdrv.h" -#include "winuser.h" -#include "winreg.h" -#include "ddrawi.h" -#define WIN32_NO_STATUS -#include "winternl.h" +
WINE_DEFAULT_DEBUG_CHANNEL(display);
diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 2998e2e364d..f7288b8d1b6 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -25,14 +25,10 @@ #endif
#include "config.h" +#include "macdrv.h"
#include <poll.h>
-#include "ntstatus.h" -#define WIN32_NO_STATUS -#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 2ef941aedb4..7c2ec2b2aa4 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 eb5939ce438..bc30c163488 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 7c49be7849f..39191d3cdf2 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 54c1278bc2f..570b1eac5c7 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -29,14 +29,27 @@
#include "macdrv_cocoa.h"
+/* All Windows headers needed by Unix C/ObjC files must be included here. */ #include "ntstatus.h" #define WIN32_NO_STATUS #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 9780d350246..9061fb1aae5 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -25,16 +25,11 @@ #endif
#include "config.h" +#include "macdrv.h"
#include <Security/AuthSession.h> #include <IOKit/pwr_mgt/IOPMLib.h>
-#include "ntstatus.h" -#define WIN32_NO_STATUS -#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 c655f56bd98..00ec9fcf25a 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 e60fc04a82e..c84be256cf1 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 a849918dfa7..7c49309d234 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 d146a45e351..74f33767cff 100644 --- a/dlls/winemac.drv/vulkan.c +++ b/dlls/winemac.drv/vulkan.c @@ -26,19 +26,12 @@ #endif
#include "config.h" +#include "macdrv.h"
#include <stdarg.h> #include <stdio.h> #include <dlfcn.h>
-#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "macdrv.h" -#include "wine/debug.h" - -#include "wine/vulkan.h" -#include "wine/vulkan_driver.h" - WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
static const struct vulkan_driver_funcs macdrv_vulkan_driver_funcs; diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index a511641e3c7..77c80d2429b 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);
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 570b1eac5c7..6111577c02c 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" #define WIN32_NO_STATUS @@ -51,6 +55,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; @@ -97,8 +113,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);
/************************************************************************** @@ -135,14 +149,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); @@ -152,24 +166,24 @@ 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 BOOL macdrv_CreateWindowSurface(HWND hwnd, BOOL layered, const RECT *surface_rect, struct window_surface **surface); +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 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); 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_ImeProcessKey(HIMC himc, UINT wparam, UINT lparam, const BYTE *state); @@ -179,10 +193,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);
@@ -358,4 +372,5 @@ static inline UINT asciiz_to_unicode(WCHAR *dst, const char *src) return (p - dst) * sizeof(WCHAR); }
+#undef BOOL #endif /* __WINE_MACDRV_H */
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 6111577c02c..255e45cc3f3 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -67,6 +67,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 c84be256cf1..5f47f629f7b 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);
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 f6ba2b4414e..47468837218 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -144,6 +144,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 b0b5120718d..970065dee6b 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 372d89381f1..a458f80efd7 100644 --- a/dlls/winemac.drv/cocoa_display.m +++ b/dlls/winemac.drv/cocoa_display.m @@ -18,13 +18,13 @@ * 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> #ifdef HAVE_MTLDEVICE_REGISTRYID #import <Metal/Metal.h> #endif -#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 cc120e4c7dc..c0b4fdc1e95 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -18,12 +18,14 @@ * 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 <libkern/OSAtomic.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 ac42db124e9..8c734a63f8c 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 255e45cc3f3..3bd9c3526ba 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -77,6 +77,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 71cc0bae04d..cae31eea616 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -208,6 +208,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); @@ -218,10 +220,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 {
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 c0b4fdc1e95..cd6ae77963f 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -32,6 +32,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 8c734a63f8c..a238da52380 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)
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/ntdll/unix/debug.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/debug.c b/dlls/ntdll/unix/debug.c index 5ec9d80f2c2..8021308f051 100644 --- a/dlls/ntdll/unix/debug.c +++ b/dlls/ntdll/unix/debug.c @@ -63,12 +63,24 @@ static int nb_debug_options = -1; static int options_size; static struct __wine_debug_channel *debug_options;
+static pthread_key_t non_wine_thread_debug_info_key; + static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" };
/* get the debug info pointer for the current thread */ static inline struct debug_info *get_info(void) { if (!init_done) return &initial_info; + if (!NtCurrentTeb()) + { + struct debug_info *info = pthread_getspecific( non_wine_thread_debug_info_key ); + if (!info) + { + info = calloc( 1, sizeof(struct debug_info) ); + pthread_setspecific( non_wine_thread_debug_info_key, info ); + } + return info; + } #ifdef _WIN64 return (struct debug_info *)((TEB32 *)((char *)NtCurrentTeb() + teb_offset) + 1); #else @@ -333,7 +345,7 @@ int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_ /* only print header if we are at the beginning of the line */ if (info->out_pos) return 0;
- if (init_done) + if (init_done && NtCurrentTeb()) { if (TRACE_ON(timestamp)) { @@ -367,6 +379,7 @@ void dbg_init(void) free( debug_options ); debug_options = options; options[nb_debug_options] = default_option; + pthread_key_create( &non_wine_thread_debug_info_key, free ); init_done = TRUE; }
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 47468837218..2c65dff5aa9 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) -
enum { WineApplicationEventWakeQuery, diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 970065dee6b..4dafa5badcc 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)
@@ -2357,30 +2354,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 cd6ae77963f..855f5138cc3 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -194,7 +194,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 @@ -263,9 +263,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 a238da52380..52ca61653c6 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -1543,7 +1543,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 3bd9c3526ba..255e45cc3f3 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -77,11 +77,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 cae31eea616..f59fdcc861e 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -112,7 +112,6 @@
/* main */ -extern bool macdrv_err_on; extern int topmost_float_inactive; extern bool capture_displays_for_fullscreen; extern bool left_option_is_alt; @@ -208,8 +207,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 9061fb1aae5..add9d015f6a 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -435,7 +435,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");
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 add9d015f6a..63f35a449f1 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -71,25 +71,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; }
How hard would it be to initialize a proper wine thread for the main thread?
I think it would make many things easier in winemac and not just traces.
On Tue Nov 18 07:04:46 2025 +0000, Rémi Bernon wrote:
How hard would it be to initialize a proper wine thread for the main thread? I think it would make many things easier in winemac and not just traces.
About a year ago I spent a while trying to make that work--my basic plan was to refactor NtCreateThreadEx so that rather than creating a new pthread, `start_thread` would be run by the main thread's runloop and then would do a unix call to a function that ran another runloop. This would run quite early (right after `signal_init_process()`) so that everything could assume that the main thread was a Wine thread, and winemac would be able to start its Cocoa runloop on the main thread later.
For text-mode apps this worked, but running GUI apps would deadlock in `loader_init()`. IIRC loading imported DLLs would end up with win32u trying to load+initialize winemac, which would then block trying to start its runloop on the main thread, which is stuck trying to load winemac...
I did see the `THREAD_CREATE_FLAGS_SKIP_LOADER_INIT` flag added recently, that could be a solution. I also wonder whether anticheats would be suspicious of a mysterious extra Win32 thread running that they didn't start.
But even if we can get that working in the future, the non-Wine thread debug logging could still be nice to have (audio threads on Mac come to mind).
On Tue Nov 18 07:04:46 2025 +0000, Brendan Shanks wrote:
About a year ago I spent a while trying to make that work--my basic plan was to refactor NtCreateThreadEx so that rather than creating a new pthread, `start_thread` would be run by the main thread's runloop and then would do a unix call to a function that ran another runloop. This would run quite early (right after `signal_init_process()`) so that everything could assume that the main thread was a Wine thread, and winemac would be able to start its Cocoa runloop on the main thread later. For text-mode apps this worked, but running GUI apps would deadlock in `loader_init()`. IIRC loading imported DLLs would end up with win32u trying to load+initialize winemac, which would then block trying to start its runloop on the main thread, which is stuck trying to load winemac... I did see the `THREAD_CREATE_FLAGS_SKIP_LOADER_INIT` flag added recently, that could be a solution. I also wonder whether anticheats would be suspicious of a mysterious extra Win32 thread running that they didn't start. But even if we can get that working in the future, the non-Wine thread debug logging could still be nice to have (audio threads on Mac come to mind).
Okay, I don't have a strong opinion (although I would be very happy to get rid of non-Wine threads) and I think this MR is mostly up to @julliard appreciation.
Note that __wine_dbg_get_channel_flags will call and require NtCurrentTeb() on the very first trace call, so that cannot be coming from a non-Wine thread (even if it's unlikely to be).