From 768b420eb81e7a65447cd26663b2f8c95986095e Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Tue, 7 Oct 2008 22:39:53 +0200 Subject: Track mouse position via events received darcs-hash:20081007203953-25a6b-820e60a7db931a5e5e27ab8736643aea932ca3ec.gz --- XMonad/Main.hsc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'XMonad/Main.hsc') diff --git a/XMonad/Main.hsc b/XMonad/Main.hsc index 430e60c..945c5ea 100644 --- a/XMonad/Main.hsc +++ b/XMonad/Main.hsc @@ -99,7 +99,8 @@ xmonad initxmc = do , focusedBorder = fbc , keyActions = keys xmc xmc , buttonActions = mouseBindings xmc xmc - , mouseFocused = False } + , mouseFocused = False + , mousePosition = Nothing } st = XState { windowset = initialWinset , mapped = S.empty @@ -136,10 +137,19 @@ xmonad initxmc = do userCode $ startupHook initxmc -- main loop, for all you HOF/recursion fans out there. - forever_ $ handle =<< io (nextEvent dpy e >> getEvent e) + forever_ $ prehandle =<< io (nextEvent dpy e >> getEvent e) return () - where forever_ a = a >> forever_ a + where + forever_ a = a >> forever_ a + + -- if the event gives us the position of the pointer, set mousePosition + prehandle e = let mouse = do guard (ev_event_type e `elem` evs) + return (fromIntegral (ev_x_root e) + ,fromIntegral (ev_y_root e)) + in local (\c -> c { mousePosition = mouse }) (handle e) + evs = [ keyPress, keyRelease, enterNotify, leaveNotify + , buttonPress, buttonRelease] -- --------------------------------------------------------------------- -- cgit v1.2.3