X11Application: Ensure TIS operations are done on the main thread
Fixes: https://github.com/XQuartz/XQuartz/issues/205
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
(cherry picked from commit b1afcecc61
)
This commit is contained in:
parent
bd3564cf37
commit
663af2f17e
|
@ -1701,8 +1701,17 @@ handle_mouse:
|
|||
}
|
||||
|
||||
if (darwinSyncKeymap) {
|
||||
TISInputSourceRef key_layout =
|
||||
TISCopyCurrentKeyboardLayoutInputSource();
|
||||
__block TISInputSourceRef key_layout;
|
||||
dispatch_block_t copyCurrentKeyboardLayoutInputSource = ^{
|
||||
key_layout = TISCopyCurrentKeyboardLayoutInputSource();
|
||||
};
|
||||
/* This is an ugly ant-pattern, but it is more expedient to address the problem right now. */
|
||||
if (pthread_main_np()) {
|
||||
copyCurrentKeyboardLayoutInputSource();
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), copyCurrentKeyboardLayoutInputSource);
|
||||
}
|
||||
|
||||
TISInputSourceRef clear;
|
||||
if (CFEqual(key_layout, last_key_layout)) {
|
||||
CFRelease(key_layout);
|
||||
|
|
Loading…
Reference in New Issue