From 9f2929ee457cfa4db66e14aacff5417689ef543a Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sat, 25 Dec 2021 10:06:42 +0100 Subject: [PATCH] macOS platform: fix for issue #325 Disabling IM disables Greek and Cyrillic layouts Thanks to Pierre Ossman who gave the fix. --- src/Fl_cocoa.mm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index a77665b11..e53f4969c 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -141,8 +141,10 @@ typedef OSStatus (*TSMSetDocumentProperty_type)(TSMDocumentID, OSType, UInt32, v static TSMSetDocumentProperty_type TSMSetDocumentProperty; typedef OSStatus (*TSMRemoveDocumentProperty_type)(TSMDocumentID, OSType); static TSMRemoveDocumentProperty_type TSMRemoveDocumentProperty; -typedef CFArrayRef (*TISCreateASCIICapableInputSourceList_type)(void); -static TISCreateASCIICapableInputSourceList_type TISCreateASCIICapableInputSourceList; +typedef CFArrayRef (*TISCreateInputSourceList_type)(CFDictionaryRef, Boolean); +static TISCreateInputSourceList_type TISCreateInputSourceList; +static CFStringRef kTISTypeKeyboardLayout; +static CFStringRef kTISPropertyInputSourceType; typedef void (*KeyScript_type)(short); static KeyScript_type KeyScript; @@ -1673,7 +1675,12 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; else { CFArrayRef inputSources; - inputSources = TISCreateASCIICapableInputSourceList(); + CFDictionaryRef filter; + filter = CFDictionaryCreate(NULL, (const void **)kTISPropertyInputSourceType, + (const void **)kTISTypeKeyboardLayout, + 1, NULL, NULL); + inputSources = TISCreateInputSourceList(filter, false); + CFRelease(filter); TSMSetDocumentProperty(doc, kTSMDocumentEnabledInputSourcesPropertyTag, sizeof(CFArrayRef), &inputSources); CFRelease(inputSources); @@ -1954,8 +1961,10 @@ static int input_method_startup() TSMGetActiveDocument = (TSMGetActiveDocument_type)Fl_X::get_carbon_function("TSMGetActiveDocument"); TSMSetDocumentProperty = (TSMSetDocumentProperty_type)Fl_X::get_carbon_function("TSMSetDocumentProperty"); TSMRemoveDocumentProperty = (TSMRemoveDocumentProperty_type)Fl_X::get_carbon_function("TSMRemoveDocumentProperty"); - TISCreateASCIICapableInputSourceList = (TISCreateASCIICapableInputSourceList_type)Fl_X::get_carbon_function("TISCreateASCIICapableInputSourceList"); - retval = (TSMGetActiveDocument && TSMSetDocumentProperty && TSMRemoveDocumentProperty && TISCreateASCIICapableInputSourceList ? 1 : 0); + TISCreateInputSourceList = (TISCreateInputSourceList_type)Fl_X::get_carbon_function("TISCreateInputSourceList"); + kTISTypeKeyboardLayout = (CFStringRef)Fl_X::get_carbon_function("kTISTypeKeyboardLayout"); + kTISPropertyInputSourceType = (CFStringRef)Fl_X::get_carbon_function("kTISPropertyInputSourceType"); + retval = (TSMGetActiveDocument && TSMSetDocumentProperty && TSMRemoveDocumentProperty && TISCreateInputSourceList && kTISTypeKeyboardLayout && kTISPropertyInputSourceType ? 1 : 0); } else { KeyScript = (KeyScript_type)Fl_X::get_carbon_function("KeyScript"); retval = (KeyScript? 1 : 0);