Fix detection of device disconnect and disabling breezy effect, remove UI elements that aren't supported yet
This commit is contained in:
parent
d07ab207ed
commit
146611ca6f
|
|
@ -53,10 +53,10 @@ function checkParityByte(dataView) {
|
|||
|
||||
export const DeviceDataStream = GObject.registerClass({
|
||||
Properties: {
|
||||
'supported-device-connected': GObject.ParamSpec.boolean(
|
||||
'supported-device-connected',
|
||||
'Supported device connected',
|
||||
'Whether a supported device is connected',
|
||||
'breezy-desktop-running': GObject.ParamSpec.boolean(
|
||||
'breezy-desktop-running',
|
||||
'Breezy Desktop running',
|
||||
'Whether Breezy Desktop mode is enabled in xr_driver and supported glasses are connected',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
false
|
||||
),
|
||||
|
|
@ -77,7 +77,7 @@ export const DeviceDataStream = GObject.registerClass({
|
|||
}, class DeviceDataStream extends GObject.Object {
|
||||
constructor(params = {}) {
|
||||
super(params);
|
||||
this.supported_device_connected = false;
|
||||
this.breezy_desktop_running = false;
|
||||
this._ipc_file = Gio.file_new_for_path(IPC_FILE_PATH);
|
||||
this._running = false;
|
||||
this._device_data = null;
|
||||
|
|
@ -92,7 +92,7 @@ export const DeviceDataStream = GObject.registerClass({
|
|||
this._running = false;
|
||||
}
|
||||
|
||||
// polling is just intended to keep supported_device_connected current, anything needing up-to-date imu data should
|
||||
// polling is just intended to keep breezy_desktop_running current, anything needing up-to-date imu data should
|
||||
// trigger a refresh with the default flag
|
||||
_poll() {
|
||||
if (this._running) {
|
||||
|
|
@ -101,13 +101,13 @@ export const DeviceDataStream = GObject.registerClass({
|
|||
}
|
||||
}
|
||||
|
||||
// Refresh the data from the IPC file. if keepalive_only is true, we'll only check and update supported_device_connected if it
|
||||
// Refresh the data from the IPC file. if keepalive_only is true, we'll only check and update breezy_desktop_running if it
|
||||
// hasn't been checked within KEEPALIVE_REFRESH_INTERVAL_SEC.
|
||||
refresh_data(keepalive_only = false) {
|
||||
if (this._ipc_file.query_exists(null) && (
|
||||
!this._device_data?.imuData ||
|
||||
!keepalive_only ||
|
||||
getEpochSec() - this._device_data.imuDateMs > KEEPALIVE_REFRESH_INTERVAL_SEC
|
||||
getEpochSec() - toSec(this._device_data?.imuDateMs ?? 0) > KEEPALIVE_REFRESH_INTERVAL_SEC
|
||||
)) {
|
||||
let data = this._ipc_file.load_contents(null);
|
||||
if (data[0]) {
|
||||
|
|
@ -165,11 +165,12 @@ export const DeviceDataStream = GObject.registerClass({
|
|||
|
||||
if (success) {
|
||||
// update the supported device connected property if the state changes, trigger "notify::" events
|
||||
if (this.supported_device_connected !== validKeepalive) this.supported_device_connected = validKeepalive;
|
||||
const breezy_desktop_running = enabled && validKeepalive;
|
||||
if (this.breezy_desktop_running !== breezy_desktop_running) this.breezy_desktop_running = breezy_desktop_running;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.supported_device_connected = false;
|
||||
this.breezy_desktop_running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
this._follow_threshold_connection = null;
|
||||
this._widescreen_mode_settings_connection = null;
|
||||
this._widescreen_mode_effect_state_connection = null;
|
||||
this._supported_device_detected_connection = null;
|
||||
this._breezy_desktop_running_connection = null;
|
||||
this._start_binding = null;
|
||||
this._end_binding = null;
|
||||
this._curved_display_binding = null;
|
||||
|
|
@ -128,18 +128,18 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
return GLib.SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
if (Globals.data_stream.supported_device_connected && target_monitor) {
|
||||
if (Globals.data_stream.breezy_desktop_running && target_monitor) {
|
||||
// Don't enable the effect yet if monitor updates are needed.
|
||||
// _setup will be triggered again since a !ready result means it will trigger monitor changes,
|
||||
// so we can remove this timeout_add no matter what.
|
||||
if (this._target_monitor_ready(target_monitor)) {
|
||||
Globals.logger.log('Glasses detected, supported monitor connected. Enabling XR effect.');
|
||||
Globals.logger.log('Breezy enabled, supported monitor connected. Enabling XR effect.');
|
||||
this._effect_enable();
|
||||
}
|
||||
this._running_poller_id = undefined;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
} else {
|
||||
Globals.logger.log_debug(`BreezyDesktopExtension _poll_for_ready - device connected: ${Globals.data_stream.supported_device_connected}, target_monitor: ${!!target_monitor}`);
|
||||
Globals.logger.log_debug(`BreezyDesktopExtension _poll_for_ready - device connected: ${Globals.data_stream.breezy_desktop_running}, target_monitor: ${!!target_monitor}`);
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -233,17 +233,17 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
if (target_monitor && this._running_poller_id === undefined) {
|
||||
this._target_monitor = target_monitor;
|
||||
|
||||
if (Globals.data_stream.supported_device_connected) {
|
||||
if (Globals.data_stream.breezy_desktop_running) {
|
||||
// Don't enable the effect yet if monitor updates are needed.
|
||||
// _setup will be triggered again since a !ready result means it will trigger monitor changes
|
||||
if (this._target_monitor_ready(target_monitor)) {
|
||||
Globals.logger.log('Ready, enabling XR effect');
|
||||
this._effect_enable();
|
||||
} else {
|
||||
Globals.logger.log_debug('BreezyDesktopExtension _setup - glasses detected but async monitor action needed');
|
||||
Globals.logger.log_debug('BreezyDesktopExtension _setup - breezy desktop enabled but async monitor action needed');
|
||||
}
|
||||
} else {
|
||||
Globals.logger.log_debug('BreezyDesktopExtension _setup - glasses not detected, starting poller');
|
||||
Globals.logger.log_debug('BreezyDesktopExtension _setup - breezy desktop not enabled, starting poller');
|
||||
this._poll_for_ready();
|
||||
}
|
||||
} else {
|
||||
|
|
@ -323,7 +323,7 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
// this._update_widescreen_mode_from_settings(this.settings);
|
||||
|
||||
// this._widescreen_mode_effect_state_connection = this._xr_effect.connect('notify::widescreen-mode-state', this._update_widescreen_mode_from_state.bind(this));
|
||||
// this._supported_device_detected_connection = this._xr_effect.connect('notify::supported-device-detected', this._handle_supported_device_change.bind(this));
|
||||
this._breezy_desktop_running_connection = Globals.data_stream.connect('notify::breezy-desktop-running', this._handle_breezy_desktop_running_change.bind(this));
|
||||
this._overlay_content.renderMonitors();
|
||||
|
||||
this._distance_binding = this.settings.bind('display-distance', this._overlay_content, 'display-distance', Gio.SettingsBindFlags.DEFAULT);
|
||||
|
|
@ -505,13 +505,13 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
this._setup();
|
||||
}
|
||||
|
||||
_handle_supported_device_change(effect, _pspec) {
|
||||
const device_connected = effect.supported_device_detected;
|
||||
Globals.logger.log_debug(`BreezyDesktopExtension _handle_supported_device_change ${device_connected}`);
|
||||
_handle_breezy_desktop_running_change(effect, _pspec) {
|
||||
const breezy_desktop_running = effect.breezy_desktop_running;
|
||||
Globals.logger.log_debug(`BreezyDesktopExtension _handle_breezy_desktop_running_change ${breezy_desktop_running}`);
|
||||
|
||||
// this will disable the effect and begin polling for a ready state again
|
||||
if (!device_connected && this._is_effect_running) {
|
||||
Globals.logger.log('Supported device disconnected');
|
||||
if (!breezy_desktop_running && this._is_effect_running) {
|
||||
Globals.logger.log('Breezy desktop disabled');
|
||||
this._setup(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -632,21 +632,21 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
this._disable_anti_aliasing_binding = null;
|
||||
}
|
||||
if (this._overlay) {
|
||||
global.stage.remove_child(this._overlay);
|
||||
this._overlay.destroy();
|
||||
this._overlay = null;
|
||||
if (this._overlay_content) {
|
||||
// if (this._widescreen_mode_effect_state_connection) {
|
||||
// this._xr_effect.disconnect(this._widescreen_mode_effect_state_connection);
|
||||
// this._widescreen_mode_effect_state_connection = null;
|
||||
// }
|
||||
// if (this._supported_device_detected_connection) {
|
||||
// this._xr_effect.disconnect(this._supported_device_detected_connection);
|
||||
// this._supported_device_detected_connection = null;
|
||||
// }
|
||||
if (this._breezy_desktop_running_connection) {
|
||||
Globals.data_stream.disconnect(this._breezy_desktop_running_connection);
|
||||
this._breezy_desktop_running_connection = null;
|
||||
}
|
||||
this._overlay_content.destroy();
|
||||
this._overlay_content = null;
|
||||
}
|
||||
global.stage.remove_child(this._overlay);
|
||||
this._overlay.destroy();
|
||||
this._overlay = null;
|
||||
|
||||
}
|
||||
if (this._cursor_manager) {
|
||||
|
|
@ -668,9 +668,9 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
disable() {
|
||||
try {
|
||||
Globals.logger.log_debug('BreezyDesktopExtension disable');
|
||||
Globals.data_stream.stop();
|
||||
|
||||
this._effect_disable();
|
||||
Globals.data_stream.stop();
|
||||
this._target_monitor = null;
|
||||
|
||||
if (this._monitor_manager) {
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ class ConnectedDevice(Gtk.Box):
|
|||
display_distance_adjustment = Gtk.Template.Child()
|
||||
display_size_scale = Gtk.Template.Child()
|
||||
display_size_adjustment = Gtk.Template.Child()
|
||||
follow_threshold_scale = Gtk.Template.Child()
|
||||
follow_threshold_adjustment = Gtk.Template.Child()
|
||||
follow_mode_switch = Gtk.Template.Child()
|
||||
widescreen_mode_switch = Gtk.Template.Child()
|
||||
widescreen_mode_row = Gtk.Template.Child()
|
||||
curved_display_switch = Gtk.Template.Child()
|
||||
# follow_threshold_scale = Gtk.Template.Child()
|
||||
# follow_threshold_adjustment = Gtk.Template.Child()
|
||||
# follow_mode_switch = Gtk.Template.Child()
|
||||
# widescreen_mode_switch = Gtk.Template.Child()
|
||||
# widescreen_mode_row = Gtk.Template.Child()
|
||||
# curved_display_switch = Gtk.Template.Child()
|
||||
add_virtual_display_button = Gtk.Template.Child()
|
||||
set_toggle_display_distance_start_button = Gtk.Template.Child()
|
||||
set_toggle_display_distance_end_button = Gtk.Template.Child()
|
||||
|
|
@ -60,9 +60,9 @@ class ConnectedDevice(Gtk.Box):
|
|||
self.all_enabled_state_inputs = [
|
||||
self.display_distance_scale,
|
||||
self.display_size_scale,
|
||||
self.follow_mode_switch,
|
||||
self.follow_threshold_scale,
|
||||
self.curved_display_switch,
|
||||
# self.follow_mode_switch,
|
||||
# self.follow_threshold_scale,
|
||||
# self.curved_display_switch,
|
||||
# self.add_virtual_display_button,
|
||||
self.set_toggle_display_distance_start_button,
|
||||
self.set_toggle_display_distance_end_button,
|
||||
|
|
@ -76,9 +76,9 @@ class ConnectedDevice(Gtk.Box):
|
|||
|
||||
self.settings.bind('display-distance', self.display_distance_adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||
self.settings.bind('display-size', self.display_size_adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||
self.settings.bind('follow-threshold', self.follow_threshold_adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||
self.settings.bind('widescreen-mode', self.widescreen_mode_switch, 'active', Gio.SettingsBindFlags.DEFAULT)
|
||||
self.settings.bind('curved-display', self.curved_display_switch, 'active', Gio.SettingsBindFlags.DEFAULT)
|
||||
# self.settings.bind('follow-threshold', self.follow_threshold_adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||
# self.settings.bind('widescreen-mode', self.widescreen_mode_switch, 'active', Gio.SettingsBindFlags.DEFAULT)
|
||||
# self.settings.bind('curved-display', self.curved_display_switch, 'active', Gio.SettingsBindFlags.DEFAULT)
|
||||
self.settings.bind('headset-as-primary', self.headset_as_primary_switch, 'active', Gio.SettingsBindFlags.DEFAULT)
|
||||
self.settings.bind('use-optimal-monitor-config', self.use_optimal_monitor_config_switch, 'active', Gio.SettingsBindFlags.DEFAULT)
|
||||
self.settings.bind('use-highest-refresh-rate', self.use_highest_refresh_rate_switch, 'active', Gio.SettingsBindFlags.DEFAULT)
|
||||
|
|
@ -100,12 +100,12 @@ class ConnectedDevice(Gtk.Box):
|
|||
self.add_virtual_display_button.connect('clicked', self.on_add_virtual_display)
|
||||
|
||||
self.state_manager = StateManager.get_instance()
|
||||
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.state_manager.connect('notify::enabled-features-list', self._handle_enabled_features)
|
||||
self.state_manager.connect('notify::device-supports-sbs', self._handle_device_supports_sbs)
|
||||
|
||||
self.follow_mode_switch.set_active(self.state_manager.get_property('follow-mode'))
|
||||
self.follow_mode_switch.connect('notify::active', self._refresh_follow_mode)
|
||||
# self.follow_mode_switch.set_active(self.state_manager.get_property('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.config_manager = ConfigManager.get_instance()
|
||||
|
|
@ -131,9 +131,9 @@ class ConnectedDevice(Gtk.Box):
|
|||
def _handle_device_supports_sbs(self, state_manager, val):
|
||||
if not state_manager.get_property('device-supports-sbs'):
|
||||
self.settings.set_boolean('widescreen-mode', False)
|
||||
self.widescreen_mode_switch.set_sensitive(state_manager.get_property('device-supports-sbs'))
|
||||
subtitle = self.widescreen_mode_subtitle if state_manager.get_property('device-supports-sbs') else self.widescreen_mode_not_supported_subtitle
|
||||
self.widescreen_mode_row.set_subtitle(subtitle)
|
||||
# self.widescreen_mode_switch.set_sensitive(state_manager.get_property('device-supports-sbs'))
|
||||
# subtitle = self.widescreen_mode_subtitle if state_manager.get_property('device-supports-sbs') else self.widescreen_mode_not_supported_subtitle
|
||||
# self.widescreen_mode_row.set_subtitle(subtitle)
|
||||
|
||||
def _handle_enabled_config(self, object, val):
|
||||
enabled = self.config_manager.get_property('breezy-desktop-enabled') and self.extensions_manager.get_property('breezy-enabled')
|
||||
|
|
@ -152,8 +152,8 @@ class ConnectedDevice(Gtk.Box):
|
|||
for widget in self.all_enabled_state_inputs:
|
||||
widget.set_sensitive(requesting_enabled)
|
||||
|
||||
if requesting_enabled:
|
||||
self._refresh_follow_mode(self.follow_mode_switch, None)
|
||||
# if requesting_enabled:
|
||||
# self._refresh_follow_mode(self.follow_mode_switch, None)
|
||||
|
||||
def _refresh_follow_mode(self, switch, param):
|
||||
self.follow_threshold_scale.set_sensitive(switch.get_active())
|
||||
|
|
@ -186,11 +186,11 @@ class ConnectedDevice(Gtk.Box):
|
|||
logger.info("Virtual display ready")
|
||||
|
||||
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-size', self.display_size_adjustment, 'value')
|
||||
self.settings.unbind('follow-threshold', self.follow_threshold_adjustment, 'value')
|
||||
self.settings.unbind('widescreen-mode', self.widescreen_mode_switch, 'active')
|
||||
# self.settings.unbind('widescreen-mode', self.widescreen_mode_switch, 'active')
|
||||
|
||||
def reload_display_distance_toggle_button(widget):
|
||||
distance = SettingsManager.get_instance().settings.get_double(widget.get_name())
|
||||
|
|
|
|||
|
|
@ -50,40 +50,6 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow" id="widescreen_mode_row">
|
||||
<property name="title" translatable="yes"><!-- feature switch -->Widescreen mode</property>
|
||||
<property name="valign">2</property>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="widescreen_mode_switch">
|
||||
<property name="valign">3</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes"><!-- feature switch -->Follow mode</property>
|
||||
<property name="subtitle" translatable="yes">Keep the virtual display near the center of your view.</property>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="follow_mode_switch">
|
||||
<property name="valign">3</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes"><!-- feature switch -->Curved display</property>
|
||||
<property name="subtitle" translatable="yes">Switch between flat and curved displays.</property>
|
||||
<property name="valign">2</property>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="curved_display_switch">
|
||||
<property name="valign">3</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes"><!-- adjustment slider -->Virtual monitors</property>
|
||||
|
|
@ -186,30 +152,6 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes"><!-- adjustment slider -->Follow threshold</property>
|
||||
<property name="subtitle" translatable="yes">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>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
|||
Loading…
Reference in New Issue