From 80fad9a8f92116feb286d28c39700523d0932167 Mon Sep 17 00:00:00 2001 From: Vidar Hokstad Date: Tue, 1 Aug 2023 20:16:11 +0100 Subject: [PATCH] Added support for some of the weirder requests by adding unpadded String8. Properly handle Bool --- lib/X11/type.rb | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/X11/type.rb b/lib/X11/type.rb index 56f9086..b49b66d 100644 --- a/lib/X11/type.rb +++ b/lib/X11/type.rb @@ -37,6 +37,7 @@ module X11 x + "\x00"*(-x.length & 3) end + def self.unpack(socket, size) val = socket.read(size) unused_padding = (4 - (size % 4)) % 4 @@ -45,9 +46,33 @@ module X11 end end + class String8Unpadded + def self.pack(x) + x + end + + + def self.unpack(socket, size) + val = socket.read(size) + end + end + + class Bool + def self.pack(x) + x ? "\x01" : "\x00" + end + + def self.unpack(str) + str[0] == "0x01" + end + + def self.size + 1 + end + end + KeyCode = Uint8 Signifigance = Uint8 - Bool = Uint8 BitGravity = Uint8 WinGravity = Uint8 BackingStore = Uint8