diff options
| author | Antoine Prieels <anp@odoo.com> | 2019-11-18 10:28:59 +0000 |
|---|---|---|
| committer | Antoine Prieels <anp@odoo.com> | 2019-11-27 14:15:18 +0000 |
| commit | ad846fcee5b1a548c2b2e1f9ac5cbf131d039042 (patch) | |
| tree | 48bced3e0e845d4b063af9b8519924156bc79a69 /addons/hw_drivers/drivers/DisplayDriver.py | |
| parent | c1c4404131bf2d2b913e6ef96106e1ef7754bcaa (diff) | |
[IMP] iot: Dual screen support for RPI4
We now support the RPI4 which has 2 micro-HDMI outputs, while the
prvious driver only supported one display. We add support for a second
display.
Taskid: 2123511
X-original-commit: 5886c3a864c990fcd7b852baafab752e7da90494
Diffstat (limited to 'addons/hw_drivers/drivers/DisplayDriver.py')
| -rw-r--r-- | addons/hw_drivers/drivers/DisplayDriver.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/addons/hw_drivers/drivers/DisplayDriver.py b/addons/hw_drivers/drivers/DisplayDriver.py index 67d9f861708..167b485586d 100644 --- a/addons/hw_drivers/drivers/DisplayDriver.py +++ b/addons/hw_drivers/drivers/DisplayDriver.py @@ -35,8 +35,9 @@ class DisplayDriver(Driver): self.event_data = threading.Event() self.owner = False self.rendered_html = '' - self.load_url() - self.call_xdotools('F11') + if self.device_identifier != 'distant_display': + self._x_screen = device.get('x_screen', '0') + self.load_url() @property def device_identifier(self): @@ -68,20 +69,22 @@ class DisplayDriver(Driver): event_manager.device_changed(self) def run(self): - while True: + while self.device_identifier != 'distant_display': time.sleep(60) if self.url != 'http://localhost:8069/point_of_sale/display/': # Refresh the page every minute self.call_xdotools('F5') def update_url(self, url=None): + os.environ['DISPLAY'] = ":0." + self._x_screen + os.environ['XAUTHORITY'] = '/run/lightdm/pi/xauthority' firefox_env = os.environ.copy() - firefox_env['HOME'] = '/tmp' - firefox_env['DISPLAY'] = ':0.0' - firefox_env['XAUTHORITY'] = '/run/lightdm/pi/xauthority' + firefox_env['HOME'] = '/tmp/' + self._x_screen self.url = url or 'http://localhost:8069/point_of_sale/display/' - if self.device_identifier != 'distant_display': - subprocess.Popen(['firefox', self.url], env=firefox_env) + new_window = subprocess.call(['xdotool', 'search', '--onlyvisible', '--screen', self._x_screen, '--class', 'Firefox']) + subprocess.Popen(['firefox', self.url], env=firefox_env) + if new_window: + self.call_xdotools('F11') def load_url(self): url = None @@ -101,10 +104,10 @@ class DisplayDriver(Driver): return self.update_url(url) def call_xdotools(self, keystroke): - os.environ['DISPLAY'] = ":0.0" + os.environ['DISPLAY'] = ":0." + self._x_screen os.environ['XAUTHORITY'] = "/run/lightdm/pi/xauthority" try: - subprocess.call(['xdotool', 'search', '--sync', '--onlyvisible', '--class', 'Firefox', 'windowactivate', 'key', keystroke]) + subprocess.call(['xdotool', 'search', '--sync', '--onlyvisible', '--screen', self._x_screen, '--class', 'Firefox', 'key', keystroke]) return "xdotool succeeded in stroking " + keystroke except: return "xdotool threw an error, maybe it is not installed on the IoTBox" |
