summaryrefslogtreecommitdiff
path: root/src/ios.m
diff options
context:
space:
mode:
Diffstat (limited to 'src/ios.m')
-rw-r--r--src/ios.m32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/ios.m b/src/ios.m
index 82596ffd..68c03827 100644
--- a/src/ios.m
+++ b/src/ios.m
@@ -163,7 +163,8 @@ API_AVAILABLE(ios(13.0))
163 163
164/*----------------------------------------------------------------------------------------------*/ 164/*----------------------------------------------------------------------------------------------*/
165 165
166@interface AppState : NSObject<UIDocumentPickerDelegate, UITextFieldDelegate, UITextViewDelegate> { 166@interface AppState : NSObject<UIDocumentPickerDelegate, UITextFieldDelegate, UITextViewDelegate,
167 UIScrollViewDelegate> {
167 iString *fileBeingSaved; 168 iString *fileBeingSaved;
168 iString *pickFileCommand; 169 iString *pickFileCommand;
169 iSystemTextInput *sysCtrl; 170 iSystemTextInput *sysCtrl;
@@ -173,6 +174,7 @@ API_AVAILABLE(ios(13.0))
173@end 174@end
174 175
175static AppState *appState_; 176static AppState *appState_;
177static UIScrollView *statusBarTapper_; /* dummy scroll view just for getting notified of taps */
176 178
177@implementation AppState 179@implementation AppState
178 180
@@ -310,8 +312,15 @@ replacementString:(NSString *)string {
310 notifyChange_SystemTextInput_(sysCtrl); 312 notifyChange_SystemTextInput_(sysCtrl);
311} 313}
312 314
315- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
316 postCommand_App("scroll.top smooth:1");
317 return NO;
318}
319
313@end 320@end
314 321
322/*----------------------------------------------------------------------------------------------*/
323
315static void enableMouse_(iBool yes) { 324static void enableMouse_(iBool yes) {
316 SDL_EventState(SDL_MOUSEBUTTONDOWN, yes); 325 SDL_EventState(SDL_MOUSEBUTTONDOWN, yes);
317 SDL_EventState(SDL_MOUSEMOTION, yes); 326 SDL_EventState(SDL_MOUSEMOTION, yes);
@@ -426,6 +435,19 @@ void setupWindow_iOS(iWindow *window) {
426 UIViewController *ctl = viewController_(window); 435 UIViewController *ctl = viewController_(window);
427 isSystemDarkMode_ = isDarkMode_(window); 436 isSystemDarkMode_ = isDarkMode_(window);
428 postCommandf_App("~os.theme.changed dark:%d contrast:1", isSystemDarkMode_ ? 1 : 0); 437 postCommandf_App("~os.theme.changed dark:%d contrast:1", isSystemDarkMode_ ? 1 : 0);
438 /* A hack to get notified on status bar taps. We create a thin dummy UIScrollView
439 that occupies the top of the screen where the status bar is located. */ {
440 CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
441 statusBarTapper_ = [[UIScrollView alloc] initWithFrame:statusBarFrame];
442// [statusBarTapper_ setBackgroundColor:[UIColor greenColor]]; /* to see where it is */
443 [statusBarTapper_ setShowsVerticalScrollIndicator:NO];
444 [statusBarTapper_ setShowsHorizontalScrollIndicator:NO];
445 [statusBarTapper_ setContentSize:(CGSize){ 10000, 10000 }];
446 [statusBarTapper_ setContentOffset:(CGPoint){ 0, 1000 }];
447 [statusBarTapper_ setScrollsToTop:YES];
448 [statusBarTapper_ setDelegate:appState_];
449 [ctl.view addSubview:statusBarTapper_];
450 }
429} 451}
430 452
431void playHapticEffect_iOS(enum iHapticEffect effect) { 453void playHapticEffect_iOS(enum iHapticEffect effect) {
@@ -443,6 +465,14 @@ void playHapticEffect_iOS(enum iHapticEffect effect) {
443} 465}
444 466
445iBool processEvent_iOS(const SDL_Event *ev) { 467iBool processEvent_iOS(const SDL_Event *ev) {
468 if (ev->type == SDL_DISPLAYEVENT) {
469 if (deviceType_App() == phone_AppDeviceType) {
470 [statusBarTapper_ setHidden:(ev->display.data1 == SDL_ORIENTATION_LANDSCAPE ||
471 ev->display.data1 == SDL_ORIENTATION_LANDSCAPE_FLIPPED)];
472 }
473 [statusBarTapper_ setFrame:[UIApplication sharedApplication].statusBarFrame];
474 return iFalse;
475 }
446 if (ev->type == SDL_WINDOWEVENT) { 476 if (ev->type == SDL_WINDOWEVENT) {
447 if (ev->window.event == SDL_WINDOWEVENT_RESTORED) { 477 if (ev->window.event == SDL_WINDOWEVENT_RESTORED) {
448 const iBool isDark = isDarkMode_(get_Window()); 478 const iBool isDark = isDarkMode_(get_Window());