aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Olaechea <pirata@gmail.com>2019-07-18 01:59:57 -0500
committerJavier Olaechea <pirata@gmail.com>2019-07-18 01:59:57 -0500
commit610ee483e18c5f3c62100c9399abeb9499db5ca6 (patch)
treee75aa3ccc0759b916a0a3b24129752e0c51446db
parent09ef4b16ec25d90ee4bb4a1378934921c7eeacea (diff)
downloadcl-xcb-refactor-into-connection.tar.gz
Fix READ-GET-ATOM-NAMErefactor-into-connection
The reply-length is the number of extra bytes the request has beyond the 32-byte minimum. Because everything up to the 22 octet padding corresponds to the first 32 bytes we have to multiple the request-length times 4, to obtain the number of octets past the first frame and subtract the octets used for the name, which are indicated by name-len.
-rw-r--r--src/xcb-proto.lisp4
-rw-r--r--tests/xcb-proto.lisp7
2 files changed, 10 insertions, 1 deletions
diff --git a/src/xcb-proto.lisp b/src/xcb-proto.lisp
index bb58a08..4e93364 100644
--- a/src/xcb-proto.lisp
+++ b/src/xcb-proto.lisp
@@ -443,7 +443,9 @@
(reply-length (read-card32 in))
(name-len (read-card16 in))
(pad-22 (loop :repeat 22 :do (read-byte in)))
- (name (read-list in :char name-len))))))
+ (name (read-list in :char name-len))
+ (pad-remaining (loop :repeat (- (* 4 reply-length) name-len)
+ :do (read-byte in)))))))
(defun cl-xcb:atom-name (atom)
(send-get-atom-name *xcb-connection* atom)
diff --git a/tests/xcb-proto.lisp b/tests/xcb-proto.lisp
index b9595e4..ec1a140 100644
--- a/tests/xcb-proto.lisp
+++ b/tests/xcb-proto.lisp
@@ -109,3 +109,10 @@ the socket provided. Leave it here in case we want to adapt it later."
"SUPERSCRIPT_X"))
(is (equalp (cl-xcb:atom-name 54)
"STRIKEOUT_DESCENT"))))
+
+(deftest cl-xcb-atom-name-4 ()
+ (with-xcb-connection (*xcb-connection*)
+ (is (equalp (cl-xcb:atom-name 54)
+ "STRIKEOUT_DESCENT"))
+ (is (equalp (cl-xcb:atom-name 47)
+ "SUPERSCRIPT_X"))))