[xmonad] XM.A.UpdatePointer interferes with XM.A.TiledWindowDragging?

Ramon Diaz-Uriarte rdiaz02 at gmail.com
Fri Mar 24 16:41:52 UTC 2023


Thanks a lot! This works perfectly.


For completeness, I noticed some corner cases if I enable focusFollowsMouse = False . Suppose the following:

- Two windows: Firefox and Emacs.
- Emacs has two buffers with different names


If the focused window is Firefox, and I move the mouse over Emacs, as soon as I cross to the other buffer in Emacs, the mouse pointer jumps back to Firefox.

Now, however, this might not be very relevant as I don't see why I would use updatePointer with focusFollowsMouse = False.


Thanks again,


R.





On Fri, 24-March-2023, at 15:23:41, Platon Pronko <platon7pronko at gmail.com> wrote:
> Hi!
>
> Seems the issue is that the pointer is warped back to the initial dragged window position before TiledWindowDragging updates the focused window, and thus no window switching is happening (because from the point of view of TiledWindowDragging the window was never dragged anywhere).
>
> As Brandon said, logHook is called on every internal state update, so UpdatePointer tries to update the pointer all the time, even in-between drag end and focus change. `updatePointer` contains some guards that are trying to detect common scenarios and prevent updating in such cases, but as we see it doesn't work perfectly.
>
> I suppose `updatePointer` should run only when it explicitly detects the window focus change event, instead of running all the time (maybe some manageHook wrapper?).
>
> That said, I found a (quite hacky) way to achieve what you want without rewriting UpdatePointer. The idea is to make a variable that stores if the drag is currently happening, and disable `updatePointer` while this variable is true:
>
> ```
> -- necessary imports
> import XMonad.Prelude
> import Data.IORef (IORef, newIORef, readIORef, writeIORef)
> import System.IO.Unsafe
> import XMonad.Actions.AfterDrag
>
> -- the hacky code
> updatePointerEnabled :: IORef Bool
> updatePointerEnabled = unsafePerformIO (newIORef True)
> enableUpdatePointer :: X ()
> enableUpdatePointer = io $ writeIORef updatePointerEnabled True
> disableUpdatePointer :: X ()
> disableUpdatePointer = io $ writeIORef updatePointerEnabled False
> dragWindowMod :: Window -> X ()
> dragWindowMod w = do
>   disableUpdatePointer
>   dragWindow w
>   afterDrag $ do
>     enableUpdatePointer
> updatePointerMod refPos ratio = do
>   enabled <- io $ readIORef updatePointerEnabled
>   when enabled $ do
>     updatePointer refPos ratio
>
> -- use dragWindowMod and updatePointerMod instead of original functions
> ```


-- 
Ramon Diaz-Uriarte
Department of Biochemistry, Lab B-31
Facultad de Medicina 
Universidad Autónoma de Madrid 
Arzobispo Morcillo, 4
28029 Madrid
Spain

Phone: +34-91-497-2412

Email: rdiaz02 at gmail.com
       r.diaz at uam.es
       ramon.diaz at iib.uam.es

https://ligarto.org/rdiaz




More information about the xmonad mailing list