Fix enable/disable shortcut so that widescreen gets disabled with the effect

This commit is contained in:
wheaney 2024-10-20 13:21:51 -07:00
parent 1e7957ef8a
commit 05e4e36ddb
2 changed files with 11 additions and 11 deletions

View File

@ -173,11 +173,13 @@ export default class BreezyDesktopExtension extends Extension {
return !needs_sbs_mode_switch && !this._monitor_manager.needsOptimalModeCheck(target_monitor.connector);
}
_setup() {
// for_disable should be true if we're using this function to disable the
// effect without anticipating an immediate re-enable
_setup(for_disable = false) {
Globals.logger.log_debug('BreezyDesktopExtension _setup');
if (this._is_effect_running) {
Globals.logger.log('Reset triggered, disabling XR effect');
this._effect_disable(true);
this._effect_disable(!for_disable);
}
const target_monitor = this._find_supported_monitor();
@ -213,9 +215,7 @@ export default class BreezyDesktopExtension extends Extension {
if (Globals.ipc_file.query_exists(null)) {
const file_info = Globals.ipc_file.query_info(Gio.FILE_ATTRIBUTE_TIME_MODIFIED, Gio.FileQueryInfoFlags.NONE, null);
const file_modified_time = file_info.get_attribute_uint64(Gio.FILE_ATTRIBUTE_TIME_MODIFIED);
// when the driver is running, the IMU file is updated at least 60x per second, do a strict check
return isValidKeepAlive(file_modified_time, true);
return isValidKeepAlive(file_modified_time);
}
} catch (e) {
Globals.logger.log(`ERROR: BreezyDesktopExtension _check_driver_running ${e.message}\n${e.stack}`);
@ -460,13 +460,13 @@ export default class BreezyDesktopExtension extends Extension {
}
_handle_supported_device_change(effect, _pspec) {
const value = effect.supported_device_detected;
Globals.logger.log_debug(`BreezyDesktopExtension _handle_supported_device_change ${value}`);
const device_connected = effect.supported_device_detected;
Globals.logger.log_debug(`BreezyDesktopExtension _handle_supported_device_change ${device_connected}`);
// this will disable the effect and begin polling for a ready state again
if (!value && this._is_effect_running) {
if (!device_connected && this._is_effect_running) {
Globals.logger.log('Supported device disconnected');
this._setup();
this._setup(true);
}
}

View File

@ -6,6 +6,6 @@ export function toSec(milliseconds) {
return Math.floor(milliseconds / 1000);
}
export function isValidKeepAlive(dateSec, strictCheck = false) {
return Math.abs(toSec(Date.now()) - dateSec) <= (strictCheck ? 1 : 5);
export function isValidKeepAlive(dateSec) {
return Math.abs(toSec(Date.now()) - dateSec) <= 1;
}