diff options
author | jao <jao@gnu.org> | 2018-11-25 23:43:41 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2018-11-25 23:43:41 +0000 |
commit | 24c84e47177b6ebbe3df99db53220def6c0951ec (patch) | |
tree | 76ab584623118b7dde610c94639d44951cf83b6e /src/Xmobar/X11/Events.hs | |
parent | 54cf675f1299a74466950be240a708a762335d5d (diff) | |
download | xmobar-24c84e47177b6ebbe3df99db53220def6c0951ec.tar.gz xmobar-24c84e47177b6ebbe3df99db53220def6c0951ec.tar.bz2 |
Xmobar.System.Utils, Xmobar.X11.Events
Diffstat (limited to 'src/Xmobar/X11/Events.hs')
-rw-r--r-- | src/Xmobar/X11/Events.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Xmobar/X11/Events.hs b/src/Xmobar/X11/Events.hs new file mode 100644 index 0000000..4334f6b --- /dev/null +++ b/src/Xmobar/X11/Events.hs @@ -0,0 +1,36 @@ +------------------------------------------------------------------------------ +-- | +-- Module: Xmobar.X11.Events +-- Copyright: (c) 2018 Jose Antonio Ortega Ruiz +-- License: BSD3-style (see LICENSE) +-- +-- Maintainer: jao@gnu.org +-- Stability: unstable +-- Portability: portable +-- Created: Sun Nov 25, 2018 23:24 +-- +-- +-- Utilities or event handling +-- +------------------------------------------------------------------------------ + + +module Xmobar.X11.Events(nextEvent') where + +import Control.Concurrent +import System.Posix.Types (Fd(..)) + +import Graphics.X11.Xlib ( + Display(..), XEventPtr, nextEvent, pending, connectionNumber) + +-- | A version of nextEvent that does not block in foreign calls. +nextEvent' :: Display -> XEventPtr -> IO () +nextEvent' d p = do + pend <- pending d + if pend /= 0 + then nextEvent d p + else do + threadWaitRead (Fd fd) + nextEvent' d p + where + fd = connectionNumber d |