Skip to content

Commit 89a4586

Browse files
authored
Merge c1ef191 into d304ed0
2 parents d304ed0 + c1ef191 commit 89a4586

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

source/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,9 @@ def handlePowerStatusChange(self):
651651
import inputCore
652652
inputCore.initialize()
653653
import keyboardHandler
654+
import watchdog
654655
log.debug("Initializing keyboard handler")
655-
keyboardHandler.initialize()
656+
keyboardHandler.initialize(watchdog.WatchdogObserver())
656657
import mouseHandler
657658
log.debug("initializing mouse handler")
658659
mouseHandler.initialize()
@@ -692,7 +693,6 @@ def handlePowerStatusChange(self):
692693
# Queue the handling of initial focus,
693694
# as API handlers might need to be pumped to get the first focus event.
694695
queueHandler.queueFunction(queueHandler.eventQueue, _setInitialFocus)
695-
import watchdog
696696
import baseObject
697697

698698
# Doing this here is a bit ugly, but we don't want these modules imported

source/keyboardHandler.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import core
3030
from contextlib import contextmanager
3131
import threading
32-
32+
_watchdogObserver = None
3333
ignoreInjected=False
3434

3535
# Fake vk codes.
@@ -195,6 +195,10 @@ def internal_keyDownEvent(vkCode,scanCode,extended,injected):
195195
currentModifiers.discard(stickyNVDAModifier)
196196
stickyNVDAModifier = None
197197

198+
if _watchdogObserver._get_isAttemptingRecovery():
199+
# When attempting recovery only process modifiers, but do not execute gesture.
200+
return True
201+
198202
try:
199203
inputCore.manager.executeGesture(gesture)
200204
gestureExecuted=True
@@ -208,6 +212,8 @@ def internal_keyDownEvent(vkCode,scanCode,extended,injected):
208212
except:
209213
log.error("internal_keyDownEvent", exc_info=True)
210214
finally:
215+
if _watchdogObserver._get_isAttemptingRecovery():
216+
return True
211217
# #6017: handle typed characters in Win10 RS2 and above where we can't detect typed characters in-process
212218
# This code must be in the 'finally' block as code above returns in several places yet we still want to execute this particular code.
213219
focus=api.getFocusObject()
@@ -275,8 +281,10 @@ def internal_keyUpEvent(vkCode,scanCode,extended,injected):
275281

276282
#Register internal key press event with operating system
277283

278-
def initialize():
284+
def initialize(watchdogObserver=None):
279285
"""Initialises keyboard support."""
286+
global _watchdogObserver
287+
_watchdogObserver = watchdogObserver
280288
winInputHook.initialize()
281289
winInputHook.setCallbacks(keyDown=internal_keyDownEvent,keyUp=internal_keyUpEvent)
282290

source/watchdog.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,8 @@ def cancellableSendMessage(hwnd, msg, wParam, lParam, flags=0, timeout=60000):
370370
result = ctypes.wintypes.DWORD()
371371
NVDAHelper.localLib.cancellableSendMessageTimeout(hwnd, msg, wParam, lParam, flags, timeout, ctypes.byref(result))
372372
return result.value
373+
374+
class WatchdogObserver:
375+
def _get_isAttemptingRecovery(self):
376+
global isAttemptingRecovery
377+
return isAttemptingRecovery

source/winInputHook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class MSLLHOOKSTRUCT(Structure):
4444

4545
@WINFUNCTYPE(c_long,c_int,WPARAM,LPARAM)
4646
def keyboardHook(code,wParam,lParam):
47-
if watchdog.isAttemptingRecovery or code!=HC_ACTION:
47+
if code != HC_ACTION:
4848
return windll.user32.CallNextHookEx(0,code,wParam,lParam)
4949
kbd=KBDLLHOOKSTRUCT.from_address(lParam)
5050
if keyUpCallback and kbd.flags&LLKHF_UP:

0 commit comments

Comments
 (0)