summaryrefslogtreecommitdiffhomepage
path: root/Xmobar.hs
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-17 15:14:11 +0200
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-17 15:14:11 +0200
commitdf7761651e426bc874b30cb52fb4205543031a91 (patch)
treef47293ddd5a841e798619d42fe202340efd1d1f2 /Xmobar.hs
parentc2b98fd88acba773135167454422ff68c85e2f49 (diff)
downloadxmobar-df7761651e426bc874b30cb52fb4205543031a91.tar.gz
xmobar-df7761651e426bc874b30cb52fb4205543031a91.tar.bz2
XExposeEvent handling: that requires X11-extras
XExposeEvent is now properly (sort of) handled, with an hackish approch: before nextEvent, that will block Xmobar since an Expose event is captured, we create a background thread that will send an Expose event after the configured refresh interval. So, either a real of a fake Expose event will reach our window within the configured interval. Quite cool, after all. darcs-hash:20070717131411-d6583-0d3438bdcb1d346ade3932ffb979cb998654e4d1.gz
Diffstat (limited to 'Xmobar.hs')
-rw-r--r--Xmobar.hs30
1 files changed, 25 insertions, 5 deletions
diff --git a/Xmobar.hs b/Xmobar.hs
index 94881b5..43bf666 100644
--- a/Xmobar.hs
+++ b/Xmobar.hs
@@ -19,6 +19,8 @@ module Xmobar (-- * Main Stuff
, runXbar
, eventLoop
, createWin
+ , updateWin
+ , sendUpdateEvent
-- * Printing
-- $print
, drawInWin
@@ -39,6 +41,8 @@ module Xmobar (-- * Main Stuff
import Graphics.X11.Xlib
import Graphics.X11.Xlib.Misc
+import Graphics.X11.Xlib.Event
+import Graphics.X11.Xlib.Extras
import Control.Monad.State
import Control.Monad.Reader
@@ -76,11 +80,11 @@ eventLoop :: Xbar ()
eventLoop =
do c <- ask
s <- get
- i <- io $ readVariables (vars s)
- ps <- io $ parseString c i
- drawInWin ps
- -- back again: we are never ending
- io $ tenthSeconds (refresh c)
+ io $ forkIO $ sendUpdateEvent (display s) (window s) (refresh c)
+ action <- io $ allocaXEvent $ \e ->
+ do nextEvent (display s) e
+ return updateWin
+ action
eventLoop
-- | The function to create the initial window
@@ -94,9 +98,25 @@ createWin config =
(fi $ yPos config)
(fi $ width config)
(fi $ height config)
+ selectInput dpy win exposureMask
mapWindow dpy win
return (dpy,win)
+sendUpdateEvent :: Display -> Window -> Int -> IO ()
+sendUpdateEvent dpy w d =
+ do tenthSeconds d
+ allocaXEvent $ \e -> do
+ setEventType e expose
+ sendEvent dpy w False noEventMask e
+ sync dpy False
+
+updateWin :: Xbar ()
+updateWin =
+ do c <- ask
+ s <- get
+ i <- io $ readVariables (vars s)
+ ps <- io $ parseString c i
+ drawInWin ps
-- $print