From cea13d71e7ceb1742d60ceec512d33fa2ffa7635 Mon Sep 17 00:00:00 2001 From: gwern0 Date: Wed, 10 Oct 2007 04:06:16 +0200 Subject: XSelection.hs: Implement Andrea's idea for handling non-UTF-8 string cases darcs-hash:20071010020616-f7719-c516e74e6e7d37e73b2926a7cea30b97d65128f6.gz --- XSelection.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'XSelection.hs') diff --git a/XSelection.hs b/XSelection.hs index dfd235c..5c93b14 100644 --- a/XSelection.hs +++ b/XSelection.hs @@ -41,6 +41,7 @@ import Graphics.X11.Xlib.Extras (currentTime, ev_event_type, getEvent, getWindow import Data.Maybe (fromMaybe) import Control.Concurrent (forkIO) import Data.Char (chr, ord) +import Control.Exception as E (catch) -- promptSelection's imports: import XMonad (io, spawn, X ()) @@ -57,13 +58,11 @@ getSelection = do rootw <- rootWindow dpy dflt win <- createSimpleWindow dpy rootw 0 0 200 100 0 0 0 p <- internAtom dpy "PRIMARY" True - ty <- internAtom dpy "UTF8_STRING" False --- import Control.Exception as E (catch) -{- ty <- E.catch + ty <- E.catch (E.catch - (internAtom dpy "sTring" False) + (internAtom dpy "UTF8_STRING" False) (\_ -> internAtom dpy "COMPOUND_TEXT" False)) - (\_ -> internAtom dpy "UTF8_STRING" False) -} + (\_ -> internAtom dpy "sTring" False) clp <- internAtom dpy "BLITZ_SEL_STRING" False xConvertSelection dpy p ty clp win currentTime allocaXEvent $ \e -> do -- cgit v1.2.3