27 Commits

Author SHA1 Message Date
gxalpha ba84bea46d libobs: Rewrite macOS Hotkeys to use CGEventTap
Using CGEventTapCreate instead of addGlobalMonitorForEventsMatchingMask
to listen to global hotkeys has the advantage of tighter control over
what permissions we need. Since we only listen to and do not modify the
event, it is enough to have "Input Monitoring" instead of the full
"Accessibility" (which would allow modifying the event after catching
it).
2025-02-05 14:33:06 -05:00
izwb003 48dad45ed5 libobs: Fix deadlock on macOS input method change 2025-01-04 12:23:21 +01:00
gxalpha 71775e3619 libobs: Assure large enough buffer in dstr_from_cfstring
Per the documentation of CFStringGetCString, the buffer provided must be
large enough not just for the string itself, but also for a NUL
terminator. This space for the NUL terminator is currently ignored, and
we just get lucky that CFStringGetMaximumSizeForEncoding often
dramatically overestimates the space required. However, it is possible
to actually hit the maximum with the string itself (for example by using
strings that contain exclusively Chinese characters such as "我"), in
which case the conversion fails. Adding the extra byte for the NUL
terminator fixes this.
At this point, we can also safely assert that our max_size is larger
than zero, silencing a clang analyzer warning that now is no longer
valid.
2024-10-04 13:36:09 -04:00
gxalpha 4420594729 libobs: Remove unused is_in_bundle() method 2024-10-03 17:09:54 -04:00
PatTheMav 4dac84999d libobs: Update macOS platform implementation
Cleans up the source code by sorting functions by topic and also
removes macros for hotkey implementation, removing the need to disable
compiler warnings.

Key codes and descriptions are now contained in arrays which either
use the OBS key code or the macOS key code as lookup keys with all
necessary context information directly associated with the key.

The implementation also uses the zero-initialization rule for arrays
of structs in such a way that the struct's "is_valid" boolean is
"false" by default so that only values explicitly initialized with a
key are ever "valid".
2024-09-12 16:44:39 -04:00
jcm 66ff8cb6d3 libobs: Always explicitly check modifiers in macOS hotkey event handler 2024-08-11 09:44:28 +10:00
jcm 78b6cf16c3 libobs: Use aligned memory allocator in Cocoa logging 2024-01-05 15:38:06 -05:00
jcm 2b38069709 libobs: Log Mac model identifier 2024-01-05 15:38:06 -05:00
PatTheMav 7f8a55d0bb libobs: Fix warnings about implicit integer downcasts in macOS code 2023-08-31 17:52:08 -04:00
PatTheMav 7628265099 Update .clang-format rules for ObjC files for version 16 2023-08-10 17:12:30 -04:00
Lain 796e2d5815 Merge pull request #9339 from tytan652/prevent_simde_contamination
Contain simde diagnostic pragmas and replace variable-length arrays
2023-08-05 17:10:33 -07:00
PatTheMav 1b194c8ebd libobs: Add local event monitor for hotkey thread
To avoid a mismatch between the state of pressed keys as held by the
hotkey thread and keys pressed while the application is in focus, local
key events need to be monitored as well (even though they are already
handled by Cocoa's main event loop).
2023-08-05 16:48:53 -07:00
tytan652 54bacd4f10 libobs: Remove variable-length array 2023-08-06 01:31:02 +02:00
PatTheMav f8e00d6071 clang-format: Update formatting of all ObjC and ObjC++ files 2023-06-11 14:56:45 +02:00
PatTheMav ee1ec26de3 libobs: Use native ObjectiveC methods to generate data and module paths 2023-05-13 16:56:11 -07:00
derrod b3cf98f230 libobs: Fix compiling in ISO C17 mode 2023-04-08 19:30:12 -04:00
PatTheMav 349372b3b3 cmake: Add changes for CMake build framework 3.0
New code path only taken if OBS_CMAKE_VERSION is set to 3.0.0 or
greater, old functionality remains unchanged.
2023-03-26 18:20:38 -04:00
Tommy Vercetti eb93011463 libobs: Log macOS Rosetta status 2022-11-09 03:03:26 -08:00
Tommy Vercetti 90b705fcbc libobs: Rename "Mac OS X" to "macOS" in log 2022-07-28 14:04:01 -04:00
Theodore Dubois 0032d349c9 libobs: Rewrite macOS hotkeys implementation
Co-authored-by: Sebastian Beckmann <beckmann.sebastian@outlook.de>
2022-07-26 14:21:21 +02:00
PatTheMav 1fd7770548 libobs: Update CMakeLists.txt for libobs and associated libraries
Also updates libobs-opengl, libobs-d3d11, libobs-winrt
2022-03-16 23:11:08 +01:00
Theodore Dubois 7852efcba6 libobs: Cleanup uses of objc_msgSend in Objective-C code
Also remove use of deprecated [NSProcessInfo operatingSystem]. It always
returns the NSMACHOperatingSystem.

Also stop parsing [NSProcessInfo operatingSystemVersionString]. The
documentation explicitly says "not for parsing".
2021-01-12 10:10:37 -08:00
jpark37 6aa50b3ef1 libobs: Use autoreleasepool for graphics thread
Apparently necessary to clean up macOS leaks.
2020-06-08 13:16:35 -07:00
Colin Edwards b7b202fac7 libobs: Fix plugin folder search path case on macOS 2020-04-16 19:28:00 -05:00
jp9000 d002345a11 libobs: Fix macOS 10.15 hotkey crash (temporary)
On 10.15, if a user activates secure input of some sort, the hotkey code
will begin to crash inside of any Apple function related to hotkeys,
even after secure input has ended.  This does not appear to be the fault
of OBS; the reason to this is still as of yet unknown, but is suspected
to be a bug inside of Apple code that's a new regression as of 10.15.

So for the time being as a temporary solution to the crash, simply
disable external hotkey support once secure input has been detected.

Because of this issue, the hotkey code should probably be replaced by a
different method of tracking hotkeys, perhaps InstallEventHandler for
example.  This commit is little more than a bandaid to the crash.
2020-03-31 10:40:17 -07:00
Colin Edwards 1819696198 libobs: Null check hotkey device on macos 2019-12-13 23:26:34 -06:00
Colin Edwards 747ce9b77c libobs: Use proper resource paths when running from an OSX bundle 2019-10-13 21:53:43 -05:00