diff --git a/gnome/breezydesktop@org.xronlinux/IMUAdjust.frag b/gnome/breezydesktop@org.xronlinux/IMUAdjust.frag index 371b577..bcbd64a 100644 --- a/gnome/breezydesktop@org.xronlinux/IMUAdjust.frag +++ b/gnome/breezydesktop@org.xronlinux/IMUAdjust.frag @@ -56,17 +56,6 @@ vec3 rateOfChange( return (v1 - v2) / delta_time; } -bool isKeepaliveRecent( - in vec4 currentDate, - in vec4 keepAliveDate) { - float _174 = currentDate.w + float(day_in_seconds); - float _176 = _174 - keepAliveDate.w; - float _178 = mod(_176, float(day_in_seconds)); - float _179 = abs(_178); - bool _181 = _179 <= 5.00000000e+00; - return _181; -} - void PS_IMU_Transform(vec4 pos, vec2 texcoord, out vec4 color) { float texcoord_x_min = 0.0; float texcoord_x_max = 1.0; diff --git a/gnome/breezydesktop@org.xronlinux/cursor.js b/gnome/breezydesktop@org.xronlinux/cursor.js index d7ff3e3..123c720 100644 --- a/gnome/breezydesktop@org.xronlinux/cursor.js +++ b/gnome/breezydesktop@org.xronlinux/cursor.js @@ -38,7 +38,7 @@ export const MouseSpriteContent = GObject.registerClass({ if (!this._texture) return; - let color = Clutter.Color.from_string('#ffffff'); // white + let color = Clutter.Color.get_static(Clutter.StaticColor.WHITE); let [minFilter, magFilter] = actor.get_content_scaling_filters(); let textureNode = new Clutter.TextureNode(this._texture, color, minFilter, magFilter); diff --git a/gnome/breezydesktop@org.xronlinux/cursormanager.js b/gnome/breezydesktop@org.xronlinux/cursormanager.js index a98e258..9b5eb93 100644 --- a/gnome/breezydesktop@org.xronlinux/cursormanager.js +++ b/gnome/breezydesktop@org.xronlinux/cursormanager.js @@ -60,6 +60,7 @@ export class CursorManager { _enable() { this._cloneMouseSetting = true; // this._settings.get_boolean('clone-mouse'); this._enableCloningMouse(); + this.startCloning(); // this._cloneMouseSettingChangedConnection = this._settings.connect('changed::clone-mouse', this._on_clone_mouse_change.bind(this)); } @@ -116,29 +117,30 @@ export class CursorManager { _on_clone_mouse_change() { const cloneMouse = true; // this._settings.get_boolean('clone-mouse'); if (cloneMouse == this._cloneMouseSetting) { - this._logger.log_debug('_on_clone_mouse_change(): no setting change, no change'); + console.log('_on_clone_mouse_change(): no setting change, no change'); return; } if (cloneMouse) { // Starting to clone mouse - this._logger.log_debug('_on_clone_mouse_change(): starting mouse cloning'); + console.log('_on_clone_mouse_change(): starting mouse cloning'); this._cloneMouseSetting = true; this._enableCloningMouse(); if (this._changeHookFn !== null) { this._changeHookFn(); } } else { - this._logger.log_debug('_on_clone_mouse_change(): stopping mouse cloning'); + console.log('_on_clone_mouse_change(): stopping mouse cloning'); this._disableCloningMouse(); this._cloneMouseSetting = false; } } _enableCloningMouse() { + console.log(`_enableCloningMouse()`); if (!this._isMouseClonable()) { return; } - this._logger.log_debug('_enableCloningMouse()'); + console.log(`_enableCloningMouse() 1`); this._cursorWantedVisible = true; this._cursorTracker = Meta.CursorTracker.get_for_display(global.display); @@ -153,6 +155,7 @@ export class CursorManager { this._cursorActor.add_actor(this._cursorSprite); this._cursorWatcher = PointerWatcher.getPointerWatcher(); this._cursorSeat = Clutter.get_default_backend().get_default_seat(); + console.log(`_enableCloningMouse() 2`); } _disableCloningMouse() { @@ -160,7 +163,7 @@ export class CursorManager { return; } this._stopCloningShowMouse(); - this._logger.log_debug('_disableCloningMouse()'); + console.log('_disableCloningMouse()'); Meta.CursorTracker.prototype.set_pointer_visible = this._cursorTrackerSetPointerVisible; @@ -182,6 +185,7 @@ export class CursorManager { } _cursorTrackerSetPointerVisibleReplacement(visible) { + console.log(`_cursorTrackerSetPointerVisibleReplacement(${visible})`); if (visible) { this._startCloningMouse(); // For some reason, exiting the magnifier causes the @@ -202,13 +206,13 @@ export class CursorManager { if (!this._isMouseClonable()) { return; } - this._logger.log_debug('_startCloningMouse()'); + console.log('_startCloningMouse()'); if (this._cursorWatch == null) { this._mainActor.add_actor(this._cursorActor); this._cursorChangedConnection = this._cursorTracker.connect('cursor-changed', this._updateMouseSprite.bind(this)); this._cursorVisibilityChangedConnection = this._cursorTracker.connect('visibility-changed', this._updateMouseSprite.bind(this)); const interval = 1000 / 60; - this._logger.log_debug('_startCloningMouse(): watch interval = ' + interval + ' ms'); + console.log('_startCloningMouse(): watch interval = ' + interval + ' ms'); this._cursorWatch = this._cursorWatcher.addWatch(interval, this._updateMousePosition.bind(this)); this._updateMouseSprite(); @@ -229,7 +233,7 @@ export class CursorManager { if (!this._isMouseClonable()) { return; } - this._logger.log_debug('_stopCloningShowMouse(), restoring cursor visibility to ' + this._cursorWantedVisible); + console.log('_stopCloningShowMouse(), restoring cursor visibility to ' + this._cursorWantedVisible); this._stopCloningMouse(); this._setPointerVisible(this._cursorWantedVisible); @@ -247,7 +251,7 @@ export class CursorManager { return; } if (this._cursorWatch != null) { - this._logger.log_debug('_stopCloningMouse()'); + console.log('_stopCloningMouse()'); this._cursorWatch.remove(); this._cursorWatch = null; @@ -267,7 +271,7 @@ export class CursorManager { _updateMousePosition(actor, event) { const [x, y, mask] = global.get_pointer(); this._cursorActor.set_position(x, y); - this._delayedSetPointerInvisible(); + // this._delayedSetPointerInvisible(); } _updateMouseSprite() { @@ -284,7 +288,7 @@ export class CursorManager { translation_x: -xHot, translation_y: -yHot, }); - this._delayedSetPointerInvisible(); + // this._delayedSetPointerInvisible(); } _delayedSetPointerInvisible() { diff --git a/gnome/breezydesktop@org.xronlinux/extension.js b/gnome/breezydesktop@org.xronlinux/extension.js index 34bdc0d..c5f0265 100644 --- a/gnome/breezydesktop@org.xronlinux/extension.js +++ b/gnome/breezydesktop@org.xronlinux/extension.js @@ -43,6 +43,7 @@ const SBS_CONTENT = [dataViewEnd(SBS_ENABLED), BOOL_SIZE, 1]; const SBS_MODE_STRETCHED = [dataViewEnd(SBS_CONTENT), BOOL_SIZE, 1]; const CUSTOM_BANNER_ENABLED = [dataViewEnd(SBS_MODE_STRETCHED), BOOL_SIZE, 1]; const IMU_QUAT_DATA = [dataViewEnd(CUSTOM_BANNER_ENABLED), FLOAT_SIZE, 16]; +const DATA_VIEW_LENGTH = dataViewEnd(IMU_QUAT_DATA); // cached after first retrieval const shaderUniformLocations = { @@ -155,46 +156,51 @@ function degreeToRadian(degree) { // most uniforms don't change frequently, this function should be called periodically function setIntermittentUniformVariables() { const dataView = this._dataView; - const version = dataViewUint8(dataView, VERSION); - const date = dataViewUint(dataView, EPOCH_SEC); - const validKeepalive = Math.abs(getEpochSec() - date) < 5; - const imuData = dataViewFloatArray(dataView, IMU_QUAT_DATA); - const imuResetState = imuData[0] === 0.0 && imuData[1] === 0.0 && imuData[2] === 0.0 && imuData[3] === 1.0; - const enabled = dataViewUint8(dataView, ENABLED) !== 0 && version === DATA_LAYOUT_VERSION && validKeepalive && !imuResetState; - if (enabled) { - const displayRes = dataViewUintArray(dataView, DISPLAY_RES); - const displayFov = dataViewFloat(dataView, DISPLAY_FOV); - const lensDistanceRatio = dataViewFloat(dataView, LENS_DISTANCE_RATIO); + if (dataView.byteLength === DATA_VIEW_LENGTH) { + const version = dataViewUint8(dataView, VERSION); + const date = dataViewUint(dataView, EPOCH_SEC); + const validKeepalive = Math.abs(getEpochSec() - date) < 5; + const imuData = dataViewFloatArray(dataView, IMU_QUAT_DATA); + const imuResetState = imuData[0] === 0.0 && imuData[1] === 0.0 && imuData[2] === 0.0 && imuData[3] === 1.0; + const enabled = dataViewUint8(dataView, ENABLED) !== 0 && version === DATA_LAYOUT_VERSION && validKeepalive && !imuResetState; - // compute these values once, they only change when the XR device changes - const displayAspectRatio = displayRes[0] / displayRes[1]; - const stageAspectRatio = global.stage.get_width() / global.stage.get_height(); - const diagToVertRatio = Math.sqrt(Math.pow(stageAspectRatio, 2) + 1); - const halfFovZRads = degreeToRadian(displayFov / diagToVertRatio) / 2; - const halfFovYRads = halfFovZRads * stageAspectRatio; - const screenDistance = 1.0 - lensDistanceRatio; - - // all these values are transferred directly, unmodified from the driver - transferUniformFloat(this, 'look_ahead_cfg', dataView, LOOK_AHEAD_CFG); - transferUniformFloat(this, 'display_zoom', dataView, DISPLAY_ZOOM); - transferUniformFloat(this, 'display_north_offset', dataView, DISPLAY_NORTH_OFFSET); - transferUniformFloat(this, 'lens_distance_ratio', dataView, LENS_DISTANCE_RATIO); - transferUniformBoolean(this, 'sbs_enabled', dataView, SBS_ENABLED); - transferUniformBoolean(this, 'sbs_content', dataView, SBS_CONTENT); - transferUniformBoolean(this, 'sbs_mode_stretched', dataView, SBS_MODE_STRETCHED); - transferUniformBoolean(this, 'custom_banner_enabled', dataView, CUSTOM_BANNER_ENABLED); + if (enabled) { + const displayRes = dataViewUintArray(dataView, DISPLAY_RES); + const displayFov = dataViewFloat(dataView, DISPLAY_FOV); + const lensDistanceRatio = dataViewFloat(dataView, LENS_DISTANCE_RATIO); - // computed values with no dataViewInfo, so we set these manually - setSingleFloat(this, 'show_banner', imuResetState); - setSingleFloat(this, 'stage_aspect_ratio', stageAspectRatio); - setSingleFloat(this, 'display_aspect_ratio', displayAspectRatio); - setSingleFloat(this, 'half_fov_z_rads', halfFovZRads); - setSingleFloat(this, 'half_fov_y_rads', halfFovYRads); - setSingleFloat(this, 'screen_distance', screenDistance); - setSingleFloat(this, 'frametime', this._frametime); + // compute these values once, they only change when the XR device changes + const displayAspectRatio = displayRes[0] / displayRes[1]; + const stageAspectRatio = global.stage.get_width() / global.stage.get_height(); + const diagToVertRatio = Math.sqrt(Math.pow(stageAspectRatio, 2) + 1); + const halfFovZRads = degreeToRadian(displayFov / diagToVertRatio) / 2; + const halfFovYRads = halfFovZRads * stageAspectRatio; + const screenDistance = 1.0 - lensDistanceRatio; + + // all these values are transferred directly, unmodified from the driver + transferUniformFloat(this, 'look_ahead_cfg', dataView, LOOK_AHEAD_CFG); + transferUniformFloat(this, 'display_zoom', dataView, DISPLAY_ZOOM); + transferUniformFloat(this, 'display_north_offset', dataView, DISPLAY_NORTH_OFFSET); + transferUniformFloat(this, 'lens_distance_ratio', dataView, LENS_DISTANCE_RATIO); + transferUniformBoolean(this, 'sbs_enabled', dataView, SBS_ENABLED); + transferUniformBoolean(this, 'sbs_content', dataView, SBS_CONTENT); + transferUniformBoolean(this, 'sbs_mode_stretched', dataView, SBS_MODE_STRETCHED); + transferUniformBoolean(this, 'custom_banner_enabled', dataView, CUSTOM_BANNER_ENABLED); + + // computed values with no dataViewInfo, so we set these manually + setSingleFloat(this, 'show_banner', imuResetState); + setSingleFloat(this, 'stage_aspect_ratio', stageAspectRatio); + setSingleFloat(this, 'display_aspect_ratio', displayAspectRatio); + setSingleFloat(this, 'half_fov_z_rads', halfFovZRads); + setSingleFloat(this, 'half_fov_y_rads', halfFovYRads); + setSingleFloat(this, 'screen_distance', screenDistance); + setSingleFloat(this, 'frametime', this._frametime); + } + setSingleFloat(this, 'enabled', enabled ? 1.0 : 0.0); + } else if (dataView.byteLength !== 0) { + console.error(`Invalid dataView.byteLength: ${dataView.byteLength} !== ${DATA_VIEW_LENGTH}`) } - setSingleFloat(this, 'enabled', enabled); } @@ -260,11 +266,14 @@ export default class BreezyDesktopExtension extends Extension { this.setIntermittentUniformVariables(); return GLib.SOURCE_CONTINUE; }).bind(this)); - Meta.CursorTracker.get_for_display(global.display).set_pointer_visible(true); this._initialized = true; } - setUniformMatrix(this, 'imu_quat_data', 4, this._dataView, IMU_QUAT_DATA); + if (this._dataView.byteLength === DATA_VIEW_LENGTH) { + setUniformMatrix(this, 'imu_quat_data', 4, this._dataView, IMU_QUAT_DATA); + } else if (this._dataView.byteLength !== 0) { + console.error(`Invalid dataView.byteLength: ${this._dataView.byteLength} !== ${DATA_VIEW_LENGTH}`) + } if (this._repaint_needed) { super.vfunc_paint_target(node, paintContext); @@ -274,10 +283,12 @@ export default class BreezyDesktopExtension extends Extension { } }); - global.stage.add_effect(new XREffect()); + this._xr_effect = new XREffect(); + global.stage.add_effect(this._xr_effect); } disable() { + global.stage.remove_effect(this._xr_effect) this._logger.log_debug('disable(), session mode = ' + Main.sessionMode.currentMode); this._cursorManager.disable(); this._cursorManager = null;