wild-bind-x11 0.2.0.1 → 0.2.0.2
raw patch · 3 files changed
+21/−16 lines, 3 filesdep ~base
Dependency ranges changed: base
Files
- ChangeLog.md +6/−0
- src/WildBind/X11/Internal/FrontEnd.hs +13/−14
- wild-bind-x11.cabal +2/−2
ChangeLog.md view
@@ -1,5 +1,11 @@ # Revision history for wild-bind-x11 +## 0.2.0.2 -- 2018-04-10++* Confirmed test with `base-4.11`.+* Stop using `ListT`, because it's deprecated since `transformers-0.5.3.0`.++ ## 0.2.0.1 -- 2018-02-06 * Confirmed test with `async-2.2.1`.
src/WildBind/X11/Internal/FrontEnd.hs view
@@ -18,11 +18,10 @@ import Control.Concurrent (rtsSupportsBoundThreads) import Control.Concurrent.STM (atomically, TChan, newTChanIO, tryReadTChan, writeTChan) import Control.Exception (bracket, throwIO)-import Control.Monad (when)+import Control.Monad (when, filterM, mapM_) import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Cont (ContT(ContT), runContT) import Control.Monad.Trans.Maybe (MaybeT, runMaybeT)-import Control.Monad.Trans.List (ListT(ListT), runListT) import Control.Monad.Trans.Writer (WriterT, execWriterT, tell) import Data.Bits ((.|.)) import Data.IORef (IORef, newIORef, readIORef, writeIORef)@@ -152,8 +151,8 @@ then return IEDebounced else return IEUnknown -convertEvent :: (XKeyInput k) => KeyMaskMap -> Xlib.Display -> Ndeb.Debouncer -> Xlib.XEventPtr -> ListT IO (FrontEvent ActiveWindow k)-convertEvent kmmap disp deb xev = ListT $ execWriterT $ convertEventWriter where+convertEvent :: (XKeyInput k) => KeyMaskMap -> Xlib.Display -> Ndeb.Debouncer -> Xlib.XEventPtr -> IO [FrontEvent ActiveWindow k]+convertEvent kmmap disp deb xev = execWriterT $ convertEventWriter where tellChangeEvent = (tellElem . FEChange) =<< (liftIO $ getActiveWindow disp) convertEventWriter :: XKeyInput k => WriterT [FrontEvent ActiveWindow k] IO () convertEventWriter = do@@ -167,13 +166,13 @@ IEActiveWindow -> liftIO (Ndeb.notify deb) >> return () IEUnknown -> return () -filterUnchangedEvent :: X11Front k -> FrontEvent ActiveWindow k -> ListT IO ()-filterUnchangedEvent front (FEChange new_state) = do+isSignificantEvent :: X11Front k -> FrontEvent ActiveWindow k -> IO Bool+isSignificantEvent front (FEChange new_state) = do m_old_state <- liftIO $ readIORef $ x11PrevActiveWindow front case m_old_state of- Nothing -> return ()- Just old_state -> if new_state == old_state then empty else return ()-filterUnchangedEvent _ _ = return ()+ Nothing -> return True+ Just old_state -> return (not $ new_state == old_state)+isSignificantEvent _ _ = return True updateState :: X11Front k -> FrontEvent ActiveWindow k -> IO () updateState front fev = case fev of@@ -195,11 +194,11 @@ (eve : rest) -> do x11UnshiftPendingEvents handle rest return eve- processEvents xev = runListT $ do- fevent <- convertEvent (x11KeyMaskMap handle) (x11Display handle) (x11Debouncer handle) xev- filterUnchangedEvent handle fevent- liftIO $ updateState handle fevent- return fevent+ processEvents xev = do+ fevents <- filterM (isSignificantEvent handle)+ =<< convertEvent (x11KeyMaskMap handle) (x11Display handle) (x11Debouncer handle) xev+ mapM_ (updateState handle) fevents+ return fevents -- | Create 'FrontEnd' from 'X11Front' object. --
wild-bind-x11.cabal view
@@ -1,5 +1,5 @@ name: wild-bind-x11-version: 0.2.0.1+version: 0.2.0.2 author: Toshio Ito <debug.ito@gmail.com> maintainer: Toshio Ito <debug.ito@gmail.com> license: BSD3@@ -28,7 +28,7 @@ WildBind.X11.Internal.NotificationDebouncer other-modules: WildBind.X11.Internal.FrontEnd, WildBind.X11.Internal.GrabMan- build-depends: base >=4.6 && <5.0,+ build-depends: base >=4.6 && <4.12, wild-bind >=0.1.0 && <0.2, text >=1.2.0 && <1.3, X11 >=1.6.1 && <1.9,