Skip to content

Commit

Permalink
Add a workaround for non-GUI programs that do not use run-loops.
Browse files Browse the repository at this point in the history
  • Loading branch information
vovkasm committed May 23, 2015
1 parent 4d46c3c commit 4c86035
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions input_source_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ extern "C" {
static char buffer[1024];

const char* Xkb_Switch_getXkbLayout(const char* /* unused */) {
// Hack to update current input source for programs that do not use standard runloop (MacVim in console mode for ex)
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);

buffer[0] = '\0';
try {
InputSourceController ctrl;
Expand Down
6 changes: 5 additions & 1 deletion test.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

const char* Xkb_Switch_getXkbLayout(const char*);

int
main() {
printf("Result: %s\n", Xkb_Switch_getXkbLayout(""));
while (1) {
printf("Result: %s\n", Xkb_Switch_getXkbLayout(""));
sleep(1);
}
return 0;
}

0 comments on commit 4c86035

Please sign in to comment.