Improve behavior when changing display distances

This commit is contained in:
wheaney 2025-12-20 21:42:52 -08:00
parent bcf2910959
commit eae448cc14
5 changed files with 26 additions and 10 deletions

View File

@ -301,6 +301,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._toggle_distance_start_connection = this.settings.connect('changed::toggle-display-distance-start', this._update_display_distance.bind(this));
this._toggle_distance_end_connection = this.settings.connect('changed::toggle-display-distance-end', this._update_display_distance.bind(this));
this._display_size_connection = this.settings.connect('changed::display-size', this._update_display_distance.bind(this)); this._display_size_connection = this.settings.connect('changed::display-size', this._update_display_distance.bind(this));
this._focused_monitor_distance_connection = this._focused_monitor_distance_connection =
this._virtual_displays_actor.connect('notify::focused-monitor-details', this._update_display_distance.bind(this)); this._virtual_displays_actor.connect('notify::focused-monitor-details', this._update_display_distance.bind(this));
@ -402,14 +404,14 @@ export default class BreezyDesktopExtension extends Extension {
_update_display_distance(object, event) { _update_display_distance(object, event) {
const distance = this.settings.get_double('display-distance'); const distance = this.settings.get_double('display-distance');
const size = this.settings.get_double('display-size');
Globals.logger.log_debug(`BreezyDesktopExtension _update_display_distance ${distance} ${size}`);
if (distance !== undefined && size !== undefined) {
const defaultDistance = Math.max( const defaultDistance = Math.max(
distance, distance,
this.settings.get_double('toggle-display-distance-start'), this.settings.get_double('toggle-display-distance-start'),
this.settings.get_double('toggle-display-distance-end') this.settings.get_double('toggle-display-distance-end')
); );
const size = this.settings.get_double('display-size');
Globals.logger.log_debug(`BreezyDesktopExtension _update_display_distance ${distance} ${size}`);
if (distance !== undefined && size !== undefined) {
let focusedMonitorSizeAdjustment = size * defaultDistance; let focusedMonitorSizeAdjustment = size * defaultDistance;
if (this._virtual_displays_actor?.focused_monitor_details && this._target_monitor) { if (this._virtual_displays_actor?.focused_monitor_details && this._target_monitor) {
const fovMonitor = this._target_monitor.monitor; const fovMonitor = this._target_monitor.monitor;
@ -595,6 +597,14 @@ 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._toggle_distance_start_connection) {
this.settings.disconnect(this._toggle_distance_start_connection);
this._toggle_distance_start_connection = null;
}
if (this._toggle_distance_end_connection) {
this.settings.disconnect(this._toggle_distance_end_connection);
this._toggle_distance_end_connection = null;
}
if (this._display_size_connection) { if (this._display_size_connection) {
this.settings.disconnect(this._display_size_connection); this.settings.disconnect(this._display_size_connection);
this._display_size_connection = null; this._display_size_connection = null;

View File

@ -262,6 +262,7 @@ export const VirtualDisplayEffect = GObject.registerClass({
this._use_smooth_follow_origin = false; this._use_smooth_follow_origin = false;
this.connect('notify::display-distance', this._update_display_distance.bind(this)); this.connect('notify::display-distance', this._update_display_distance.bind(this));
this.connect('notify::display-distance-default', this._update_display_distance.bind(this));
this.connect('notify::display-size', this._update_display_position.bind(this)); this.connect('notify::display-size', this._update_display_position.bind(this));
this.connect('notify::focused-monitor-index', this._update_display_distance.bind(this)); this.connect('notify::focused-monitor-index', this._update_display_distance.bind(this));
this.connect('notify::monitor-placements', this._update_display_position.bind(this)); this.connect('notify::monitor-placements', this._update_display_position.bind(this));

View File

@ -646,7 +646,6 @@ export const VirtualDisplaysActor = GObject.registerClass({
this._property_connections.push(this.connect(`notify::${property}`, fn.bind(this))); this._property_connections.push(this.connect(`notify::${property}`, fn.bind(this)));
}).bind(this); }).bind(this);
this._distance_ease_timeline = null;
notifyToFunction('toggle-display-distance-start', this._handle_display_distance_properties_change); notifyToFunction('toggle-display-distance-start', this._handle_display_distance_properties_change);
notifyToFunction('toggle-display-distance-end', this._handle_display_distance_properties_change); notifyToFunction('toggle-display-distance-end', this._handle_display_distance_properties_change);
notifyToFunction('display-distance', this._handle_display_distance_properties_change); notifyToFunction('display-distance', this._handle_display_distance_properties_change);

View File

@ -374,18 +374,25 @@ class ConnectedDevice(Gtk.Box):
if (distance < focused_display_distance): if (distance < focused_display_distance):
self._set_focused_display_distance(distance) self._set_focused_display_distance(distance)
all_displays_distance = self.settings.get_double('toggle-display-distance-end')
self._set_all_displays_distance(distance) self._set_all_displays_distance(distance)
if prev_distance == focused_display_distance: # if we were at the unfocused distance, put us at the new unfocused distance
self.settings.set_double('display-distance', prev_distance) if prev_distance == all_displays_distance:
self.settings.set_double('display-distance', distance)
def _on_set_focused_display_distance(self, prev_distance, distance): def _on_set_focused_display_distance(self, prev_distance, distance):
all_displays_distance = self.settings.get_double('toggle-display-distance-end') all_displays_distance = self.settings.get_double('toggle-display-distance-end')
if (distance > all_displays_distance): if (distance > all_displays_distance):
self._set_all_displays_distance(distance) self._set_all_displays_distance(distance)
focused_display_distance = self.settings.get_double('toggle-display-distance-start')
self._set_focused_display_distance(distance) self._set_focused_display_distance(distance)
# if we were at the focused distance, put us at the new focused distance
if prev_distance == focused_display_distance:
self.settings.set_double('display-distance', distance)
def _save_custom_resolutions(self): def _save_custom_resolutions(self):
with open(self._custom_resolutions_file_path, 'w') as f: with open(self._custom_resolutions_file_path, 'w') as f:
json.dump(self._custom_resolution_options, f) json.dump(self._custom_resolution_options, f)

View File

@ -25,8 +25,7 @@ class DisplayDistanceDialogContent(Gtk.Box):
self.settings = SettingsManager.get_instance().settings self.settings = SettingsManager.get_instance().settings
self.state_manager = StateManager.get_instance() self.state_manager = StateManager.get_instance()
self.prev_distance = self.settings.get_double('display-distance') self.prev_distance = self.settings.get_double('display-distance')
self.display_distance_adjustment.set_value(self.settings.get_double(settings_key))
self.settings.bind('display-distance', self.display_distance_adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
self.display_distance_scale.set_format_value_func(lambda scale, val: self._format_distance(val)) self.display_distance_scale.set_format_value_func(lambda scale, val: self._format_distance(val))
self.state_manager.connect('notify::connected-device-full-distance-cm', lambda *args: self.display_distance_scale.queue_draw()) self.state_manager.connect('notify::connected-device-full-distance-cm', lambda *args: self.display_distance_scale.queue_draw())