diff options
| author | Jeremy Huddleston Sequoia <jeremyhu@apple.com> | 2022-06-12 22:06:01 -0700 |
|---|---|---|
| committer | Jeremy Huddleston Sequoia <jeremyhu@apple.com> | 2022-06-13 22:01:06 -0700 |
| commit | b1afcecc61d841f95e786e4f4f84184f91d149f1 (patch) | |
| tree | 044b8764e8ca84836ae4a7ca4d1cfa9562950177 | |
| parent | c11b55f3c0c64645bca964aece825de0bdd92b1f (diff) | |
| download | xserver-b1afcecc61d841f95e786e4f4f84184f91d149f1.tar.gz | |
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>
| -rw-r--r-- | hw/xquartz/X11Application.m | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 3db0b2487..a100f5a6f 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -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); |
