Update display size so it's relative to distance, update UI to better represent this
This commit is contained in:
parent
ac53ff2298
commit
bcf2910959
|
|
@ -402,15 +402,20 @@ 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 defaultDistance = Math.max(
|
||||||
|
distance,
|
||||||
|
this.settings.get_double('toggle-display-distance-start'),
|
||||||
|
this.settings.get_double('toggle-display-distance-end')
|
||||||
|
);
|
||||||
const size = this.settings.get_double('display-size');
|
const size = this.settings.get_double('display-size');
|
||||||
Globals.logger.log_debug(`BreezyDesktopExtension _update_display_distance ${distance} ${size}`);
|
Globals.logger.log_debug(`BreezyDesktopExtension _update_display_distance ${distance} ${size}`);
|
||||||
if (distance !== undefined && size !== undefined) {
|
if (distance !== undefined && size !== undefined) {
|
||||||
let focusedMonitorSizeAdjustment = 1.0;
|
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;
|
||||||
const focusedMonitor = this._virtual_displays_actor.focused_monitor_details;
|
const focusedMonitor = this._virtual_displays_actor.focused_monitor_details;
|
||||||
focusedMonitorSizeAdjustment =
|
focusedMonitorSizeAdjustment *=
|
||||||
Math.max(size * focusedMonitor.width / fovMonitor.width, size * focusedMonitor.height / fovMonitor.height);
|
Math.max(focusedMonitor.width / fovMonitor.width, focusedMonitor.height / fovMonitor.height);
|
||||||
}
|
}
|
||||||
this._write_control('breezy_desktop_display_distance', distance / focusedMonitorSizeAdjustment);
|
this._write_control('breezy_desktop_display_distance', distance / focusedMonitorSizeAdjustment);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -389,6 +389,8 @@ export const VirtualDisplayEffect = GObject.registerClass({
|
||||||
|
|
||||||
// follow_ease transitions this from a rotated display (progress 0.0) to a centered/focused display (progress 1.0)
|
// follow_ease transitions this from a rotated display (progress 0.0) to a centered/focused display (progress 1.0)
|
||||||
_update_display_position() {
|
_update_display_position() {
|
||||||
|
const distance_adjusted_size = this.display_distance_default * this.display_size;
|
||||||
|
|
||||||
// this is in NWU coordinates
|
// this is in NWU coordinates
|
||||||
const monitorPlacement = this.monitor_placements[this.monitor_index];
|
const monitorPlacement = this.monitor_placements[this.monitor_index];
|
||||||
const noRotationVector = monitorPlacement.centerNoRotate.map(coord => coord * this._current_display_distance / this.display_distance_default);
|
const noRotationVector = monitorPlacement.centerNoRotate.map(coord => coord * this._current_display_distance / this.display_distance_default);
|
||||||
|
|
@ -400,8 +402,8 @@ export const VirtualDisplayEffect = GObject.registerClass({
|
||||||
finalPositionVector[0] = noRotationVector[0];
|
finalPositionVector[0] = noRotationVector[0];
|
||||||
}
|
}
|
||||||
const resizedMonitorDetails = {
|
const resizedMonitorDetails = {
|
||||||
width: this.monitor_details.width * this.display_size,
|
width: this.monitor_details.width * distance_adjusted_size,
|
||||||
height: this.monitor_details.height * this.display_size
|
height: this.monitor_details.height * distance_adjusted_size
|
||||||
};
|
};
|
||||||
this._vertices = createVertexMesh(this.fov_details, resizedMonitorDetails, finalPositionVector);
|
this._vertices = createVertexMesh(this.fov_details, resizedMonitorDetails, finalPositionVector);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -851,8 +851,8 @@ export const VirtualDisplaysActor = GObject.registerClass({
|
||||||
// distance of a display at the default (most zoomed out) distance, plus the lens distance constant
|
// distance of a display at the default (most zoomed out) distance, plus the lens distance constant
|
||||||
const lensToScreenDistance = this.target_monitor.height / 2 / Math.tan(defaultDistanceVerticalRadians / 2);
|
const lensToScreenDistance = this.target_monitor.height / 2 / Math.tan(defaultDistanceVerticalRadians / 2);
|
||||||
const completeScreenDistancePixels = lensToScreenDistance + lensDistancePixels;
|
const completeScreenDistancePixels = lensToScreenDistance + lensDistancePixels;
|
||||||
const sizeAdjustedWidthPixels = this.target_monitor.width * this.display_size;
|
const sizeAdjustedWidthPixels = this.target_monitor.width * this._distance_adjusted_size;
|
||||||
const sizeAdjustedHeightPixels = this.target_monitor.height * this.display_size;
|
const sizeAdjustedHeightPixels = this.target_monitor.height * this._distance_adjusted_size;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
widthPixels: this.target_monitor.width,
|
widthPixels: this.target_monitor.width,
|
||||||
|
|
@ -923,6 +923,8 @@ export const VirtualDisplaysActor = GObject.registerClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
_handle_display_distance_properties_change() {
|
_handle_display_distance_properties_change() {
|
||||||
|
this._distance_adjusted_size = this._display_distance_default() * this.display_size;
|
||||||
|
|
||||||
const distance_from_end = Math.abs(this.display_distance - this.toggle_display_distance_end);
|
const distance_from_end = Math.abs(this.display_distance - this.toggle_display_distance_end);
|
||||||
const distance_from_start = Math.abs(this.display_distance - this.toggle_display_distance_start);
|
const distance_from_start = Math.abs(this.display_distance - this.toggle_display_distance_start);
|
||||||
this._is_display_distance_at_end = distance_from_end < distance_from_start;
|
this._is_display_distance_at_end = distance_from_end < distance_from_start;
|
||||||
|
|
@ -930,14 +932,16 @@ export const VirtualDisplaysActor = GObject.registerClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
_handle_display_size_change(update_placements = true) {
|
_handle_display_size_change(update_placements = true) {
|
||||||
const sizeComplement = (1.0 - this.display_size) / 2.0;
|
this._distance_adjusted_size = this._display_distance_default() * this.display_size;
|
||||||
|
|
||||||
|
const sizeComplement = (1.0 - this._distance_adjusted_size) / 2.0;
|
||||||
const sizeViewportOffsetX = sizeComplement * this.target_monitor.width;
|
const sizeViewportOffsetX = sizeComplement * this.target_monitor.width;
|
||||||
const sizeViewportOffsetY = sizeComplement * this.target_monitor.height;
|
const sizeViewportOffsetY = sizeComplement * this.target_monitor.height;
|
||||||
this._all_monitors = this._all_monitors_unmodified.map(monitor => ({
|
this._all_monitors = this._all_monitors_unmodified.map(monitor => ({
|
||||||
x: monitor.x * this.display_size + sizeViewportOffsetX,
|
x: monitor.x * this._distance_adjusted_size + sizeViewportOffsetX,
|
||||||
y: monitor.y * this.display_size + sizeViewportOffsetY,
|
y: monitor.y * this._distance_adjusted_size + sizeViewportOffsetY,
|
||||||
width: monitor.width * this.display_size,
|
width: monitor.width * this._distance_adjusted_size,
|
||||||
height: monitor.height * this.display_size
|
height: monitor.height * this._distance_adjusted_size
|
||||||
}));
|
}));
|
||||||
if (update_placements) this._update_monitor_placements();
|
if (update_placements) this._update_monitor_placements();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,6 @@ class ConnectedDevice(Gtk.Box):
|
||||||
self.follow_mode_switch.connect('notify::active', self._refresh_follow_mode)
|
self.follow_mode_switch.connect('notify::active', self._refresh_follow_mode)
|
||||||
self.effect_enable_switch.connect('notify::active', self._handle_switch_enabled_state)
|
self.effect_enable_switch.connect('notify::active', self._handle_switch_enabled_state)
|
||||||
|
|
||||||
self.display_size_scale.set_format_value_func(lambda scale, val: self._format_size(val))
|
|
||||||
self.state_manager.connect('notify::connected-device-full-size-cm', self._handle_metric_change)
|
self.state_manager.connect('notify::connected-device-full-size-cm', self._handle_metric_change)
|
||||||
self.state_manager.connect('notify::connected-device-full-distance-cm', self._handle_metric_change)
|
self.state_manager.connect('notify::connected-device-full-distance-cm', self._handle_metric_change)
|
||||||
self.settings.connect('changed::units', self._handle_units_changed)
|
self.settings.connect('changed::units', self._handle_units_changed)
|
||||||
|
|
@ -255,22 +254,13 @@ class ConnectedDevice(Gtk.Box):
|
||||||
self.settings.set_string('units', active_id)
|
self.settings.set_string('units', active_id)
|
||||||
|
|
||||||
def _handle_units_changed(self, *args):
|
def _handle_units_changed(self, *args):
|
||||||
self._refresh_display_size_scale_value()
|
|
||||||
self._set_all_displays_distance(self.settings.get_double('toggle-display-distance-end'))
|
self._set_all_displays_distance(self.settings.get_double('toggle-display-distance-end'))
|
||||||
self._set_focused_display_distance(self.settings.get_double('toggle-display-distance-start'))
|
self._set_focused_display_distance(self.settings.get_double('toggle-display-distance-start'))
|
||||||
|
|
||||||
def _handle_metric_change(self, *args):
|
def _handle_metric_change(self, *args):
|
||||||
self._refresh_display_size_scale_value()
|
|
||||||
self._set_all_displays_distance(self.settings.get_double('toggle-display-distance-end'))
|
self._set_all_displays_distance(self.settings.get_double('toggle-display-distance-end'))
|
||||||
self._set_focused_display_distance(self.settings.get_double('toggle-display-distance-start'))
|
self._set_focused_display_distance(self.settings.get_double('toggle-display-distance-start'))
|
||||||
|
|
||||||
def _refresh_display_size_scale_value(self):
|
|
||||||
if self.display_size_scale.get_draw_value():
|
|
||||||
self.display_size_scale.set_draw_value(False)
|
|
||||||
self.display_size_scale.set_draw_value(True)
|
|
||||||
else:
|
|
||||||
self.display_size_scale.queue_draw()
|
|
||||||
|
|
||||||
def _handle_monitor_wrapping_scheme_setting_changed(self, settings, val):
|
def _handle_monitor_wrapping_scheme_setting_changed(self, settings, val):
|
||||||
self.monitor_wrapping_scheme_menu.set_active_id(val)
|
self.monitor_wrapping_scheme_menu.set_active_id(val)
|
||||||
|
|
||||||
|
|
@ -374,18 +364,6 @@ class ConnectedDevice(Gtk.Box):
|
||||||
return f"{inches:.2f} in"
|
return f"{inches:.2f} in"
|
||||||
return f"{cm:.1f} cm"
|
return f"{cm:.1f} cm"
|
||||||
|
|
||||||
def _format_size(self, normalized):
|
|
||||||
sm = getattr(self, 'state_manager', None) or StateManager.get_instance()
|
|
||||||
full_cm = float(sm.get_property('connected-device-full-size-cm') or 0.0)
|
|
||||||
if full_cm <= 0:
|
|
||||||
# Fallback to normalized display if metric unknown
|
|
||||||
return f"{round(normalized, 2)}"
|
|
||||||
cm = normalized * full_cm
|
|
||||||
if self._get_units() == 'in':
|
|
||||||
inches = cm / 2.54
|
|
||||||
return f"{inches:.2f} in"
|
|
||||||
return f"{cm:.1f} cm"
|
|
||||||
|
|
||||||
def _on_display_distance_preset_change_button_clicked(self, widget, settings_key, on_save_callback, title, subtitle, lower_limit, upper_limit):
|
def _on_display_distance_preset_change_button_clicked(self, widget, settings_key, on_save_callback, title, subtitle, lower_limit, upper_limit):
|
||||||
dialog = DisplayDistanceDialog(settings_key, on_save_callback, title, subtitle, lower_limit, upper_limit)
|
dialog = DisplayDistanceDialog(settings_key, on_save_callback, title, subtitle, lower_limit, upper_limit)
|
||||||
dialog.set_transient_for(widget.get_ancestor(Gtk.Window))
|
dialog.set_transient_for(widget.get_ancestor(Gtk.Window))
|
||||||
|
|
@ -393,7 +371,6 @@ class ConnectedDevice(Gtk.Box):
|
||||||
|
|
||||||
def _on_set_all_displays_distance(self, prev_distance, distance):
|
def _on_set_all_displays_distance(self, prev_distance, distance):
|
||||||
focused_display_distance = self.settings.get_double('toggle-display-distance-start')
|
focused_display_distance = self.settings.get_double('toggle-display-distance-start')
|
||||||
all_displays_distance = self.settings.get_double('toggle-display-distance-end')
|
|
||||||
if (distance < focused_display_distance):
|
if (distance < focused_display_distance):
|
||||||
self._set_focused_display_distance(distance)
|
self._set_focused_display_distance(distance)
|
||||||
|
|
||||||
|
|
@ -403,7 +380,6 @@ class ConnectedDevice(Gtk.Box):
|
||||||
self.settings.set_double('display-distance', prev_distance)
|
self.settings.set_double('display-distance', prev_distance)
|
||||||
|
|
||||||
def _on_set_focused_display_distance(self, prev_distance, distance):
|
def _on_set_focused_display_distance(self, prev_distance, distance):
|
||||||
focused_display_distance = self.settings.get_double('toggle-display-distance-start')
|
|
||||||
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)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from .displaydistancedialogcontent import DisplayDistanceDialogContent
|
||||||
class DisplayDistanceDialog(Gtk.Dialog):
|
class DisplayDistanceDialog(Gtk.Dialog):
|
||||||
__gtype_name__ = 'DisplayDistanceDialog'
|
__gtype_name__ = 'DisplayDistanceDialog'
|
||||||
|
|
||||||
show_full_scale_button = Gtk.Template.Child()
|
|
||||||
save_button = Gtk.Template.Child()
|
save_button = Gtk.Template.Child()
|
||||||
|
|
||||||
def __init__(self, settings_key, on_save_callback, title, subtitle, lower_limit, upper_limit):
|
def __init__(self, settings_key, on_save_callback, title, subtitle, lower_limit, upper_limit):
|
||||||
|
|
@ -15,14 +14,9 @@ class DisplayDistanceDialog(Gtk.Dialog):
|
||||||
self.on_save_callback = on_save_callback
|
self.on_save_callback = on_save_callback
|
||||||
self.set_title(title)
|
self.set_title(title)
|
||||||
|
|
||||||
self.content = DisplayDistanceDialogContent(settings_key, self.show_full_scale_button, self.save_button, self._on_save_callback, subtitle, lower_limit, upper_limit)
|
self.content = DisplayDistanceDialogContent(settings_key, self.save_button, self._on_save_callback, subtitle, lower_limit, upper_limit)
|
||||||
self.get_content_area().append(self.content)
|
self.get_content_area().append(self.content)
|
||||||
|
|
||||||
self.show_full_scale_button.connect('clicked', self._on_show_full_scale_button_clicked)
|
|
||||||
|
|
||||||
def _on_show_full_scale_button_clicked(self, button):
|
|
||||||
self.show_full_scale_button.set_visible(False)
|
|
||||||
|
|
||||||
def _on_save_callback(self, prev_distance, distance):
|
def _on_save_callback(self, prev_distance, distance):
|
||||||
self.on_save_callback(prev_distance, distance)
|
self.on_save_callback(prev_distance, distance)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
@ -15,7 +15,7 @@ class DisplayDistanceDialogContent(Gtk.Box):
|
||||||
display_distance_scale = Gtk.Template.Child()
|
display_distance_scale = Gtk.Template.Child()
|
||||||
display_distance_adjustment = Gtk.Template.Child()
|
display_distance_adjustment = Gtk.Template.Child()
|
||||||
|
|
||||||
def __init__(self, settings_key, show_full_scale_button, save_button, on_save_callback, subtitle, lower_limit, upper_limit):
|
def __init__(self, settings_key, save_button, on_save_callback, subtitle, lower_limit, upper_limit):
|
||||||
super(Gtk.Box, self).__init__()
|
super(Gtk.Box, self).__init__()
|
||||||
self.init_template()
|
self.init_template()
|
||||||
|
|
||||||
|
|
@ -26,40 +26,13 @@ class DisplayDistanceDialogContent(Gtk.Box):
|
||||||
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.lower_limit_orig = self.display_distance_adjustment.get_lower()
|
|
||||||
self.upper_limit_orig = self.display_distance_adjustment.get_upper()
|
|
||||||
|
|
||||||
self._add_marks(lower_limit, upper_limit)
|
|
||||||
|
|
||||||
self.settings.bind('display-distance', self.display_distance_adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
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())
|
||||||
self.settings.connect('changed::units', lambda *args: self.display_distance_scale.queue_draw())
|
self.settings.connect('changed::units', lambda *args: self.display_distance_scale.queue_draw())
|
||||||
|
|
||||||
show_full_scale_button.connect('clicked', self._on_show_full_scale_button_clicked)
|
|
||||||
save_button.connect('clicked', self._on_save_button_clicked)
|
save_button.connect('clicked', self._on_save_button_clicked)
|
||||||
|
|
||||||
def _add_marks(self, lower_limit, upper_limit):
|
|
||||||
self.display_distance_scale.clear_marks()
|
|
||||||
|
|
||||||
if self.lower_limit_orig == lower_limit:
|
|
||||||
self.display_distance_scale.add_mark(self.lower_limit_orig, Gtk.PositionType.BOTTOM, _("closer"))
|
|
||||||
else:
|
|
||||||
self.display_distance_adjustment.set_lower(lower_limit)
|
|
||||||
|
|
||||||
self.display_distance_scale.add_mark(1.0, Gtk.PositionType.BOTTOM, _("fullscreen"))
|
|
||||||
|
|
||||||
if self.upper_limit_orig == upper_limit:
|
|
||||||
self.display_distance_scale.add_mark(self.upper_limit_orig, Gtk.PositionType.BOTTOM, _("farther"))
|
|
||||||
else:
|
|
||||||
self.display_distance_adjustment.set_upper(upper_limit)
|
|
||||||
|
|
||||||
def _on_show_full_scale_button_clicked(self, button):
|
|
||||||
self._add_marks(self.lower_limit_orig, self.upper_limit_orig)
|
|
||||||
self.display_distance_adjustment.set_lower(self.lower_limit_orig)
|
|
||||||
self.display_distance_adjustment.set_upper(self.upper_limit_orig)
|
|
||||||
|
|
||||||
def _on_save_button_clicked(self, button):
|
def _on_save_button_clicked(self, button):
|
||||||
self.on_save_callback(self.prev_distance, self.display_distance_adjustment.get_value())
|
self.on_save_callback(self.prev_distance, self.display_distance_adjustment.get_value())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,16 @@
|
||||||
<property name="adjustment">
|
<property name="adjustment">
|
||||||
<object class="GtkAdjustment" id="display_distance_adjustment">
|
<object class="GtkAdjustment" id="display_distance_adjustment">
|
||||||
<property name="lower">0.1</property>
|
<property name="lower">0.1</property>
|
||||||
<property name="upper">2.5</property>
|
<property name="upper">1.5</property>
|
||||||
<property name="step-increment">0.01</property>
|
<property name="step-increment">0.01</property>
|
||||||
<property name="value">1.05</property>
|
<property name="value">1.05</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
<marks>
|
||||||
|
<mark value="0.1" position="bottom" translatable="yes">closer</mark>
|
||||||
|
<mark value="1.0" position="bottom" translatable="yes">default</mark>
|
||||||
|
<mark value="1.5" position="bottom" translatable="yes">farther</mark>
|
||||||
|
</marks>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,6 @@
|
||||||
<template class="DisplayDistanceDialog" parent="GtkDialog">
|
<template class="DisplayDistanceDialog" parent="GtkDialog">
|
||||||
<property name="modal">1</property>
|
<property name="modal">1</property>
|
||||||
<property name="use-header-bar">1</property>
|
<property name="use-header-bar">1</property>
|
||||||
<child type="action">
|
|
||||||
<object class="GtkButton" id="show_full_scale_button">
|
|
||||||
<property name="label" translatable="yes">Show full range</property>
|
|
||||||
<property name="margin-top">10</property>
|
|
||||||
<property name="margin-bottom">10</property>
|
|
||||||
<property name="margin-start">10</property>
|
|
||||||
<property name="margin-end">10</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child type="action">
|
<child type="action">
|
||||||
<object class="GtkButton" id="save_button">
|
<object class="GtkButton" id="save_button">
|
||||||
<property name="label" translatable="yes">Done</property>
|
<property name="label" translatable="yes">Done</property>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue