From abc449bec25da23c5af4bd9c8d81fb1305a897b2 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 13 May 2018 23:40:05 +0200 Subject: [PATCH] grab/ungrab on noKeyPressed() --- src/fenrirscreenreader/core/screenManager.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/fenrirscreenreader/core/screenManager.py b/src/fenrirscreenreader/core/screenManager.py index 29f2ed28..b58e0b98 100644 --- a/src/fenrirscreenreader/core/screenManager.py +++ b/src/fenrirscreenreader/core/screenManager.py @@ -12,6 +12,7 @@ class screenManager(): def __init__(self): self.currScreenIgnored = False self.prevScreenIgnored = False + self.toggleDeviceGrab = False def initialize(self, environment): self.env = environment self.env['runtime']['settingsManager'].loadDriver(\ @@ -40,15 +41,22 @@ class screenManager(): if not self.isSuspendingScreen(self.env['screen']['newTTY']): self.update(eventData, 'onScreenChange') self.env['screen']['lastScreenUpdate'] = time.time() + def handleDeviceGrab(self): + if self.getCurrScreenIgnored() != self.getPrevScreenIgnored(): + self.toggleDeviceGrab = True + if self.toggleDeviceGrab: + if self.env['runtime']['inputManager'].noKeyPressed(): + if self.getCurrScreenIgnored(): + self.env['runtime']['inputManager'].ungrabAllDevices() + self.env['runtime']['outputManager'].interruptOutput() + else: + self.env['runtime']['inputManager'].grabAllDevices() + self.toggleDeviceGrab = True + def handleScreenUpdate(self, eventData): self.env['screen']['oldApplication'] = self.env['screen']['newApplication'] self.updateScreenIgnored() - if self.getCurrScreenIgnored() != self.getPrevScreenIgnored(): - if self.getCurrScreenIgnored(): - self.env['runtime']['inputManager'].ungrabAllDevices() - self.env['runtime']['outputManager'].interruptOutput() - else: - self.env['runtime']['inputManager'].grabAllDevices() + self.handleDeviceGrab() if not self.getCurrScreenIgnored(): self.update(eventData, 'onScreenUpdate') #if trigger == 'onUpdate' or self.isScreenChange() \