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

Platon Pronko platon7pronko at gmail.com
Fri Mar 24 14:23:41 UTC 2023


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
```

--
Best regards,
Platon Pronko
PGP 2A62D77A7A2CB94E

On 2023-03-24 22:04, Brandon Allbery wrote:
> I think that would not be surprising; we needed to update xmonad's
> internal state, including running the `logHook`, during drags to avoid
> other bugs. (https://github.com/xmonad/xmonad/commit/4565e2c90ef522d23d3afc2cf95b9f0b423d8de4)
> Not sure what to do about this.
> 
> On Fri, Mar 24, 2023 at 8:32 AM Ramon Diaz-Uriarte <rdiaz02 at gmail.com> wrote:
>>
>> Dear All,
>>
>> When I use XMonad.Actions.UpdatePointer, window dragging no longer works. If I do not use XM.A.UpdatePointer, window dragging works.
>>
>>
>> Details:
>>
>> These are (what I think are) the relevant pieces from my xmonad.hs:
>>
>>
>> (...)
>> import XMonad.Actions.UpdatePointer
>> import XMonad.Actions.TiledWindowDragging
>> import XMonad.Layout.DraggingVisualizer
>>
>> (...)
>>
>> myConfig myWorkspaces = def {
>> (...)
>>   , logHook = refocusLastLogHook <+> logHook def >> updatePointer (0.5, 0.5) (0.1, 0.1)
>> }  `additionalKeysP` myKeys2
>>    `additionalMouseBindings`
>>    [((mod4Mask, 2), dragWindow)] --drag with mod + center button
>>
>>
>>
>> With the above, window dragging no longer works. However, if I comment out ">> updatePointer (0.5, 0.5) (0.1, 0.1)"  window dragging works again.
>>
>>
>> Am I doing something wrong? I've searched, and have not seen this mentioned (TiledWindowDragging is mentioned in relation to UpdatePointer here: https://github.com/xmonad/xmonad-contrib/issues/566#issuecomment-869240906, but it seemed a different issue)
>>
>>
>> I am using xmonad and xmonad-contrib, both from master branches, updated as of today (2023-03-24): latest commits are 386d4e and e60805b for xmonad and xmonad-contrib, respectively.
>>
>>
>> Best,
>>
>>
>>
>>
>> --
>> 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
>>
>>
>> _______________________________________________
>> xmonad mailing list
>> xmonad at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
> 
> 
> 


More information about the xmonad mailing list