From 598ef8d96cbbb7cd7694e618e919eb92f067f664 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 29 Sep 2016 23:11:57 +0200 Subject: [PATCH] fix playing change screen sound, directly bypass keypress on ignorescreen --- src/fenrir-package/core/screenManager.py | 7 ++++--- src/fenrir-package/fenrir.py | 2 +- src/fenrir-package/screenDriver/linux.py | 14 ++++---------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/fenrir-package/core/screenManager.py b/src/fenrir-package/core/screenManager.py index c96fa4e0..a517cab3 100644 --- a/src/fenrir-package/core/screenManager.py +++ b/src/fenrir-package/core/screenManager.py @@ -22,10 +22,11 @@ class screenManager(): self.env['runtime']['settingsManager'].shutdownDriver('screenDriver') def update(self, trigger = 'onUpdate'): - self.env['screenData']['newTTY'] = self.env['runtime']['screenDriver'].getCurrScreen() - if trigger == 'onUpdate': - self.env['runtime']['applicationManager'].getCurrentApplication() + self.env['runtime']['screenDriver'].getCurrScreen() + if not self.isSuspendingScreen(): + if trigger == 'onUpdate': + self.env['runtime']['applicationManager'].getCurrentApplication() self.env['runtime']['screenDriver'].update(trigger) self.env['screenData']['lastScreenUpdate'] = time.time() diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index 23d85fe9..ba7d60bf 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -39,7 +39,7 @@ class fenrir(): eventReceived = self.environment['runtime']['inputManager'].getInputEvent() if eventReceived: self.prepareCommand() - if not (self.wasCommand or self.environment['runtime']['inputManager'].isFenrirKeyPressed() or self.environment['generalInformation']['tutorialMode']): + if not (self.wasCommand or self.environment['runtime']['inputManager'].isFenrirKeyPressed() or self.environment['generalInformation']['tutorialMode']) or self.environment['runtime']['screenManager'].isSuspendingScreen(): self.environment['runtime']['inputManager'].writeEventBuffer() if self.environment['runtime']['inputManager'].noKeyPressed(): diff --git a/src/fenrir-package/screenDriver/linux.py b/src/fenrir-package/screenDriver/linux.py index 7daef844..3f941b29 100644 --- a/src/fenrir-package/screenDriver/linux.py +++ b/src/fenrir-package/screenDriver/linux.py @@ -19,19 +19,18 @@ class driver(): return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) def getCurrScreen(self): - currScreen = '' + self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] try: currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r') - currScreen = currScreenFile.read()[3:-1] + self.env['screenData']['newTTY'] = str(currScreenFile.read()[3:-1]) currScreenFile.close() except Exception as e: self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) - return currScreen def getCurrApplication(self): apps = [] try: - currScreen = str(self.env['screenData']['newTTY']) + currScreen = self.env['screenData']['newTTY'] apps = subprocess.Popen('ps -t tty' + currScreen + ' -o comm,tty,stat', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n') except Exception as e: print(e) @@ -73,11 +72,10 @@ class driver(): def update(self, trigger='updateScreen'): - newTTY = '' newContentBytes = b'' try: # read screen - vcsa = open(self.vcsaDevicePath + newTTY,'rb',0) + vcsa = open(self.vcsaDevicePath + self.env['screenData']['newTTY'],'rb',0) newContentBytes = vcsa.read() vcsa.close() if len(newContentBytes) < 5: @@ -92,10 +90,6 @@ class driver(): self.env['screenData']['oldContentTextAttrib'] = self.env['screenData']['newContentAttrib'] self.env['screenData']['oldCursor']['x'] = self.env['screenData']['newCursor']['x'] self.env['screenData']['oldCursor']['y'] = self.env['screenData']['newCursor']['y'] - if self.env['screenData']['oldTTY'] == '-1': - self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] - else: - self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta'] self.env['screenData']['oldNegativeDelta'] = self.env['screenData']['newNegativeDelta'] self.env['screenData']['newContentBytes'] = newContentBytes