summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar
diff options
context:
space:
mode:
authorTomas Janousek <tomi@nomi.cz>2022-02-17 14:56:49 +0000
committerTomas Janousek <tomi@nomi.cz>2022-02-17 17:42:27 +0000
commitb3249613e36d1909b1ecab867b4c556284f70362 (patch)
treeddb782292bf8e2d13a3efee79d2de9202b2a846c /src/Xmobar
parentbfd02987485210646800f4184a21b1143f2e301c (diff)
downloadxmobar-b3249613e36d1909b1ecab867b4c556284f70362.tar.gz
xmobar-b3249613e36d1909b1ecab867b4c556284f70362.tar.bz2
Fix memory leak in drawInWin
In f8c835a33a7a, I flipped the discard flag to XSync to False on a false assumption that it may discard events from under the eventer thread (since renamed to handleXEvent). This can't happen—the eventer thread and the main loop do not share a Display connection, they have two separate ones. Turns out, the main loop doesn't read/process any events from its Display connection, which is why it was necessary to discard them once in a while. The fix restores that discarding, adds a comment to explain why that discarding should stay, and just to make things a bit cleaner, also prevents some of those events from being emitted in the first place: by configuring the graphics context that we don't want any exposure events (https://tronche.com/gui/x/xlib/events/exposure/graphics-expose-and-no-expose.html). Fixes: f8c835a33a7a ("Fix delayed reaction to USR1/2 signals")
Diffstat (limited to 'src/Xmobar')
-rw-r--r--src/Xmobar/X11/Draw.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Xmobar/X11/Draw.hs b/src/Xmobar/X11/Draw.hs
index 6348a1a..aed9420 100644
--- a/src/Xmobar/X11/Draw.hs
+++ b/src/Xmobar/X11/Draw.hs
@@ -70,6 +70,7 @@ drawInWin wr@(Rectangle _ _ wid ht) ~[left,center,right] = do
#endif
withColors d [bgColor c, borderColor c] $ \[bgcolor, bdcolor] -> do
gc <- liftIO $ createGC d w
+ liftIO $ setGraphicsExposures d gc False
#if XFT
when (alpha c == 255) $ do
#else
@@ -88,8 +89,8 @@ drawInWin wr@(Rectangle _ _ wid ht) ~[left,center,right] = do
-- free up everything (we do not want to leak memory!)
liftIO $ freeGC d gc
liftIO $ freePixmap d p
- -- resync
- liftIO $ sync d False
+ -- resync (discard events, we don't read/process events from this display conn)
+ liftIO $ sync d True
verticalOffset :: (Integral b, Integral a, MonadIO m) =>
a -> Widget -> XFont -> Int -> Config -> m b