Optimize monitor focus checking, fix toggle XR effect not working when disabled, v2.0.16

This commit is contained in:
wheaney 2025-03-19 16:54:08 -07:00
parent dd10f4ee50
commit a81e205c06
4 changed files with 15 additions and 11 deletions

View File

@ -1 +1 @@
2.0.15 2.0.16

View File

@ -98,6 +98,8 @@ class BreezyDesktopExtension {
} }
} }
this._add_settings_keybinding('toggle-xr-effect-shortcut', this._toggle_xr_effect.bind(this));
this._setup(); this._setup();
} catch (e) { } catch (e) {
Globals.logger.log(`[ERROR] BreezyDesktopExtension enable ${e.message}\n${e.stack}`); Globals.logger.log(`[ERROR] BreezyDesktopExtension enable ${e.message}\n${e.stack}`);
@ -308,7 +310,6 @@ class BreezyDesktopExtension {
Meta.disable_unredirect_for_display(global.display); Meta.disable_unredirect_for_display(global.display);
} }
this._add_settings_keybinding('toggle-xr-effect-shortcut', this._toggle_xr_effect.bind(this));
this._add_settings_keybinding('recenter-display-shortcut', this._recenter_display.bind(this)); this._add_settings_keybinding('recenter-display-shortcut', this._recenter_display.bind(this));
this._add_settings_keybinding('toggle-display-distance-shortcut', this._virtual_displays_actor._change_distance.bind(this._virtual_displays_actor)); this._add_settings_keybinding('toggle-display-distance-shortcut', this._virtual_displays_actor._change_distance.bind(this._virtual_displays_actor));
this._add_settings_keybinding('toggle-follow-shortcut', this._toggle_follow_mode.bind(this)); this._add_settings_keybinding('toggle-follow-shortcut', this._toggle_follow_mode.bind(this));
@ -560,7 +561,6 @@ class BreezyDesktopExtension {
if (Globals.data_stream.smooth_follow_enabled) this._toggle_follow_mode(); if (Globals.data_stream.smooth_follow_enabled) this._toggle_follow_mode();
Main.wm.removeKeybinding('toggle-xr-effect-shortcut');
Main.wm.removeKeybinding('recenter-display-shortcut'); Main.wm.removeKeybinding('recenter-display-shortcut');
Main.wm.removeKeybinding('toggle-display-distance-shortcut'); Main.wm.removeKeybinding('toggle-display-distance-shortcut');
Main.wm.removeKeybinding('toggle-follow-shortcut'); Main.wm.removeKeybinding('toggle-follow-shortcut');
@ -646,6 +646,7 @@ class BreezyDesktopExtension {
Globals.data_stream.disconnect(this._breezy_desktop_running_connection); Globals.data_stream.disconnect(this._breezy_desktop_running_connection);
this._breezy_desktop_running_connection = null; this._breezy_desktop_running_connection = null;
} }
Main.wm.removeKeybinding('toggle-xr-effect-shortcut');
Gio.Settings.unbind(this.settings, 'debug'); Gio.Settings.unbind(this.settings, 'debug');
Gio.Settings.unbind(this.settings, 'use-optimal-monitor-config'); Gio.Settings.unbind(this.settings, 'use-optimal-monitor-config');
Gio.Settings.unbind(this.settings, 'headset-as-primary'); Gio.Settings.unbind(this.settings, 'headset-as-primary');

View File

@ -249,8 +249,9 @@ var VirtualDisplayEffect = GObject.registerClass({
if (this._follow_ease_timeline?.is_playing()) this._follow_ease_timeline.stop(); if (this._follow_ease_timeline?.is_playing()) this._follow_ease_timeline.stop();
const ease_to_focus = this.smooth_follow_enabled && this._is_focused();
const from = this._current_follow_ease_progress; const from = this._current_follow_ease_progress;
const to = this.smooth_follow_enabled && this._is_focused() ? 1.0 : 0.0; const to = ease_to_focus ? 1.0 : 0.0;
const toggleTime = this.smooth_follow_toggle_epoch_ms === 0 ? Date.now() : this.smooth_follow_toggle_epoch_ms; const toggleTime = this.smooth_follow_toggle_epoch_ms === 0 ? Date.now() : this.smooth_follow_toggle_epoch_ms;
// would have been a slight delay between request and slerp actually starting // would have been a slight delay between request and slerp actually starting

View File

@ -32,7 +32,7 @@ function applyQuaternionToVector(vector, quaternion) {
const FOCUS_THRESHOLD = 0.95 / 2.0; const FOCUS_THRESHOLD = 0.95 / 2.0;
// if we leave the monitor with some margin, unfocus even if no other monitor is in focus // if we leave the monitor with some margin, unfocus even if no other monitor is in focus
const UNFOCUS_THRESHOLD = 1.2 / 2.0; const UNFOCUS_THRESHOLD = 1.1 / 2.0;
/** /**
* Find the vector in the array that's closest to the quaternion rotation * Find the vector in the array that's closest to the quaternion rotation
@ -58,12 +58,12 @@ function findFocusedMonitor(quaternion, monitorVectors, currentFocusedIndex, foc
let currentFocusedDistance = Infinity; let currentFocusedDistance = Infinity;
// find the vector closest to the rotated look vector // find the vector closest to the rotated look vector
monitorVectors.forEach((vector, index) => { monitorVectors.forEach((monitorVector, index) => {
const monitor = monitorsDetails[index]; const monitor = monitorsDetails[index];
const monitorAspectRatio = monitor.width / monitor.height; const monitorAspectRatio = monitor.width / monitor.height;
// weight the rotation about the y-axis between the two vectors, by the aspect ratio // weight the rotation about the y-axis between the two vectors, by the aspect ratio
const vectorUpTheta = Math.atan2(vector[2], vector[0]); const vectorUpTheta = Math.atan2(monitorVector[2], monitorVector[0]);
const upDelta = lookUpTheta - vectorUpTheta; const upDelta = lookUpTheta - vectorUpTheta;
const newLookUpTheta = Math.tan(Math.max( const newLookUpTheta = Math.tan(Math.max(
-Math.PI, -Math.PI,
@ -81,9 +81,9 @@ function findFocusedMonitor(quaternion, monitorVectors, currentFocusedIndex, foc
// find the distance between the monitor vector and weighted look vector // find the distance between the monitor vector and weighted look vector
const distance = Math.acos( const distance = Math.acos(
Math.min(1.0, Math.max(-1.0, Math.min(1.0, Math.max(-1.0,
vector[0] * weightedLookVector[0] + monitorVector[0] * weightedLookVector[0] +
vector[1] * weightedLookVector[1] + monitorVector[1] * weightedLookVector[1] +
vector[2] * weightedLookVector[2] monitorVector[2] * weightedLookVector[2]
)) ))
); );
@ -777,7 +777,9 @@ var VirtualDisplaysActor = GObject.registerClass({
if (this.show_banner) { if (this.show_banner) {
this.focused_monitor_index = -1; this.focused_monitor_index = -1;
this.focused_monitor_details = null; this.focused_monitor_details = null;
} else if (this.imu_snapshots && (!this._smooth_follow_slerping || this.focused_monitor_index === -1)) { } else if (this.imu_snapshots &&
(!this.smooth_follow_enabled || this.focused_monitor_index === -1) &&
(!this._smooth_follow_slerping || this.focused_monitor_index === -1)) {
// if smooth follow is enabled, use the origin IMU data to inform the initial focused monitor // if smooth follow is enabled, use the origin IMU data to inform the initial focused monitor
// since it reflects where the user is looking in relation to the original monitor positions // since it reflects where the user is looking in relation to the original monitor positions
const currentPoseQuat = this.smooth_follow_enabled ? const currentPoseQuat = this.smooth_follow_enabled ?