Working recenter shortcut

This commit is contained in:
wheaney 2024-04-24 21:59:56 -07:00
parent 0742eeb83a
commit 9bd034533f
7 changed files with 29 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
/vulkan/build/
/build/
/gnome/setup-45.sh

View File

@ -1,4 +1,3 @@
# require a first parameter, the user home directory
if [ -z "$1" ]; then
echo "Usage: $0 username [group]"
exit 1
@ -30,7 +29,6 @@ $user_home/bin/xreal_driver_config -vd
sed -i 's/virtual_display/breezy_desktop/g' $user_home/.xreal_driver_config
# if breezy-desktop directory doesn't exit
if [ ! -d breezy-desktop ]; then
git clone https://github.com/wheaney/breezy-desktop.git

View File

@ -1,5 +1,4 @@
import Clutter from 'gi://Clutter';
import GLib from 'gi://GLib';
import Meta from 'gi://Meta';
import * as PointerWatcher from 'resource:///org/gnome/shell/ui/pointerWatcher.js';
import { MouseSpriteContent } from './cursor.js';

View File

@ -54,7 +54,6 @@ export default class BreezyDesktopExtension extends Extension {
this._effect_enable();
return GLib.SOURCE_REMOVE;
} else {
console.log(`Not ready: driver_running ${is_driver_running}, target_monitor ${JSON.stringify(target_monitor)}`);
return GLib.SOURCE_CONTINUE;
}
}).bind(this));
@ -135,6 +134,13 @@ 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(
'shortcut-recenter',
this.getSettings(),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW | Shell.ActionMode.POPUP,
this._recenter_display.bind(this)
)
} catch (e) {
console.error('Error enabling XR effect', e);
this._effect_disable();
@ -142,6 +148,13 @@ export default class BreezyDesktopExtension extends Extension {
}
}
_recenter_display() {
const file = Gio.file_new_for_path('/dev/shm/xr_driver_control');
const stream = file.replace(null, false, Gio.FileCreateFlags.NONE, null);
stream.write('recenter_screen=true', null);
stream.close(null);
}
_effect_disable() {
this._is_effect_running = false;
@ -150,8 +163,8 @@ export default class BreezyDesktopExtension extends Extension {
Meta.enable_unredirect_for_display(global.display);
if (this._overlay) {
this._overlay.remove_effect_by_name('xr-desktop');
global.stage.remove_child(this._overlay);
this._overlay.remove_effect_by_name('xr-desktop');
this._overlay.destroy();
this._overlay = null;
}
@ -164,7 +177,6 @@ export default class BreezyDesktopExtension extends Extension {
this._cursor_manager.disable();
this._cursor_manager = null;
}
}
disable() {

View File

@ -2,6 +2,7 @@
"uuid": "breezydesktop@org.xronlinux",
"name": "Breezy GNOME XR Desktop",
"description": "XR virtual desktop for GNOME.",
"settings-schema": "org.gnome.shell.extensions.breezy-desktop",
"shell-version": [
"45", "46"
],

View File

@ -0,0 +1,13 @@
<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">
<default>
<![CDATA[['<Control><Super>space']]]>
</default>
<summary>Re-center display</summary>
<description>
Shortcut to re-center the virtual display.
</description>
</key>
</schema>
</schemalist>