Add basic zoom shortcut
This commit is contained in:
parent
9bd034533f
commit
0cba1b8075
|
|
@ -152,7 +152,7 @@ void PS_IMU_Transform(vec4 pos, vec2 texcoord, out vec4 color) {
|
|||
|
||||
// divide all values by x to scale the magnitude so x is exactly 1, and multiply by the final display distance
|
||||
// so the vector is pointing at a coordinate on the screen
|
||||
float display_distance = (sbs_enabled ? display_north_offset : 1.0) - rotated_lens_vector.x;
|
||||
float display_distance = display_north_offset - rotated_lens_vector.x;
|
||||
res *= display_distance / res.x;
|
||||
res += rotated_lens_vector;
|
||||
|
||||
|
|
|
|||
|
|
@ -134,13 +134,21 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
|
||||
this._overlay.add_effect_with_name('xr-desktop', this._xr_effect);
|
||||
Meta.disable_unredirect_for_display(global.display);
|
||||
const action = Main.wm.addKeybinding(
|
||||
Main.wm.addKeybinding(
|
||||
'shortcut-recenter',
|
||||
this.getSettings(),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW | Shell.ActionMode.POPUP,
|
||||
this._recenter_display.bind(this)
|
||||
)
|
||||
);
|
||||
|
||||
Main.wm.addKeybinding(
|
||||
'shortcut-change-distance',
|
||||
this.getSettings(),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW | Shell.ActionMode.POPUP,
|
||||
this._xr_effect._change_distance.bind(this._xr_effect)
|
||||
);
|
||||
} catch (e) {
|
||||
console.error('Error enabling XR effect', e);
|
||||
this._effect_disable();
|
||||
|
|
@ -160,6 +168,8 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
|
||||
if (this._running_poller_id) GLib.source_remove(this._running_poller_id);
|
||||
|
||||
Main.wm.removeKeybinding('shortcut-recenter');
|
||||
Main.wm.removeKeybinding('shortcut-change-distance');
|
||||
Meta.enable_unredirect_for_display(global.display);
|
||||
|
||||
if (this._overlay) {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,6 +1,6 @@
|
|||
<schemalist gettext-domain="breezydesktop@org.xronlinux">
|
||||
<schema id="org.gnome.shell.extensions.breezy-desktop" path="/org/gnome/shell/extensions/breezy-desktop/">
|
||||
<key name="shortcut-recenter" type="as">
|
||||
<key name="shortcut-recenter" type="as">
|
||||
<default>
|
||||
<![CDATA[['<Control><Super>space']]]>
|
||||
</default>
|
||||
|
|
@ -9,5 +9,14 @@
|
|||
Shortcut to re-center the virtual display.
|
||||
</description>
|
||||
</key>
|
||||
<key name="shortcut-change-distance" type="as">
|
||||
<default>
|
||||
<![CDATA[['<Control><Super>Return']]]>
|
||||
</default>
|
||||
<summary>Trigger change to display distance</summary>
|
||||
<description>
|
||||
Shortcut to change the display distance.
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
import Clutter from 'gi://Clutter';
|
||||
import Cogl from 'gi://Cogl';
|
||||
import GLib from 'gi://GLib';
|
||||
import GObject from 'gi://GObject';
|
||||
import Shell from 'gi://Shell';
|
||||
|
||||
import Globals from './globals.js';
|
||||
|
||||
import {
|
||||
dataViewEnd,
|
||||
dataViewUint8,
|
||||
|
|
@ -23,6 +25,8 @@ import { getShaderSource } from "./shader.js";
|
|||
import { toSec } from "./time.js";
|
||||
|
||||
export const IPC_FILE_PATH = "/dev/shm/breezy_desktop_imu";
|
||||
const display_distance_nearest = 0.85;
|
||||
const display_distance_furthest = 1.05;
|
||||
|
||||
// the driver should be using the same data layout version
|
||||
const DATA_LAYOUT_VERSION = 2;
|
||||
|
|
@ -157,7 +161,6 @@ function setIntermittentUniformVariables() {
|
|||
|
||||
// TOOD - drive from settings
|
||||
setSingleFloat(this, 'display_zoom', 1.0);
|
||||
setSingleFloat(this, 'display_north_offset', 1.0);
|
||||
setSingleFloat(this, 'sbs_content', 0.0);
|
||||
}
|
||||
setSingleFloat(this, 'enabled', enabled ? 1.0 : 0.0);
|
||||
|
|
@ -186,6 +189,31 @@ export const XREffect = GObject.registerClass({
|
|||
super(params);
|
||||
|
||||
this._frametime = Math.floor(1000 / this.target_framerate);
|
||||
|
||||
// slightly zoomed out by default
|
||||
this._display_distance = display_distance_furthest;
|
||||
this._display_distance_near = false;
|
||||
this._distance_ease_timeline = null;
|
||||
}
|
||||
|
||||
_change_distance() {
|
||||
if (this._distance_ease_timeline?.is_playing()) this._distance_ease_timeline.stop();
|
||||
this._distance_ease_start = this._display_distance;
|
||||
this._distance_ease_timeline = Clutter.Timeline.new_for_actor(this.get_actor(), 250);
|
||||
|
||||
if (this._display_distance_near) {
|
||||
this._distance_ease_timeline.connect('new-frame', () => {
|
||||
this._display_distance = this._distance_ease_start + this._distance_ease_timeline.get_progress() * (display_distance_furthest - this._distance_ease_start);
|
||||
});
|
||||
this._display_distance_near = false;
|
||||
} else {
|
||||
this._distance_ease_timeline.connect('new-frame', () => {
|
||||
this._display_distance = this._distance_ease_start - this._distance_ease_timeline.get_progress() * (this._distance_ease_start - display_distance_nearest);
|
||||
});
|
||||
this._display_distance_near = true;
|
||||
}
|
||||
|
||||
this._distance_ease_timeline.start();
|
||||
}
|
||||
|
||||
vfunc_build_pipeline() {
|
||||
|
|
@ -219,10 +247,12 @@ export const XREffect = GObject.registerClass({
|
|||
this.setIntermittentUniformVariables();
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
}).bind(this));
|
||||
|
||||
this._initialized = true;
|
||||
}
|
||||
|
||||
if (this._dataView.byteLength === DATA_VIEW_LENGTH) {
|
||||
setSingleFloat(this, 'display_north_offset', this._display_distance);
|
||||
setSingleFloat(this, 'look_ahead_ms', lookAheadMS(this._dataView));
|
||||
setUniformMatrix(this, 'imu_quat_data', 4, this._dataView, IMU_QUAT_DATA);
|
||||
} else if (this._dataView.byteLength !== 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue