From b77ede606d229e353cd0ac12d41d1ea47721ff52 Mon Sep 17 00:00:00 2001 From: wheaney <42350981+wheaney@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:17:40 -0800 Subject: [PATCH] Update UI wording, handle case where device data comes in with all zeroes --- gnome/src/devicedatastream.js | 96 ++++++++++++++++--------------- gnome/src/virtualmonitorsactor.js | 2 +- modules/XRLinuxDriver | 2 +- ui/src/connecteddevice.py | 10 +++- ui/src/gtk/connected-device.ui | 42 +++++++------- 5 files changed, 81 insertions(+), 71 deletions(-) diff --git a/gnome/src/devicedatastream.js b/gnome/src/devicedatastream.js index 66b8725..2e4169e 100644 --- a/gnome/src/devicedatastream.js +++ b/gnome/src/devicedatastream.js @@ -176,68 +176,74 @@ export const DeviceDataStream = GObject.registerClass({ let dataView = new DataView(buffer); if (dataView.byteLength === DATA_VIEW_LENGTH) { let imuDateMs = dataViewBigUint(dataView, EPOCH_MS); - const validKeepalive = isValidKeepAlive(toSec(imuDateMs)); + const displayFov = dataViewFloat(dataView, DISPLAY_FOV); + const validKeepAlive = isValidKeepAlive(toSec(imuDateMs)); + const validData = validKeepAlive && displayFov !== 0.0; const version = dataViewUint8(dataView, VERSION); - const enabled = dataViewUint8(dataView, ENABLED) !== 0 && version === DATA_LAYOUT_VERSION && validKeepalive; + const enabled = dataViewUint8(dataView, ENABLED) !== 0 && version === DATA_LAYOUT_VERSION && validData; let imuData = dataViewFloatArray(dataView, IMU_QUAT_DATA); - const imuResetState = enabled && validKeepalive && imuData[0] === 0.0 && imuData[1] === 0.0 && imuData[2] === 0.0 && imuData[3] === 1.0; + const imuResetState = enabled && validData && imuData[0] === 0.0 && imuData[1] === 0.0 && imuData[2] === 0.0 && imuData[3] === 1.0; const customBannerEnabled = dataViewUint8(dataView, CUSTOM_BANNER_ENABLED) !== 0; const sbsEnabled = dataViewUint8(dataView, SBS_ENABLED) !== 0; + if (validKeepAlive && !validData) Globals.logger.log('[ERROR] Received invalid device data'); + // trigger "notify::" events for properties we want to check on every cycle if (enabled && this.widescreen_mode_state !== sbsEnabled) this.widescreen_mode_state = sbsEnabled; if (this.show_banner !== imuResetState) this.show_banner = imuResetState; if (this.custom_banner_enabled !== customBannerEnabled) this.custom_banner_enabled = customBannerEnabled; - if (!this.device_data) { - this.device_data = { - version, - enabled, - imuResetState, - displayRes: dataViewUint32Array(dataView, DISPLAY_RES), - sbsEnabled, - displayFov: dataViewFloat(dataView, DISPLAY_FOV), - lookAheadCfg: dataViewFloatArray(dataView, LOOK_AHEAD_CFG), - lensDistanceRatio: dataViewFloat(dataView, LENS_DISTANCE_RATIO) - }; - } else if (keepalive_only) { - this.device_data = { - ...this.device_data, - imuResetState, - enabled, - sbsEnabled - } - } - let success = keepalive_only; - let attempts = 0; - while (!success && attempts < 3) { - if (dataView.byteLength === DATA_VIEW_LENGTH) { - if (checkParityByte(dataView)) { - this.device_data.imuData = imuData; - this.device_data.imuDateMs = imuDateMs; - this.imu_snapshots = { - imu_data: imuData, - timestamp_ms: imuDateMs - }; - success = true; + if (validData) { + if (!this.device_data) { + this.device_data = { + version, + enabled, + imuResetState, + displayRes: dataViewUint32Array(dataView, DISPLAY_RES), + sbsEnabled, + displayFov, + lookAheadCfg: dataViewFloatArray(dataView, LOOK_AHEAD_CFG), + lensDistanceRatio: dataViewFloat(dataView, LENS_DISTANCE_RATIO) + }; + } else if (keepalive_only) { + this.device_data = { + ...this.device_data, + imuResetState, + enabled, + sbsEnabled } - } else if (dataView.byteLength !== 0) { - Globals.logger.log(`[ERROR] Invalid dataView.byteLength: ${dataView.byteLength} !== ${DATA_VIEW_LENGTH}`) } - - if (!success && ++attempts < 3) { - data = this._ipc_file.load_contents(null); - if (data[0]) { - buffer = new Uint8Array(data[1]).buffer; - dataView = new DataView(buffer); - imuDateMs = dataViewBigUint(dataView, EPOCH_MS); - imuData = dataViewFloatArray(dataView, IMU_QUAT_DATA); + + let attempts = 0; + while (!success && attempts < 3) { + if (dataView.byteLength === DATA_VIEW_LENGTH) { + if (checkParityByte(dataView)) { + this.device_data.imuData = imuData; + this.device_data.imuDateMs = imuDateMs; + this.imu_snapshots = { + imu_data: imuData, + timestamp_ms: imuDateMs + }; + success = true; + } + } else if (dataView.byteLength !== 0) { + Globals.logger.log(`[ERROR] Invalid dataView.byteLength: ${dataView.byteLength} !== ${DATA_VIEW_LENGTH}`) + } + + if (!success && ++attempts < 3) { + data = this._ipc_file.load_contents(null); + if (data[0]) { + buffer = new Uint8Array(data[1]).buffer; + dataView = new DataView(buffer); + imuDateMs = dataViewBigUint(dataView, EPOCH_MS); + imuData = dataViewFloatArray(dataView, IMU_QUAT_DATA); + } } } } - this.breezy_desktop_actually_running = success && enabled && validKeepalive; + this.breezy_desktop_actually_running = success && enabled && validData; } else { this.breezy_desktop_actually_running = false; } diff --git a/gnome/src/virtualmonitorsactor.js b/gnome/src/virtualmonitorsactor.js index 138273d..834185a 100644 --- a/gnome/src/virtualmonitorsactor.js +++ b/gnome/src/virtualmonitorsactor.js @@ -1096,7 +1096,7 @@ export const VirtualMonitorsActor = GObject.registerClass({ // shift all monitors so they center around the target monitor, then adjusted by the offsets this._all_monitors.map(monitor => ({ x: monitor.x - this.target_monitor.x - this.viewport_offset_x * this.target_monitor.width, - y: monitor.y - this.target_monitor.y - this.viewport_offset_y * this.target_monitor.height, + y: monitor.y - this.target_monitor.y + this.viewport_offset_y * this.target_monitor.height, width: monitor.width, height: monitor.height })), diff --git a/modules/XRLinuxDriver b/modules/XRLinuxDriver index 831a016..4f299ec 160000 --- a/modules/XRLinuxDriver +++ b/modules/XRLinuxDriver @@ -1 +1 @@ -Subproject commit 831a016d71f638b683157f9d85d5ffc34848a1c1 +Subproject commit 4f299ecc7da6d4cdfb164cbcb22f60580fb2295a diff --git a/ui/src/connecteddevice.py b/ui/src/connecteddevice.py index 23587ba..f262a7e 100644 --- a/ui/src/connecteddevice.py +++ b/ui/src/connecteddevice.py @@ -153,7 +153,6 @@ class ConnectedDevice(Gtk.Box): self._settings_displays_app_info = None - # use Gio.AppInfo.get_all() and find the one where appinfo.get_id() == 'gnome-display-panel.desktop' for appinfo in Gio.AppInfo.get_all(): if appinfo.get_id() == 'gnome-display-panel.desktop': self._settings_displays_app_info = appinfo @@ -185,6 +184,9 @@ class ConnectedDevice(Gtk.Box): self.effect_enable_switch.set_active(enabled) def _handle_switch_enabled_state(self, switch, param): + GLib.idle_add(self._handle_switch_enabled_state_gui, switch, param) + + def _handle_switch_enabled_state_gui(self, switch, param): requesting_enabled = switch.get_active() # never turn off the extension, disabling the effect is done via configs only @@ -239,9 +241,13 @@ class ConnectedDevice(Gtk.Box): GLib.idle_add(self._on_virtual_displays_update_gui, virtual_display_manager) def _on_virtual_displays_update_gui(self, virtual_display_manager): + effect_enabled = self.effect_enable_switch.get_active() + virtual_displays_present = len(virtual_display_manager.displays) > 0 self.launch_display_settings_button.set_visible( - self._settings_displays_app_info is not None and len(virtual_display_manager.displays) > 0 + self._settings_displays_app_info is not None and virtual_displays_present ) + self.monitor_wrapping_scheme_menu.set_sensitive(effect_enabled and virtual_displays_present) + self.monitor_spacing_scale.set_sensitive(effect_enabled and virtual_displays_present) for pid, child in self.virtual_displays_by_pid.items(): self.top_features_group.remove(child) diff --git a/ui/src/gtk/connected-device.ui b/ui/src/gtk/connected-device.ui index 3dbc084..98389a7 100644 --- a/ui/src/gtk/connected-device.ui +++ b/ui/src/gtk/connected-device.ui @@ -52,7 +52,7 @@ - Virtual monitors + Virtual displays 2 @@ -123,9 +123,9 @@ - - - + 0.2 + 1.0 + 2.5 @@ -159,8 +159,8 @@ - Multi-monitor wrapping - When there are multiple monitors, choose how they should wrap around you. + Display angling + When there are multiple displays, choose how they should angle towards you. 2 @@ -175,9 +175,9 @@ Automatic - Horizontal - Vertical - None + Side-angled + Top-angled + Flat @@ -187,8 +187,8 @@ - Multi-monitor spacing - Put empty space between monitors, when there are multiple. + Display spacing + Put empty space between displays, when there are multiple. 3 @@ -206,11 +206,11 @@ - + 0 - + 50 - + 100 @@ -223,7 +223,6 @@ 3 - true 0 1 350 @@ -237,11 +236,11 @@ - + left - + center - + right @@ -254,7 +253,6 @@ 3 - true 0 1 350 @@ -268,11 +266,11 @@ - + down - + center - + up