Better disable support, still not perfect
This commit is contained in:
parent
f5e08e4ba6
commit
0779ffe7d2
|
|
@ -114,12 +114,12 @@ export class CursorManager {
|
|||
}
|
||||
|
||||
_cursorTrackerSetPointerVisibleReplacement(visible) {
|
||||
this._cursorWantedVisible = visible;
|
||||
if (visible) {
|
||||
this._startCloningMouse();
|
||||
} else {
|
||||
this._stopCloningMouse();
|
||||
}
|
||||
this._cursorWantedVisible = visible;
|
||||
}
|
||||
|
||||
_startCloningMouse() {
|
||||
|
|
@ -143,9 +143,6 @@ export class CursorManager {
|
|||
}
|
||||
|
||||
_stopCloningShowMouse() {
|
||||
if (!this._isMouseClonable()) {
|
||||
return;
|
||||
}
|
||||
this._stopCloningMouse();
|
||||
this._cursorTrackerSetPointerVisibleBound(this._cursorWantedVisible);
|
||||
|
||||
|
|
@ -159,9 +156,6 @@ export class CursorManager {
|
|||
}
|
||||
|
||||
_stopCloningMouse() {
|
||||
if (!this._isMouseClonable()) {
|
||||
return;
|
||||
}
|
||||
if (this._cursorWatch != null) {
|
||||
this._cursorWatch.remove();
|
||||
this._cursorWatch = null;
|
||||
|
|
|
|||
|
|
@ -208,13 +208,37 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
|
||||
// Set/destroyed by enable/disable
|
||||
this._cursorManager = null;
|
||||
this._shared_mem_file = null;
|
||||
this._xr_effect = null;
|
||||
}
|
||||
|
||||
enable() {
|
||||
this._cursorManager = new CursorManager(global.stage);
|
||||
if (!this._check_driver_running()) {
|
||||
this._running_poller_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, (() => {
|
||||
if (this._check_driver_running()) {
|
||||
this._effect_enable();
|
||||
return GLib.SOURCE_REMOVE;
|
||||
} else {
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
}
|
||||
}).bind(this));
|
||||
}
|
||||
this._effect_enable();
|
||||
}
|
||||
|
||||
_check_driver_running() {
|
||||
if (!this._shared_mem_file) this._shared_mem_file = Gio.file_new_for_path("/dev/shm/imu_data");
|
||||
return this._shared_mem_file.query_exists(null);
|
||||
}
|
||||
|
||||
_effect_enable() {
|
||||
this._running_poller_id = undefined;
|
||||
if (!this._cursorManager) this._cursorManager = new CursorManager(global.stage);
|
||||
this._cursorManager.enable();
|
||||
|
||||
if (!this._xr_effect) {
|
||||
const extensionPath = this._extensionPath;
|
||||
const shared_mem_file = this._shared_mem_file;
|
||||
var XREffect = GObject.registerClass({}, class XREffect extends Shell.GLSLEffect {
|
||||
vfunc_build_pipeline() {
|
||||
const code = getShaderSource(`${extensionPath}/IMUAdjust.frag`);
|
||||
|
|
@ -225,19 +249,12 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
}
|
||||
|
||||
vfunc_paint_target(node, paintContext) {
|
||||
if (!this._initialized) {
|
||||
this._shared_mem_file = Gio.file_new_for_path("/dev/shm/imu_data");
|
||||
}
|
||||
|
||||
if (this._shared_mem_file.query_exists(null)) {
|
||||
const data = this._shared_mem_file.load_contents(null);
|
||||
const data = shared_mem_file.load_contents(null);
|
||||
if (data[0]) {
|
||||
const buffer = new Uint8Array(data[1]).buffer;
|
||||
this._dataView = new DataView(buffer);
|
||||
if (!this._initialized) {
|
||||
this.set_uniform_float(this.get_uniform_location('uDesktopTexture'), 1, [8]);
|
||||
|
||||
// iterate over shaderUniformLocations keys and set the uniform locations
|
||||
this.set_uniform_float(this.get_uniform_location('uDesktopTexture'), 1, [0]);
|
||||
for (let key in shaderUniformLocations) {
|
||||
shaderUniformLocations[key] = this.get_uniform_location(key);
|
||||
}
|
||||
|
|
@ -270,19 +287,26 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this._xr_effect = new XREffect();
|
||||
}
|
||||
|
||||
global.stage.add_effect_with_name('xr-desktop', this._xr_effect);
|
||||
Meta.disable_unredirect_for_display(global.display);
|
||||
global.stage.add_effect_with_name('xr-desktop', new XREffect());
|
||||
}
|
||||
|
||||
disable() {
|
||||
if (this._running_poller_id) {
|
||||
GLib.source_remove(this._running_poller_id);
|
||||
} else {
|
||||
Meta.enable_unredirect_for_display(global.display);
|
||||
global.stage.remove_effect_by_name('xr-desktop');
|
||||
this._cursorManager.disable();
|
||||
this._cursorManager = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
return new Extension();
|
||||
|
|
|
|||
Loading…
Reference in New Issue