From 3c4c0792db9fc8da8115d6be5994c22244e08759 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 10 Apr 2023 13:59:10 +0200 Subject: [PATCH] read pixmap formats --- libx11.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/libx11.sh b/libx11.sh index a109939..014431c 100755 --- a/libx11.sh +++ b/libx11.sh @@ -3,6 +3,8 @@ _EXEC="${0}" X11_FORK="${X11_FORK:-0}" +BR=' +' debug(){ DEBUG="${DEBUG:-/dev/stderr}" if [ $# -gt 0 ]; then @@ -141,8 +143,13 @@ x11_read_values(){ done shift 2 ;; - FORMAT): - #printf + FORMAT) + m1="${data%% *}" data="${data#* }" + m2="${data%% *}" data="${data#* }" + m3="${data%% *}" data="${data#* }" + data="${data#* * * * * }" + printf '%i %i %i\n' "$m1" "$m2" "$m3" + shift 1 ;; *) debug 'Unknown value type: %s\n' "$1" @@ -176,7 +183,6 @@ x11_setup(){ return 2 ;; 1): # Success - debug 'X11: Setup Success\nProtocol Version: %s\n' "$X11_VERSION" { read X11_RELEASE X11_RID_BASE X11_RID_MASK X11_MBUF_SIZE \ m1 X11_MAX_RQ_LENGTH \ m2 m3 X11_IMAGE_BO X11_BITMAP_BO \ @@ -193,11 +199,20 @@ x11_setup(){ CARD32 ) EOF - debug "Number of Screens: %i\n" $m2 + { read X11_VENDOR; read data; } <<-EOF $( printf '%i ' $data |x11_read_values STRING8 $m1 pad $(( (4 - m1 % 4) % 4 )) ) EOF debug "Vendor (%i): %s\n" "$m1" "$X11_VENDOR" + + while [ $m3 -gt 0 ]; do + { read m1; read data; } <<-EOF + $( printf '%i ' $data |x11_read_values FORMAT ) + EOF + X11_PIXMAP_FORMATS="${X11_PIXMAP_FORMATS}${m1}${BR}" + m3=$((m3 - 1)) + done + debug "Pixmap Formats:\nDepth BPP SL pad\n%s" "$X11_PIXMAP_FORMATS" ;; esac } -- 2.39.5