Skip to content

Commit 4cbf00a

Browse files
committed
[mac] improve UI, feature
1 parent f3b8cc3 commit 4cbf00a

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

Sources/OpenKey/macOS/ModernKey/OpenKey.mm

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535

3636
//app which error with unicode Compound
3737
NSArray* _unicodeCompoundApp = @[@"com.apple.",
38-
@"com.google.Chrome", @"com.brave.Browser", @"com.microsoft.Edge.Dev", @"com.microsoft.Edge", @"com.microsoft.edgemac.Dev"];
38+
@"com.google.Chrome", @"com.brave.Browser",
39+
@"com.microsoft.edgemac.Dev", @"com.microsoft.edgemac.Beta", @"com.microsoft.Edge.Dev", @"com.microsoft.Edge"];
3940

4041
CGEventSourceRef myEventSource = NULL;
4142
vKeyHookState* pData;
@@ -57,7 +58,8 @@
5758
Uint16 _uniChar[2];
5859
int _i, _j, _k;
5960
Uint32 _tempChar;
60-
61+
bool _hasJustUsedHotKey = false;
62+
6163
int _languageTemp = 0; //use for smart switch key
6264
vector<Byte> savedSmartSwitchKeyData; ////use for smart switch key
6365

@@ -517,37 +519,43 @@ CGEventRef OpenKeyCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef e
517519
if (GET_SWITCH_KEY(vSwitchKeyStatus) == _keycode && checkHotKey(vSwitchKeyStatus, GET_SWITCH_KEY(vSwitchKeyStatus) != 0xFE)){
518520
switchLanguage();
519521
_lastFlag = 0;
522+
_hasJustUsedHotKey = true;
520523
return NULL;
521524
}
522525
if (GET_SWITCH_KEY(convertToolHotKey) == _keycode && checkHotKey(convertToolHotKey, GET_SWITCH_KEY(convertToolHotKey) != 0xFE)){
523526
[appDelegate onQuickConvert];
524527
_lastFlag = 0;
528+
_hasJustUsedHotKey = true;
525529
return NULL;
526530
}
527531
}
532+
_hasJustUsedHotKey = _lastFlag != 0;
528533
} else if (type == kCGEventFlagsChanged) {
529534
if (_lastFlag == 0 || _lastFlag < _flag) {
530535
_lastFlag = _flag;
531536
} else if (_lastFlag > _flag) {
532-
//check temporarily turn off spell checking
533-
if (vTempOffSpelling && _lastFlag & kCGEventFlagMaskControl) {
534-
vTempOffSpellChecking();
535-
}
536-
if (vTempOffOpenKey && _lastFlag & kCGEventFlagMaskCommand) {
537-
vTempOffEngine();
538-
}
539537
//check switch
540538
if (checkHotKey(vSwitchKeyStatus, GET_SWITCH_KEY(vSwitchKeyStatus) != 0xFE)) {
541539
_lastFlag = 0;
542540
switchLanguage();
541+
_hasJustUsedHotKey = true;
543542
return NULL;
544543
}
545544
if (checkHotKey(convertToolHotKey, GET_SWITCH_KEY(convertToolHotKey) != 0xFE)) {
546545
_lastFlag = 0;
547546
[appDelegate onQuickConvert];
547+
_hasJustUsedHotKey = true;
548548
return NULL;
549549
}
550+
//check temporarily turn off spell checking
551+
if (vTempOffSpelling && !_hasJustUsedHotKey && _lastFlag & kCGEventFlagMaskControl) {
552+
vTempOffSpellChecking();
553+
}
554+
if (vTempOffOpenKey && !_hasJustUsedHotKey && _lastFlag & kCGEventFlagMaskCommand) {
555+
vTempOffEngine();
556+
}
550557
_lastFlag = 0;
558+
_hasJustUsedHotKey = false;
551559
}
552560
}
553561

Sources/OpenKey/macOS/ModernKey/ViewController.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ - (void)viewDidLoad {
5858
self.retryButton.enabled = NO;
5959

6060
NSRect parentRect = self.viewParent.frame;
61-
parentRect.size.height = 490;
61+
parentRect.size.height = 460;
6262
self.viewParent.frame = parentRect;
6363

6464
//set correct tabgroup
@@ -105,10 +105,10 @@ - (void)viewWillAppear {
105105
-(void)initKey {
106106
dispatch_async(dispatch_get_main_queue(), ^{
107107
if (![OpenKeyManager initEventTap]) {
108-
self.permissionWarning.hidden = NO;
109-
self.retryButton.enabled = YES;
108+
//self.permissionWarning.hidden = NO;
109+
//self.retryButton.enabled = YES;
110110
} else {
111-
self.appOK.hidden = NO;
111+
//self.appOK.hidden = NO;
112112
}
113113
});
114114
}

0 commit comments

Comments
 (0)