iOS: fix screen black flickers and queue UI api calls to the main thread
This commit is contained in:
@@ -41,8 +41,10 @@ void App::showKeyboard()
|
||||
LOG("show keyboard");
|
||||
redraw = true;
|
||||
#ifdef __IOS__
|
||||
[ios_view registerForKeyboardNotifications];
|
||||
[ios_view becomeFirstResponder];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view registerForKeyboardNotifications];
|
||||
[ios_view becomeFirstResponder];
|
||||
});
|
||||
#elif __ANDROID__
|
||||
displayKeyboard(and_app, true);
|
||||
#endif
|
||||
@@ -53,8 +55,10 @@ void App::hideKeyboard()
|
||||
LOG("hide keyboard");
|
||||
redraw = true;
|
||||
#ifdef __IOS__
|
||||
[ios_view resignFirstResponder];
|
||||
// [ios_view unregisterForKeyboardNotifications];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view resignFirstResponder];
|
||||
// [ios_view unregisterForKeyboardNotifications];
|
||||
});
|
||||
#elif __ANDROID__
|
||||
displayKeyboard(and_app, false);
|
||||
#endif
|
||||
@@ -64,7 +68,9 @@ void App::pick_image(std::function<void(std::string path)> callback)
|
||||
{
|
||||
redraw = true;
|
||||
#ifdef __IOS__
|
||||
[ios_view pick_photo:callback];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view pick_photo:callback];
|
||||
});
|
||||
#elif __OSX__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSArray* fileTypes = [NSArray arrayWithObjects:@"png", @"PNG", @"jpg", @"JPG", @"jpeg", nil];
|
||||
@@ -87,7 +93,9 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
|
||||
#ifdef __IOS__
|
||||
// not implemented on ios
|
||||
// fallback to pick_image
|
||||
[ios_view pick_photo:callback];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view pick_photo:callback];
|
||||
});
|
||||
#elif __OSX__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//NSArray* fileTypes = [NSArray arrayWithObjects:@"ppi", @"PPI", nil];
|
||||
@@ -147,7 +155,9 @@ void App::pick_dir(std::function<void(std::string path)> callback)
|
||||
void App::display_file(std::string path)
|
||||
{
|
||||
#ifdef __IOS__
|
||||
[ios_view display_file:path];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view display_file:path];
|
||||
});
|
||||
#elif __OSX__
|
||||
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithUTF8String:path.c_str()]];
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
Reference in New Issue
Block a user