Skip to content

Commit

Permalink
Fix for splitview
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Apr 7, 2020
1 parent 3ae5ed8 commit e974859
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Blink/KBTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ class KBTracker {
let isLocal = userInfo[UIResponder.keyboardIsLocalUserInfoKey] as? Bool,
isLocal // we reconfigure kb only for local notifications
else {
if notification.userInfo?[UIResponder.keyboardIsLocalUserInfoKey] as? Bool == false {
self.input?.reportFocus(false)
}
// if notification.userInfo?[UIResponder.keyboardIsLocalUserInfoKey] as? Bool == false {
// self.input?.reportFocus(false)
// }
return
}

Expand Down
29 changes: 16 additions & 13 deletions Blink/SmarterKeys/SmarterTermInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class SmarterTermInput: KBWebView {

super.init(frame: frame, configuration: configuration)

// self.allowDisplayingKeyboardWithoutUserAction()
kbView.keyInput = self
kbView.lang = textInputMode?.primaryLanguage ?? ""

Expand Down Expand Up @@ -97,19 +98,8 @@ class SmarterTermInput: KBWebView {
override func layoutSubviews() {
super.layoutSubviews()

guard
let scene = window?.windowScene
else {
return
}

if traitCollection.userInterfaceIdiom == .phone {
kbView.traits.isPortrait = scene.interfaceOrientation.isPortrait
} else if kbView.traits.isFloatingKB {
kbView.traits.isPortrait = true
} else {
kbView.traits.isPortrait = scene.interfaceOrientation.isPortrait
}

kbView.setNeedsLayout()
}

private var _caretHider: CaretHider? = nil
Expand Down Expand Up @@ -245,7 +235,20 @@ class SmarterTermInput: KBWebView {

var needToReload = false
defer {

kbView.traits = traits

if let scene = window?.windowScene {
if traitCollection.userInterfaceIdiom == .phone {
kbView.traits.isPortrait = scene.interfaceOrientation.isPortrait
} else if kbView.traits.isFloatingKB {
kbView.traits.isPortrait = true
} else {
kbView.traits.isPortrait = scene.interfaceOrientation.isPortrait
}
}


if needToReload {
DispatchQueue.main.async {
self._refreshInputViews()
Expand Down
11 changes: 10 additions & 1 deletion KB/Native/Views/KBWebViewBase.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ @implementation KBWebViewBase {
NSArray<UIKeyCommand *> *_keyCommands;
NSString *_jsPath;
NSString *_interopName;
BOOL _focused;

KeyCommand *_activeModsCommand;
NSArray<KeyCommand *> *_imeGuardCommands;
Expand All @@ -85,6 +86,7 @@ - (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguratio
_keyCommands = @[];
_jsPath = @"_onKB";
_interopName = @"_kb";
_focused = YES;
[self.configuration.userContentController addScriptMessageHandler:self name:_interopName];
self.configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeDesktop;
// [self.configuration.preferences setJavaScriptCanOpenWindowsAutomatically:true];
Expand Down Expand Up @@ -196,7 +198,13 @@ - (void)_imeGuardDown:(KeyCommand *)cmd {
}

- (id)_inputDelegate { return self; }
- (int)_webView:(WKWebView *)webView decidePolicyForFocusedElement:(id) info { return 1; }
- (int)_webView:(WKWebView *)webView decidePolicyForFocusedElement:(id) info {
return _focused ? 1 : 0;
}

//- (_Bool)_webView:(WKWebView *)arg1 focusShouldStartInputSession:(id)arg2 {
// return NO;
//}

- (BOOL)becomeFirstResponder {
BOOL res = [super becomeFirstResponder];
Expand All @@ -207,6 +215,7 @@ - (BOOL)becomeFirstResponder {
}

- (void)reportFocus:(BOOL) value {
_focused = value;
[self report:@"focus" arg:value ? @"true" : @"false"];
}

Expand Down
4 changes: 2 additions & 2 deletions Resources/hterm_all.min.js

Large diffs are not rendered by default.

0 comments on commit e974859

Please sign in to comment.