Skip to content

Commit 7aec532

Browse files
committed
입력기가 변경되는 시점에 보안 입력 상태인 경우 영문 소문자 입력 상태로 초기화
1 parent d5a38cb commit 7aec532

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

SokIM/AppDelegate.swift

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
5959
name: NSTextInputContext.keyboardSelectionDidChangeNotification,
6060
object: nil
6161
)
62+
63+
// 입력기가 변경되는 시점에 보안 입력 상태인 경우 영문 소문자 입력 상태로 초기화
64+
NotificationCenter.default.addObserver(
65+
self,
66+
selector: #selector(abcOnSecureInput),
67+
name: NSTextInputContext.keyboardSelectionDidChangeNotification,
68+
object: nil
69+
)
70+
6271
}
6372

6473
func applicationWillTerminate(_ aNotification: Notification) {
@@ -145,6 +154,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
145154
}
146155
inputMonitor.flush()
147156
state = State(engine: state.engine)
157+
if getKeyboardCapsLock() {
158+
setKeyboardCapsLock(enabled: false)
159+
}
148160
eventContext = EventContext()
149161
}
150162

@@ -187,18 +199,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
187199
eventContext = interimEventContext
188200
}
189201

190-
// 별도 처리: 보안 입력 상태인 경우 Monitor가 작동하지 않음
191-
if IsSecureEventInputEnabled() {
192-
// Caps Lock 끄기
193-
setKeyboardCapsLock(enabled: false)
194-
195-
// modifier 끄기
196-
state.modifier.removeAll()
197-
198-
// OS가 대신 처리하도록 반환
199-
return false
200-
}
201-
202202
// 기존 state 보존
203203
let oldState = state
204204

@@ -331,5 +331,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {
331331
debug("ABC 입력기 제한 성공")
332332
}
333333
}
334+
335+
@objc private func abcOnSecureInput(_ aNotification: Notification) {
336+
debug("\(String(describing: aNotification))")
337+
338+
guard IsSecureEventInputEnabled() else { return }
339+
340+
state.engine = QwertyEngine.self
341+
statusBar.setEngine(QwertyEngine.self)
342+
343+
reset(nil)
344+
345+
debug("abcOnSecureInput 성공")
346+
}
334347
}
335348
// swiftlint:enable function_body_length

0 commit comments

Comments
 (0)