git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commitf448a94296be979a078ac128363119d8e80152bf
parentd97bd7382b
authorLeon Henrik Plickat <[email protected]>
date2020-06-13 03:11
Contrib: Add debug layouts

 contrib/random-correct-layout.sh   | 16 ++++++++++++++
 contrib/random-incorrect-layout.sh | 44 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/contrib/random-correct-layout.sh b/contrib/random-correct-layout.sh
new file mode 100755
index 0000000..cf663a1
--- /dev/null
+++ b/contrib/random-correct-layout.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+# Randomized Layout for debug purposes.
+
+CLIENTS="$1"
+OUTPUT_WIDTH="$4"
+OUTPUT_HEIGHT="$5"
+
+for _ in $(seq 1 "$CLIENTS")
+do
+	WIDTH="$(( ( OUTPUT_WIDTH  / 5 ) ))"
+	HEIGHT="$(( ( OUTPUT_HEIGHT  / 5 ) ))"
+	X="$(( ( RANDOM % ( OUTPUT_WIDTH  - WIDTH  ) )  + 1 ))"
+	Y="$(( ( RANDOM % ( OUTPUT_HEIGHT - HEIGHT ) )  + 1 ))"
+	echo "$X $Y $WIDTH $HEIGHT"
+done
+
diff --git a/contrib/random-incorrect-layout.sh b/contrib/random-incorrect-layout.sh
new file mode 100755
index 0000000..d6b250f
--- /dev/null
+++ b/contrib/random-incorrect-layout.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Randomized Layout for debug purposes. This version randomly makes some errors
+# see how river handles incorrect output of layout executables.
+
+CLIENTS="$1"
+OUTPUT_WIDTH="$4"
+OUTPUT_HEIGHT="$5"
+
+for _ in $(seq 1 "$CLIENTS")
+do
+	WIDTH="$(( ( OUTPUT_WIDTH  / 5 ) ))"
+	HEIGHT="$(( ( OUTPUT_HEIGHT  / 5 ) ))"
+	X="$(( ( RANDOM % ( OUTPUT_WIDTH  - WIDTH  ) )  + 1 ))"
+	Y="$(( ( RANDOM % ( OUTPUT_HEIGHT - HEIGHT ) )  + 1 ))"
+
+	# Mix in some errors
+	case "$(( ( RANDOM % 10 ) ))" in
+		0) # Too few layout rows
+			;;
+
+		1) # Too many layout rows
+			echo "$X $Y $WIDTH $HEIGHT"
+			echo "$X $Y $WIDTH $HEIGHT"
+			;;
+
+		2) # Too few layout columns
+			echo "$X $Y $WIDTH"
+			;;
+
+		3) # Too many layout columns
+			echo "$X $Y $WIDTH $HEIGHT $X"
+			;;
+
+
+		4) # Negative view size
+			echo "$X $Y -$WIDTH $HEIGHT $X"
+			;;
+
+		*) # Expected behaviour
+			echo "$X $Y $WIDTH $HEIGHT"
+			;;
+	esac
+done
+