From efdae569d19012aa4c7c56b9d972f9e472445bbb Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sat, 14 Mar 2020 02:08:33 -0400 Subject: [PATCH] FIX handle garbage in data field of clientmessage events --- lib/SendXMsg.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/SendXMsg.hs b/lib/SendXMsg.hs index 8ba24e2..f94fe2f 100644 --- a/lib/SendXMsg.hs +++ b/lib/SendXMsg.hs @@ -25,10 +25,17 @@ sendXMsg magic tag = do flush dpy where m = str2digit magic - t = str2digit tag + t = str2digit $ tag ++ [garbageDelim] + +-- WORKAROUND: setClientMessageEvent seems to put garbage on the end +-- of the data field (which is probably some yucky c problem I don't +-- understand). Easy solution, put something at the end of the tag to +-- separate the tag from the garbage +garbageDelim :: Char +garbageDelim = '~' splitXMsg :: (Integral a) => [a] -> (String, String) -splitXMsg s = (magic, filter isAlphaNum tag) +splitXMsg s = (magic, filter isAlphaNum . takeWhile (/= garbageDelim) $ tag) where (magic, tag) = splitAt 5 $ map (chr . fromInteger . toInteger) s