Add better display size awareness to smooth follow
This commit is contained in:
parent
e81004d136
commit
5f20d11a5b
|
|
@ -35,6 +35,7 @@ export default class BreezyDesktopExtension extends Extension {
|
||||||
this._data_stream_bindings = [];
|
this._data_stream_bindings = [];
|
||||||
this._show_banner_connection = null;
|
this._show_banner_connection = null;
|
||||||
this._distance_connection = null;
|
this._distance_connection = null;
|
||||||
|
this._focused_monitor_distance_connection = null;
|
||||||
this._follow_threshold_connection = null;
|
this._follow_threshold_connection = null;
|
||||||
this._breezy_desktop_running_connection = null;
|
this._breezy_desktop_running_connection = null;
|
||||||
|
|
||||||
|
|
@ -288,6 +289,8 @@ export default class BreezyDesktopExtension extends Extension {
|
||||||
);
|
);
|
||||||
|
|
||||||
this._distance_connection = this.settings.connect('changed::display-distance', this._update_display_distance.bind(this));
|
this._distance_connection = this.settings.connect('changed::display-distance', this._update_display_distance.bind(this));
|
||||||
|
this._focused_monitor_distance_connection =
|
||||||
|
this._virtual_displays_actor.connect('notify::focused-monitor-details', this._update_display_distance.bind(this));
|
||||||
this._follow_threshold_connection = this.settings.connect('changed::follow-threshold', this._update_follow_threshold.bind(this));
|
this._follow_threshold_connection = this.settings.connect('changed::follow-threshold', this._update_follow_threshold.bind(this));
|
||||||
|
|
||||||
Meta.Compositor?.disable_unredirect?.() ?? Meta.disable_unredirect_for_display(global.display);
|
Meta.Compositor?.disable_unredirect?.() ?? Meta.disable_unredirect_for_display(global.display);
|
||||||
|
|
@ -378,10 +381,19 @@ export default class BreezyDesktopExtension extends Extension {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
_update_display_distance(settings, event) {
|
_update_display_distance(object, event) {
|
||||||
const value = settings.get_double('display-distance');
|
const value = this.settings.get_double('display-distance');
|
||||||
Globals.logger.log_debug(`BreezyDesktopExtension _update_display_distance ${value}`);
|
Globals.logger.log_debug(`BreezyDesktopExtension _update_display_distance ${value}`);
|
||||||
if (value !== undefined) this._write_control('breezy_desktop_display_distance', value);
|
if (value !== undefined) {
|
||||||
|
let focusedMonitorSizeAdjustment = 1.0;
|
||||||
|
if (this._virtual_displays_actor?.focused_monitor_details && this._target_monitor) {
|
||||||
|
const fovMonitor = this._target_monitor.monitor;
|
||||||
|
const focusedMonitor = this._virtual_displays_actor.focused_monitor_details;
|
||||||
|
focusedMonitorSizeAdjustment =
|
||||||
|
Math.max(focusedMonitor.width / fovMonitor.width, focusedMonitor.height / fovMonitor.height);
|
||||||
|
}
|
||||||
|
this._write_control('breezy_desktop_display_distance', value / focusedMonitorSizeAdjustment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_update_follow_threshold(settings, event) {
|
_update_follow_threshold(settings, event) {
|
||||||
|
|
@ -541,6 +553,10 @@ export default class BreezyDesktopExtension extends Extension {
|
||||||
this.settings.disconnect(this._distance_connection);
|
this.settings.disconnect(this._distance_connection);
|
||||||
this._distance_connection = null;
|
this._distance_connection = null;
|
||||||
}
|
}
|
||||||
|
if (this._focused_monitor_distance_connection) {
|
||||||
|
this._virtual_displays_actor.disconnect(this._focused_monitor_distance_connection);
|
||||||
|
this._focused_monitor_distance_connection = null;
|
||||||
|
}
|
||||||
if (this._follow_threshold_connection) {
|
if (this._follow_threshold_connection) {
|
||||||
this.settings.disconnect(this._follow_threshold_connection);
|
this.settings.disconnect(this._follow_threshold_connection);
|
||||||
this._follow_threshold_connection = null;
|
this._follow_threshold_connection = null;
|
||||||
|
|
|
||||||
|
|
@ -452,6 +452,12 @@ export const VirtualDisplaysActor = GObject.registerClass({
|
||||||
GObject.ParamFlags.READWRITE,
|
GObject.ParamFlags.READWRITE,
|
||||||
-1, 100, -1
|
-1, 100, -1
|
||||||
),
|
),
|
||||||
|
'focused-monitor-details': GObject.ParamSpec.jsobject(
|
||||||
|
'focused-monitor-details',
|
||||||
|
'Focused Monitor Details',
|
||||||
|
'Details about the monitor that is currently focused',
|
||||||
|
GObject.ParamFlags.READWRITE
|
||||||
|
),
|
||||||
'display-size': GObject.ParamSpec.double(
|
'display-size': GObject.ParamSpec.double(
|
||||||
'display-size',
|
'display-size',
|
||||||
'Display size',
|
'Display size',
|
||||||
|
|
@ -700,6 +706,7 @@ export const 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;
|
||||||
} else if (this.imu_snapshots && (!this._smooth_follow_slerping || this.focused_monitor_index === -1)) {
|
} else if (this.imu_snapshots && (!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
|
||||||
|
|
@ -720,6 +727,7 @@ export const VirtualDisplaysActor = GObject.registerClass({
|
||||||
if (this.focused_monitor_index !== focusedMonitorIndex) {
|
if (this.focused_monitor_index !== focusedMonitorIndex) {
|
||||||
Globals.logger.log_debug(`Switching to monitor ${focusedMonitorIndex}`);
|
Globals.logger.log_debug(`Switching to monitor ${focusedMonitorIndex}`);
|
||||||
this.focused_monitor_index = focusedMonitorIndex;
|
this.focused_monitor_index = focusedMonitorIndex;
|
||||||
|
this.focused_monitor_details = this._sorted_monitors[focusedMonitorIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue