Address PR review feedback

This commit is contained in:
Alexey Shurygin
2026-03-15 01:33:38 +03:00
parent b66c6c4932
commit 827c8dd614
2 changed files with 9 additions and 3 deletions

View File

@@ -844,6 +844,8 @@ has_apple_fn_global_shortcut(void) {
NSDictionary *hitoolbox_settings = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.HIToolbox"]; NSDictionary *hitoolbox_settings = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.HIToolbox"];
id obj = [hitoolbox_settings objectForKey:@"AppleFnUsageType"]; id obj = [hitoolbox_settings objectForKey:@"AppleFnUsageType"];
if (![obj isKindOfClass:[NSNumber class]]) return false; if (![obj isKindOfClass:[NSNumber class]]) return false;
// Non-zero AppleFnUsageType means macOS has reserved Fn/Globe for a
// system action such as input source switching, emoji picker, or dictation.
return [obj integerValue] != 0; return [obj integerValue] != 0;
} }

View File

@@ -47,6 +47,7 @@ class TestBuild(BaseTest):
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#import <dlfcn.h> #import <dlfcn.h>
#import <objc/runtime.h> #import <objc/runtime.h>
#import <objc/message.h>
static int start_calls = 0; static int start_calls = 0;
static int stop_calls = 0; static int stop_calls = 0;
@@ -91,7 +92,9 @@ class TestBuild(BaseTest):
require_true(view_cls != Nil, "GLFWContentView class not loaded"); require_true(view_cls != Nil, "GLFWContentView class not loaded");
require_true(context_cls != Nil, "GLFWTextInputContext class not loaded"); require_true(context_cls != Nil, "GLFWTextInputContext class not loaded");
id view = [[view_cls alloc] initWithFrame:NSMakeRect(0, 0, 10, 10)]; SEL init_with_glfw_window = NSSelectorFromString(@"initWithGlfwWindow:");
id view = ((id (*)(id, SEL, void *)) objc_msgSend)([view_cls alloc], init_with_glfw_window, NULL);
require_true(view != nil, "GLFWContentView initWithGlfwWindow: failed");
require_true([view respondsToSelector:start], "GLFWContentView does not expose startDictation:"); require_true([view respondsToSelector:start], "GLFWContentView does not expose startDictation:");
require_true([view respondsToSelector:stop], "GLFWContentView does not expose stopDictation:"); require_true([view respondsToSelector:stop], "GLFWContentView does not expose stopDictation:");
@@ -106,8 +109,9 @@ class TestBuild(BaseTest):
require_true(start_calls == 2, "doCommandBySelector:startDictation: was swallowed"); require_true(start_calls == 2, "doCommandBySelector:startDictation: was swallowed");
require_true(last_sender == view, "doCommandBySelector:startDictation: should forward self as sender"); require_true(last_sender == view, "doCommandBySelector:startDictation: should forward self as sender");
id context = [[context_cls alloc] initWithClient:view]; id context = [view inputContext];
require_true(context != nil, "GLFWTextInputContext initWithClient: failed"); require_true(context != nil, "GLFWContentView inputContext missing");
require_true([context isKindOfClass:context_cls], "GLFWContentView inputContext has wrong class");
[context doCommandBySelector:stop]; [context doCommandBySelector:stop];
require_true(stop_calls == 1, "GLFWTextInputContext did not forward stopDictation:"); require_true(stop_calls == 1, "GLFWTextInputContext did not forward stopDictation:");
require_true(last_sender == nil, "GLFWTextInputContext should forward nil sender"); require_true(last_sender == nil, "GLFWTextInputContext should forward nil sender");