retry grabbing

This commit is contained in:
Chrys 2019-10-04 17:08:27 +02:00
parent c50b64b2f1
commit ca5ce66f31
4 changed files with 85 additions and 76 deletions

View File

@ -36,10 +36,12 @@ class inputDriver():
return
def grabAllDevices(self):
if not self._initialized:
return
return True
return True
def ungrabAllDevices(self):
if not self._initialized:
return
return True
return True
def hasIDevices(self):
if not self._initialized:
return False

View File

@ -57,12 +57,14 @@ class inputManager():
if not self.noKeyPressed():
return
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
self.executeDeviceGrab = False
return
if self.env['runtime']['screenManager'].getCurrScreenIgnored():
self.ungrabAllDevices()
if self.ungrabAllDevices():
self.executeDeviceGrab = False
else:
self.grabAllDevices()
self.executeDeviceGrab = False
if self.grabAllDevices():
self.executeDeviceGrab = False
def sendKeys(self, keyMacro):
for e in keyMacro:
key = ''
@ -143,15 +145,17 @@ class inputManager():
def grabAllDevices(self):
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
try:
self.env['runtime']['inputDriver'].grabAllDevices()
return self.env['runtime']['inputDriver'].grabAllDevices()
except Exception as e:
pass
return False
return True
def ungrabAllDevices(self):
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
try:
self.env['runtime']['inputDriver'].ungrabAllDevices()
return self.env['runtime']['inputDriver'].ungrabAllDevices()
except Exception as e:
pass
return False
return True
def handlePlugInputDevice(self, eventData):
for deviceEntry in eventData:
self.env['runtime']['inputManager'].updateInputDevices(deviceEntry['device'])

View File

@ -48,7 +48,6 @@ class screenManager():
self.env['runtime']['screenDriver'].getSessionInformation()
except:
pass
def shutdown(self):
self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
def isCurrScreenIgnoredChanged(self):
@ -60,16 +59,13 @@ class screenManager():
if self.isCurrScreenIgnoredChanged():
self.env['runtime']['inputManager'].setExecuteDeviceGrab()
self.env['runtime']['inputManager'].handleDeviceGrab()
if self.isScreenChange():
self.changeBrailleScreen()
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
self.update(eventData, 'onScreenChange')
self.env['screen']['lastScreenUpdate'] = time.time()
else:
self.env['runtime']['outputManager'].interruptOutput()
def handleScreenUpdate(self, eventData):
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
self.updateScreenIgnored()

View File

@ -281,16 +281,18 @@ class driver(inputDriver):
self.iDevices[i].set_led(led , 1)
def grabAllDevices(self):
if not self._initialized:
return
return True
ok = True
for fd in self.iDevices:
self.grabDevice(fd)
ok = ok and self.grabDevice(fd)
return ok
def ungrabAllDevices(self):
if not self._initialized:
return
return True
ok = True
for fd in self.iDevices:
self.ungrabDevice(fd)
ok = ok and self.ungrabDevice(fd)
return ok
def createUInputDev(self, fd):
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
self.uDevices[fd] = None
@ -324,7 +326,7 @@ class driver(inputDriver):
self.createUInputDev(newDevice.fd)
def grabDevice(self, fd):
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
return
return True
try:
self.iDevices[fd].grab()
self.gDevices[fd] = True
@ -333,15 +335,20 @@ class driver(inputDriver):
self.gDevices[fd] = True
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
return False
return True
def ungrabDevice(self,fd):
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
return
return True
try:
self.gDevices[fd] = False
self.iDevices[fd].ungrab()
self.gDevices[fd] = False
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: ungrab device ('+ str(self.iDevices[fd].name) + ')',debug.debugLevel.INFO)
except:
pass
except IOError:
self.gDevices[fd] = False
except Exception as e:
return False
return True
def removeDevice(self,fd):
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device removed: ' + str(fd) + ' ' +str(self.iDevices[fd]),debug.debugLevel.INFO)
self.clearEventBuffer()