Add the follow threshold control
This commit is contained in:
parent
aef60af4a6
commit
0d3f9ff757
|
|
@ -35,6 +35,8 @@ export default class BreezyDesktopExtension extends Extension {
|
||||||
this._target_monitor = null;
|
this._target_monitor = null;
|
||||||
this._is_effect_running = false;
|
this._is_effect_running = false;
|
||||||
this._distance_binding = null;
|
this._distance_binding = null;
|
||||||
|
this._distance_connection = null;
|
||||||
|
this._follow_threshold_connection = null;
|
||||||
this._start_binding = null;
|
this._start_binding = null;
|
||||||
this._end_binding = null;
|
this._end_binding = null;
|
||||||
|
|
||||||
|
|
@ -179,7 +181,12 @@ export default class BreezyDesktopExtension extends Extension {
|
||||||
toggle_display_distance_end: this.settings.get_double('toggle-display-distance-end'),
|
toggle_display_distance_end: this.settings.get_double('toggle-display-distance-end'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._update_display_distance(this.settings);
|
||||||
|
this._update_follow_threshold(this.settings);
|
||||||
|
|
||||||
this._distance_binding = this.settings.bind('display-distance', this._xr_effect, 'display-distance', Gio.SettingsBindFlags.DEFAULT)
|
this._distance_binding = this.settings.bind('display-distance', this._xr_effect, 'display-distance', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
this._distance_connection = this.settings.connect('changed::display-distance', this._update_display_distance.bind(this))
|
||||||
|
this._follow_threshold_connection = this.settings.connect('changed::follow-threshold', this._update_follow_threshold.bind(this))
|
||||||
this._start_binding = this.settings.bind('toggle-display-distance-start', this._xr_effect, 'toggle-display-distance-start', Gio.SettingsBindFlags.DEFAULT)
|
this._start_binding = this.settings.bind('toggle-display-distance-start', this._xr_effect, 'toggle-display-distance-start', Gio.SettingsBindFlags.DEFAULT)
|
||||||
this._end_binding = this.settings.bind('toggle-display-distance-end', this._xr_effect, 'toggle-display-distance-end', Gio.SettingsBindFlags.DEFAULT)
|
this._end_binding = this.settings.bind('toggle-display-distance-end', this._xr_effect, 'toggle-display-distance-end', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
|
||||||
|
|
@ -236,6 +243,18 @@ export default class BreezyDesktopExtension extends Extension {
|
||||||
stream.close(null);
|
stream.close(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_update_display_distance(settings, event) {
|
||||||
|
const value = settings.get_double('display-distance');
|
||||||
|
Globals.logger.log_debug(`BreezyDesktopExtension _update_display_distance ${value}`);
|
||||||
|
if (value !== undefined) this._write_control('breezy_desktop_display_distance', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
_update_follow_threshold(settings, event) {
|
||||||
|
const value = settings.get_double('follow-threshold');
|
||||||
|
Globals.logger.log_debug(`BreezyDesktopExtension _update_follow_threshold ${value}`);
|
||||||
|
if (value !== undefined) this._write_control('breezy_desktop_follow_threshold', value);
|
||||||
|
}
|
||||||
|
|
||||||
_recenter_display() {
|
_recenter_display() {
|
||||||
Globals.logger.log_debug('BreezyDesktopExtension _recenter_display');
|
Globals.logger.log_debug('BreezyDesktopExtension _recenter_display');
|
||||||
this._write_control('recenter_screen', 'true');
|
this._write_control('recenter_screen', 'true');
|
||||||
|
|
@ -269,6 +288,14 @@ export default class BreezyDesktopExtension extends Extension {
|
||||||
this.settings.unbind(this._distance_binding);
|
this.settings.unbind(this._distance_binding);
|
||||||
this._distance_binding = null;
|
this._distance_binding = null;
|
||||||
}
|
}
|
||||||
|
if (this._distance_connection) {
|
||||||
|
this.settings.disconnect(this._distance_connection);
|
||||||
|
this._distance_connection = null;
|
||||||
|
}
|
||||||
|
if (this._follow_threshold_connection) {
|
||||||
|
this.settings.disconnect(this._follow_threshold_connection);
|
||||||
|
this._follow_threshold_connection = null;
|
||||||
|
}
|
||||||
if (this._start_binding) {
|
if (this._start_binding) {
|
||||||
this.settings.unbind(this._start_binding);
|
this.settings.unbind(this._start_binding);
|
||||||
this._start_binding = null;
|
this._start_binding = null;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8e5513c89df30ca2cfdcd03947dcb8d9562db6b3
|
Subproject commit 4e74072c2e5656243767ba6c205453c3d3137975
|
||||||
|
|
@ -37,6 +37,15 @@
|
||||||
How far away the display appears. Farther will look smaller, closer will look larger.
|
How far away the display appears. Farther will look smaller, closer will look larger.
|
||||||
</description>
|
</description>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="follow-threshold" type="d">
|
||||||
|
<default>
|
||||||
|
15
|
||||||
|
</default>
|
||||||
|
<summary>Follow threshold</summary>
|
||||||
|
<description>
|
||||||
|
When follow mode is enabled: the threshold, in degrees, at which the display will begin to follow
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
<key name="toggle-display-distance-start" type="d">
|
<key name="toggle-display-distance-start" type="d">
|
||||||
<default>
|
<default>
|
||||||
0.85
|
0.85
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ class ConnectedDevice(Gtk.Box):
|
||||||
effect_enable_switch = Gtk.Template.Child()
|
effect_enable_switch = Gtk.Template.Child()
|
||||||
display_distance_scale = Gtk.Template.Child()
|
display_distance_scale = Gtk.Template.Child()
|
||||||
display_distance_adjustment = Gtk.Template.Child()
|
display_distance_adjustment = Gtk.Template.Child()
|
||||||
|
follow_threshold_scale = Gtk.Template.Child()
|
||||||
|
follow_threshold_adjustment = Gtk.Template.Child()
|
||||||
follow_mode_switch = Gtk.Template.Child()
|
follow_mode_switch = Gtk.Template.Child()
|
||||||
device_label = Gtk.Template.Child()
|
device_label = Gtk.Template.Child()
|
||||||
set_toggle_display_distance_start_button = Gtk.Template.Child()
|
set_toggle_display_distance_start_button = Gtk.Template.Child()
|
||||||
|
|
@ -29,6 +31,7 @@ class ConnectedDevice(Gtk.Box):
|
||||||
self.all_enabled_state_inputs = [
|
self.all_enabled_state_inputs = [
|
||||||
self.display_distance_scale,
|
self.display_distance_scale,
|
||||||
self.follow_mode_switch,
|
self.follow_mode_switch,
|
||||||
|
self.follow_threshold_scale,
|
||||||
self.set_toggle_display_distance_start_button,
|
self.set_toggle_display_distance_start_button,
|
||||||
self.set_toggle_display_distance_end_button,
|
self.set_toggle_display_distance_end_button,
|
||||||
self.reassign_recenter_display_shortcut_button,
|
self.reassign_recenter_display_shortcut_button,
|
||||||
|
|
@ -41,6 +44,7 @@ class ConnectedDevice(Gtk.Box):
|
||||||
self.extensions_manager = ExtensionsManager.get_instance()
|
self.extensions_manager = ExtensionsManager.get_instance()
|
||||||
|
|
||||||
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.settings.bind('follow-threshold', self.follow_threshold_adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
|
||||||
bind_shortcut_settings(self.get_parent(), [
|
bind_shortcut_settings(self.get_parent(), [
|
||||||
[self.reassign_recenter_display_shortcut_button, self.recenter_display_shortcut_label],
|
[self.reassign_recenter_display_shortcut_button, self.recenter_display_shortcut_label],
|
||||||
|
|
@ -57,7 +61,7 @@ class ConnectedDevice(Gtk.Box):
|
||||||
self.state_manager.bind_property('follow-mode', self.follow_mode_switch, 'active', GObject.BindingFlags.DEFAULT)
|
self.state_manager.bind_property('follow-mode', self.follow_mode_switch, 'active', GObject.BindingFlags.DEFAULT)
|
||||||
|
|
||||||
self.follow_mode_switch.set_active(self.state_manager.follow_mode)
|
self.follow_mode_switch.set_active(self.state_manager.follow_mode)
|
||||||
self.follow_mode_switch.connect('notify::active', self._request_follow_mode)
|
self.follow_mode_switch.connect('notify::active', self._refresh_follow_mode)
|
||||||
|
|
||||||
self.effect_enable_switch.set_active(self._is_config_enabled(self.ipc.retrieve_config()) and self.extensions_manager.is_enabled())
|
self.effect_enable_switch.set_active(self._is_config_enabled(self.ipc.retrieve_config()) and self.extensions_manager.is_enabled())
|
||||||
self.effect_enable_switch.connect('notify::active', self._refresh_inputs_for_enabled_state)
|
self.effect_enable_switch.connect('notify::active', self._refresh_inputs_for_enabled_state)
|
||||||
|
|
@ -83,8 +87,11 @@ class ConnectedDevice(Gtk.Box):
|
||||||
|
|
||||||
for widget in self.all_enabled_state_inputs:
|
for widget in self.all_enabled_state_inputs:
|
||||||
widget.set_sensitive(requesting_enabled)
|
widget.set_sensitive(requesting_enabled)
|
||||||
|
|
||||||
|
if requesting_enabled: self._refresh_follow_mode(self.follow_mode_switch, None)
|
||||||
|
|
||||||
def _request_follow_mode(self, switch, param):
|
def _refresh_follow_mode(self, switch, param):
|
||||||
|
self.follow_threshold_scale.set_sensitive(switch.get_active())
|
||||||
if (self.state_manager.follow_mode == switch.get_active()):
|
if (self.state_manager.follow_mode == switch.get_active()):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -103,6 +110,7 @@ class ConnectedDevice(Gtk.Box):
|
||||||
def _on_widget_destroy(self, widget):
|
def _on_widget_destroy(self, widget):
|
||||||
self.state_manager.unbind_property('follow-mode', self.follow_mode_switch, 'active')
|
self.state_manager.unbind_property('follow-mode', self.follow_mode_switch, 'active')
|
||||||
self.settings.unbind('display-distance', self.display_distance_adjustment, 'value')
|
self.settings.unbind('display-distance', self.display_distance_adjustment, 'value')
|
||||||
|
self.settings.unbind('follow-threshold', self.follow_threshold_adjustment, 'value')
|
||||||
self.extensions_manager.unbind_property('breezy-enabled', self.effect_enable_switch, 'active')
|
self.extensions_manager.unbind_property('breezy-enabled', self.effect_enable_switch, 'active')
|
||||||
|
|
||||||
def reload_display_distance_toggle_button(widget):
|
def reload_display_distance_toggle_button(widget):
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,30 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow">
|
||||||
|
<property name="title" translatable="true">Follow threshold</property>
|
||||||
|
<property name="subtitle" translatable="true">How far away you can look before the display follows</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkScale" id="follow_threshold_scale">
|
||||||
|
<property name="valign">3</property>
|
||||||
|
<property name="draw-value">true</property>
|
||||||
|
<property name="value-pos">0</property>
|
||||||
|
<property name="digits">0</property>
|
||||||
|
<property name="width-request">350</property>
|
||||||
|
<property name="has-origin">false</property>
|
||||||
|
<property name="adjustment">
|
||||||
|
<object class="GtkAdjustment" id="follow_threshold_adjustment">
|
||||||
|
<property name="lower">1</property>
|
||||||
|
<property name="upper">45</property>
|
||||||
|
<property name="step-increment">1</property>
|
||||||
|
<property name="value">15</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class LicenseDialog(Gtk.Dialog):
|
||||||
def _handle_license_idle(self, state_manager):
|
def _handle_license_idle(self, state_manager):
|
||||||
self.refresh_license_button.set_sensitive(False)
|
self.refresh_license_button.set_sensitive(False)
|
||||||
|
|
||||||
license_view = state_manager.state['ui_view']['license']
|
license_view = state_manager.state['ui_view'].get('license', {})
|
||||||
self.request_token.set_visible(not state_manager.confirmed_token)
|
self.request_token.set_visible(not state_manager.confirmed_token)
|
||||||
self.verify_token.set_visible(not state_manager.confirmed_token)
|
self.verify_token.set_visible(not state_manager.confirmed_token)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ class StateManager(GObject.GObject):
|
||||||
|
|
||||||
__gproperties__ = {
|
__gproperties__ = {
|
||||||
'follow-mode': (bool, 'Follow Mode', 'Whether the follow mode is enabled', False, GObject.ParamFlags.READWRITE),
|
'follow-mode': (bool, 'Follow Mode', 'Whether the follow mode is enabled', False, GObject.ParamFlags.READWRITE),
|
||||||
|
'follow-threshold': (float, 'Follow Threshold', 'The follow threshold', 1.0, 45.0, 15.0, GObject.ParamFlags.READWRITE),
|
||||||
'license-action-needed-seconds': (int, 'License Action Needed Seconds', 'The remaining time until the license action is needed', 0, LICENSE_ACTION_NEEDED_MAX, 0, GObject.ParamFlags.READWRITE),
|
'license-action-needed-seconds': (int, 'License Action Needed Seconds', 'The remaining time until the license action is needed', 0, LICENSE_ACTION_NEEDED_MAX, 0, GObject.ParamFlags.READWRITE),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue