Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
9f311766
Commit
9f311766
authored
Nov 20, 2015
by
Craig Watson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed keyboard switching on Mac OS
parent
642d1546
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
UBPlatformUtils_mac.mm
src/frameworks/UBPlatformUtils_mac.mm
+19
-13
No files found.
src/frameworks/UBPlatformUtils_mac.mm
View file @
9f311766
...
...
@@ -533,29 +533,35 @@ QString UBPlatformUtils::urlFromClipboard()
void UBPlatformUtils::SetMacLocaleByIdentifier(const QString& id)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@autoreleasepool {
// convert id from QString to CFString
// TODO: clean this up
const QByteArray utf8 = id.toUtf8();
const char* cString = utf8.constData();
NSString * ns = [[NSString alloc] initWithUTF8String:cString];
const char * strName = id.toLatin1().data()
;
CFStringRef iName = (__bridge CFStringRef)ns
;
CFStringRef iName = CFStringCreateWithCString(NULL, strName, kCFStringEncodingISOLatin1 );
CFStringRef keys[] = { kTISPropertyInputSourceCategory,
kTISPropertyInputSourceID };
CFStringRef values[] = { kTISCategoryKeyboardInputSource,
iName };
CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 2
, NULL, NULL);
CFStringRef keys[] = {
kTISPropertyInputSourceID };
CFStringRef values[] = {
iName };
CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 1
, NULL, NULL);
// get list of current enabled keyboard layouts. dict filters the list
CFArrayRef kbds = TISCreateInputSourceList(dict, true);
if (kbds!=NULL)
{
if (CFArrayGetCount(kbds)!=0)
{
// get list of current enabled keyboard layouts. dict filters the list
// false specifies that we search only through the active input sources
CFArrayRef kbds = TISCreateInputSourceList(dict, false);
if (kbds && CFArrayGetCount(kbds) == 0)
// if not found in the active sources, we search again through all sources installed
kbds = TISCreateInputSourceList(dict, true);
if (kbds && CFArrayGetCount(kbds)!=0) {
TISInputSourceRef klRef = (TISInputSourceRef)CFArrayGetValueAtIndex(kbds, 0);
if (klRef!=NULL)
TISSelectInputSource(klRef);
}
}
[pool drain];
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment