Compare commits
52 Commits
main
...
breezy-gno
| Author | SHA1 | Date |
|---|---|---|
|
|
58d4e4bb55 | |
|
|
96b39498a4 | |
|
|
e50a3f1c2b | |
|
|
204ae71dd9 | |
|
|
2f99b84ef2 | |
|
|
ae214cf1a2 | |
|
|
b5915cfdf2 | |
|
|
4a64639fdf | |
|
|
554e0a607c | |
|
|
d732a1eb07 | |
|
|
e2ba7444ba | |
|
|
7f8793ce53 | |
|
|
029a17d969 | |
|
|
53011a7d4c | |
|
|
7dc965c684 | |
|
|
0cba1b8075 | |
|
|
9bd034533f | |
|
|
0742eeb83a | |
|
|
1264af4ff8 | |
|
|
73ac5a67b6 | |
|
|
9429b29ac8 | |
|
|
85a809031c | |
|
|
0d3971931b | |
|
|
8d1ce3a42e | |
|
|
8653088721 | |
|
|
a3efb03dd9 | |
|
|
6a4de14eb4 | |
|
|
fd4c60336a | |
|
|
cc573b9897 | |
|
|
8d4da0d56e | |
|
|
b6c913ddb2 | |
|
|
3ba8a98169 | |
|
|
01285ec525 | |
|
|
a3edc7443f | |
|
|
1ba9185a59 | |
|
|
140f4d21ab | |
|
|
fb01689871 | |
|
|
8cb73e3a43 | |
|
|
2df1ff0cf7 | |
|
|
864a468684 | |
|
|
88a97542e0 | |
|
|
7c6d7ef84d | |
|
|
0779ffe7d2 | |
|
|
f5e08e4ba6 | |
|
|
82276b3ae3 | |
|
|
2f0a053a4a | |
|
|
7da53847cb | |
|
|
fe828db999 | |
|
|
a109b5e897 | |
|
|
8ba4f790c0 | |
|
|
4f80efdf75 | |
|
|
47294824b9 |
|
|
@ -1,2 +1,6 @@
|
||||||
/vulkan/build/
|
build/
|
||||||
/build/
|
__pycache__
|
||||||
|
*.zip
|
||||||
|
gschemas.compiled
|
||||||
|
.flatpak-builder/
|
||||||
|
out/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This setup script should do the minimum work required to download the release package, unzip it, and kick off the
|
||||||
|
# setup script contained within.
|
||||||
|
|
||||||
|
# exit when any command fails
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Make sure only root can run our script
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "This script must be run as root" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
start_dir=$(pwd)
|
||||||
|
|
||||||
|
# create temp directory
|
||||||
|
tmp_dir=$(mktemp -d -t breezy-gnome-XXXXXXXXXX)
|
||||||
|
pushd $tmp_dir > /dev/null
|
||||||
|
echo "Created temp directory: ${tmp_dir}"
|
||||||
|
|
||||||
|
# if the first argument is "-v" then the second argument is metrics version, and the third argument is binary path
|
||||||
|
# otherwise, if the first argument is present, it's the binary path
|
||||||
|
if [ "$1" = "-v" ]
|
||||||
|
then
|
||||||
|
metrics_version="$2"
|
||||||
|
binary_path_arg="$3"
|
||||||
|
else
|
||||||
|
binary_path_arg="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$binary_path_arg" ]
|
||||||
|
then
|
||||||
|
# download and unzip the latest driver
|
||||||
|
echo "Downloading latest release to: ${tmp_dir}/breezyGNOME.tar.gz"
|
||||||
|
curl -L -O https://github.com/wheaney/breezy-desktop/releases/latest/download/breezyGNOME.tar.gz
|
||||||
|
else
|
||||||
|
if [[ "$binary_path_arg" = /* ]]; then
|
||||||
|
abs_path="$binary_path_arg"
|
||||||
|
else
|
||||||
|
# Convert relative path to absolute path
|
||||||
|
abs_path=$(realpath "$start_dir/$binary_path_arg")
|
||||||
|
fi
|
||||||
|
cp $abs_path $tmp_dir
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Extracting to: ${tmp_dir}/breezy_gnome"
|
||||||
|
tar -xf breezyGNOME.tar.gz
|
||||||
|
|
||||||
|
pushd breezy_gnome > /dev/null
|
||||||
|
|
||||||
|
# run the setup script that comes with this release
|
||||||
|
bin/setup $metrics_version
|
||||||
|
|
||||||
|
echo "Deleting temp directory: ${tmp_dir}"
|
||||||
|
rm -rf $tmp_dir
|
||||||
|
cd "$(dirs -l -0)" && dirs -c
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# needs:flatpak-builder, elfutils
|
||||||
|
# flatpak-builder --force-clean /tmp/flatpak-builddir ui/com.xronlinux.BreezyDesktop.json
|
||||||
|
# flatpak build-export /tmp/flatpak-export /tmp/flatpak-builddir
|
||||||
|
# flatpak build-bundle /tmp/flatpak-export com.xronlinux.BreezyDesktop.flatpak com.xronlinux.BreezyDesktop --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo
|
||||||
|
|
||||||
|
# exit when any command fails
|
||||||
|
set -e
|
||||||
|
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/246128
|
||||||
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||||
|
ROOT_DIR=$(realpath $SCRIPT_DIR/..)
|
||||||
|
VULKAN_DIR=$ROOT_DIR/vulkan
|
||||||
|
GNOME_DIR=$ROOT_DIR/gnome
|
||||||
|
GNOME_BUILD_DIR=$GNOME_DIR/build
|
||||||
|
|
||||||
|
rm -rf $GNOME_BUILD_DIR
|
||||||
|
mkdir -p $GNOME_BUILD_DIR
|
||||||
|
|
||||||
|
PACKAGE_DIR=$GNOME_BUILD_DIR/breezy_gnome
|
||||||
|
rm -rf $PACKAGE_DIR
|
||||||
|
mkdir -p $PACKAGE_DIR
|
||||||
|
|
||||||
|
XREAL_DRIVER_DIR=$ROOT_DIR/modules/xrealAirLinuxDriver
|
||||||
|
source $XREAL_DRIVER_DIR/bin/inject_ua
|
||||||
|
|
||||||
|
# check out submodules, recursively for nested ones
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
# if a custom_banner image exists, copy it over the sombrero one
|
||||||
|
if [ -e "$VULKAN_DIR/custom_banner.png" ]; then
|
||||||
|
cp $VULKAN_DIR/custom_banner.png $PACKAGE_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
# copy vulkan setup scripts and configs
|
||||||
|
mkdir -p $PACKAGE_DIR/bin
|
||||||
|
copy_and_inject_ua "$XREAL_DRIVER_DIR/bin/ua.sh" "$PACKAGE_DIR/bin" "$GNOME_DIR/bin/setup" "$GNOME_DIR/bin/breezy_gnome_verify" "$GNOME_DIR/bin/breezy_gnome_uninstall"
|
||||||
|
|
||||||
|
XREAL_BINARY=$XREAL_DRIVER_DIR/build/xrealAirLinuxDriver.tar.gz
|
||||||
|
pushd $XREAL_DRIVER_DIR
|
||||||
|
|
||||||
|
if [ ! -e "$XREAL_BINARY" ] || [ "$1" != "--skip-module-builds" ]; then
|
||||||
|
# if a file exists at custom_banner_config.yml, copy it to the xrealAirLinuxDriver directory
|
||||||
|
if [ -e "$VULKAN_DIR/custom_banner_config.yml" ]; then
|
||||||
|
cp $VULKAN_DIR/custom_banner_config.yml $XREAL_DRIVER_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
bin/package
|
||||||
|
fi
|
||||||
|
|
||||||
|
XREAL_MANIFEST_LINE=$(sha256sum build/driver_air_glasses/manifest)
|
||||||
|
popd
|
||||||
|
|
||||||
|
cp $XREAL_BINARY $PACKAGE_DIR
|
||||||
|
cp $XREAL_DRIVER_DIR/bin/xreal_driver_setup $PACKAGE_DIR/bin
|
||||||
|
|
||||||
|
gnome/bin/package_extension
|
||||||
|
cp gnome/out/* $PACKAGE_DIR
|
||||||
|
|
||||||
|
# create a checksum that combines the checksums of all files in the directory
|
||||||
|
pushd gnome/src
|
||||||
|
GNOME_MANIFEST_LINE=$(find -L . -type f -exec sha256sum {} \; | sort | sha256sum | sed 's/ .*//')
|
||||||
|
popd
|
||||||
|
|
||||||
|
ui/bin/package
|
||||||
|
cp ui/out/* $PACKAGE_DIR
|
||||||
|
|
||||||
|
# create manifest file for verifying installed file checksums against the originally packaged versions
|
||||||
|
# include any file that doesn't get modified during setup (e.g. vkBasalt.json files)
|
||||||
|
pushd $PACKAGE_DIR
|
||||||
|
echo $XREAL_MANIFEST_LINE > manifest
|
||||||
|
echo -e "$GNOME_MANIFEST_LINE breezydesktop@xronlinux.com" >> manifest
|
||||||
|
popd
|
||||||
|
|
||||||
|
# bundle everything up
|
||||||
|
pushd $GNOME_BUILD_DIR
|
||||||
|
tar -zcvf breezyGNOME.tar.gz breezy_gnome
|
||||||
|
popd
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
UUID="breezydesktop@xronlinux.com"
|
||||||
|
|
||||||
|
# fail on error
|
||||||
|
set -e
|
||||||
|
# log executed commands
|
||||||
|
set -x
|
||||||
|
|
||||||
|
if [[ $EUID -eq 0 ]]; then
|
||||||
|
echo "This script must NOT be run as root" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/246128
|
||||||
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||||
|
|
||||||
|
SRC_DIR="$SCRIPT_DIR/../src"
|
||||||
|
TMP_DIR=$(mktemp -d -t breezy-gnome-XXXXXXXXXX)
|
||||||
|
DEST_DIR="$TMP_DIR/$UUID"
|
||||||
|
OUT_DIR="$SCRIPT_DIR/../out"
|
||||||
|
rm -rf "$OUT_DIR"
|
||||||
|
|
||||||
|
cd "$SCRIPT_DIR" || exit 1
|
||||||
|
|
||||||
|
check_command() {
|
||||||
|
if ! command -v "$1" &>/dev/null; then
|
||||||
|
echo "Please install \"$1\" and make sure it's available in your \$PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
compile_schemas() {
|
||||||
|
check_command "glib-compile-schemas"
|
||||||
|
mkdir -p "$DEST_DIR/schemas/"
|
||||||
|
|
||||||
|
# the pack command also compiles the schemas but only into the zip file
|
||||||
|
glib-compile-schemas --targetdir="$DEST_DIR/schemas" "$SRC_DIR/schemas/"
|
||||||
|
}
|
||||||
|
|
||||||
|
copy_static_files() {
|
||||||
|
# Copy non generated files to destdir
|
||||||
|
cp $SRC_DIR/*.js $DEST_DIR/
|
||||||
|
cp $SRC_DIR/*.frag $DEST_DIR/
|
||||||
|
mkdir -p "$DEST_DIR/schemas/"
|
||||||
|
cp $SRC_DIR/schemas/*.xml $DEST_DIR/schemas/
|
||||||
|
mkdir -p $DEST_DIR/dbus-interfaces/
|
||||||
|
cp $SRC_DIR/dbus-interfaces/*.xml $DEST_DIR/dbus-interfaces/
|
||||||
|
cp $SRC_DIR/metadata.json $DEST_DIR/
|
||||||
|
}
|
||||||
|
|
||||||
|
pack() {
|
||||||
|
check_command "gnome-extensions"
|
||||||
|
|
||||||
|
# pack everything into a sharable zip file
|
||||||
|
extra_source=()
|
||||||
|
for file in "$DEST_DIR"/*; do
|
||||||
|
extra_source+=("--extra-source=$file")
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p "$OUT_DIR"
|
||||||
|
gnome-extensions pack --force "${extra_source[@]}" "$DEST_DIR" -o "$OUT_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
# No arguments, do everything
|
||||||
|
compile_schemas
|
||||||
|
copy_static_files
|
||||||
|
pack
|
||||||
|
elif [ "$1" == "build_local" ]; then
|
||||||
|
compile_schemas
|
||||||
|
copy_static_files
|
||||||
|
elif [ "$1" == "pack" ]; then
|
||||||
|
pack
|
||||||
|
elif [ "$1" == "copy_static" ]; then
|
||||||
|
copy_static_files
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# This script gets packaged with the release and should do the bulk of the setup work. This allows this setup to be tied
|
||||||
|
# to a specific release of the code, and guarantees it will never run along-side newer or older binaries.
|
||||||
|
|
||||||
|
USER=${SUDO_USER:-$USER}
|
||||||
|
USER_HOME=$(getent passwd $USER | cut -d: -f6)
|
||||||
|
|
||||||
|
if [ -z "$XDG_BIN_HOME" ]; then
|
||||||
|
XDG_BIN_HOME="$USER_HOME/.local/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$XDG_DATA_HOME" ]; then
|
||||||
|
XDG_DATA_HOME="$USER_HOME/.local/share"
|
||||||
|
fi
|
||||||
|
DATA_DIR="$XDG_DATA_HOME/breezy_gnome"
|
||||||
|
|
||||||
|
UA_EVENT_NAME="breezy_gnome_install"
|
||||||
|
if [ -e "$XDG_BIN_HOME/breezy_gnome_uninstall" ]; then
|
||||||
|
echo "Cleaning up the previous installation"
|
||||||
|
|
||||||
|
# ` || true` will ensure that this can't cause a failure, even with `set -e`
|
||||||
|
$XDG_BIN_HOME/breezy_gnome_uninstall --for-install || true
|
||||||
|
|
||||||
|
UA_EVENT_NAME="breezy_gnome_update"
|
||||||
|
fi
|
||||||
|
|
||||||
|
UA_CLIENT_ID="BreezyGNOME"
|
||||||
|
UA_EVENT_VERSION="$1"
|
||||||
|
#INJECT_UA_CALL
|
||||||
|
|
||||||
|
echo "Copying the breezy_gnome scripts to ${XDG_BIN_HOME}"
|
||||||
|
mkdir -p $XDG_BIN_HOME
|
||||||
|
cp bin/breezy_gnome_uninstall $XDG_BIN_HOME
|
||||||
|
cp bin/breezy_gnome_verify $XDG_BIN_HOME
|
||||||
|
chown -R $USER:$USER $XDG_BIN_HOME
|
||||||
|
chmod -R 755 $XDG_BIN_HOME
|
||||||
|
|
||||||
|
echo "Copying the manifest file to ${DATA_DIR}"
|
||||||
|
mkdir -p $DATA_DIR
|
||||||
|
cp manifest $DATA_DIR
|
||||||
|
chown -R $USER:$USER $DATA_DIR
|
||||||
|
chmod -R 755 $DATA_DIR
|
||||||
|
|
||||||
|
echo "Installing the breezydesktop@xronlinux.com GNOME extension"
|
||||||
|
gnome-extensions install --force --quiet breezydesktop@xronlinux.com.shell-extension.zip > /dev/null 2>&1
|
||||||
|
|
||||||
|
echo "Installing the Breezy Desktop UI Flatpak"
|
||||||
|
flatpak install --noninteractive --reinstall com.xronlinux.BreezyDesktop.flatpak > /dev/null 2>&1
|
||||||
|
|
||||||
|
# set up the XREAL driver using the local binary
|
||||||
|
echo "Installing xrealAirLinuxDriver"
|
||||||
|
echo "BEGIN - xreal_driver_setup"
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
bin/xreal_driver_setup $(pwd)/xrealAirLinuxDriver.tar.gz
|
||||||
|
else
|
||||||
|
bin/xreal_driver_setup -v $1 $(pwd)/xrealAirLinuxDriver.tar.gz
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "END - xreal_driver_setup"
|
||||||
|
|
||||||
|
echo "Enabling the driver and setting it to Breezy Desktop mode"
|
||||||
|
$USER_HOME/bin/xreal_driver_config -e
|
||||||
|
$USER_HOME/bin/xreal_driver_config -vd
|
||||||
|
|
||||||
|
sed -i 's/virtual_display/breezy_desktop/g' $USER_HOME/.xreal_driver_config
|
||||||
|
|
@ -0,0 +1,176 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
uniform bool enabled;
|
||||||
|
uniform bool show_banner;
|
||||||
|
uniform sampler2D uDesktopTexture;
|
||||||
|
uniform mat4 imu_quat_data;
|
||||||
|
uniform vec4 look_ahead_cfg;
|
||||||
|
uniform float look_ahead_ms;
|
||||||
|
uniform float display_zoom;
|
||||||
|
uniform float display_north_offset;
|
||||||
|
uniform float lens_distance_ratio;
|
||||||
|
uniform bool sbs_enabled;
|
||||||
|
uniform bool sbs_content;
|
||||||
|
uniform bool custom_banner_enabled;
|
||||||
|
uniform float stage_aspect_ratio;
|
||||||
|
uniform float display_aspect_ratio;
|
||||||
|
uniform float trim_width_percent;
|
||||||
|
uniform float trim_height_percent;
|
||||||
|
uniform float half_fov_z_rads;
|
||||||
|
uniform float half_fov_y_rads;
|
||||||
|
uniform float screen_distance;
|
||||||
|
|
||||||
|
float look_ahead_ms_cap = 45.0;
|
||||||
|
|
||||||
|
vec4 quatMul(vec4 q1, vec4 q2) {
|
||||||
|
vec3 u = vec3(q1.x, q1.y, q1.z);
|
||||||
|
float s = q1.w;
|
||||||
|
vec3 v = vec3(q2.x, q2.y, q2.z);
|
||||||
|
float t = q2.w;
|
||||||
|
return vec4(s * v + t * u + cross(u, v), s * t - dot(u, v));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 quatConj(vec4 q) {
|
||||||
|
return vec4(-q.x, -q.y, -q.z, q.w);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 applyQuaternionToVector(vec4 q, vec3 v) {
|
||||||
|
vec4 p = quatMul(quatMul(q, vec4(v, 0)), quatConj(q));
|
||||||
|
return p.xyz;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int day_in_seconds = 24 * 60 * 60;
|
||||||
|
|
||||||
|
vec3 applyLookAhead(
|
||||||
|
in vec3 position,
|
||||||
|
in vec3 velocity,
|
||||||
|
in vec3 accel,
|
||||||
|
in float t,
|
||||||
|
in float t_squared
|
||||||
|
) {
|
||||||
|
return position + velocity * t + 0.5 * accel * t_squared;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 rateOfChange(
|
||||||
|
in vec3 v1,
|
||||||
|
in vec3 v2,
|
||||||
|
in float delta_time
|
||||||
|
) {
|
||||||
|
return (v1 - v2) / delta_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PS_IMU_Transform(vec4 pos, vec2 texcoord, out vec4 color) {
|
||||||
|
float texcoord_x_min = 0.0;
|
||||||
|
float texcoord_x_max = 1.0;
|
||||||
|
float lens_y_offset = 0.0;
|
||||||
|
float lens_z_offset = 0.0;
|
||||||
|
float aspect_ratio = stage_aspect_ratio;
|
||||||
|
|
||||||
|
// if(enabled && sbs_enabled) {
|
||||||
|
// bool right_display = texcoord.x > 0.5;
|
||||||
|
// aspect_ratio /= 2;
|
||||||
|
|
||||||
|
// lens_y_offset = lens_distance_ratio / 3;
|
||||||
|
// if(right_display)
|
||||||
|
// lens_y_offset = -lens_y_offset;
|
||||||
|
// if(sbs_content) {
|
||||||
|
// // source video is SBS, left-half of the screen goes to the left lens, right-half to the right lens
|
||||||
|
// if(right_display)
|
||||||
|
// texcoord_x_min = 0.5;
|
||||||
|
// else
|
||||||
|
// texcoord_x_max = 0.5;
|
||||||
|
// }
|
||||||
|
// if(!sbs_mode_stretched) {
|
||||||
|
// // if the content isn't stretched, assume it's centered in the middle 50% of the screen
|
||||||
|
// texcoord_x_min = max(0.25, texcoord_x_min);
|
||||||
|
// texcoord_x_max = min(0.75, texcoord_x_max);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // translate the texcoord respresenting the current lens's half of the screen to a full-screen texcoord
|
||||||
|
// texcoord.x = (texcoord.x - (right_display ? 0.5 : 0.0)) * 2;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(!enabled || show_banner) {
|
||||||
|
// vec2 banner_size = vec2(800.0 / ReShade::ScreenSize.x, 200.0 / ReShade::ScreenSize.y); // Assuming ScreenWidth and ScreenHeight are defined
|
||||||
|
|
||||||
|
// if (show_banner &&
|
||||||
|
// texcoord.x >= banner_position.x - banner_size.x / 2 &&
|
||||||
|
// texcoord.x <= banner_position.x + banner_size.x / 2 &&
|
||||||
|
// texcoord.y >= banner_position.y - banner_size.y / 2 &&
|
||||||
|
// texcoord.y <= banner_position.y + banner_size.y / 2)
|
||||||
|
// {
|
||||||
|
// vec2 banner_texcoord = (texcoord - (banner_position - banner_size / 2)) / banner_size;
|
||||||
|
// if (custom_banner_enabled) {
|
||||||
|
// color = tex2D(customBannerSampler, banner_texcoord);
|
||||||
|
// } else {
|
||||||
|
// color = tex2D(calibratingSampler, banner_texcoord);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// adjust texcoord back to the range that describes where the content is displayed
|
||||||
|
float texcoord_width = texcoord_x_max - texcoord_x_min;
|
||||||
|
texcoord.x = texcoord.x * texcoord_width + texcoord_x_min;
|
||||||
|
|
||||||
|
color = texture2D(uDesktopTexture, texcoord);
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
float fov_y_half_width = tan(half_fov_y_rads);
|
||||||
|
float fov_y_width = fov_y_half_width * 2;
|
||||||
|
float fov_z_half_width = tan(half_fov_z_rads);
|
||||||
|
float fov_z_width = fov_z_half_width * 2;
|
||||||
|
|
||||||
|
float vec_y = -texcoord.x * fov_y_width + fov_y_half_width;
|
||||||
|
float vec_z = -texcoord.y * fov_z_width + fov_z_half_width;
|
||||||
|
vec3 lens_vector = vec3(lens_distance_ratio, lens_y_offset, lens_z_offset);
|
||||||
|
vec3 texcoord_vector = vec3(1.0, vec_y, vec_z);
|
||||||
|
|
||||||
|
// then rotate the vector using each of the snapshots provided
|
||||||
|
vec3 rotated_vector_t0 = applyQuaternionToVector(imu_quat_data[0], texcoord_vector);
|
||||||
|
vec3 rotated_vector_t1 = applyQuaternionToVector(imu_quat_data[1], texcoord_vector);
|
||||||
|
vec3 rotated_vector_t2 = applyQuaternionToVector(imu_quat_data[2], texcoord_vector);
|
||||||
|
vec3 rotated_lens_vector = applyQuaternionToVector(imu_quat_data[0], lens_vector);
|
||||||
|
|
||||||
|
// compute the two velocities (units/ms) as change in the 3 rotation snapshots
|
||||||
|
float delta_time_t0 = imu_quat_data[3].x - imu_quat_data[3].y;
|
||||||
|
vec3 velocity_t0 = rateOfChange(rotated_vector_t0, rotated_vector_t1, delta_time_t0);
|
||||||
|
vec3 velocity_t1 = rateOfChange(rotated_vector_t1, rotated_vector_t2, imu_quat_data[3].y - imu_quat_data[3].z);
|
||||||
|
|
||||||
|
// and then the acceleration (units/ms^2) as the change in velocities
|
||||||
|
vec3 accel_t0 = rateOfChange(velocity_t0, velocity_t1, delta_time_t0);
|
||||||
|
|
||||||
|
// allows for the bottom and top of the screen to have different look-ahead values
|
||||||
|
float look_ahead_scanline_adjust = texcoord.y * look_ahead_cfg.z;
|
||||||
|
|
||||||
|
// use the 4th value of the look-ahead config to cap the look-ahead value
|
||||||
|
float look_ahead_ms_capped = min(min(look_ahead_ms, look_ahead_cfg.w), look_ahead_ms_cap) + look_ahead_scanline_adjust;
|
||||||
|
float look_ahead_ms_squared = pow(look_ahead_ms_capped, 2);
|
||||||
|
|
||||||
|
// apply most recent velocity and acceleration to most recent position to get a predicted position
|
||||||
|
vec3 res = applyLookAhead(rotated_vector_t0, velocity_t0, accel_t0, look_ahead_ms, look_ahead_ms_squared) -
|
||||||
|
rotated_lens_vector;
|
||||||
|
|
||||||
|
bool looking_behind = res.x < 0.0;
|
||||||
|
|
||||||
|
// 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 = display_north_offset - rotated_lens_vector.x;
|
||||||
|
res *= display_distance / res.x;
|
||||||
|
res += rotated_lens_vector;
|
||||||
|
|
||||||
|
// deconstruct the rotated and scaled vector back to a texcoord (just inverse operations of the first conversion
|
||||||
|
// above)
|
||||||
|
texcoord.x = (fov_y_half_width - res.y) / fov_y_width;
|
||||||
|
texcoord.y = (fov_z_half_width - res.z) / fov_z_width;
|
||||||
|
|
||||||
|
// apply the screen offsets now
|
||||||
|
float texcoord_width = texcoord_x_max - texcoord_x_min;
|
||||||
|
texcoord.x = texcoord.x * texcoord_width + texcoord_x_min;
|
||||||
|
|
||||||
|
if(looking_behind || texcoord.x < texcoord_x_min || texcoord.y < 0.0 || texcoord.x > texcoord_x_max || texcoord.y > 1.0 || texcoord.x <= 0.001 && texcoord.y <= 0.002) {
|
||||||
|
color = vec4(0, 0, 0, 1);
|
||||||
|
} else {
|
||||||
|
texcoord.x = (1.0 - trim_width_percent * 2) * texcoord.x + trim_width_percent;
|
||||||
|
texcoord.y = (1.0 - trim_height_percent * 2) * texcoord.y + trim_height_percent;
|
||||||
|
color = texture2D(uDesktopTexture, texcoord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
// Taken from https://github.com/jkitching/soft-brightness-plus
|
||||||
|
//
|
||||||
|
// Copyright (C) 2023 Joel Kitching (jkitching on Github)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import Clutter from 'gi://Clutter';
|
||||||
|
import GObject from 'gi://GObject';
|
||||||
|
|
||||||
|
// Copied almost verbatim from ui/magnifier.js.
|
||||||
|
export const MouseSpriteContent = GObject.registerClass({
|
||||||
|
Implements: [Clutter.Content],
|
||||||
|
}, class MouseSpriteContent extends GObject.Object {
|
||||||
|
_init() {
|
||||||
|
super._init();
|
||||||
|
this._texture = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
vfunc_get_preferred_size() {
|
||||||
|
if (!this._texture)
|
||||||
|
return [false, 0, 0];
|
||||||
|
|
||||||
|
return [true, this._texture.get_width(), this._texture.get_height()];
|
||||||
|
}
|
||||||
|
|
||||||
|
vfunc_paint_content(actor, node, _paintContext) {
|
||||||
|
if (!this._texture)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let [minFilter, magFilter] = actor.get_content_scaling_filters();
|
||||||
|
let textureNode = new Clutter.TextureNode(this._texture,
|
||||||
|
null, minFilter, magFilter);
|
||||||
|
textureNode.set_name('BreezyDesktopSpriteContent');
|
||||||
|
node.add_child(textureNode);
|
||||||
|
|
||||||
|
textureNode.add_rectangle(actor.get_content_box());
|
||||||
|
}
|
||||||
|
|
||||||
|
get texture() {
|
||||||
|
return this._texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
set texture(coglTexture) {
|
||||||
|
if (this._texture === coglTexture)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let oldTexture = this._texture;
|
||||||
|
this._texture = coglTexture;
|
||||||
|
this.invalidate();
|
||||||
|
|
||||||
|
if (!oldTexture || !coglTexture ||
|
||||||
|
oldTexture.get_width() !== coglTexture.get_width() ||
|
||||||
|
oldTexture.get_height() !== coglTexture.get_height())
|
||||||
|
this.invalidate_size();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,211 @@
|
||||||
|
import Clutter from 'gi://Clutter';
|
||||||
|
import Meta from 'gi://Meta';
|
||||||
|
import * as PointerWatcher from 'resource:///org/gnome/shell/ui/pointerWatcher.js';
|
||||||
|
import { MouseSpriteContent } from './cursor.js';
|
||||||
|
|
||||||
|
// Taken from https://github.com/jkitching/soft-brightness-plus
|
||||||
|
export class CursorManager {
|
||||||
|
constructor(mainActor) {
|
||||||
|
this._mainActor = mainActor;
|
||||||
|
|
||||||
|
this._changeHookFn = null;
|
||||||
|
|
||||||
|
// Set/destroyed by _enableCloningMouse/_disableCloningMouse
|
||||||
|
this._cursorWantedVisible = null;
|
||||||
|
this._cursorTracker = null;
|
||||||
|
this._cursorTrackerSetPointerVisible = null;
|
||||||
|
this._cursorTrackerSetPointerVisibleBound = null;
|
||||||
|
this._cursorSprite = null;
|
||||||
|
this._cursorActor = null;
|
||||||
|
this._cursorWatcher = null;
|
||||||
|
this._cursorSeat = null;
|
||||||
|
this._cursorUnfocusInhibited = false;
|
||||||
|
|
||||||
|
// Set/destroyed by _startCloningMouse / _stopCloningMouse
|
||||||
|
this._cursorWatch = null;
|
||||||
|
this._cursorChangedConnection = null;
|
||||||
|
this._cursorVisibilityChangedConnection = null;
|
||||||
|
this._cursorPositionInvalidatedConnection = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
enable() {
|
||||||
|
this._enableCloningMouse();
|
||||||
|
this.startCloning();
|
||||||
|
}
|
||||||
|
|
||||||
|
disable() {
|
||||||
|
this._disableCloningMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
startCloning() {
|
||||||
|
this._startCloningMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
stopCloning() {
|
||||||
|
this._stopCloningMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
// After this:
|
||||||
|
// * real cursor is disabled
|
||||||
|
// * cloning is "on"
|
||||||
|
// * cloned cursor not visible, but ready for _startCloningMouse to make it visible
|
||||||
|
//
|
||||||
|
// okay if _startCloningMouse is not immediately called since set_pointer_visible is bound to our replacement function
|
||||||
|
// and will trigger _startCloningMouse when the cursor should be shown
|
||||||
|
_enableCloningMouse() {
|
||||||
|
this._cursorTracker = Meta.CursorTracker.get_for_display(global.display);
|
||||||
|
this._cursorWantedVisible = this._cursorTracker.get_pointer_visible();
|
||||||
|
this._cursorTrackerSetPointerVisible = Meta.CursorTracker.prototype.set_pointer_visible;
|
||||||
|
this._cursorTrackerSetPointerVisibleBound = this._cursorTrackerSetPointerVisible.bind(this._cursorTracker);
|
||||||
|
Meta.CursorTracker.prototype.set_pointer_visible = this._cursorTrackerSetPointerVisibleReplacement.bind(this);
|
||||||
|
|
||||||
|
this._cursorTrackerSetPointerVisibleBound(false);
|
||||||
|
|
||||||
|
this._cursorSprite = new Clutter.Actor({ request_mode: Clutter.RequestMode.CONTENT_SIZE });
|
||||||
|
this._cursorSprite.content = new MouseSpriteContent();
|
||||||
|
|
||||||
|
this._cursorActor = new Clutter.Actor();
|
||||||
|
if (Clutter.Container === undefined) {
|
||||||
|
this._cursorActor.add_child(this._cursorSprite);
|
||||||
|
} else {
|
||||||
|
this._cursorActor.add_actor(this._cursorSprite);
|
||||||
|
}
|
||||||
|
this._cursorWatcher = PointerWatcher.getPointerWatcher();
|
||||||
|
this._cursorSeat = Clutter.get_default_backend().get_default_seat();
|
||||||
|
}
|
||||||
|
|
||||||
|
// After this:
|
||||||
|
// * real cursor enabled, manages its own visibility
|
||||||
|
// * cloning is "off"
|
||||||
|
// * no cloned cursor
|
||||||
|
//
|
||||||
|
// completely reverts _enableCloningMouse
|
||||||
|
_disableCloningMouse() {
|
||||||
|
this._stopCloningMouse();
|
||||||
|
Meta.CursorTracker.prototype.set_pointer_visible = this._cursorTrackerSetPointerVisible;
|
||||||
|
this._cursorTracker.set_pointer_visible(this._cursorWantedVisible);
|
||||||
|
|
||||||
|
this._cursorWantedVisible = null;
|
||||||
|
this._cursorTracker = null;
|
||||||
|
this._cursorTrackerSetPointerVisible = null;
|
||||||
|
this._cursorTrackerSetPointerVisibleBound = null;
|
||||||
|
this._cursorSprite = null;
|
||||||
|
this._cursorActor = null;
|
||||||
|
this._cursorWatcher = null;
|
||||||
|
this._cursorSeat = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// bound to Meta.CursorTracker.prototype.set_pointer_visible when cloning is "on"
|
||||||
|
// original function available in this._cursorTrackerSetPointerVisibleBound
|
||||||
|
_cursorTrackerSetPointerVisibleReplacement(visible) {
|
||||||
|
this._cursorWantedVisible = visible;
|
||||||
|
if (visible) {
|
||||||
|
this._startCloningMouse();
|
||||||
|
} else {
|
||||||
|
this._stopCloningMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// After this:
|
||||||
|
// * real cursor is hidden
|
||||||
|
// * cloning is "on"
|
||||||
|
// * clone cursor is visible
|
||||||
|
//
|
||||||
|
// add the clone cursor actor, watch for pointer movement and cursor changes, reflect them in the cloned cursor
|
||||||
|
// prereqs: setup in _enableCloningMouse, _cursorWantedVisible is true
|
||||||
|
_startCloningMouse() {
|
||||||
|
if (this._cursorWatch == null) {
|
||||||
|
if (Clutter.Container === undefined) {
|
||||||
|
this._mainActor.add_child(this._cursorActor);
|
||||||
|
} else {
|
||||||
|
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));
|
||||||
|
this._cursorPositionInvalidatedConnection = this._cursorTracker.connect('position-invalidated', this._updateMouseSprite.bind(this));
|
||||||
|
|
||||||
|
const interval = 1000 / 250;
|
||||||
|
this._cursorWatch = this._cursorWatcher.addWatch(interval, this._updateMousePosition.bind(this));
|
||||||
|
|
||||||
|
const [x, y] = global.get_pointer();
|
||||||
|
this._updateMousePosition(x, y);
|
||||||
|
this._updateMouseSprite();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._cursorTracker.set_keep_focus_while_hidden) {
|
||||||
|
this._cursorTracker.set_keep_focus_while_hidden(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this._cursorUnfocusInhibited) {
|
||||||
|
console.log('Breezy debug - inhibit_unfocus\n');
|
||||||
|
this._cursorSeat.inhibit_unfocus();
|
||||||
|
this._cursorUnfocusInhibited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// After this:
|
||||||
|
// * real cursor is hidden
|
||||||
|
// * cloning is "on"
|
||||||
|
// * cloned cursor not visible, but ready for _startCloningMouse to make it visible
|
||||||
|
//
|
||||||
|
// completely reverts _startCloningMouse
|
||||||
|
_stopCloningMouse() {
|
||||||
|
if (this._cursorWatch != null) {
|
||||||
|
this._cursorWatch.remove();
|
||||||
|
this._cursorWatch = null;
|
||||||
|
|
||||||
|
this._cursorTracker.disconnect(this._cursorChangedConnection);
|
||||||
|
this._cursorChangedConnection = null;
|
||||||
|
|
||||||
|
this._cursorTracker.disconnect(this._cursorVisibilityChangedConnection);
|
||||||
|
this._cursorVisibilityChangedConnection = null;
|
||||||
|
|
||||||
|
this._cursorTracker.disconnect(this._cursorPositionInvalidatedConnection);
|
||||||
|
this._cursorPositionInvalidatedConnection = null;
|
||||||
|
|
||||||
|
if (Clutter.Container === undefined) {
|
||||||
|
this._mainActor.remove_child(this._cursorActor);
|
||||||
|
} else {
|
||||||
|
this._mainActor.remove_actor(this._cursorActor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._cursorTracker.set_keep_focus_while_hidden) {
|
||||||
|
this._cursorTracker.set_keep_focus_while_hidden(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._cursorUnfocusInhibited) {
|
||||||
|
console.log('Breezy debug - uninhibit_unfocus\n');
|
||||||
|
this._cursorSeat.uninhibit_unfocus();
|
||||||
|
this._cursorUnfocusInhibited = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateMousePosition(x, y) {
|
||||||
|
this._cursorActor.set_position(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateMouseSprite() {
|
||||||
|
const sprite = this._cursorTracker.get_sprite();
|
||||||
|
if (sprite) {
|
||||||
|
this._cursorSprite.content.texture = sprite;
|
||||||
|
this._cursorSprite.show();
|
||||||
|
} else {
|
||||||
|
this._cursorSprite.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
const [xHot, yHot] = this._cursorTracker.get_hot();
|
||||||
|
this._cursorSprite.set({
|
||||||
|
translation_x: -xHot,
|
||||||
|
translation_y: -yHot,
|
||||||
|
});
|
||||||
|
this._mainActor.set_child_above_sibling(this._cursorActor, null);
|
||||||
|
this._cursorTrackerSetPointerVisibleBound(false);
|
||||||
|
|
||||||
|
// some other processes are uninhibiting when they shouldn't, so we need to re-inhibit here
|
||||||
|
if (!this._cursorSeat.is_unfocus_inhibited() && this._cursorUnfocusInhibited) {
|
||||||
|
console.log('Breezy debug - reinhibiting\n');
|
||||||
|
this._cursorSeat.inhibit_unfocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,453 @@
|
||||||
|
<!DOCTYPE node PUBLIC
|
||||||
|
'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'
|
||||||
|
'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>
|
||||||
|
<node>
|
||||||
|
<!--
|
||||||
|
org.gnome.Mutter.DisplayConfig:
|
||||||
|
@short_description: display configuration interface
|
||||||
|
|
||||||
|
This interface is used by mutter and gnome-settings-daemon
|
||||||
|
to apply multiple monitor configuration.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<interface name="org.gnome.Mutter.DisplayConfig">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
GetResources:
|
||||||
|
@serial: configuration serial
|
||||||
|
@crtcs: available CRTCs
|
||||||
|
@outputs: available outputs
|
||||||
|
@modes: available modes
|
||||||
|
@max_screen_width:
|
||||||
|
@max_screen_height:
|
||||||
|
|
||||||
|
Retrieves the current layout of the hardware.
|
||||||
|
|
||||||
|
@serial is an unique identifier representing the current state
|
||||||
|
of the screen. It must be passed back to ApplyConfiguration()
|
||||||
|
and will be increased for every configuration change (so that
|
||||||
|
mutter can detect that the new configuration is based on old
|
||||||
|
state).
|
||||||
|
|
||||||
|
A CRTC (CRT controller) is a logical monitor, ie a portion
|
||||||
|
of the compositor coordinate space. It might correspond
|
||||||
|
to multiple monitors, when in clone mode, but not that
|
||||||
|
it is possible to implement clone mode also by setting different
|
||||||
|
CRTCs to the same coordinates.
|
||||||
|
|
||||||
|
The number of CRTCs represent the maximum number of monitors
|
||||||
|
that can be set to expand and it is a HW constraint; if more
|
||||||
|
monitors are connected, then necessarily some will clone. This
|
||||||
|
is complementary to the concept of the encoder (not exposed in
|
||||||
|
the API), which groups outputs that necessarily will show the
|
||||||
|
same image (again a HW constraint).
|
||||||
|
|
||||||
|
A CRTC is represented by a DBus structure with the following
|
||||||
|
layout:
|
||||||
|
* u ID: the ID in the API of this CRTC
|
||||||
|
* x winsys_id: the low-level ID of this CRTC (which might
|
||||||
|
be a XID, a KMS handle or something entirely
|
||||||
|
different)
|
||||||
|
* i x, y, width, height: the geometry of this CRTC
|
||||||
|
(might be invalid if the CRTC is not in
|
||||||
|
use)
|
||||||
|
* i current_mode: the current mode of the CRTC, or -1 if this
|
||||||
|
CRTC is not used
|
||||||
|
Note: the size of the mode will always correspond
|
||||||
|
to the width and height of the CRTC
|
||||||
|
* u current_transform: the current transform (espressed according
|
||||||
|
to the wayland protocol)
|
||||||
|
* au transforms: all possible transforms
|
||||||
|
* a{sv} properties: other high-level properties that affect this
|
||||||
|
CRTC; they are not necessarily reflected in
|
||||||
|
the hardware.
|
||||||
|
No property is specified in this version of the API.
|
||||||
|
|
||||||
|
Note: all geometry information refers to the untransformed
|
||||||
|
display.
|
||||||
|
|
||||||
|
An output represents a physical screen, connected somewhere to
|
||||||
|
the computer. Floating connectors are not exposed in the API.
|
||||||
|
An output is a DBus struct with the following fields:
|
||||||
|
* u ID: the ID in the API
|
||||||
|
* x winsys_id: the low-level ID of this output (XID or KMS handle)
|
||||||
|
* i current_crtc: the CRTC that is currently driving this output,
|
||||||
|
or -1 if the output is disabled
|
||||||
|
* au possible_crtcs: all CRTCs that can control this output
|
||||||
|
* s name: the name of the connector to which the output is attached
|
||||||
|
(like VGA1 or HDMI)
|
||||||
|
* au modes: valid modes for this output
|
||||||
|
* au clones: valid clones for this output, ie other outputs that
|
||||||
|
can be assigned the same CRTC as this one; if you
|
||||||
|
want to mirror two outputs that don't have each other
|
||||||
|
in the clone list, you must configure two different
|
||||||
|
CRTCs for the same geometry
|
||||||
|
* a{sv} properties: other high-level properties that affect this
|
||||||
|
output; they are not necessarily reflected in
|
||||||
|
the hardware.
|
||||||
|
Known properties:
|
||||||
|
- "vendor" (s): (readonly) the human readable name
|
||||||
|
of the manufacturer
|
||||||
|
- "product" (s): (readonly) the human readable name
|
||||||
|
of the display model
|
||||||
|
- "serial" (s): (readonly) the serial number of this
|
||||||
|
particular hardware part
|
||||||
|
- "display-name" (s): (readonly) a human readable name
|
||||||
|
of this output, to be shown in the UI
|
||||||
|
- "backlight" (i): (readonly, use the specific interface)
|
||||||
|
the backlight value as a percentage
|
||||||
|
(-1 if not supported)
|
||||||
|
- "primary" (b): whether this output is primary
|
||||||
|
or not
|
||||||
|
- "presentation" (b): whether this output is
|
||||||
|
for presentation only
|
||||||
|
Note: properties might be ignored if not consistenly
|
||||||
|
applied to all outputs in the same clone group. In
|
||||||
|
general, it's expected that presentation or primary
|
||||||
|
outputs will not be cloned.
|
||||||
|
|
||||||
|
A mode represents a set of parameters that are applied to
|
||||||
|
each output, such as resolution and refresh rate. It is a separate
|
||||||
|
object so that it can be referenced by CRTCs and outputs.
|
||||||
|
Multiple outputs in the same CRTCs must all have the same mode.
|
||||||
|
A mode is exposed as:
|
||||||
|
* u ID: the ID in the API
|
||||||
|
* x winsys_id: the low-level ID of this mode
|
||||||
|
* u width, height: the resolution
|
||||||
|
* d frequency: refresh rate
|
||||||
|
* u flags: mode flags as defined in xf86drmMode.h and randr.h
|
||||||
|
|
||||||
|
Output and modes are read-only objects (except for output properties),
|
||||||
|
they can change only in accordance to HW changes (such as hotplugging
|
||||||
|
a monitor), while CRTCs can be changed with ApplyConfiguration().
|
||||||
|
|
||||||
|
XXX: actually, if you insist enough, you can add new modes
|
||||||
|
through xrandr command line or the KMS API, overriding what the
|
||||||
|
kernel driver and the EDID say.
|
||||||
|
Usually, it only matters with old cards with broken drivers, or
|
||||||
|
old monitors with broken EDIDs, but it happens more often with
|
||||||
|
projectors (if for example the kernel driver doesn't add the
|
||||||
|
640x480 - 800x600 - 1024x768 default modes). Probably something
|
||||||
|
that we need to handle in mutter anyway.
|
||||||
|
-->
|
||||||
|
<method name="GetResources">
|
||||||
|
<arg name="serial" direction="out" type="u" />
|
||||||
|
<arg name="crtcs" direction="out" type="a(uxiiiiiuaua{sv})" />
|
||||||
|
<arg name="outputs" direction="out" type="a(uxiausauaua{sv})" />
|
||||||
|
<arg name="modes" direction="out" type="a(uxuudu)" />
|
||||||
|
<arg name="max_screen_width" direction="out" type="i" />
|
||||||
|
<arg name="max_screen_height" direction="out" type="i" />
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
ApplyConfiguration:
|
||||||
|
@serial: configuration serial
|
||||||
|
@persistent: whether this configuration should be saved on disk
|
||||||
|
@crtcs: new data for CRTCs
|
||||||
|
@outputs: new data for outputs
|
||||||
|
|
||||||
|
Applies the requested configuration changes.
|
||||||
|
|
||||||
|
@serial must match the serial from the last GetResources() call,
|
||||||
|
or org.freedesktop.DBus.AccessDenied will be generated.
|
||||||
|
|
||||||
|
If @persistent is true, mutter will attempt to replicate this
|
||||||
|
configuration the next time this HW layout appears.
|
||||||
|
|
||||||
|
@crtcs represents the new logical configuration, as a list
|
||||||
|
of structures containing:
|
||||||
|
- u ID: the API ID from the corresponding GetResources() call
|
||||||
|
- i new_mode: the API ID of the new mode to configure the CRTC
|
||||||
|
with, or -1 if the CRTC should be disabled
|
||||||
|
- i x, y: the new coordinates of the top left corner
|
||||||
|
the geometry will be completed with the size information
|
||||||
|
from @new_mode
|
||||||
|
- u transform: the desired transform
|
||||||
|
- au outputs: the API ID of outputs that should be assigned to
|
||||||
|
this CRTC
|
||||||
|
- a{sv} properties: properties whose value should be changed
|
||||||
|
|
||||||
|
Note: CRTCs not referenced in the array will be disabled.
|
||||||
|
|
||||||
|
@outputs represent the output property changes as:
|
||||||
|
- u ID: the API ID of the output to change
|
||||||
|
- a{sv} properties: properties whose value should be changed
|
||||||
|
|
||||||
|
Note: both for CRTCs and outputs, properties not included in
|
||||||
|
the dictionary will not be changed.
|
||||||
|
|
||||||
|
Note: unrecognized properties will have no effect, but if the
|
||||||
|
configuration change succeeds the property will be reported
|
||||||
|
by the next GetResources() call, and if @persistent is true,
|
||||||
|
it will also be saved to disk.
|
||||||
|
|
||||||
|
If the configuration is invalid according to the previous
|
||||||
|
GetResources() call, for example because a CRTC references
|
||||||
|
an output it cannot drive, or not all outputs support the
|
||||||
|
chosen mode, the error org.freedesktop.DBus.InvalidArgs will
|
||||||
|
be generated.
|
||||||
|
|
||||||
|
If the configuration cannot be applied for any other reason
|
||||||
|
(eg. the screen size would exceed texture limits), the error
|
||||||
|
org.freedesktop.DBus.Error.LimitsExceeded will be generated.
|
||||||
|
-->
|
||||||
|
<method name="ApplyConfiguration">
|
||||||
|
<arg name="serial" direction="in" type="u" />
|
||||||
|
<arg name="persistent" direction="in" type="b" />
|
||||||
|
<arg name="crtcs" direction="in" type="a(uiiiuaua{sv})" />
|
||||||
|
<arg name="outputs" direction="in" type="a(ua{sv})" />
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
ChangeBacklight:
|
||||||
|
@serial: configuration serial
|
||||||
|
@output: the API id of the output
|
||||||
|
@value: the new backlight value
|
||||||
|
|
||||||
|
Changes the backlight of @output to @value, which is
|
||||||
|
expressed as a percentage and rounded to the HW limits.
|
||||||
|
|
||||||
|
Returns the new value after rounding.
|
||||||
|
-->
|
||||||
|
<method name="ChangeBacklight">
|
||||||
|
<arg name="serial" direction="in" type="u" />
|
||||||
|
<arg name="output" direction="in" type="u" />
|
||||||
|
<arg name="value" direction="in" type="i" />
|
||||||
|
<arg name="new_value" direction="out" type="i" />
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
GetCrtcGamma:
|
||||||
|
@serial: configuration serial
|
||||||
|
@crtc: API id of the crtc
|
||||||
|
@red: red gamma ramp
|
||||||
|
@green: green gamma ramp
|
||||||
|
@blue: blue gamma ramp
|
||||||
|
|
||||||
|
Requests the current gamma ramps of @crtc.
|
||||||
|
-->
|
||||||
|
<method name="GetCrtcGamma">
|
||||||
|
<arg name="serial" direction="in" type="u" />
|
||||||
|
<arg name="crtc" direction="in" type="u" />
|
||||||
|
<arg name="red" direction="out" type="aq" />
|
||||||
|
<arg name="green" direction="out" type="aq" />
|
||||||
|
<arg name="blue" direction="out" type="aq" />
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
SetCrtcGamma:
|
||||||
|
@serial: configuration serial
|
||||||
|
@crtc: API id of the crtc
|
||||||
|
@red: red gamma ramp
|
||||||
|
@green: green gamma ramp
|
||||||
|
@blue: blue gamma ramp
|
||||||
|
|
||||||
|
Changes the gamma ramps of @crtc.
|
||||||
|
-->
|
||||||
|
<method name="SetCrtcGamma">
|
||||||
|
<arg name="serial" direction="in" type="u" />
|
||||||
|
<arg name="crtc" direction="in" type="u" />
|
||||||
|
<arg name="red" direction="in" type="aq" />
|
||||||
|
<arg name="green" direction="in" type="aq" />
|
||||||
|
<arg name="blue" direction="in" type="aq" />
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
PowerSaveMode:
|
||||||
|
|
||||||
|
Contains the current power saving mode for the screen, and
|
||||||
|
allows changing it.
|
||||||
|
|
||||||
|
Possible values:
|
||||||
|
- 0: on
|
||||||
|
- 1: standby
|
||||||
|
- 2: suspend
|
||||||
|
- 3: off
|
||||||
|
- -1: unknown (unsupported)
|
||||||
|
|
||||||
|
A client should not attempt to change the powersave mode
|
||||||
|
from -1 (unknown) to any other value, and viceversa.
|
||||||
|
Note that the actual effects of the different values
|
||||||
|
depend on the hardware and the kernel driver in use, and
|
||||||
|
it's perfectly possible that all values different than on
|
||||||
|
have the same effect.
|
||||||
|
Also, setting the PowerSaveMode to 3 (off) may or may
|
||||||
|
not have the same effect as disabling all outputs by
|
||||||
|
setting no CRTC on them with ApplyConfiguration(), and
|
||||||
|
may or may not cause a configuration change.
|
||||||
|
|
||||||
|
Also note that this property might become out of date
|
||||||
|
if changed through different means (for example using the
|
||||||
|
XRandR interface directly).
|
||||||
|
-->
|
||||||
|
<property name="PowerSaveMode" type="i" access="readwrite" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
MonitorsChanged:
|
||||||
|
|
||||||
|
The signal is emitted every time the screen configuration
|
||||||
|
changes.
|
||||||
|
The client should then call GetResources() to read the new layout.
|
||||||
|
-->
|
||||||
|
<signal name="MonitorsChanged" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
GetCurrentState:
|
||||||
|
@serial: configuration serial
|
||||||
|
@monitors: available monitors
|
||||||
|
@logical_monitors: current logical monitor configuration
|
||||||
|
@properties: display configuration properties
|
||||||
|
|
||||||
|
@monitors represent connected physical monitors
|
||||||
|
|
||||||
|
* s connector: connector name (e.g. HDMI-1, DP-1, etc)
|
||||||
|
* s vendor: vendor name
|
||||||
|
* s product: product name
|
||||||
|
* s serial: product serial
|
||||||
|
* a(siiddada{sv}) modes: available modes
|
||||||
|
* s id: mode ID
|
||||||
|
* i width: width in physical pixels
|
||||||
|
* i height: height in physical pixels
|
||||||
|
* d refresh rate: refresh rate
|
||||||
|
* d preferred scale: scale preferred as per calculations
|
||||||
|
* ad supported scales: scales supported by this mode
|
||||||
|
* a{sv} properties: optional properties, including:
|
||||||
|
- "is-current" (b): the mode is currently active mode
|
||||||
|
- "is-preferred" (b): the mode is the preferred mode
|
||||||
|
- "is-interlaced" (b): the mode is an interlaced mode
|
||||||
|
* a{sv} properties: optional properties, including:
|
||||||
|
- "width-mm" (i): physical width of monitor in millimeters
|
||||||
|
- "height-mm" (i): physical height of monitor in millimeters
|
||||||
|
- "is-underscanning" (b): whether underscanning is enabled
|
||||||
|
(absence of this means underscanning
|
||||||
|
not being supported)
|
||||||
|
- "max-screen-size" (ii): the maximum size a screen may have
|
||||||
|
(absence of this means unlimited screen
|
||||||
|
size)
|
||||||
|
- "is-builtin" (b): whether the monitor is built in, e.g. a
|
||||||
|
laptop panel (absence of this means it is
|
||||||
|
not built in)
|
||||||
|
- "display-name" (s): a human readable display name of the monitor
|
||||||
|
|
||||||
|
Possible mode flags:
|
||||||
|
1 : preferred mode
|
||||||
|
2 : current mode
|
||||||
|
|
||||||
|
|
||||||
|
@logical_monitors represent current logical monitor configuration
|
||||||
|
|
||||||
|
* i x: x position
|
||||||
|
* i y: y position
|
||||||
|
* d scale: scale
|
||||||
|
* u transform: transform (see below)
|
||||||
|
* b primary: true if this is the primary logical monitor
|
||||||
|
* a(sss) monitors: monitors displaying this logical monitor
|
||||||
|
* connector: name of the connector (e.g. DP-1, eDP-1 etc)
|
||||||
|
* vendor: vendor name
|
||||||
|
* product: product name
|
||||||
|
* serial: product serial
|
||||||
|
* a{sv} properties: possibly other properties
|
||||||
|
|
||||||
|
Posisble transform values:
|
||||||
|
0: normal
|
||||||
|
1: 90°
|
||||||
|
2: 180°
|
||||||
|
3: 270°
|
||||||
|
4: flipped
|
||||||
|
5: 90° flipped
|
||||||
|
6: 180° flipped
|
||||||
|
7: 270° flipped
|
||||||
|
|
||||||
|
|
||||||
|
@layout_mode current layout mode represents the way logical monitors
|
||||||
|
are layed out on the screen. Possible modes include:
|
||||||
|
|
||||||
|
1 : physical
|
||||||
|
2 : logical
|
||||||
|
|
||||||
|
With physical layout mode, each logical monitor has the same dimensions
|
||||||
|
as the monitor modes of the associated monitors assigned to it, no
|
||||||
|
matter what scale is in use.
|
||||||
|
|
||||||
|
With logical mode, the dimension of a logical monitor is the dimension
|
||||||
|
of the monitor mode, divided by the logical monitor scale.
|
||||||
|
|
||||||
|
|
||||||
|
Possible @properties are:
|
||||||
|
|
||||||
|
* "supports-mirroring" (b): FALSE if mirroring not supported; TRUE or not
|
||||||
|
present if mirroring is supported.
|
||||||
|
* "layout-mode" (u): Represents in what way logical monitors are laid
|
||||||
|
out on the screen. The layout mode can be either
|
||||||
|
of the ones listed below. Absence of this property
|
||||||
|
means the layout mode cannot be changed, and that
|
||||||
|
"logical" mode is assumed to be used.
|
||||||
|
* 1 : logical - the dimension of a logical monitor is derived from
|
||||||
|
the monitor modes associated with it, then scaled
|
||||||
|
using the logical monitor scale.
|
||||||
|
* 2 : physical - the dimension of a logical monitor is derived from
|
||||||
|
the monitor modes associated with it.
|
||||||
|
* "supports-changing-layout-mode" (b): True if the layout mode can be
|
||||||
|
changed. Absence of this means the
|
||||||
|
layout mode cannot be changed.
|
||||||
|
* "global-scale-required" (b): True if all the logical monitors must
|
||||||
|
always use the same scale. Absence of
|
||||||
|
this means logical monitor scales can
|
||||||
|
differ.
|
||||||
|
* "legacy-ui-scaling-factor" (i): The legacy scaling factor traditionally
|
||||||
|
used to scale X11 clients (commonly
|
||||||
|
communicated via the
|
||||||
|
Gdk/WindowScalingFactor XSetting entry).
|
||||||
|
-->
|
||||||
|
<method name="GetCurrentState">
|
||||||
|
<arg name="serial" direction="out" type="u" />
|
||||||
|
<arg name="monitors" direction="out" type="a((ssss)a(siiddada{sv})a{sv})" />
|
||||||
|
<arg name="logical_monitors" direction="out" type="a(iiduba(ssss)a{sv})" />
|
||||||
|
<arg name="properties" direction="out" type="a{sv}" />
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
ApplyMonitorsConfig:
|
||||||
|
@serial: configuration serial
|
||||||
|
@method: configuration method
|
||||||
|
@logical_monitors: monitors configuration
|
||||||
|
@properties: properties
|
||||||
|
|
||||||
|
@method represents the way the configuration should be handled.
|
||||||
|
|
||||||
|
Possible methods:
|
||||||
|
0: verify
|
||||||
|
1: temporary
|
||||||
|
2: persistent
|
||||||
|
|
||||||
|
@logical_monitors consists of a list of logical monitor configurations.
|
||||||
|
Each logical monitor configuration consists of:
|
||||||
|
|
||||||
|
* i: layout x position
|
||||||
|
* i: layout y position
|
||||||
|
* d: scale
|
||||||
|
* u: transform (see GetCurrentState)
|
||||||
|
* b primary: true if this is the primary logical monitor
|
||||||
|
* a(ssa{sv}): a list of monitors, each consisting of:
|
||||||
|
* s: connector
|
||||||
|
* s: monitor mode ID
|
||||||
|
* a{sv}: monitor properties, including:
|
||||||
|
- "enable_underscanning" (b): enable monitor underscanning;
|
||||||
|
may only be set when underscanning
|
||||||
|
is supported (see GetCurrentState).
|
||||||
|
|
||||||
|
@properties may effect the global monitor configuration state. Possible
|
||||||
|
properties are:
|
||||||
|
|
||||||
|
* "layout-mode" (u): layout mode the passed configuration is in; may
|
||||||
|
only be set when changing the layout mode is
|
||||||
|
supported (see GetCurrentState).
|
||||||
|
-->
|
||||||
|
<method name="ApplyMonitorsConfig">
|
||||||
|
<arg name="serial" direction="in" type="u" />
|
||||||
|
<arg name="method" direction="in" type="u" />
|
||||||
|
<arg name="logical_monitors" direction="in" type="a(iiduba(ssa{sv}))" />
|
||||||
|
<arg name="properties" direction="in" type="a{sv}" />
|
||||||
|
</method>
|
||||||
|
</interface>
|
||||||
|
</node>
|
||||||
|
|
@ -0,0 +1,244 @@
|
||||||
|
import Clutter from 'gi://Clutter'
|
||||||
|
import Gio from 'gi://Gio';
|
||||||
|
import GLib from 'gi://GLib';
|
||||||
|
import Meta from 'gi://Meta';
|
||||||
|
import Shell from 'gi://Shell';
|
||||||
|
import St from 'gi://St';
|
||||||
|
|
||||||
|
import { CursorManager } from './cursormanager.js';
|
||||||
|
import Globals from './globals.js';
|
||||||
|
import MonitorManager from './monitormanager.js';
|
||||||
|
import { IPC_FILE_PATH, XREffect } from './xrEffect.js';
|
||||||
|
|
||||||
|
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||||
|
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||||
|
|
||||||
|
const SUPPORTED_MONITOR_PRODUCTS = [
|
||||||
|
'VITURE',
|
||||||
|
'nreal air',
|
||||||
|
'Air',
|
||||||
|
'MetaMonitor' // nested mode dummy monitor
|
||||||
|
];
|
||||||
|
|
||||||
|
export default class BreezyDesktopExtension extends Extension {
|
||||||
|
constructor(metadata, uuid) {
|
||||||
|
super(metadata, uuid);
|
||||||
|
|
||||||
|
this.settings = this.getSettings();
|
||||||
|
|
||||||
|
// Set/destroyed by enable/disable
|
||||||
|
this._cursor_manager = null;
|
||||||
|
this._monitor_manager = null;
|
||||||
|
this._xr_effect = null;
|
||||||
|
this._overlay = null;
|
||||||
|
this._target_monitor = null;
|
||||||
|
this._is_effect_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
enable() {
|
||||||
|
Globals.extension_dir = this.path;
|
||||||
|
this._monitor_manager = new MonitorManager(this.path);
|
||||||
|
this._monitor_manager.setChangeHook(this._setup.bind(this));
|
||||||
|
this._monitor_manager.enable();
|
||||||
|
|
||||||
|
this._setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
_poll_for_ready() {
|
||||||
|
var target_monitor = this._target_monitor;
|
||||||
|
var is_effect_running = this._is_effect_running;
|
||||||
|
this._running_poller_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, (() => {
|
||||||
|
if (is_effect_running) return GLib.SOURCE_REMOVE;
|
||||||
|
|
||||||
|
const is_driver_running = this._check_driver_running();
|
||||||
|
if (is_driver_running && target_monitor) {
|
||||||
|
console.log('Driver is running, supported monitor connected. Enabling XR effect.');
|
||||||
|
this._effect_enable();
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
|
} else {
|
||||||
|
return GLib.SOURCE_CONTINUE;
|
||||||
|
}
|
||||||
|
}).bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
_find_supported_monitor() {
|
||||||
|
const target_monitor = this._monitor_manager.getMonitorPropertiesList()?.find(
|
||||||
|
monitor => SUPPORTED_MONITOR_PRODUCTS.includes(monitor.product));
|
||||||
|
if (target_monitor !== undefined) {
|
||||||
|
return {
|
||||||
|
monitor: this._monitor_manager.getMonitors()[target_monitor.index],
|
||||||
|
refreshRate: target_monitor.refreshRate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.settings.get_boolean('developer-mode')) {
|
||||||
|
// allow testing XR devices with just USB, no video needed
|
||||||
|
return {
|
||||||
|
monitor: this._monitor_manager.getMonitors()[0],
|
||||||
|
refreshRate: 60,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_setup() {
|
||||||
|
if (this._is_effect_running) {
|
||||||
|
console.log('Monitors changed, disabling XR effect');
|
||||||
|
this._effect_disable();
|
||||||
|
}
|
||||||
|
const target_monitor = this._find_supported_monitor();
|
||||||
|
|
||||||
|
// if target_monitor isn't set, do nothing and wait for MonitorManager to call this again
|
||||||
|
if (target_monitor && this._running_poller_id === undefined) {
|
||||||
|
this._target_monitor = target_monitor.monitor;
|
||||||
|
this._refresh_rate = target_monitor.refreshRate;
|
||||||
|
|
||||||
|
if (this._check_driver_running()) {
|
||||||
|
console.log('Ready, enabling XR effect');
|
||||||
|
this._effect_enable();
|
||||||
|
} else {
|
||||||
|
this._poll_for_ready();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_check_driver_running() {
|
||||||
|
if (!Globals.ipc_file) Globals.ipc_file = Gio.file_new_for_path(IPC_FILE_PATH);
|
||||||
|
return Globals.ipc_file.query_exists(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
_effect_enable() {
|
||||||
|
this._running_poller_id = undefined;
|
||||||
|
if (!this._is_effect_running) {
|
||||||
|
this._is_effect_running = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
this._cursor_manager = new CursorManager(Main.layoutManager.uiGroup);
|
||||||
|
this._cursor_manager.enable();
|
||||||
|
|
||||||
|
this._overlay = new St.Bin({ style: 'background-color: rgba(0, 0, 0, 1);'});
|
||||||
|
this._overlay.opacity = 255;
|
||||||
|
this._overlay.set_position(this._target_monitor.x, this._target_monitor.y);
|
||||||
|
this._overlay.set_size(this._target_monitor.width, this._target_monitor.height);
|
||||||
|
|
||||||
|
const overlayContent = new Clutter.Actor({clip_to_allocation: true});
|
||||||
|
const uiClone = new Clutter.Clone({ source: Main.layoutManager.uiGroup, clip_to_allocation: true });
|
||||||
|
uiClone.x = -this._target_monitor.x;
|
||||||
|
uiClone.y = -this._target_monitor.y;
|
||||||
|
if (Clutter.Container === undefined) {
|
||||||
|
overlayContent.add_child(uiClone);
|
||||||
|
} else {
|
||||||
|
overlayContent.add_actor(uiClone);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._overlay.set_child(overlayContent);
|
||||||
|
|
||||||
|
global.stage.insert_child_above(this._overlay, null);
|
||||||
|
Shell.util_set_hidden_from_pick(this._overlay, true);
|
||||||
|
|
||||||
|
this._xr_effect = new XREffect({
|
||||||
|
target_monitor: this._target_monitor,
|
||||||
|
target_framerate: this._refresh_rate ?? 60,
|
||||||
|
display_distance: this.settings.get_double('display-distance'),
|
||||||
|
toggle_display_distance_start: this.settings.get_double('toggle-display-distance-start'),
|
||||||
|
toggle_display_distance_end: this.settings.get_double('toggle-display-distance-end'),
|
||||||
|
});
|
||||||
|
|
||||||
|
this.settings.bind('effect-enable', this._xr_effect, 'effect-enable', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
this.settings.bind('display-distance', this._xr_effect, 'display-distance', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
this.settings.bind('toggle-display-distance-start', this._xr_effect, 'toggle-display-distance-start', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
this.settings.bind('toggle-display-distance-end', this._xr_effect, 'toggle-display-distance-end', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
|
||||||
|
this._overlay.add_effect_with_name('xr-desktop', this._xr_effect);
|
||||||
|
Meta.disable_unredirect_for_display(global.display);
|
||||||
|
|
||||||
|
this._add_settings_keybinding('recenter-display-shortcut', this._recenter_display.bind(this));
|
||||||
|
this._add_settings_keybinding('toggle-display-distance-shortcut', this._xr_effect._change_distance.bind(this._xr_effect));
|
||||||
|
this._add_settings_keybinding('toggle-follow-shortcut', this._toggle_follow_mode.bind(this));
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error enabling XR effect', e);
|
||||||
|
this._effect_disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_add_settings_keybinding(settings_key, bind_to_function) {
|
||||||
|
Main.wm.addKeybinding(
|
||||||
|
settings_key,
|
||||||
|
this.settings,
|
||||||
|
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||||
|
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW | Shell.ActionMode.POPUP,
|
||||||
|
bind_to_function
|
||||||
|
);
|
||||||
|
|
||||||
|
// Connect to the 'changed' signal for the keybinding property
|
||||||
|
this.settings.connect(`changed::${settings_key}`, () => {
|
||||||
|
// Remove the old keybinding
|
||||||
|
Main.wm.removeKeybinding(settings_key);
|
||||||
|
|
||||||
|
// Add the updated keybinding
|
||||||
|
Main.wm.addKeybinding(
|
||||||
|
settings_key,
|
||||||
|
this.settings,
|
||||||
|
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||||
|
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW | Shell.ActionMode.POPUP,
|
||||||
|
bind_to_function
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_write_control(key, value) {
|
||||||
|
const file = Gio.file_new_for_path('/dev/shm/xr_driver_control');
|
||||||
|
const stream = file.replace(null, false, Gio.FileCreateFlags.NONE, null);
|
||||||
|
stream.write(`${key}=${value}`, null);
|
||||||
|
stream.close(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
_recenter_display() {
|
||||||
|
this._write_control('recenter_screen', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
_toggle_follow_mode() {
|
||||||
|
this._write_control('toggle_breezy_desktop_smooth_follow', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
_effect_disable() {
|
||||||
|
this._is_effect_running = false;
|
||||||
|
|
||||||
|
if (this._running_poller_id) GLib.source_remove(this._running_poller_id);
|
||||||
|
|
||||||
|
Main.wm.removeKeybinding('recenter-display-shortcut');
|
||||||
|
Main.wm.removeKeybinding('toggle-display-distance-shortcut');
|
||||||
|
Meta.enable_unredirect_for_display(global.display);
|
||||||
|
|
||||||
|
if (this._overlay) {
|
||||||
|
global.stage.remove_child(this._overlay);
|
||||||
|
this._overlay.remove_effect_by_name('xr-desktop');
|
||||||
|
this._overlay.destroy();
|
||||||
|
this._overlay = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._xr_effect) {
|
||||||
|
this._xr_effect = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._cursor_manager) {
|
||||||
|
this._cursor_manager.disable();
|
||||||
|
this._cursor_manager = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
disable() {
|
||||||
|
this._effect_disable();
|
||||||
|
this._target_monitor = null;
|
||||||
|
if (this._monitor_manager) {
|
||||||
|
this._monitor_manager.disable();
|
||||||
|
this._monitor_manager = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
return new Extension();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
const Globals = {
|
||||||
|
ipc_file: null, // Gio.File instance, file exists
|
||||||
|
extension_dir: null // string path
|
||||||
|
}
|
||||||
|
export default Globals;
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
export const UINT8_SIZE = 1;
|
||||||
|
export const BOOL_SIZE = UINT8_SIZE;
|
||||||
|
export const UINT_SIZE = 4;
|
||||||
|
export const FLOAT_SIZE = 4;
|
||||||
|
|
||||||
|
export const DATA_VIEW_INFO_OFFSET_INDEX = 0;
|
||||||
|
export const DATA_VIEW_INFO_SIZE_INDEX = 1;
|
||||||
|
export const DATA_VIEW_INFO_COUNT_INDEX = 2;
|
||||||
|
|
||||||
|
// computes the end offset, exclusive
|
||||||
|
export function dataViewEnd(dataViewInfo) {
|
||||||
|
return dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX] + dataViewInfo[DATA_VIEW_INFO_SIZE_INDEX] * dataViewInfo[DATA_VIEW_INFO_COUNT_INDEX];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dataViewUint8(dataView, dataViewInfo) {
|
||||||
|
return dataView.getUint8(dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dataViewUint(dataView, dataViewInfo) {
|
||||||
|
return dataView.getUint32(dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dataViewBigUint(dataView, dataViewInfo) {
|
||||||
|
return Number(dataView.getBigUint64(dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX], true));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dataViewUintArray(dataView, dataViewInfo) {
|
||||||
|
const uintArray = []
|
||||||
|
let offset = dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX];
|
||||||
|
for (let i = 0; i < dataViewInfo[DATA_VIEW_INFO_COUNT_INDEX]; i++) {
|
||||||
|
uintArray.push(dataView.getUint32(offset, true));
|
||||||
|
offset += UINT_SIZE;
|
||||||
|
}
|
||||||
|
return uintArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dataViewFloat(dataView, dataViewInfo) {
|
||||||
|
return dataView.getFloat32(dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dataViewFloatArray(dataView, dataViewInfo) {
|
||||||
|
const floatArray = []
|
||||||
|
let offset = dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX];
|
||||||
|
for (let i = 0; i < dataViewInfo[DATA_VIEW_INFO_COUNT_INDEX]; i++) {
|
||||||
|
floatArray.push(dataView.getFloat32(offset, true));
|
||||||
|
offset += FLOAT_SIZE;
|
||||||
|
}
|
||||||
|
return floatArray;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
export function degreeToRadian(degree) {
|
||||||
|
return degree * Math.PI / 180;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"uuid": "breezydesktop@xronlinux.com",
|
||||||
|
"name": "Breezy GNOME XR Desktop",
|
||||||
|
"description": "XR virtual desktop for GNOME.",
|
||||||
|
"settings-schema": "com.xronlinux.BreezyDesktop",
|
||||||
|
"shell-version": [
|
||||||
|
"45", "46"
|
||||||
|
],
|
||||||
|
"url": "https://github.com/wheaney/breezy-desktop"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,167 @@
|
||||||
|
// Taken from https://github.com/jkitching/soft-brightness-plus
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019, 2021 Philippe Troin (F-i-f on Github)
|
||||||
|
// Copyright (C) 2023 Joel Kitching (jkitching on Github)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import Gio from 'gi://Gio';
|
||||||
|
|
||||||
|
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||||
|
|
||||||
|
let cachedDisplayConfigProxy = null;
|
||||||
|
|
||||||
|
function getDisplayConfigProxy(extPath) {
|
||||||
|
if (cachedDisplayConfigProxy == null) {
|
||||||
|
let xml = null;
|
||||||
|
const file = Gio.File.new_for_path(extPath + '/dbus-interfaces/org.gnome.Mutter.DisplayConfig.xml');
|
||||||
|
try {
|
||||||
|
const [ok, bytes] = file.load_contents(null);
|
||||||
|
if (ok) {
|
||||||
|
xml = new TextDecoder().decode(bytes);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('failed to load DisplayConfig interface XML');
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
cachedDisplayConfigProxy = Gio.DBusProxy.makeProxyWrapper(xml);
|
||||||
|
}
|
||||||
|
return cachedDisplayConfigProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function newDisplayConfig(extPath, callback) {
|
||||||
|
const DisplayConfigProxy = getDisplayConfigProxy(extPath);
|
||||||
|
new DisplayConfigProxy(
|
||||||
|
Gio.DBus.session,
|
||||||
|
'org.gnome.Mutter.DisplayConfig',
|
||||||
|
'/org/gnome/Mutter/DisplayConfig',
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMonitorConfig(displayConfigProxy, callback) {
|
||||||
|
displayConfigProxy.GetResourcesRemote((result) => {
|
||||||
|
if (result.length <= 2) {
|
||||||
|
callback(null, 'Cannot get DisplayConfig: No outputs in GetResources()');
|
||||||
|
} else {
|
||||||
|
const monitors = [];
|
||||||
|
for (let i = 0; i < result[2].length; i++) {
|
||||||
|
const output = result[2][i];
|
||||||
|
if (output.length <= 7) {
|
||||||
|
callback(null, 'Cannot get DisplayConfig: No properties on output #' + i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const props = output[7];
|
||||||
|
const displayName = props['display-name'].get_string()[0];
|
||||||
|
const connectorName = output[4];
|
||||||
|
if (!displayName || displayName == '') {
|
||||||
|
const displayName = 'Monitor on output ' + connectorName;
|
||||||
|
}
|
||||||
|
const vendor = props['vendor'].get_string()[0];
|
||||||
|
const product = props['product'].get_string()[0];
|
||||||
|
const serial = props['serial'].get_string()[0];
|
||||||
|
|
||||||
|
// grab refresh rate from the modes array
|
||||||
|
const refreshRate = result[3][i][4];
|
||||||
|
|
||||||
|
monitors.push([displayName, connectorName, vendor, product, serial, refreshRate]);
|
||||||
|
}
|
||||||
|
callback(monitors, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monitor change handling
|
||||||
|
export default class MonitorManager {
|
||||||
|
constructor(extPath) {
|
||||||
|
this._extPath = extPath;
|
||||||
|
|
||||||
|
this._monitorsChangedConnection = null;
|
||||||
|
this._displayConfigProxy = null;
|
||||||
|
this._backendManager = null;
|
||||||
|
this._monitorProperties = null;
|
||||||
|
this._changeHookFn = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
enable() {
|
||||||
|
this._backendManager = global.backend.get_monitor_manager();
|
||||||
|
newDisplayConfig(this._extPath, (proxy, error) => {
|
||||||
|
if (error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._displayConfigProxy = proxy;
|
||||||
|
this._on_monitors_change();
|
||||||
|
});
|
||||||
|
|
||||||
|
this._monitorsChangedConnection = Main.layoutManager.connect('monitors-changed', this._on_monitors_change.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
disable() {
|
||||||
|
Main.layoutManager.disconnect(this._monitorsChangedConnection);
|
||||||
|
|
||||||
|
this._monitorsChangedConnection = null;
|
||||||
|
this._displayConfigProxy = null;
|
||||||
|
this._backendManager = null;
|
||||||
|
this._monitorProperties = null;
|
||||||
|
this._changeHookFn = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
setChangeHook(fn) {
|
||||||
|
this._changeHookFn = fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPostCallback(callback) {
|
||||||
|
this._postCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
getMonitors() {
|
||||||
|
return Main.layoutManager.monitors;
|
||||||
|
}
|
||||||
|
|
||||||
|
getMonitorPropertiesList() {
|
||||||
|
return this._monitorProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
_on_monitors_change() {
|
||||||
|
if (this._displayConfigProxy == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getMonitorConfig(this._displayConfigProxy, (result, error) => {
|
||||||
|
if (error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const monitorProperties = [];
|
||||||
|
for (let i = 0; i < result.length; i++) {
|
||||||
|
const [monitorName, connectorName, vendor, product, serial, refreshRate] = result[i];
|
||||||
|
const monitorIndex = this._backendManager.get_monitor_for_connector(connectorName);
|
||||||
|
console.log(`\n\nFound monitor ${monitorName}, vendor ${vendor}, product ${product}, serial ${serial}, connector ${connectorName}, index ${monitorIndex}\n\n`);
|
||||||
|
if (monitorIndex >= 0) {
|
||||||
|
monitorProperties[monitorIndex] = {
|
||||||
|
index: monitorIndex,
|
||||||
|
name: monitorName,
|
||||||
|
vendor: vendor,
|
||||||
|
product: product,
|
||||||
|
serial: serial,
|
||||||
|
connector: connectorName,
|
||||||
|
refreshRate: refreshRate
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._monitorProperties = monitorProperties;
|
||||||
|
if (this._changeHookFn !== null) {
|
||||||
|
this._changeHookFn();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../ui/data/com.xronlinux.BreezyDesktop.gschema.xml
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import Gio from 'gi://Gio';
|
||||||
|
|
||||||
|
export function getShaderSource(path) {
|
||||||
|
const file = Gio.file_new_for_path(path);
|
||||||
|
const data = file.load_contents(null);
|
||||||
|
|
||||||
|
// version string helps with linting, but GNOME extension doesn't like it, so remove it if it's there
|
||||||
|
//
|
||||||
|
// TODO - Gjs on GNOME 45.5 WARNING: Some code called array.toString() on a Uint8Array instance. Previously this
|
||||||
|
// would have interpreted the bytes of the array as a string, but that is nonstandard. In the future this
|
||||||
|
// will return the bytes as comma-separated digits. For the time being, the old behavior has been preserved,
|
||||||
|
// but please fix your code anyway to use TextDecoder.
|
||||||
|
return data[1].toString().replace(/^#version .*$/gm, '') + '\n';
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
export function getEpochSec() {
|
||||||
|
return toSec(Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toSec(milliseconds) {
|
||||||
|
return Math.floor(milliseconds / 1000);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,308 @@
|
||||||
|
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,
|
||||||
|
dataViewBigUint,
|
||||||
|
dataViewUintArray,
|
||||||
|
dataViewFloat,
|
||||||
|
dataViewFloatArray,
|
||||||
|
BOOL_SIZE,
|
||||||
|
DATA_VIEW_INFO_COUNT_INDEX,
|
||||||
|
DATA_VIEW_INFO_OFFSET_INDEX,
|
||||||
|
FLOAT_SIZE,
|
||||||
|
UINT_SIZE,
|
||||||
|
UINT8_SIZE
|
||||||
|
} from "./ipc.js";
|
||||||
|
import { degreeToRadian } from "./math.js";
|
||||||
|
import { getShaderSource } from "./shader.js";
|
||||||
|
import { toSec } from "./time.js";
|
||||||
|
|
||||||
|
export const IPC_FILE_PATH = "/dev/shm/breezy_desktop_imu";
|
||||||
|
|
||||||
|
// the driver should be using the same data layout version
|
||||||
|
const DATA_LAYOUT_VERSION = 2;
|
||||||
|
|
||||||
|
// DataView info: [offset, size, count]
|
||||||
|
const VERSION = [0, UINT8_SIZE, 1];
|
||||||
|
const ENABLED = [dataViewEnd(VERSION), BOOL_SIZE, 1];
|
||||||
|
const LOOK_AHEAD_CFG = [dataViewEnd(ENABLED), FLOAT_SIZE, 4];
|
||||||
|
const DISPLAY_RES = [dataViewEnd(LOOK_AHEAD_CFG), UINT_SIZE, 2];
|
||||||
|
const DISPLAY_FOV = [dataViewEnd(DISPLAY_RES), FLOAT_SIZE, 1];
|
||||||
|
const LENS_DISTANCE_RATIO = [dataViewEnd(DISPLAY_FOV), FLOAT_SIZE, 1];
|
||||||
|
const SBS_ENABLED = [dataViewEnd(LENS_DISTANCE_RATIO), BOOL_SIZE, 1];
|
||||||
|
const CUSTOM_BANNER_ENABLED = [dataViewEnd(SBS_ENABLED), BOOL_SIZE, 1];
|
||||||
|
const EPOCH_MS = [dataViewEnd(CUSTOM_BANNER_ENABLED), UINT_SIZE, 2];
|
||||||
|
const IMU_QUAT_DATA = [dataViewEnd(EPOCH_MS), FLOAT_SIZE, 16];
|
||||||
|
const DATA_VIEW_LENGTH = dataViewEnd(IMU_QUAT_DATA);
|
||||||
|
|
||||||
|
// cached after first retrieval
|
||||||
|
const shaderUniformLocations = {
|
||||||
|
'enabled': null,
|
||||||
|
'show_banner': null,
|
||||||
|
'imu_quat_data': null,
|
||||||
|
'look_ahead_cfg': null,
|
||||||
|
'look_ahead_ms': null,
|
||||||
|
'stage_aspect_ratio': null,
|
||||||
|
'display_aspect_ratio': null,
|
||||||
|
'trim_width_percent': null,
|
||||||
|
'trim_height_percent': null,
|
||||||
|
'display_zoom': null,
|
||||||
|
'display_north_offset': null,
|
||||||
|
'lens_distance_ratio': null,
|
||||||
|
'sbs_enabled': null,
|
||||||
|
'sbs_content': null,
|
||||||
|
'custom_banner_enabled': null,
|
||||||
|
'half_fov_z_rads': null,
|
||||||
|
'half_fov_y_rads': null,
|
||||||
|
'screen_distance': null
|
||||||
|
};
|
||||||
|
|
||||||
|
function transferUniformBoolean(effect, location, dataView, dataViewInfo) {
|
||||||
|
// GLSL bool is a float under the hood, evaluates false if 0 or 0.0, true otherwise
|
||||||
|
effect.set_uniform_float(location, 1, [dataViewUint8(dataView, dataViewInfo)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUniformFloat(effect, locationName, dataViewInfo, value) {
|
||||||
|
effect.set_uniform_float(shaderUniformLocations[locationName], dataViewInfo[DATA_VIEW_INFO_COUNT_INDEX], value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function transferUniformFloat(effect, locationName, dataView, dataViewInfo) {
|
||||||
|
setUniformFloat(effect, locationName, dataViewInfo, dataViewFloatArray(dataView, dataViewInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSingleFloat(effect, locationName, value) {
|
||||||
|
effect.set_uniform_float(shaderUniformLocations[locationName], 1, [value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUniformMatrix(effect, locationName, components, dataView, dataViewInfo) {
|
||||||
|
const numValues = dataViewInfo[DATA_VIEW_INFO_COUNT_INDEX];
|
||||||
|
if (numValues / components !== components) {
|
||||||
|
throw new Error('Invalid matrix size');
|
||||||
|
}
|
||||||
|
|
||||||
|
const floatArray = [].fill(0, 0, numValues);
|
||||||
|
let offset = dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX];
|
||||||
|
for (let i = 0; i < numValues; i++) {
|
||||||
|
// GLSL uses column-major order, so we need to transpose the matrix
|
||||||
|
const row = i % components;
|
||||||
|
const column = Math.floor(i / components);
|
||||||
|
|
||||||
|
floatArray[row * components + column] = dataView.getFloat32(offset, true);
|
||||||
|
offset += FLOAT_SIZE;
|
||||||
|
}
|
||||||
|
effect.set_uniform_matrix(shaderUniformLocations[locationName], true, components, floatArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
function lookAheadMS(dataView) {
|
||||||
|
const lookAheadCfg = dataViewFloatArray(dataView, LOOK_AHEAD_CFG);
|
||||||
|
const imuDateMS = dataViewBigUint(dataView, EPOCH_MS);
|
||||||
|
|
||||||
|
// how stale the imu data is
|
||||||
|
const dataAge = Date.now() - imuDateMS;
|
||||||
|
|
||||||
|
return lookAheadCfg[0] + dataAge;
|
||||||
|
}
|
||||||
|
|
||||||
|
// most uniforms don't change frequently, this function should be called periodically
|
||||||
|
function setIntermittentUniformVariables() {
|
||||||
|
const dataView = this._dataView;
|
||||||
|
|
||||||
|
if (dataView.byteLength === DATA_VIEW_LENGTH) {
|
||||||
|
const version = dataViewUint8(dataView, VERSION);
|
||||||
|
const imuDateMS = dataViewBigUint(dataView, EPOCH_MS);
|
||||||
|
const currentDateMS = Date.now();
|
||||||
|
const validKeepalive = Math.abs(toSec(currentDateMS) - toSec(imuDateMS)) < 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 = this.effect_enable && 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);
|
||||||
|
|
||||||
|
// compute these values once, they only change when the XR device changes
|
||||||
|
const displayAspectRatio = displayRes[0] / displayRes[1];
|
||||||
|
const stageAspectRatio = this.target_monitor.width / this.target_monitor.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;
|
||||||
|
|
||||||
|
// our overlay doesn't quite cover the full screen texture, which allows us to see some of the real desktop
|
||||||
|
// underneath, so we trim two pixels around the entire edge of the texture
|
||||||
|
const trimWidthPercent = 2.0 / this.target_monitor.width;
|
||||||
|
const trimHeightPercent = 2.0 / this.target_monitor.height;
|
||||||
|
|
||||||
|
// all these values are transferred directly, unmodified from the driver
|
||||||
|
transferUniformFloat(this, 'look_ahead_cfg', dataView, LOOK_AHEAD_CFG);
|
||||||
|
transferUniformFloat(this, 'lens_distance_ratio', dataView, LENS_DISTANCE_RATIO);
|
||||||
|
transferUniformBoolean(this, 'sbs_enabled', dataView, SBS_ENABLED);
|
||||||
|
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, 'trim_width_percent', trimWidthPercent);
|
||||||
|
setSingleFloat(this, 'trim_height_percent', trimHeightPercent);
|
||||||
|
setSingleFloat(this, 'half_fov_z_rads', halfFovZRads);
|
||||||
|
setSingleFloat(this, 'half_fov_y_rads', halfFovYRads);
|
||||||
|
setSingleFloat(this, 'screen_distance', screenDistance);
|
||||||
|
|
||||||
|
// TOOD - drive from settings
|
||||||
|
setSingleFloat(this, 'display_zoom', 1.0);
|
||||||
|
setSingleFloat(this, 'sbs_content', 0.0);
|
||||||
|
}
|
||||||
|
setSingleFloat(this, 'enabled', enabled ? 1.0 : 0.0);
|
||||||
|
} else if (dataView.byteLength !== 0) {
|
||||||
|
console.error(`Invalid dataView.byteLength: ${dataView.byteLength} !== ${DATA_VIEW_LENGTH}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const XREffect = GObject.registerClass({
|
||||||
|
Properties: {
|
||||||
|
'effect-enable': GObject.ParamSpec.boolean(
|
||||||
|
'effect-enable',
|
||||||
|
'Effect enable',
|
||||||
|
'Whether this effect is enabled',
|
||||||
|
GObject.ParamFlags.READWRITE,
|
||||||
|
true
|
||||||
|
),
|
||||||
|
'target-monitor': GObject.ParamSpec.jsobject(
|
||||||
|
'target-monitor',
|
||||||
|
'Target Monitor',
|
||||||
|
'Geometry of the target monitor for this effect',
|
||||||
|
GObject.ParamFlags.READWRITE
|
||||||
|
),
|
||||||
|
'target-framerate': GObject.ParamSpec.uint(
|
||||||
|
'target-framerate',
|
||||||
|
'Target Framerate',
|
||||||
|
'Target framerate for this effect',
|
||||||
|
GObject.ParamFlags.READWRITE, 60, 240, 60
|
||||||
|
),
|
||||||
|
'display-distance': GObject.ParamSpec.double(
|
||||||
|
'display-distance',
|
||||||
|
'Display Distance',
|
||||||
|
'How far away the display appears',
|
||||||
|
GObject.ParamFlags.READWRITE,
|
||||||
|
0.2,
|
||||||
|
2.5,
|
||||||
|
1.05
|
||||||
|
),
|
||||||
|
'toggle-display-distance-start': GObject.ParamSpec.double(
|
||||||
|
'toggle-display-distance-start',
|
||||||
|
'Display distance start',
|
||||||
|
'Start distance when using the "change distance" shortcut.',
|
||||||
|
GObject.ParamFlags.READWRITE,
|
||||||
|
0.2,
|
||||||
|
2.5,
|
||||||
|
1.05
|
||||||
|
),
|
||||||
|
'toggle-display-distance-end': GObject.ParamSpec.double(
|
||||||
|
'toggle-display-distance-end',
|
||||||
|
'Display distance end',
|
||||||
|
'End distance when using the "change distance" shortcut.',
|
||||||
|
GObject.ParamFlags.READWRITE,
|
||||||
|
0.2,
|
||||||
|
2.5,
|
||||||
|
1.05
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}, class XREffect extends Shell.GLSLEffect {
|
||||||
|
constructor(params = {}) {
|
||||||
|
super(params);
|
||||||
|
|
||||||
|
this._frametime = Math.floor(1000 / this.target_framerate);
|
||||||
|
|
||||||
|
this._is_display_distance_at_end = 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);
|
||||||
|
|
||||||
|
const toggle_display_distance_target = this._is_display_distance_at_end ?
|
||||||
|
this.toggle_display_distance_start : this.toggle_display_distance_end;
|
||||||
|
this._distance_ease_timeline.connect('new-frame', () => {
|
||||||
|
this.display_distance = this._distance_ease_start +
|
||||||
|
this._distance_ease_timeline.get_progress() *
|
||||||
|
(toggle_display_distance_target - this._distance_ease_start);
|
||||||
|
});
|
||||||
|
this._is_display_distance_at_end = !this._is_display_distance_at_end;
|
||||||
|
|
||||||
|
this._distance_ease_timeline.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
vfunc_build_pipeline() {
|
||||||
|
const code = getShaderSource(`${Globals.extension_dir}/IMUAdjust.frag`);
|
||||||
|
const main = 'PS_IMU_Transform(vec4(0, 0, 0, 0), cogl_tex_coord_in[0].xy, cogl_color_out);';
|
||||||
|
this.add_glsl_snippet(Shell.SnippetHook.FRAGMENT, code, main, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
vfunc_paint_target(node, paintContext) {
|
||||||
|
var now = Date.now();
|
||||||
|
var lastPaint = this._last_paint || 0;
|
||||||
|
var frametime = this._frametime;
|
||||||
|
const data = Globals.ipc_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, [0]);
|
||||||
|
for (let key in shaderUniformLocations) {
|
||||||
|
shaderUniformLocations[key] = this.get_uniform_location(key);
|
||||||
|
}
|
||||||
|
this.setIntermittentUniformVariables = setIntermittentUniformVariables.bind(this);
|
||||||
|
this.setIntermittentUniformVariables();
|
||||||
|
|
||||||
|
this._redraw_timeout_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this._frametime, () => {
|
||||||
|
if ((now - lastPaint) > frametime) global.stage.queue_redraw();
|
||||||
|
return GLib.SOURCE_CONTINUE;
|
||||||
|
});
|
||||||
|
|
||||||
|
this._uniforms_timeout_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => {
|
||||||
|
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) {
|
||||||
|
console.error(`Invalid dataView.byteLength: ${this._dataView.byteLength} !== ${DATA_VIEW_LENGTH}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// improves sampling quality for smooth text and edges
|
||||||
|
this.get_pipeline().set_layer_filters (
|
||||||
|
0,
|
||||||
|
Cogl.PipelineFilter.LINEAR_MIPMAP_LINEAR,
|
||||||
|
Cogl.PipelineFilter.LINEAR
|
||||||
|
);
|
||||||
|
|
||||||
|
super.vfunc_paint_target(node, paintContext);
|
||||||
|
} else {
|
||||||
|
super.vfunc_paint_target(node, paintContext);
|
||||||
|
}
|
||||||
|
this._last_paint = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
vfunc_dispose() {
|
||||||
|
if (this._redraw_timeout_id) GLib.source_remove(this._redraw_timeout_id);
|
||||||
|
if (this._uniforms_timeout_id) GLib.source_remove(this._uniforms_timeout_id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 08c6b2a91c9ed5eba6fed66406f90980918406b4
|
Subproject commit 0869b8686aa204b581c212ee20ad3d63dce0e73a
|
||||||
|
|
@ -0,0 +1,675 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# breezydesktop
|
||||||
|
|
||||||
|
A description of this project.
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# exit when any command fails
|
||||||
|
set -e
|
||||||
|
|
||||||
|
check_command() {
|
||||||
|
if ! command -v "$1" &>/dev/null; then
|
||||||
|
echo "Please install \"$1\" and make sure it's available in your \$PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_command "flatpak"
|
||||||
|
check_command "flatpak-builder"
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/246128
|
||||||
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||||
|
|
||||||
|
TMP_DIR=$(mktemp -d -t breezy-ui-flatpak-XXXXXXXXXX)
|
||||||
|
OUT_DIR=$SCRIPT_DIR/../out
|
||||||
|
rm -rf $OUT_DIR
|
||||||
|
mkdir -p $OUT_DIR
|
||||||
|
|
||||||
|
flatpak-builder --force-clean $TMP_DIR/build $SCRIPT_DIR/../com.xronlinux.BreezyDesktop.json
|
||||||
|
flatpak build-export $TMP_DIR/export $TMP_DIR/build
|
||||||
|
flatpak build-bundle $TMP_DIR/export $OUT_DIR/com.xronlinux.BreezyDesktop.flatpak com.xronlinux.BreezyDesktop --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
diff --git a/engine/dconf-engine-source-user.c b/engine/dconf-engine-source-user.c
|
||||||
|
index 1657875..e4f8786 100644
|
||||||
|
--- a/engine/dconf-engine-source-user.c
|
||||||
|
+++ b/engine/dconf-engine-source-user.c
|
||||||
|
@@ -39,11 +39,17 @@ dconf_engine_source_user_open_gvdb (const gchar *name)
|
||||||
|
{
|
||||||
|
GvdbTable *table;
|
||||||
|
gchar *filename;
|
||||||
|
+ const gchar *override;
|
||||||
|
+
|
||||||
|
+ override = g_getenv ("DCONF_USER_CONFIG_DIR");
|
||||||
|
+ if (override == NULL)
|
||||||
|
+ filename = g_build_filename (g_get_user_config_dir (), "dconf", name, NULL);
|
||||||
|
+ else
|
||||||
|
+ filename = g_build_filename (g_get_home_dir (), override, name, NULL);
|
||||||
|
|
||||||
|
/* This can fail in the normal case of the user not having any
|
||||||
|
* settings. That's OK and it shouldn't be considered as an error.
|
||||||
|
*/
|
||||||
|
- filename = g_build_filename (g_get_user_config_dir (), "dconf", name, NULL);
|
||||||
|
table = gvdb_table_new (filename, FALSE, NULL);
|
||||||
|
g_free (filename);
|
||||||
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# stolen from dconf-editor:
|
||||||
|
# https://gitlab.gnome.org/GNOME/dconf-editor/-/blob/master/build-aux/start-dconf-editor.sh
|
||||||
|
|
||||||
|
IFS=: read -ra host_data_dirs < <(flatpak-spawn --host sh -c 'echo "$XDG_DATA_DIRS"')
|
||||||
|
|
||||||
|
# To avoid potentially muddying up $XDG_DATA_DIRS too much, we link the schema paths
|
||||||
|
# into a temporary directory.
|
||||||
|
bridge_dir=$XDG_RUNTIME_DIR/dconf-bridge
|
||||||
|
mkdir -p "$bridge_dir"
|
||||||
|
|
||||||
|
HOST_XDG_DATA_DIRS=""
|
||||||
|
|
||||||
|
for dir in "${host_data_dirs[@]}"; do
|
||||||
|
if [[ "$dir" == /usr/* ]]; then
|
||||||
|
dir=/run/host/"$dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
schemas="$dir/glib-2.0/schemas"
|
||||||
|
if [[ -d "$schemas" ]]; then
|
||||||
|
bridged=$(mktemp -d XXXXXXXXXX -p "$bridge_dir")
|
||||||
|
mkdir -p "$bridged"/glib-2.0
|
||||||
|
ln -s "$schemas" "$bridged"/glib-2.0
|
||||||
|
HOST_XDG_DATA_DIRS="${HOST_XDG_DATA_DIRS}:${bridged}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# We MUST prepend the host's data dirs BEFORE the Flatpak environment's own dirs,
|
||||||
|
# otherwise data (such as default values) load in the wrong order and would then
|
||||||
|
# incorrectly prefer the Flatpak's internal defaults instead of the host's defaults!
|
||||||
|
if [[ ! -z "${HOST_XDG_DATA_DIRS}" ]]; then
|
||||||
|
XDG_DATA_DIRS="${HOST_XDG_DATA_DIRS:1}:${XDG_DATA_DIRS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export XDG_DATA_DIRS
|
||||||
|
exec breezydesktop "$@"
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
{
|
||||||
|
"id" : "com.xronlinux.BreezyDesktop",
|
||||||
|
"runtime" : "org.gnome.Platform",
|
||||||
|
"runtime-version" : "46",
|
||||||
|
"sdk" : "org.gnome.Sdk",
|
||||||
|
"command" : "breezydesktop",
|
||||||
|
"finish-args" : [
|
||||||
|
"--share=network",
|
||||||
|
"--share=ipc",
|
||||||
|
"--socket=fallback-x11",
|
||||||
|
"--device=dri",
|
||||||
|
"--socket=wayland",
|
||||||
|
"--device=shm",
|
||||||
|
"--talk-name=ca.desrt.dconf",
|
||||||
|
"--filesystem=xdg-run/dconf",
|
||||||
|
"--filesystem=host:ro",
|
||||||
|
"--env=DCONF_USER_CONFIG_DIR=.config/dconf",
|
||||||
|
"--env=GIO_EXTRA_MODULES=/app/lib/gio/modules/",
|
||||||
|
"--talk-name=org.freedesktop.Flatpak"
|
||||||
|
],
|
||||||
|
"cleanup" : [
|
||||||
|
"/include",
|
||||||
|
"/lib/pkgconfig",
|
||||||
|
"/man",
|
||||||
|
"/share/doc",
|
||||||
|
"/share/gtk-doc",
|
||||||
|
"/share/man",
|
||||||
|
"/share/pkgconfig",
|
||||||
|
"*.la",
|
||||||
|
"*.a"
|
||||||
|
],
|
||||||
|
"modules" : [
|
||||||
|
{
|
||||||
|
"name": "dconf",
|
||||||
|
"buildsystem": "meson",
|
||||||
|
"config-opts": [
|
||||||
|
"-Dbash_completion=false",
|
||||||
|
"-Dman=false",
|
||||||
|
"-Dsystemduserunitdir=' '"
|
||||||
|
],
|
||||||
|
"cleanup": [
|
||||||
|
"/include",
|
||||||
|
"/lib/pkgconfig",
|
||||||
|
"/libexec",
|
||||||
|
"/share/dbus-1"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "archive",
|
||||||
|
"url": "https://download.gnome.org/sources/dconf/0.40/dconf-0.40.0.tar.xz",
|
||||||
|
"sha256": "cf7f22a4c9200421d8d3325c5c1b8b93a36843650c9f95d6451e20f0bcb24533"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patch",
|
||||||
|
"path": "build-aux/dconf-override.patch"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "scripts",
|
||||||
|
"buildsystem": "simple",
|
||||||
|
"build-commands": [
|
||||||
|
"install -Dm 755 start-breezy-desktop.sh /app/bin/start-breezy-desktop"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "file",
|
||||||
|
"path": "build-aux/start-breezy-desktop.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"name" : "breezydesktop",
|
||||||
|
"builddir" : true,
|
||||||
|
"buildsystem" : "meson",
|
||||||
|
"sources" : [
|
||||||
|
{
|
||||||
|
"type" : "dir",
|
||||||
|
"path" : "."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=Breezy Desktop
|
||||||
|
Exec=start-breezy-desktop
|
||||||
|
Icon=com.xronlinux.BreezyDesktop
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
Categories=GTK;
|
||||||
|
StartupNotify=true
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<schemalist gettext-domain="breezydesktop">
|
||||||
|
<schema id="com.xronlinux.BreezyDesktop" path="/com/xronlinux/BreezyDesktop/">
|
||||||
|
<key name="effect-enable" type="b">
|
||||||
|
<default>
|
||||||
|
true
|
||||||
|
</default>
|
||||||
|
<summary>Enable XR effect</summary>
|
||||||
|
<description>
|
||||||
|
Enable XR effect
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="recenter-display-shortcut" type="as">
|
||||||
|
<default>
|
||||||
|
<![CDATA[['<Control><Super>space']]]>
|
||||||
|
</default>
|
||||||
|
<summary>Re-center display</summary>
|
||||||
|
<description>
|
||||||
|
Shortcut to re-center the virtual display.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="toggle-display-distance-shortcut" type="as">
|
||||||
|
<default>
|
||||||
|
<![CDATA[['<Control><Super>Return']]]>
|
||||||
|
</default>
|
||||||
|
<summary>Trigger change to display distance</summary>
|
||||||
|
<description>
|
||||||
|
Shortcut to change the display distance.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="toggle-follow-shortcut" type="as">
|
||||||
|
<default>
|
||||||
|
<![CDATA[['<Control><Super>0']]]>
|
||||||
|
</default>
|
||||||
|
<summary>Toggle follow mode</summary>
|
||||||
|
<description>
|
||||||
|
Shortcut to toggle follow mode.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="display-distance" type="d">
|
||||||
|
<default>
|
||||||
|
1.05
|
||||||
|
</default>
|
||||||
|
<summary>Display distance</summary>
|
||||||
|
<description>
|
||||||
|
How far away the display appears. Farther will look smaller, closer will look larger.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="toggle-display-distance-start" type="d">
|
||||||
|
<default>
|
||||||
|
0.85
|
||||||
|
</default>
|
||||||
|
<summary>Display distance start</summary>
|
||||||
|
<description>
|
||||||
|
Start distance when using the "change distance" shortcut.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="toggle-display-distance-end" type="d">
|
||||||
|
<default>
|
||||||
|
1.05
|
||||||
|
</default>
|
||||||
|
<summary>Display distance end</summary>
|
||||||
|
<description>
|
||||||
|
End distance when using the "toggle display distance" shortcut.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="developer-mode" type="b">
|
||||||
|
<default>
|
||||||
|
false
|
||||||
|
</default>
|
||||||
|
<summary>Developer mode</summary>
|
||||||
|
<description>
|
||||||
|
Enable developer mode
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
</schemalist>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<component type="desktop">
|
||||||
|
<id>com.xronlinux.BreezyDesktop.desktop</id>
|
||||||
|
<metadata_license>CC0-1.0</metadata_license>
|
||||||
|
<project_license>GPL-3.0-or-later</project_license>
|
||||||
|
<description>
|
||||||
|
<p>No description</p>
|
||||||
|
</description>
|
||||||
|
</component>
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="33.750061mm"
|
||||||
|
height="33.750061mm"
|
||||||
|
viewBox="0 0 33.750061 33.750061"
|
||||||
|
version="1.1"
|
||||||
|
id="svg974">
|
||||||
|
<defs
|
||||||
|
id="defs968">
|
||||||
|
<clipPath
|
||||||
|
clipPathUnits="userSpaceOnUse"
|
||||||
|
id="clipPath18689">
|
||||||
|
<rect
|
||||||
|
clip-path="none"
|
||||||
|
transform="rotate(45)"
|
||||||
|
ry="32.000008"
|
||||||
|
rx="32.000008"
|
||||||
|
y="123.9986"
|
||||||
|
x="486.03726"
|
||||||
|
height="362.94299"
|
||||||
|
width="362.94299"
|
||||||
|
id="rect18691"
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#4a86cf;fill-opacity:1;stroke:none;stroke-width:26.0669;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
||||||
|
</clipPath>
|
||||||
|
<clipPath
|
||||||
|
clipPathUnits="userSpaceOnUse"
|
||||||
|
id="clipPath18689-3">
|
||||||
|
<rect
|
||||||
|
clip-path="none"
|
||||||
|
transform="rotate(45)"
|
||||||
|
ry="32.000008"
|
||||||
|
rx="32.000008"
|
||||||
|
y="123.9986"
|
||||||
|
x="486.03726"
|
||||||
|
height="362.94299"
|
||||||
|
width="362.94299"
|
||||||
|
id="rect18691-6"
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#4a86cf;fill-opacity:1;stroke:none;stroke-width:26.0669;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
<metadata
|
||||||
|
id="metadata971">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-61.819823,-103.94395)">
|
||||||
|
<g
|
||||||
|
transform="matrix(0.26367235,0,0,0.26367235,61.819823,-529.39703)"
|
||||||
|
style="display:inline;stroke-width:0.25;enable-background:new"
|
||||||
|
id="g1836">
|
||||||
|
<title
|
||||||
|
id="title1838">application-x-executable</title>
|
||||||
|
<g
|
||||||
|
transform="matrix(0.25,0,0,0.25,0,2295)"
|
||||||
|
id="g18818"
|
||||||
|
style="stroke-width:0.25">
|
||||||
|
<g
|
||||||
|
style="stroke-width:0.269963"
|
||||||
|
transform="matrix(0.92605186,0,0,0.92605186,18.930729,50.876335)"
|
||||||
|
id="g18590">
|
||||||
|
<g
|
||||||
|
style="stroke-width:0.269963"
|
||||||
|
id="g18681"
|
||||||
|
clip-path="url(#clipPath18689-3)">
|
||||||
|
<rect
|
||||||
|
style="opacity:1;vector-effect:none;fill:#3584e4;fill-opacity:1;stroke:none;stroke-width:8.22095;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
||||||
|
id="rect18571"
|
||||||
|
width="424"
|
||||||
|
height="424"
|
||||||
|
x="458.33722"
|
||||||
|
y="90.641701"
|
||||||
|
rx="10.092117"
|
||||||
|
ry="10.092117"
|
||||||
|
transform="matrix(0.60528171,0.60528171,-0.60528171,0.60528171,33.440632,99.073632)"
|
||||||
|
clip-path="none" />
|
||||||
|
<circle
|
||||||
|
style="opacity:1;vector-effect:none;fill:#f66151;fill-opacity:1;stroke:none;stroke-width:7.03712;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
||||||
|
id="path18706"
|
||||||
|
cx="0"
|
||||||
|
cy="0"
|
||||||
|
r="0"
|
||||||
|
transform="translate(0,-212)" />
|
||||||
|
<circle
|
||||||
|
style="opacity:1;vector-effect:none;fill:#f66151;fill-opacity:1;stroke:none;stroke-width:7.03712;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
||||||
|
id="path18708"
|
||||||
|
cx="0"
|
||||||
|
cy="0"
|
||||||
|
r="0"
|
||||||
|
transform="translate(0,-212)" />
|
||||||
|
<path
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#98c1f1;fill-opacity:1;stroke:none;stroke-width:7.03712;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new"
|
||||||
|
d="m 408.91993,561.9183 -9.8861,29.82892 a 172.97099,172.97099 0 0 0 -1.42693,-0.0713 172.97099,172.97099 0 0 0 -23.92891,1.85189 l -13.80082,-28.50125 a 203.29325,203.29325 0 0 0 -29.40085,7.97217 l 2.28619,31.40474 a 172.97099,172.97099 0 0 0 -22.73152,11.31923 l -23.71796,-21.103 a 203.29325,203.29325 0 0 0 -24.05918,18.6741 l 14.09863,28.07319 a 172.97099,172.97099 0 0 0 -16.63608,19.21074 l -30.05845,-10.44758 a 203.29325,203.29325 0 0 0 -15.01683,26.48807 l 23.73035,20.50738 a 172.97099,172.97099 0 0 0 -7.98456,24.14293 l -31.73044,1.84879 a 203.29325,203.29325 0 0 0 -3.77825,30.21664 l 29.82892,9.8861 a 172.97099,172.97099 0 0 0 -0.0713,1.42693 172.97099,172.97099 0 0 0 1.85188,23.92889 l -28.50125,13.80084 a 203.29325,203.29325 0 0 0 7.97215,29.40084 l 31.40475,-2.28619 a 172.97099,172.97099 0 0 0 11.31922,22.73152 l -21.10296,23.71797 a 203.29325,203.29325 0 0 0 18.67409,24.05918 l 28.07319,-14.09863 a 172.97099,172.97099 0 0 0 19.21074,16.63606 l -10.44758,30.05847 a 203.29325,203.29325 0 0 0 26.48806,15.01683 l 20.50739,-23.73036 a 172.97099,172.97099 0 0 0 24.14293,7.98457 l 1.8488,31.73043 a 203.29325,203.29325 0 0 0 30.21666,3.77826 l 9.8861,-29.82892 a 172.97099,172.97099 0 0 0 1.42693,0.0713 172.97099,172.97099 0 0 0 23.9289,-1.85188 l 13.80084,28.50125 a 203.29325,203.29325 0 0 0 29.40084,-7.97217 l -2.2862,-31.40474 a 172.97099,172.97099 0 0 0 22.73153,-11.31922 l 23.71796,21.10297 A 203.29325,203.29325 0 0 0 532.96,916.00016 l -14.09864,-28.07319 a 172.97099,172.97099 0 0 0 16.63607,-19.21073 l 30.05846,10.44757 a 203.29325,203.29325 0 0 0 15.01683,-26.48807 l -23.73036,-20.50738 a 172.97099,172.97099 0 0 0 7.98457,-24.14293 l 31.73044,-1.84879 a 203.29325,203.29325 0 0 0 3.77825,-30.21667 l -29.82892,-9.8861 a 172.97099,172.97099 0 0 0 0.0713,-1.42692 172.97099,172.97099 0 0 0 -1.85189,-23.9289 l 28.50124,-13.80084 a 203.29325,203.29325 0 0 0 -7.97215,-29.40084 l -31.40474,2.2862 a 172.97099,172.97099 0 0 0 -11.31923,-22.73153 l 21.10297,-23.71797 a 203.29325,203.29325 0 0 0 -18.67409,-24.05918 l -28.07319,14.09863 a 172.97099,172.97099 0 0 0 -19.21074,-16.63606 l 10.44757,-30.05847 A 203.29325,203.29325 0 0 0 485.6357,581.68117 l -20.50738,23.73035 a 172.97099,172.97099 0 0 0 -24.14293,-7.98455 l -1.84879,-31.73044 a 203.29325,203.29325 0 0 0 -30.21667,-3.77826 z M 397.6069,637.72208 A 126.92605,126.92605 0 0 1 524.5318,764.64699 126.92605,126.92605 0 0 1 397.6069,891.57189 126.92605,126.92605 0 0 1 270.682,764.64699 126.92605,126.92605 0 0 1 397.6069,637.72208 Z"
|
||||||
|
id="path18717-4" />
|
||||||
|
<path
|
||||||
|
id="path18758"
|
||||||
|
d="m 51.748325,401.28402 -9.8861,29.82892 c -0.475543,-0.0257 -0.951191,-0.0495 -1.42693,-0.0713 -8.00956,0.0625 -16.005106,0.6813 -23.92891,1.85189 L 2.7055639,404.39228 c -9.9858697,1.91835 -19.8137359,4.58322 -29.4008489,7.97217 l 2.28619,31.40474 c -7.844275,3.21103 -15.441918,6.9943 -22.73152,11.31923 l -23.71796,-21.103 c -8.475372,5.61437 -16.517661,11.85658 -24.05918,18.6741 l 14.09863,28.07319 c -6.008901,5.98701 -11.569263,12.40791 -16.636077,19.21074 l -30.058438,-10.44758 c -5.66072,8.44155 -10.68041,17.29574 -15.01683,26.48807 l 23.73035,20.50738 c -3.25027,7.84084 -5.919,15.91028 -7.98456,24.14293 l -31.73044,1.84879 c -2.01308,9.96359 -3.27604,20.06413 -3.77825,30.21664 l 29.82892,9.8861 c -0.0257,0.47554 -0.0495,0.95119 -0.0713,1.42693 0.0625,8.00955 0.68129,16.00509 1.85188,23.92889 l -28.50125,13.80084 c 1.91835,9.98587 4.58321,19.81373 7.97215,29.40084 l 31.40475,-2.28619 c 3.21102,7.84427 6.99429,15.44192 11.31922,22.73152 l -21.10296,23.71797 c 5.61437,8.47537 11.85658,16.51766 18.67409,24.05918 l 28.073175,-14.09863 c 5.987006,6.00889 12.407911,11.56925 19.21074,16.63606 l -10.44758,30.05847 c 8.441549,5.66072 17.295731,10.68041 26.48806,15.01683 l 20.50739,-23.73036 c 7.840839,3.25027 15.910282,5.91901 24.142929,7.98457 l 1.8488,31.73043 c 9.9635962,2.01309 20.064147,3.27605 30.216661,3.77826 l 9.8861,-29.82892 c 0.475543,0.0257 0.951191,0.0495 1.42693,0.0713 8.009557,-0.0625 16.005099,-0.68129 23.9289,-1.85188 l 13.80084,28.50125 c 9.985867,-1.91835 19.813731,-4.58322 29.400855,-7.97217 l -2.2862,-31.40474 c 7.84428,-3.21102 15.44192,-6.99429 22.73153,-11.31922 l 23.71796,21.10297 c 8.47538,-5.61437 16.51767,-11.85658 24.05919,-18.6741 l -14.09864,-28.07319 c 6.0089,-5.987 11.56926,-12.4079 16.63607,-19.21073 l 30.05846,10.44757 c 5.66072,-8.44155 10.68041,-17.29574 15.01683,-26.48807 l -23.73036,-20.50738 c 3.25027,-7.84084 5.91901,-15.91028 7.98457,-24.14293 l 31.73044,-1.84879 c 2.01308,-9.9636 3.27604,-20.06415 3.77825,-30.21667 l -29.82892,-9.8861 c 0.0257,-0.47554 0.0495,-0.95118 0.0713,-1.42692 -0.0625,-8.00956 -0.6813,-16.0051 -1.85189,-23.9289 l 28.50124,-13.80084 c -1.91835,-9.98587 -4.58321,-19.81373 -7.97215,-29.40084 l -31.40474,2.2862 c -3.21103,-7.84428 -6.9943,-15.44192 -11.31923,-22.73153 l 21.10297,-23.71797 c -5.61437,-8.47537 -11.85658,-16.51766 -18.67409,-24.05918 l -28.07319,14.09863 c -5.98701,-6.00889 -12.40791,-11.56925 -19.21074,-16.63606 l 10.44757,-30.05847 c -8.44155,-5.66072 -17.29572,-10.6804 -26.48805,-15.01682 l -20.50738,23.73035 c -7.84085,-3.25027 -15.910298,-5.91899 -24.142945,-7.98455 l -1.84879,-31.73044 c -9.9636,-2.01309 -20.064152,-3.27605 -30.21667,-3.77826 z"
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#1a5fb4;fill-opacity:1;stroke:none;stroke-width:7.03712;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
style="display:inline;opacity:0.534;vector-effect:none;fill:#1a5fb4;fill-opacity:1;stroke:none;stroke-width:1.62918;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new"
|
||||||
|
clip-path="none"
|
||||||
|
d="m 8.4765625,2676 c -1.1711695,2.8866 -0.5827763,6.3078 1.7656255,8.6562 l 48.101562,48.1016 c 3.133898,3.1339 8.178602,3.1339 11.3125,0 l 48.10156,-48.1016 c 2.3484,-2.3484 2.9368,-5.7696 1.76563,-8.6562 -0.39174,0.9655 -0.98013,1.8708 -1.76563,2.6562 l -48.10156,48.1016 c -3.133898,3.1339 -8.178602,3.1339 -11.3125,0 L 10.242188,2678.6562 C 9.4566904,2677.8708 8.8682972,2676.9655 8.4765625,2676 Z"
|
||||||
|
transform="matrix(4,0,0,4,0,-10028)"
|
||||||
|
id="rect18571-6" />
|
||||||
|
</g>
|
||||||
|
<rect
|
||||||
|
y="2402"
|
||||||
|
x="-1.5000001e-06"
|
||||||
|
height="128"
|
||||||
|
width="128"
|
||||||
|
id="rect9125-7-2"
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:none;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 12 KiB |
|
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g color="#000" fill="#2e3436"><path d="M7.188 2.281c-.094.056-.192.125-.29.19L5.566 3.803a1.684 1.684 0 11-2.17 2.17L2.332 7.037c.506-.069 1.017-.136 1.2.026.242.214.139 1.031.155 1.656.213.088.427.171.657.219.04.008.085-.007.125 0 .337-.525.683-1.288 1-1.344.322-.057.905.562 1.406.937a3.67 3.67 0 00.656-.468c-.195-.595-.594-1.369-.437-1.657.158-.29 1.019-.37 1.625-.531.028-.183.062-.371.062-.562 0-.075-.027-.146-.031-.22-.587-.217-1.435-.385-1.562-.687-.128-.302.34-1.021.593-1.593a3.722 3.722 0 00-.593-.532zm3.875 3.25c-.165.475-.305 1.086-.47 1.563-.43.047-.84.14-1.218.312-.38-.322-.787-.773-1.156-1.093a5.562 5.562 0 00-.688.468c.177.46.453 1.001.625 1.469-.298.309-.531.67-.719 1.063-.494 0-1.102-.084-1.593-.094a5.68 5.68 0 00-.219.812c.435.24 1.006.468 1.438.72-.006.093-.032.185-.032.28 0 .333.049.66.125.97-.382.304-.898.63-1.28.937.015.044.04.083.058.127l.613.613c.417-.1.868-.223 1.266-.303.248.343.532.626.875.875-.027.135-.068.283-.104.428.174-.063.34-.155.482-.297l1.432-1.432a1.994 1.994 0 01.533-3.918c.919 0 1.684.623 1.918 1.467l1.338-1.338c.06-.06.11-.124.156-.191-.035-.062-.06-.13-.1-.188.096-.152.205-.31.315-.47.017-.348-.1-.7-.37-.971l-.177-.176c-.28.192-.561.387-.83.555-.345-.233-.746-.383-1.156-.5-.077-.507-.107-1.132-.187-1.625a5.44 5.44 0 00-.875-.063zm-9.247.608c-.087.068-.173.138-.254.205l.014.035z" style="marker:none" overflow="visible"/><path d="M8.707.293a1 1 0 00-1.415 0l-6.999 7a1 1 0 000 1.413l7 7.001a1 1 0 001.415 0l7-7a1 1 0 000-1.413zm-.708 2.121l5.587 5.587L8 13.586 2.414 7.999z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal;marker:none" font-weight="400" font-family="sans-serif" overflow="visible"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 2.0 KiB |
|
|
@ -0,0 +1,13 @@
|
||||||
|
application_id = 'com.xronlinux.BreezyDesktop'
|
||||||
|
|
||||||
|
scalable_dir = 'hicolor' / 'scalable' / 'apps'
|
||||||
|
install_data(
|
||||||
|
scalable_dir / ('@0@.svg').format(application_id),
|
||||||
|
install_dir: get_option('datadir') / 'icons' / scalable_dir
|
||||||
|
)
|
||||||
|
|
||||||
|
symbolic_dir = 'hicolor' / 'symbolic' / 'apps'
|
||||||
|
install_data(
|
||||||
|
symbolic_dir / ('@0@-symbolic.svg').format(application_id),
|
||||||
|
install_dir: get_option('datadir') / 'icons' / symbolic_dir
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
desktop_file = i18n.merge_file(
|
||||||
|
input: 'com.xronlinux.BreezyDesktop.desktop.in',
|
||||||
|
output: 'com.xronlinux.BreezyDesktop.desktop',
|
||||||
|
type: 'desktop',
|
||||||
|
po_dir: '../po',
|
||||||
|
install: true,
|
||||||
|
install_dir: get_option('datadir') / 'applications'
|
||||||
|
)
|
||||||
|
|
||||||
|
desktop_utils = find_program('desktop-file-validate', required: false)
|
||||||
|
if desktop_utils.found()
|
||||||
|
test('Validate desktop file', desktop_utils, args: [desktop_file])
|
||||||
|
endif
|
||||||
|
|
||||||
|
appstream_file = i18n.merge_file(
|
||||||
|
input: 'com.xronlinux.BreezyDesktop.metainfo.xml.in',
|
||||||
|
output: 'com.xronlinux.BreezyDesktop.metainfo.xml',
|
||||||
|
po_dir: '../po',
|
||||||
|
install: true,
|
||||||
|
install_dir: get_option('datadir') / 'metainfo'
|
||||||
|
)
|
||||||
|
|
||||||
|
appstreamcli = find_program('appstreamcli', required: false, disabler: true)
|
||||||
|
test('Validate appstream file', appstreamcli,
|
||||||
|
args: ['validate', '--no-net', '--explain', appstream_file])
|
||||||
|
|
||||||
|
install_data('com.xronlinux.BreezyDesktop.gschema.xml',
|
||||||
|
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas'
|
||||||
|
)
|
||||||
|
|
||||||
|
compile_schemas = find_program('glib-compile-schemas', required: false, disabler: true)
|
||||||
|
test('Validate schema file',
|
||||||
|
compile_schemas,
|
||||||
|
args: ['--strict', '--dry-run', meson.current_source_dir()])
|
||||||
|
|
||||||
|
subdir('icons')
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
project('breezydesktop',
|
||||||
|
version: '0.1.0',
|
||||||
|
meson_version: '>= 0.62.0',
|
||||||
|
default_options: [ 'warning_level=2', 'werror=false', ],
|
||||||
|
)
|
||||||
|
|
||||||
|
i18n = import('i18n')
|
||||||
|
gnome = import('gnome')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
subdir('data')
|
||||||
|
subdir('src')
|
||||||
|
subdir('po')
|
||||||
|
|
||||||
|
gnome.post_install(
|
||||||
|
glib_compile_schemas: true,
|
||||||
|
gtk_update_icon_cache: true,
|
||||||
|
update_desktop_database: true,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
data/com.xronlinux.BreezyDesktop.desktop.in
|
||||||
|
data/com.xronlinux.BreezyDesktop.metainfo.xml.in
|
||||||
|
data/com.xronlinux.BreezyDesktop.gschema.xml
|
||||||
|
src/main.py
|
||||||
|
src/window.py
|
||||||
|
src/window.ui
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
i18n.gettext('breezydesktop', preset: 'glib')
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gresources>
|
||||||
|
<gresource prefix="/com/xronlinux/BreezyDesktop">
|
||||||
|
<file preprocess="xml-stripblanks">gtk/connected-device.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">gtk/no-device.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">gtk/shortcut-dialog.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">gtk/window.ui</file>
|
||||||
|
</gresource>
|
||||||
|
</gresources>
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
#!@PYTHON@
|
||||||
|
|
||||||
|
# breezydesktop.in
|
||||||
|
#
|
||||||
|
# Copyright 2024 Unknown
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import signal
|
||||||
|
import locale
|
||||||
|
import gettext
|
||||||
|
|
||||||
|
VERSION = '@VERSION@'
|
||||||
|
pkgdatadir = '@pkgdatadir@'
|
||||||
|
localedir = '@localedir@'
|
||||||
|
|
||||||
|
sys.path.insert(1, pkgdatadir)
|
||||||
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
locale.bindtextdomain('breezydesktop', localedir)
|
||||||
|
locale.textdomain('breezydesktop')
|
||||||
|
gettext.install('breezydesktop', localedir)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import gi
|
||||||
|
|
||||||
|
from gi.repository import Gio
|
||||||
|
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'breezydesktop.gresource'))
|
||||||
|
resource._register()
|
||||||
|
|
||||||
|
from breezydesktop import main
|
||||||
|
sys.exit(main.main(VERSION))
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
from gi.repository import Gio, Gtk, GObject
|
||||||
|
from .settingsmanager import SettingsManager
|
||||||
|
from .shortcutdialog import bind_shortcut_settings
|
||||||
|
from .statemanager import StateManager
|
||||||
|
from .xrdriveripc import XRDriverIPC
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path='/com/xronlinux/BreezyDesktop/gtk/connected-device.ui')
|
||||||
|
class ConnectedDevice(Gtk.Box):
|
||||||
|
__gtype_name__ = "ConnectedDevice"
|
||||||
|
|
||||||
|
effect_enable_switch = Gtk.Template.Child()
|
||||||
|
display_distance_scale = Gtk.Template.Child()
|
||||||
|
follow_mode_switch = Gtk.Template.Child()
|
||||||
|
device_label = Gtk.Template.Child()
|
||||||
|
set_toggle_display_distance_start_button = Gtk.Template.Child()
|
||||||
|
set_toggle_display_distance_end_button = Gtk.Template.Child()
|
||||||
|
reassign_recenter_display_shortcut_button = Gtk.Template.Child()
|
||||||
|
recenter_display_shortcut_label = Gtk.Template.Child()
|
||||||
|
reassign_toggle_display_distance_shortcut_button = Gtk.Template.Child()
|
||||||
|
toggle_display_distance_shortcut_label = Gtk.Template.Child()
|
||||||
|
reassign_toggle_follow_shortcut_button = Gtk.Template.Child()
|
||||||
|
toggle_follow_shortcut_label = Gtk.Template.Child()
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(Gtk.Box, self).__init__()
|
||||||
|
self.init_template()
|
||||||
|
self.settings = SettingsManager.get_instance().settings
|
||||||
|
self.ipc = XRDriverIPC.get_instance()
|
||||||
|
|
||||||
|
self.settings.bind('display-distance', self.display_distance_scale, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
self.settings.bind('effect-enable', self.effect_enable_switch, 'active', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
|
||||||
|
bind_shortcut_settings(self.get_parent(), [
|
||||||
|
[self.reassign_recenter_display_shortcut_button, self.recenter_display_shortcut_label],
|
||||||
|
[self.reassign_toggle_display_distance_shortcut_button, self.toggle_display_distance_shortcut_label],
|
||||||
|
[self.reassign_toggle_follow_shortcut_button, self.toggle_follow_shortcut_label]
|
||||||
|
])
|
||||||
|
|
||||||
|
self.bind_set_distance_toggle([
|
||||||
|
self.set_toggle_display_distance_start_button,
|
||||||
|
self.set_toggle_display_distance_end_button
|
||||||
|
])
|
||||||
|
|
||||||
|
self.state_manager = StateManager.get_instance()
|
||||||
|
self.state_manager.bind_property('follow-mode', self.follow_mode_switch, 'active', GObject.BindingFlags.DEFAULT)
|
||||||
|
|
||||||
|
self.follow_mode_switch.set_active(self.state_manager.follow_mode)
|
||||||
|
self.follow_mode_switch.connect('notify::active', self._request_follow_mode)
|
||||||
|
|
||||||
|
def _request_follow_mode(self, switch, param):
|
||||||
|
if (self.state_manager.follow_mode == switch.get_active()):
|
||||||
|
return
|
||||||
|
|
||||||
|
self.ipc.write_control_flags({
|
||||||
|
'enable_breezy_desktop_smooth_follow': switch.get_active()
|
||||||
|
})
|
||||||
|
|
||||||
|
def set_device_name(self, name):
|
||||||
|
self.device_label.set_markup(f"<b>{name}</b>")
|
||||||
|
|
||||||
|
def bind_set_distance_toggle(self, widgets):
|
||||||
|
for widget in widgets:
|
||||||
|
widget.connect('clicked', lambda *args, widget=widget: on_set_display_distance_toggle(widget))
|
||||||
|
reload_display_distance_toggle_button(widget)
|
||||||
|
|
||||||
|
def reload_display_distance_toggle_button(widget):
|
||||||
|
distance = SettingsManager.get_instance().settings.get_double(widget.get_name())
|
||||||
|
if distance: widget.set_label(str(distance))
|
||||||
|
|
||||||
|
def on_set_display_distance_toggle(widget):
|
||||||
|
settings = SettingsManager.get_instance().settings
|
||||||
|
distance = settings.get_double('display-distance')
|
||||||
|
settings.set_double(widget.get_name(), distance)
|
||||||
|
reload_display_distance_toggle_button(widget)
|
||||||
|
|
@ -0,0 +1,201 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<template class="ConnectedDevice" parent="GtkBox">
|
||||||
|
<property name="orientation">1</property>
|
||||||
|
<property name="margin-top">20</property>
|
||||||
|
<property name="margin-bottom">20</property>
|
||||||
|
<property name="margin-start">20</property>
|
||||||
|
<property name="margin-end">20</property>
|
||||||
|
<property name="spacing">20</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid">
|
||||||
|
<property name="column-spacing">4</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="device_label">
|
||||||
|
<property name="label">VITURE One</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">connected</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwPreferencesGroup">
|
||||||
|
<property name="title" translatable="true">Settings</property>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow">
|
||||||
|
<property name="title" translatable="true">Effect enabled</property>
|
||||||
|
<property name="subtitle" translatable="true">Turn on or off the XR desktop effect</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSwitch" id="effect_enable_switch">
|
||||||
|
<property name="valign">3</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow">
|
||||||
|
<property name="title" translatable="true">Display distance</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkScale">
|
||||||
|
<property name="valign">3</property>
|
||||||
|
<property name="draw-value">true</property>
|
||||||
|
<property name="value-pos">0</property>
|
||||||
|
<property name="digits">2</property>
|
||||||
|
<property name="width-request">350</property>
|
||||||
|
<property name="has-origin">false</property>
|
||||||
|
<property name="adjustment">
|
||||||
|
<object class="GtkAdjustment" id="display_distance_scale">
|
||||||
|
<property name="lower">0.2</property>
|
||||||
|
<property name="upper">2.5</property>
|
||||||
|
<property name="step-increment">0.01</property>
|
||||||
|
<property name="value">1.05</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
<marks>
|
||||||
|
<mark value="0.2" position="bottom"></mark>
|
||||||
|
<mark value="1.0" position="bottom"></mark>
|
||||||
|
<mark value="2.5" position="bottom"></mark>
|
||||||
|
</marks>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow">
|
||||||
|
<property name="title" translatable="true">Follow enabled</property>
|
||||||
|
<property name="subtitle" translatable="true">Keep the virtual display near the center of your view</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSwitch" id="follow_mode_switch">
|
||||||
|
<property name="valign">3</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwPreferencesGroup">
|
||||||
|
<property name="title" translatable="true">Shortcuts</property>
|
||||||
|
<property name="description" translatable="true">Modify keyboard shortcuts and how they work</property>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow">
|
||||||
|
<property name="title" translatable="true">Re-center display shortcut</property>
|
||||||
|
<property name="subtitle" translatable="true">Pin the virtual display to the current position</property>
|
||||||
|
<property name="valign">2</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="spacing">30</property>
|
||||||
|
<property name="margin-start">30</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutLabel" id="recenter_display_shortcut_label">
|
||||||
|
<property name="valign">3</property>
|
||||||
|
<property name="accelerator"></property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="reassign_recenter_display_shortcut_button">
|
||||||
|
<style>
|
||||||
|
<class name="row-button"/>
|
||||||
|
</style>
|
||||||
|
<property name="name">recenter-display-shortcut</property>
|
||||||
|
<property name="valign">3</property>
|
||||||
|
<property name="label" translatable="true">Change</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow">
|
||||||
|
<property name="title" translatable="true">Display distance shortcut</property>
|
||||||
|
<property name="subtitle" translatable="true">Quickly toggle between two predefined distances</property>
|
||||||
|
<property name="valign">2</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="spacing">30</property>
|
||||||
|
<property name="margin-start">30</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutLabel" id="toggle_display_distance_shortcut_label">
|
||||||
|
<property name="valign">3</property>
|
||||||
|
<property name="accelerator"></property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="reassign_toggle_display_distance_shortcut_button">
|
||||||
|
<style>
|
||||||
|
<class name="row-button"/>
|
||||||
|
</style>
|
||||||
|
<property name="name">toggle-display-distance-shortcut</property>
|
||||||
|
<property name="valign">3</property>
|
||||||
|
<property name="label" translatable="true">Change</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow">
|
||||||
|
<property name="title" translatable="true">Display distance start and end</property>
|
||||||
|
<property name="subtitle" translatable="true">Use the buttons to capture the current display distance as start and end points.</property>
|
||||||
|
<property name="valign">2</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="spacing">30</property>
|
||||||
|
<property name="width-request">150</property>
|
||||||
|
<property name="margin-start">30</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="set_toggle_display_distance_start_button">
|
||||||
|
<property name="name">toggle-display-distance-start</property>
|
||||||
|
<property name="valign">3</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="set_toggle_display_distance_end_button">
|
||||||
|
<property name="name">toggle-display-distance-end</property>
|
||||||
|
<property name="valign">3</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow">
|
||||||
|
<property name="title" translatable="true">Toggle follow mode shortcut</property>
|
||||||
|
<property name="subtitle" translatable="true">Quickly toggle follow mode</property>
|
||||||
|
<property name="valign">2</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="spacing">30</property>
|
||||||
|
<property name="margin-start">30</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutLabel" id="toggle_follow_shortcut_label">
|
||||||
|
<property name="valign">3</property>
|
||||||
|
<property name="accelerator"></property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="reassign_toggle_follow_shortcut_button">
|
||||||
|
<style>
|
||||||
|
<class name="row-button"/>
|
||||||
|
</style>
|
||||||
|
<property name="name">toggle-follow-shortcut</property>
|
||||||
|
<property name="valign">3</property>
|
||||||
|
<property name="label" translatable="true">Change</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<template class="NoDevice" parent="GtkBox">
|
||||||
|
<property name="orientation">1</property>
|
||||||
|
<property name="margin-top">20</property>
|
||||||
|
<property name="margin-bottom">20</property>
|
||||||
|
<property name="margin-start">20</property>
|
||||||
|
<property name="margin-end">20</property>
|
||||||
|
<property name="spacing">20</property>
|
||||||
|
<child>
|
||||||
|
<object class="AdwStatusPage">
|
||||||
|
<property name="title" translatable="true">No device connected</property>
|
||||||
|
<property name="description" translatable="true">Breezy Desktop was unable to detect any supported XR devices.</property>
|
||||||
|
<property name="width-request">650</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<template class="ShortcutDialog" parent="GtkDialog">
|
||||||
|
<property name="modal">1</property>
|
||||||
|
<property name="default_width">440</property>
|
||||||
|
<property name="default_height">200</property>
|
||||||
|
<child internal-child="content_area">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">2</property>
|
||||||
|
<property name="margin-start">16</property>
|
||||||
|
<property name="margin-end">16</property>
|
||||||
|
<property name="margin-top">16</property>
|
||||||
|
<property name="margin-bottom">16</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="vexpand">1</property>
|
||||||
|
<property name="label" translatable="yes">Press your keyboard shortcut or 'Backspace' to disable...</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="titlebar">
|
||||||
|
<object class="GtkHeaderBar">
|
||||||
|
<property name="title-widget">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">Keyboard Shortcut</property>
|
||||||
|
<property name="single-line-mode">1</property>
|
||||||
|
<property name="ellipsize">end</property>
|
||||||
|
<property name="width-chars">5</property>
|
||||||
|
<style>
|
||||||
|
<class name="title"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEventControllerKey" id="event_controller" />
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<template class="BreezydesktopWindow" parent="GtkApplicationWindow">
|
||||||
|
<property name="default-width">800</property>
|
||||||
|
<property name="titlebar">
|
||||||
|
<object class="GtkHeaderBar" id="header_bar">
|
||||||
|
<property name="title-widget">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">Breezy Desktop</property>
|
||||||
|
<property name="single-line-mode">1</property>
|
||||||
|
<property name="ellipsize">end</property>
|
||||||
|
<property name="width-chars">5</property>
|
||||||
|
<style>
|
||||||
|
<class name="title"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
<child type="end">
|
||||||
|
<object class="GtkMenuButton">
|
||||||
|
<property name="primary">True</property>
|
||||||
|
<property name="icon-name">open-menu-symbolic</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Menu</property>
|
||||||
|
<property name="menu-model">primary_menu</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
<menu id="primary_menu">
|
||||||
|
<section>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">_About BreezyDesktop</attribute>
|
||||||
|
<attribute name="action">app.about</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
|
</menu>
|
||||||
|
</interface>
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
# main.py
|
||||||
|
#
|
||||||
|
# Copyright 2024 Unknown
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version('Gtk', '4.0')
|
||||||
|
gi.require_version('Adw', '1')
|
||||||
|
gi.require_version('Gio', '2.0')
|
||||||
|
|
||||||
|
from gi.repository import Adw, Gtk, Gio
|
||||||
|
from .window import BreezydesktopWindow
|
||||||
|
|
||||||
|
class BreezydesktopApplication(Adw.Application):
|
||||||
|
"""The main application singleton class."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(application_id='com.xronlinux.BreezyDesktop',
|
||||||
|
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
|
||||||
|
self.create_action('quit', lambda *_: self.quit(), ['<primary>q'])
|
||||||
|
self.create_action('about', self.on_about_action)
|
||||||
|
|
||||||
|
def do_activate(self):
|
||||||
|
"""Called when the application is activated.
|
||||||
|
|
||||||
|
We raise the application's main window, creating it if
|
||||||
|
necessary.
|
||||||
|
"""
|
||||||
|
win = self.props.active_window
|
||||||
|
if not win:
|
||||||
|
win = BreezydesktopWindow(application=self)
|
||||||
|
win.present()
|
||||||
|
|
||||||
|
def on_about_action(self, widget, _):
|
||||||
|
"""Callback for the app.about action."""
|
||||||
|
about = Gtk.AboutDialog(transient_for=self.props.active_window,
|
||||||
|
modal=True,
|
||||||
|
program_name='Breezy Desktop',
|
||||||
|
logo_icon_name='com.xronlinux.BreezyDesktop',
|
||||||
|
version='0.1.0',
|
||||||
|
authors=['Wayne Heaney'],
|
||||||
|
copyright='© 2024 Wayne Heaney')
|
||||||
|
about.present()
|
||||||
|
|
||||||
|
def create_action(self, name, callback, shortcuts=None):
|
||||||
|
"""Add an application action.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name: the name of the action
|
||||||
|
callback: the function to be called when the action is
|
||||||
|
activated
|
||||||
|
shortcuts: an optional list of accelerators
|
||||||
|
"""
|
||||||
|
action = Gio.SimpleAction.new(name, None)
|
||||||
|
action.connect("activate", callback)
|
||||||
|
self.add_action(action)
|
||||||
|
if shortcuts:
|
||||||
|
self.set_accels_for_action(f"app.{name}", shortcuts)
|
||||||
|
|
||||||
|
|
||||||
|
def main(version):
|
||||||
|
"""The application's entry point."""
|
||||||
|
app = BreezydesktopApplication()
|
||||||
|
return app.run(sys.argv)
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name()
|
||||||
|
moduledir = pkgdatadir / 'breezydesktop'
|
||||||
|
gnome = import('gnome')
|
||||||
|
|
||||||
|
gnome.compile_resources('breezydesktop',
|
||||||
|
'breezydesktop.gresource.xml',
|
||||||
|
gresource_bundle: true,
|
||||||
|
install: true,
|
||||||
|
install_dir: pkgdatadir,
|
||||||
|
)
|
||||||
|
|
||||||
|
python = import('python')
|
||||||
|
|
||||||
|
conf = configuration_data()
|
||||||
|
conf.set('PYTHON', python.find_installation('python3').full_path())
|
||||||
|
conf.set('VERSION', meson.project_version())
|
||||||
|
conf.set('localedir', get_option('prefix') / get_option('localedir'))
|
||||||
|
conf.set('pkgdatadir', pkgdatadir)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
input: 'breezydesktop.in',
|
||||||
|
output: 'breezydesktop',
|
||||||
|
configuration: conf,
|
||||||
|
install: true,
|
||||||
|
install_dir: get_option('bindir'),
|
||||||
|
install_mode: 'r-xr-xr-x'
|
||||||
|
)
|
||||||
|
|
||||||
|
breezydesktop_sources = [
|
||||||
|
'__init__.py',
|
||||||
|
'connecteddevice.py',
|
||||||
|
'main.py',
|
||||||
|
'nodevice.py',
|
||||||
|
'settingsmanager.py',
|
||||||
|
'shortcutdialog.py',
|
||||||
|
'statemanager.py',
|
||||||
|
'window.py',
|
||||||
|
'xrdriveripc.py'
|
||||||
|
]
|
||||||
|
|
||||||
|
install_data(breezydesktop_sources, install_dir: moduledir)
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
from gi.repository import Adw, Gtk
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path='/com/xronlinux/BreezyDesktop/gtk/no-device.ui')
|
||||||
|
class NoDevice(Gtk.Box):
|
||||||
|
__gtype_name__ = "NoDevice"
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
from gi.repository import Gio
|
||||||
|
|
||||||
|
class SettingsManager:
|
||||||
|
_instance = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_instance():
|
||||||
|
if not SettingsManager._instance:
|
||||||
|
SettingsManager._instance = SettingsManager()
|
||||||
|
|
||||||
|
return SettingsManager._instance
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.settings = Gio.Settings.new_with_path("com.xronlinux.BreezyDesktop", "/com/xronlinux/BreezyDesktop/")
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
from gi.repository import Gtk, Gdk
|
||||||
|
|
||||||
|
from .settingsmanager import SettingsManager
|
||||||
|
|
||||||
|
# ported from https://github.com/velitasali/gnome-shell-extension-awesome-tiles
|
||||||
|
@Gtk.Template(resource_path='/com/xronlinux/BreezyDesktop/gtk/shortcut-dialog.ui')
|
||||||
|
class ShortcutDialog(Gtk.Dialog):
|
||||||
|
__gtype_name__ = 'ShortcutDialog'
|
||||||
|
|
||||||
|
event_controller = Gtk.Template.Child()
|
||||||
|
|
||||||
|
def __init__(self, settings_key):
|
||||||
|
super(Gtk.Dialog, self).__init__()
|
||||||
|
self.init_template()
|
||||||
|
|
||||||
|
self.settings_key = settings_key
|
||||||
|
self.key_pressed_connect_id = self.event_controller.connect('key-pressed', self._on_key_pressed)
|
||||||
|
|
||||||
|
def _on_key_pressed(self, widget, keyval, keycode, state):
|
||||||
|
mask = state & Gtk.accelerator_get_default_mod_mask()
|
||||||
|
mask &= ~Gdk.ModifierType.LOCK_MASK
|
||||||
|
|
||||||
|
done = True
|
||||||
|
if mask == 0 and keyval == Gdk.KEY_Escape:
|
||||||
|
self.visible = False
|
||||||
|
elif keyval == Gdk.KEY_BackSpace:
|
||||||
|
SettingsManager.get_instance().settings.set_strv(self.settings_key, [])
|
||||||
|
self.close()
|
||||||
|
elif is_binding_valid(mask, keycode, keyval) and is_accel_valid(state, keyval):
|
||||||
|
binding = Gtk.accelerator_name_with_keycode(
|
||||||
|
None,
|
||||||
|
keyval,
|
||||||
|
keycode,
|
||||||
|
state
|
||||||
|
)
|
||||||
|
label = Gtk.accelerator_get_label(keyval, state)
|
||||||
|
|
||||||
|
# hacky way to store the label, causes warnings from the WM
|
||||||
|
SettingsManager.get_instance().settings.set_strv(self.settings_key, [binding])
|
||||||
|
|
||||||
|
self.close()
|
||||||
|
else:
|
||||||
|
done = False
|
||||||
|
|
||||||
|
if done and self.key_pressed_connect_id:
|
||||||
|
self.event_controller.disconnect(self.key_pressed_connect_id)
|
||||||
|
self.key_pressed_connect_id = None
|
||||||
|
|
||||||
|
return Gdk.EVENT_STOP
|
||||||
|
|
||||||
|
def is_binding_valid(mask, keycode, keyval):
|
||||||
|
if mask == 0 or mask == Gdk.ModifierType.SHIFT_MASK and keycode != 0:
|
||||||
|
if keyval >= Gdk.KEY_a and keyval <= Gdk.KEY_z or \
|
||||||
|
keyval >= Gdk.KEY_A and keyval <= Gdk.KEY_Z or \
|
||||||
|
keyval >= Gdk.KEY_0 and keyval <= Gdk.KEY_9 or \
|
||||||
|
keyval >= Gdk.KEY_kana_fullstop and keyval <= Gdk.KEY_semivoicedsound or \
|
||||||
|
keyval >= Gdk.KEY_Arabic_comma and keyval <= Gdk.KEY_Arabic_sukun or \
|
||||||
|
keyval >= Gdk.KEY_Serbian_dje and keyval <= Gdk.KEY_Cyrillic_HARDSIGN or \
|
||||||
|
keyval >= Gdk.KEY_Greek_ALPHAaccent and keyval <= Gdk.KEY_Greek_omega or \
|
||||||
|
keyval >= Gdk.KEY_hebrew_doublelowline and keyval <= Gdk.KEY_hebrew_taf or \
|
||||||
|
keyval >= Gdk.KEY_Thai_kokai and keyval <= Gdk.KEY_Thai_lekkao or \
|
||||||
|
keyval >= Gdk.KEY_Hangul_Kiyeog and keyval <= Gdk.KEY_Hangul_J_YeorinHieuh or \
|
||||||
|
keyval == Gdk.KEY_space and mask == 0 or \
|
||||||
|
is_keyval_forbidden(keyval):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def is_keyval_forbidden(keyval):
|
||||||
|
forbidden_keyvals = [
|
||||||
|
Gdk.KEY_Home,
|
||||||
|
Gdk.KEY_Left,
|
||||||
|
Gdk.KEY_Up,
|
||||||
|
Gdk.KEY_Right,
|
||||||
|
Gdk.KEY_Down,
|
||||||
|
Gdk.KEY_Page_Up,
|
||||||
|
Gdk.KEY_Page_Down,
|
||||||
|
Gdk.KEY_End,
|
||||||
|
Gdk.KEY_Tab,
|
||||||
|
Gdk.KEY_KP_Enter,
|
||||||
|
Gdk.KEY_Return,
|
||||||
|
Gdk.KEY_Mode_switch
|
||||||
|
]
|
||||||
|
return keyval in forbidden_keyvals
|
||||||
|
|
||||||
|
def is_accel_valid(mask, keyval):
|
||||||
|
return Gtk.accelerator_valid(keyval, mask) or (keyval == Gdk.KEY_Tab and mask != 0)
|
||||||
|
|
||||||
|
def bind_shortcut_settings(window, widget_tuples):
|
||||||
|
for widget_tuple in widget_tuples:
|
||||||
|
widget, label = widget_tuple
|
||||||
|
SettingsManager.get_instance().settings.connect('changed::' + widget.get_name(),
|
||||||
|
lambda *args, widget=widget, label=label: reload_shortcut_widget(widget, label))
|
||||||
|
widget.connect('clicked', lambda *args, widget=widget: on_assign_shortcut(window, widget))
|
||||||
|
|
||||||
|
reload_shortcut_widgets(widget_tuples)
|
||||||
|
|
||||||
|
def on_assign_shortcut(window, widget):
|
||||||
|
dialog = ShortcutDialog(widget.get_name())
|
||||||
|
dialog.set_transient_for(widget.get_ancestor(Gtk.Window))
|
||||||
|
dialog.present()
|
||||||
|
|
||||||
|
def reload_shortcut_widget(widget, label):
|
||||||
|
shortcut = SettingsManager.get_instance().settings.get_strv(widget.get_name())
|
||||||
|
label.set_accelerator(shortcut[0] if len(shortcut) > 0 else 'Disabled')
|
||||||
|
|
||||||
|
def reload_shortcut_widgets(widget_tuples):
|
||||||
|
for widget_tuple in widget_tuples:
|
||||||
|
widget, label = widget_tuple
|
||||||
|
reload_shortcut_widget(widget, label)
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
import threading
|
||||||
|
from gi.repository import GObject
|
||||||
|
from .xrdriveripc import XRDriverIPC
|
||||||
|
|
||||||
|
class Logger:
|
||||||
|
def info(self, message):
|
||||||
|
print(message)
|
||||||
|
|
||||||
|
def error(self, message):
|
||||||
|
print(message)
|
||||||
|
|
||||||
|
class StateManager(GObject.GObject):
|
||||||
|
__gsignals__ = {
|
||||||
|
'device-update': (GObject.SIGNAL_RUN_FIRST, None, (str,))
|
||||||
|
}
|
||||||
|
|
||||||
|
__gproperties__ = {
|
||||||
|
'follow-mode': (bool, 'Follow Mode', 'Whether the follow mode is enabled', False, GObject.ParamFlags.READWRITE)
|
||||||
|
}
|
||||||
|
|
||||||
|
_instance = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_instance():
|
||||||
|
if not StateManager._instance:
|
||||||
|
StateManager._instance = StateManager()
|
||||||
|
|
||||||
|
return StateManager._instance
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def device_name(state):
|
||||||
|
if state.get('connected_device_brand') and state.get('connected_device_model'):
|
||||||
|
return f"{state['connected_device_brand']} {state['connected_device_model']}"
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
GObject.GObject.__init__(self)
|
||||||
|
self.ipc = XRDriverIPC.get_instance()
|
||||||
|
self.connected_device_name = None
|
||||||
|
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
self.running = True
|
||||||
|
self._refresh_state()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.running = False
|
||||||
|
|
||||||
|
def _refresh_state(self):
|
||||||
|
self.state = self.ipc.retrieve_driver_state()
|
||||||
|
new_device_name = StateManager.device_name(self.state)
|
||||||
|
if self.connected_device_name != new_device_name:
|
||||||
|
self.connected_device_name = new_device_name
|
||||||
|
self.emit('device-update', self.connected_device_name)
|
||||||
|
|
||||||
|
self.set_property('follow-mode', self.state.get('breezy_desktop_smooth_follow_enabled'))
|
||||||
|
|
||||||
|
if self.running: threading.Timer(1.0, self._refresh_state).start()
|
||||||
|
|
||||||
|
def do_set_property(self, prop, value):
|
||||||
|
if prop.name == 'follow-mode':
|
||||||
|
self.follow_mode = value
|
||||||
|
|
||||||
|
def do_get_property(self, prop):
|
||||||
|
if prop.name == 'follow-mode':
|
||||||
|
return self.follow_mode
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
# window.py
|
||||||
|
#
|
||||||
|
# Copyright 2024 Unknown
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from gi.repository import Gtk
|
||||||
|
from .statemanager import StateManager
|
||||||
|
from .connecteddevice import ConnectedDevice
|
||||||
|
from .nodevice import NoDevice
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path='/com/xronlinux/BreezyDesktop/gtk/window.ui')
|
||||||
|
class BreezydesktopWindow(Gtk.ApplicationWindow):
|
||||||
|
__gtype_name__ = 'BreezydesktopWindow'
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
state_manager = StateManager.get_instance()
|
||||||
|
state_manager.connect('device-update', self._handle_device_update)
|
||||||
|
|
||||||
|
self.connected_device = ConnectedDevice()
|
||||||
|
self.no_device = NoDevice()
|
||||||
|
|
||||||
|
self._handle_device_update(state_manager, StateManager.device_name(state_manager.state))
|
||||||
|
|
||||||
|
def _handle_device_update(self, state_manager, connected_device_name):
|
||||||
|
if connected_device_name:
|
||||||
|
self.set_child(self.connected_device)
|
||||||
|
self.connected_device.set_device_name(connected_device_name)
|
||||||
|
else:
|
||||||
|
self.set_child(self.no_device)
|
||||||
|
|
@ -0,0 +1,297 @@
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import pwd
|
||||||
|
import stat
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
# write-only file that the driver reads (but never writes) to get user-specified control flags
|
||||||
|
CONTROL_FLAGS_FILE_PATH = '/dev/shm/xr_driver_control'
|
||||||
|
|
||||||
|
# read-only file that the driver writes (but never reads) to with its current state
|
||||||
|
DRIVER_STATE_FILE_PATH = '/dev/shm/xr_driver_state'
|
||||||
|
|
||||||
|
CONTROL_FLAGS = ['recenter_screen', 'recalibrate', 'sbs_mode', 'refresh_device_license', 'enable_breezy_desktop_smooth_follow']
|
||||||
|
SBS_MODE_VALUES = ['unset', 'enable', 'disable']
|
||||||
|
MANAGED_EXTERNAL_MODES = ['virtual_display', 'sideview', 'none']
|
||||||
|
VR_LITE_OUTPUT_MODES = ['mouse', 'joystick']
|
||||||
|
|
||||||
|
def parse_boolean(value, default):
|
||||||
|
if not value:
|
||||||
|
return default
|
||||||
|
|
||||||
|
return value.lower() == 'true'
|
||||||
|
|
||||||
|
|
||||||
|
def parse_int(value, default):
|
||||||
|
return int(value) if value.isdigit() else default
|
||||||
|
|
||||||
|
def parse_float(value, default):
|
||||||
|
try:
|
||||||
|
return float(value)
|
||||||
|
except ValueError:
|
||||||
|
return default
|
||||||
|
|
||||||
|
def parse_string(value, default):
|
||||||
|
return value if value else default
|
||||||
|
|
||||||
|
def parse_array(value, default):
|
||||||
|
return value.split(",") if value else default
|
||||||
|
|
||||||
|
|
||||||
|
CONFIG_PARSER_INDEX = 0
|
||||||
|
CONFIG_DEFAULT_VALUE_INDEX = 1
|
||||||
|
CONFIG_ENTRIES = {
|
||||||
|
'disabled': [parse_boolean, True],
|
||||||
|
'output_mode': [parse_string, 'mouse'],
|
||||||
|
'external_mode': [parse_array, 'none'],
|
||||||
|
'mouse_sensitivity': [parse_int, 30],
|
||||||
|
'display_zoom': [parse_float, 1.0],
|
||||||
|
'look_ahead': [parse_int, 0],
|
||||||
|
'sbs_display_size': [parse_float, 1.0],
|
||||||
|
'sbs_display_distance': [parse_float, 1.0],
|
||||||
|
'sbs_content': [parse_boolean, False],
|
||||||
|
'sbs_mode_stretched': [parse_boolean, False],
|
||||||
|
'sideview_position': [parse_string, 'center'],
|
||||||
|
'sideview_display_size': [parse_float, 1.0],
|
||||||
|
'virtual_display_smooth_follow_enabled': [parse_boolean, False],
|
||||||
|
'sideview_smooth_follow_enabled': [parse_boolean, False]
|
||||||
|
}
|
||||||
|
|
||||||
|
class Logger:
|
||||||
|
def info(self, message):
|
||||||
|
print(message)
|
||||||
|
|
||||||
|
def error(self, message):
|
||||||
|
print(message)
|
||||||
|
|
||||||
|
class XRDriverIPC:
|
||||||
|
_instance = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_instance():
|
||||||
|
if not XRDriverIPC._instance:
|
||||||
|
XRDriverIPC._instance = XRDriverIPC()
|
||||||
|
|
||||||
|
return XRDriverIPC._instance
|
||||||
|
|
||||||
|
def __init__(self, logger=Logger(), user=None, user_home=None):
|
||||||
|
self.breezy_installed = False
|
||||||
|
self.breezy_installing = False
|
||||||
|
self.user = user if user else pwd.getpwuid( os.getuid() )[0]
|
||||||
|
self.user_home = user_home if user_home else os.path.expanduser("~")
|
||||||
|
self.config_file_path = os.path.join(self.user_home, ".xreal_driver_config")
|
||||||
|
self.config_script_path = os.path.join(self.user_home, "bin/xreal_driver_config")
|
||||||
|
self.logger = logger
|
||||||
|
|
||||||
|
def retrieve_config(self):
|
||||||
|
config = {}
|
||||||
|
for key, value in CONFIG_ENTRIES.items():
|
||||||
|
config[key] = value[CONFIG_DEFAULT_VALUE_INDEX]
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(self.config_file_path, 'r') as f:
|
||||||
|
for line in f:
|
||||||
|
try:
|
||||||
|
if not line.strip():
|
||||||
|
continue
|
||||||
|
|
||||||
|
key, value = line.strip().split('=')
|
||||||
|
if key in CONFIG_ENTRIES:
|
||||||
|
parser = CONFIG_ENTRIES[key][CONFIG_PARSER_INDEX]
|
||||||
|
default_val = CONFIG_ENTRIES[key][CONFIG_DEFAULT_VALUE_INDEX]
|
||||||
|
config[key] = parser(value, default_val)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(f"Error parsing line {line}: {e}")
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
self.logger.error(f"Config file not found {e}")
|
||||||
|
return config
|
||||||
|
|
||||||
|
config['ui_view'] = self.build_ui_view(config)
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
||||||
|
def write_config(self, config):
|
||||||
|
try:
|
||||||
|
output = ""
|
||||||
|
|
||||||
|
# Since the UI doesn't refresh the config before it updates, the external_mode can get out of sync with
|
||||||
|
# what's on disk. To avoid losing external_mode values, we retrieve the previous configs to preserve
|
||||||
|
# any non-managed external modes.
|
||||||
|
old_config = self._retrieve_config(self)
|
||||||
|
|
||||||
|
# remove the UI's "view" data, translate back to config values, and merge them in
|
||||||
|
view = config.pop('ui_view', None)
|
||||||
|
config.update(self.headset_mode_to_config(view['headset_mode'], view['is_joystick_mode'], old_config['external_mode']))
|
||||||
|
|
||||||
|
for key, value in config.items():
|
||||||
|
if key != "updated":
|
||||||
|
if isinstance(value, bool):
|
||||||
|
output += f'{key}={str(value).lower()}\n'
|
||||||
|
elif isinstance(value, int):
|
||||||
|
output += f'{key}={value}\n'
|
||||||
|
elif isinstance(value, list):
|
||||||
|
output += f'{key}={",".join(value)}\n'
|
||||||
|
else:
|
||||||
|
output += f'{key}={value}\n'
|
||||||
|
|
||||||
|
temp_file = "temp.txt"
|
||||||
|
|
||||||
|
# Write to a temporary file
|
||||||
|
with open(temp_file, 'w') as f:
|
||||||
|
f.write(output)
|
||||||
|
|
||||||
|
# Atomically replace the old config file with the new one
|
||||||
|
os.replace(temp_file, self.config_file_path)
|
||||||
|
os.chmod(self.config_file_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)
|
||||||
|
|
||||||
|
config['ui_view'] = self.build_ui_view(self, config)
|
||||||
|
|
||||||
|
return config
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(f"Error writing config {e}")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
# like a SQL "view," these are computed values that are commonly used in the UI
|
||||||
|
def build_ui_view(self, config):
|
||||||
|
view = {}
|
||||||
|
view['headset_mode'] = self.config_to_headset_mode(config)
|
||||||
|
view['is_joystick_mode'] = config['output_mode'] == 'joystick'
|
||||||
|
return view
|
||||||
|
|
||||||
|
def filter_to_other_external_modes(self, external_modes):
|
||||||
|
return [mode for mode in external_modes if mode not in MANAGED_EXTERNAL_MODES]
|
||||||
|
|
||||||
|
def headset_mode_to_config(self, headset_mode, joystick_mode, old_external_modes):
|
||||||
|
new_external_modes = self.filter_to_other_external_modes(old_external_modes)
|
||||||
|
|
||||||
|
config = {}
|
||||||
|
if headset_mode == "virtual_display":
|
||||||
|
# TODO - uncomment this when the driver can support multiple external_mode values
|
||||||
|
# new_external_modes.append("virtual_display")
|
||||||
|
new_external_modes = ["virtual_display"]
|
||||||
|
config['output_mode'] = "external_only"
|
||||||
|
config['disabled'] = False
|
||||||
|
elif headset_mode == "vr_lite":
|
||||||
|
config['output_mode'] = "joystick" if joystick_mode else "mouse"
|
||||||
|
config['disabled'] = False
|
||||||
|
elif headset_mode == "sideview":
|
||||||
|
# TODO - uncomment this when the driver can support multiple external_mode values
|
||||||
|
# new_external_modes.append("sideview")
|
||||||
|
new_external_modes = ["sideview"]
|
||||||
|
config['output_mode'] = "external_only"
|
||||||
|
config['disabled'] = False
|
||||||
|
else:
|
||||||
|
config['output_mode'] = "external_only"
|
||||||
|
|
||||||
|
has_external_mode = len(new_external_modes) > 0
|
||||||
|
if not has_external_mode:
|
||||||
|
new_external_modes.append("none")
|
||||||
|
config['external_mode'] = new_external_modes
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
||||||
|
def config_to_headset_mode(self, config):
|
||||||
|
if not config or config['disabled']:
|
||||||
|
return "disabled"
|
||||||
|
|
||||||
|
if config['output_mode'] in VR_LITE_OUTPUT_MODES:
|
||||||
|
return "vr_lite"
|
||||||
|
|
||||||
|
managed_mode = next((mode for mode in MANAGED_EXTERNAL_MODES if mode in config['external_mode']), None)
|
||||||
|
if managed_mode and managed_mode != "none":
|
||||||
|
return managed_mode
|
||||||
|
|
||||||
|
return "disabled"
|
||||||
|
|
||||||
|
def write_control_flags(self, control_flags):
|
||||||
|
try:
|
||||||
|
output = ""
|
||||||
|
for key, value in control_flags.items():
|
||||||
|
if key in CONTROL_FLAGS:
|
||||||
|
if key == 'sbs_mode':
|
||||||
|
if value not in SBS_MODE_VALUES:
|
||||||
|
self.logger.error(f"Invalid value {value} for sbs_mode flag")
|
||||||
|
continue
|
||||||
|
elif not isinstance(value, bool):
|
||||||
|
self.logger.error(f"Invalid value {value} for {key} flag")
|
||||||
|
continue
|
||||||
|
output += f'{key}={str(value).lower()}\n'
|
||||||
|
|
||||||
|
with open(CONTROL_FLAGS_FILE_PATH, 'w') as f:
|
||||||
|
f.write(output)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(f"Error writing control flags {e}")
|
||||||
|
|
||||||
|
def retrieve_driver_state(self):
|
||||||
|
state = {}
|
||||||
|
state['heartbeat'] = 0
|
||||||
|
state['connected_device_brand'] = None
|
||||||
|
state['connected_device_model'] = None
|
||||||
|
state['calibration_setup'] = "AUTOMATIC"
|
||||||
|
state['calibration_state'] = "NOT_CALIBRATED"
|
||||||
|
state['sbs_mode_enabled'] = False
|
||||||
|
state['sbs_mode_supported'] = False
|
||||||
|
state['firmware_update_recommended'] = False
|
||||||
|
state['device_license'] = {}
|
||||||
|
state['breezy_desktop_smooth_follow_enabled'] = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(DRIVER_STATE_FILE_PATH, 'r') as f:
|
||||||
|
output = f.read()
|
||||||
|
for line in output.splitlines():
|
||||||
|
try:
|
||||||
|
if not line.strip():
|
||||||
|
continue
|
||||||
|
|
||||||
|
key, value = line.strip().split('=')
|
||||||
|
if key == 'heartbeat':
|
||||||
|
state[key] = parse_int(value, 0)
|
||||||
|
elif key in ['calibration_setup', 'calibration_state', 'connected_device_brand', 'connected_device_model']:
|
||||||
|
state[key] = value
|
||||||
|
elif key in ['sbs_mode_enabled', 'sbs_mode_supported', 'firmware_update_recommended', 'breezy_desktop_smooth_follow_enabled']:
|
||||||
|
state[key] = parse_boolean(value, False)
|
||||||
|
elif key == 'device_license':
|
||||||
|
state[key] = json.loads(value)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(f"Error parsing key-value pair {key}={value}: {e}")
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# state is stale, just send the license
|
||||||
|
if state['heartbeat'] == 0 or (time.time() - state['heartbeat']) > 5:
|
||||||
|
return {
|
||||||
|
'heartbeat': state['heartbeat'],
|
||||||
|
'device_license': state['device_license']
|
||||||
|
}
|
||||||
|
|
||||||
|
return state
|
||||||
|
|
||||||
|
async def request_token(self, email):
|
||||||
|
self.logger.info(f"Requesting a new token for {email}")
|
||||||
|
|
||||||
|
# Set the USER environment variable for this command
|
||||||
|
env_copy = os.environ.copy()
|
||||||
|
env_copy["USER"] = self.user
|
||||||
|
|
||||||
|
try:
|
||||||
|
output = subprocess.check_output([self.config_script_path, "--request-token", email], stderr=subprocess.STDOUT, env=env_copy)
|
||||||
|
return output.strip() == b"Token request sent"
|
||||||
|
except subprocess.CalledProcessError as exc:
|
||||||
|
self.logger.error(f"Error running config script {exc.output}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def verify_token(self, token):
|
||||||
|
self.logger.info(f"Verifying token {token}")
|
||||||
|
|
||||||
|
# Set the USER environment variable for this command
|
||||||
|
env_copy = os.environ.copy()
|
||||||
|
env_copy["USER"] = self.user
|
||||||
|
|
||||||
|
try:
|
||||||
|
output = subprocess.check_output([self.config_script_path, "--verify-token", token], stderr=subprocess.STDOUT, env=env_copy)
|
||||||
|
return output.strip() == b"Token verified"
|
||||||
|
except subprocess.CalledProcessError as exc:
|
||||||
|
self.logger.error(f"Error running config script {exc.output}")
|
||||||
|
return False
|
||||||
|
|
||||||
Loading…
Reference in New Issue