summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorTomas Janousek <tomi@nomi.cz>2021-05-14 21:47:41 +0100
committerTomas Janousek <tomi@nomi.cz>2021-05-14 22:05:09 +0100
commitf8c835a33a7acd6f60e27f82ac40027d3ae15e25 (patch)
tree2a61095406d166d0803c3b51dc4ac540e67fd80a /src
parent141f51828df91aca5508902164e7bbaa691ae759 (diff)
downloadxmobar-f8c835a33a7acd6f60e27f82ac40027d3ae15e25.tar.gz
xmobar-f8c835a33a7acd6f60e27f82ac40027d3ae15e25.tar.bz2
Fix delayed reaction to USR1/2 signals
While using xmobar to reproduce/fix a bug in xmonad I noticed that xmobar doesn't react immediately to the signals to reposition or change screen. Apparently none of the Xlib functions called from `repositionWin` flush the Xlib output buffer (XMoveResizeWindow is known to not flush, although it's unfortunately not documented), so when compiled with the threaded runtime that runs XNextEvent in a separate thread, the reposition is sent to the X server only later when other stuff happens. With all monitors set to refresh once a minute, this can take a looong time. (It's entirely possible this happens even without the threaded runtime, I didn't test that, sorry.) The fix is to call XSync at the end of `repositionWin`. While at it, I spotted that drawInWin calls XSync with discard=true, which seems like a mistake. We don't want to discard any events, do we? (In practice, I'd expect the `eventer` thread to read all events even before the drawing thread manages to discard them, so even if this discarding XSync ever had any reason to be there, I don't think it does anything meaningful these days. I may be wrong, though.)
Diffstat (limited to 'src')
-rw-r--r--src/Xmobar/X11/Draw.hs2
-rw-r--r--src/Xmobar/X11/Window.hs1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/Xmobar/X11/Draw.hs b/src/Xmobar/X11/Draw.hs
index 6c00ee6..6044eff 100644
--- a/src/Xmobar/X11/Draw.hs
+++ b/src/Xmobar/X11/Draw.hs
@@ -89,7 +89,7 @@ drawInWin wr@(Rectangle _ _ wid ht) ~[left,center,right] = do
liftIO $ freeGC d gc
liftIO $ freePixmap d p
-- resync
- liftIO $ sync d True
+ liftIO $ sync d False
verticalOffset :: (Integral b, Integral a, MonadIO m) =>
a -> Widget -> XFont -> Int -> Config -> m b
diff --git a/src/Xmobar/X11/Window.hs b/src/Xmobar/X11/Window.hs
index 796e213..6de8e66 100644
--- a/src/Xmobar/X11/Window.hs
+++ b/src/Xmobar/X11/Window.hs
@@ -69,6 +69,7 @@ repositionWin d win fs c = do
r = setPosition c (position c) srs (fromIntegral ht)
moveResizeWindow d win (rect_x r) (rect_y r) (rect_width r) (rect_height r)
setStruts r c d win srs
+ sync d False
return r
fi :: (Integral a, Num b) => a -> b