From a75c8e611190f6537d86cd01e8793c189400c82b Mon Sep 17 00:00:00 2001 From: Eric Blevins Date: Sun, 16 Jun 2024 20:28:24 -0400 Subject: [PATCH] Changes to ensure the weston window is started with same resolution as it will be displayed within pyefis. Also set waydroid height and width properties to match before starting waydroid. Without this waydroid would get disconnected from weston when interacting with the interface. This seems to be a problem when the screen with wydroid is not the default screen and the waydroid screen is only displayed after waydroid has fully booted --- extras/extras/waydroid_monitor.sh | 26 ++++++++++++++++++++++++-- src/pyefis/__init__.py | 2 +- src/pyefis/screens/screenbuilder.py | 4 ++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/extras/extras/waydroid_monitor.sh b/extras/extras/waydroid_monitor.sh index 5d539182..4ed36c02 100755 --- a/extras/extras/waydroid_monitor.sh +++ b/extras/extras/waydroid_monitor.sh @@ -1,7 +1,7 @@ #!/bin/bash pid=0 - +weston_pid=0 # Stop waydroid on exit if running trap "exit" INT TERM trap "kill 0" EXIT @@ -10,12 +10,34 @@ while : do if [ -S ${XDG_RUNTIME_DIR}/snap.pyefis/pyefis-waydroid-1 ]; then if (( pid == 0 )); then - echo "starting waydroid" + cmd=$(ps x|grep weston|grep -v grep|head -n 1) + regex='([0-9]+) .* --width=([0-9]+) --height=([0-9]+) ' + if [[ "$cmd" =~ $regex ]]; then + weston_pid=${BASH_REMATCH[1]} + width=${BASH_REMATCH[2]} + height=${BASH_REMATCH[3]} + # Set waydroid resolution to match weston to prevent crash + waydroid prop set persist.waydroid.width ${width} + waydroid prop set persist.waydroid.width ${height} + echo "Set ${width}x${height}" + fi # Wait a couple seconds to ensure weston is ready sleep 2 export WAYLAND_DISPLAY=snap.pyefis/pyefis-waydroid-1 waydroid show-full-ui & pid=$! + else + cmd=$(ps x|grep weston|grep -v grep|head -n 1) + regex='([0-9]+) .*' + if [[ "$cmd" =~ $regex ]]; then + new_weston_pid=${BASH_REMATCH[1]} + if [ $new_weston_pid -ne $weston_pid ]; then + echo "Killing waydroid pid for weston restart: ${pid}" + kill ${pid} + pid=0 + weston_pid=$new_weston_pid + fi + fi fi else if (( pid > 0 )); then diff --git a/src/pyefis/__init__.py b/src/pyefis/__init__.py index aaf7950b..fc6cb763 100644 --- a/src/pyefis/__init__.py +++ b/src/pyefis/__init__.py @@ -1,2 +1,2 @@ -__version__ = "2.0.21" +__version__ = "2.0.22" diff --git a/src/pyefis/screens/screenbuilder.py b/src/pyefis/screens/screenbuilder.py index bfa7add5..70d92817 100644 --- a/src/pyefis/screens/screenbuilder.py +++ b/src/pyefis/screens/screenbuilder.py @@ -420,8 +420,8 @@ def setup_instruments(self,count,i,ganged=False,replace=None,state=False): and 'row' in i \ and 'column' in i: grid_x, grid_y, grid_width, grid_height = self.get_grid_coordinates( i['column'], i['row']) - weston_width = int(grid_width * i['span']['columns']) - weston_height = int(grid_height * i['span']['rows']) + weston_width = qRound(grid_width * i['span']['columns']) + weston_height = qRound(grid_height * i['span']['rows']) # span rows/columns are required for weston to work properly and they need to be at least 200px x 200px self.instruments[count] = weston.Weston(self,socket=i['options']['socket'],ini=os.path.join(self.parent.config_path,i['options']['ini']),command=i['options']['command'],args=i['options']['args'],wide=weston_width,high=weston_height) else: