RetroArch/gfx/common/wayland/generate_wayland_protos.sh
Colin Kinloch e8ec3031a8
(Wayland) wp_viewporter + scaling fix (#15176)
* Use wp_viewporter
* Set buffer scale to highest of displays the window is touching
* Fixes fullscreen issue mentioned in #15168
* Simplify process of adding new wayland protocols
2023-04-10 06:29:41 +01:00

74 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
set -eu
cd -- "$(cd -- "${0%/*}/" && pwd -P)"
. ../../../qb/qb.init.sh
PROTOS=''
SCANNER_VERSION=''
SHARE_DIR=''
usage="generate_wayland_protos.sh - Generates wayland protocols.
Usage: generate_wayland_protos.sh [OPTIONS]
-c, --codegen version Sets the wayland scanner compatibility version.
-h, --help Shows this message.
-p, --protos yes|no Set to 'no' to use the bundled wayland-protocols.
-s, --share path Sets the path of the wayland protocols directory."
while [ $# -gt 0 ]; do
option="$1"
shift
case "$option" in
-- ) break ;;
-c|--codegen ) SCANNER_VERSION="$1"; shift ;;
-h|--help ) die 0 "$usage" ;;
-p|--protos ) PROTOS="$1"; shift ;;
-s|--share ) SHARE_DIR="$1/wayland-protocols"; shift ;;
* ) die 1 "Unrecognized option '$option', use -h for help." ;;
esac
done
WAYSCAN="$(exists wayland-scanner || :)"
[ "${WAYSCAN}" ] || die 1 "Error: No wayscan in ($PATH)"
WAYLAND_PROTOS=''
if [ "$PROTOS" != 'no' ]; then
for protos in "$SHARE_DIR" /usr/local/share/wayland-protocols /usr/share/wayland-protocols; do
[ -d "$protos" ] || continue
WAYLAND_PROTOS="$protos"
break
done
fi
if [ -z "${WAYLAND_PROTOS}" ]; then
WAYLAND_PROTOS='../../../deps/wayland-protocols'
die : 'Notice: Using the bundled wayland-protocols.'
fi
if [ "$SCANNER_VERSION" = '1.12' ]; then
CODEGEN=code
else
CODEGEN=private-code
fi
generate_source () {
PROTO_DIR="$1"
PROTO_NAME="$2"
PROTO_FILE="$WAYLAND_PROTOS/$PROTO_DIR/$PROTO_NAME.xml"
"$WAYSCAN" client-header "$PROTO_FILE" "./$PROTO_NAME.h"
"$WAYSCAN" $CODEGEN "$PROTO_FILE" "./$PROTO_NAME.c"
}
generate_source 'stable/viewporter' 'viewporter'
generate_source 'stable/xdg-shell' 'xdg-shell'
generate_source 'unstable/xdg-decoration' 'xdg-decoration-unstable-v1'
generate_source 'unstable/idle-inhibit' 'idle-inhibit-unstable-v1'
generate_source 'unstable/pointer-constraints' 'pointer-constraints-unstable-v1'
generate_source 'unstable/relative-pointer' 'relative-pointer-unstable-v1'