FIX handle garbage in data field of clientmessage events

This commit is contained in:
Nathan Dwarshuis 2020-03-14 02:08:33 -04:00
parent ae87f6e10b
commit efdae569d1
1 changed files with 9 additions and 2 deletions

View File

@ -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