xmonad / xmonad-contrib

Contributed modules for xmonad
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
584 stars 274 forks source link

XMonad.Actions.Navigation2D issue with XMonad.Layout.Spacing #611

Closed Kncklcht closed 2 years ago

Kncklcht commented 2 years ago

Problem Description

I use XMonad.Actions.Navigation2D to navigate between windows in an XMonad.Layout.BinarySpacePartition layout.

The problem arises when I have a window bordering an even amount n of other windows, so that each of the other windows takes up an nth of the window border in question.

When I add XMonad.Layout.Spacing to my configuration, I can't switch from the large window to any of the other windows, since it seems to try to focus an element in the middle of the border (where there is a gap due to the use of XMonad.Layout.Spacing).

Steps to Reproduce

Run XMonad with the config specified below.

Hit Super + Shift + Enter 3 times to get the most common scenario matching the problematic situation described above. Use Super + [Arrow Keys] to navigate from the most recently opened small window to the large window. Use Super + [Arrow Keys] to try to navigate back to either of the small windows.

Configuration File

import XMonad
import XMonad.Layout.BinarySpacePartition
import XMonad.Layout.BorderResize
import XMonad.Layout.Spacing
import qualified Data.Map as M

main = xmonad $ settings

layout = spacing 10 $ (borderResize (emptyBSP))

keybinds conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  [ ((modm, xK_q               ), spawn "xmonad --recompile; xmonad --restart"),
    ((modm, xK_Right                      ), windowGo R False                 ),  
    ((modm, xK_Left                       ), windowGo L False                 ),  
    ((modm, xK_Up                         ), windowGo U False                 ),  
    ((modm, xK_Down                       ), windowGo D False                 ),  
    ((modm .|. shiftMask, xK_Right        ), windowSwap R False               ),  
    ((modm .|. shiftMask, xK_Left         ), windowSwap L False               ),  
    ((modm .|. shiftMask, xK_Up           ), windowSwap U False               ),  
    ((modm .|. shiftMask, xK_Down         ), windowSwap D False               ),  
    ((modm .|. shiftMask, xK_q            ), io(exitWith ExitSuccess)         ),  
    ((modm .|. shiftMask, xK_Return       ), spawn $ XMonad.terminal conf     ),  
    ((modm .|. shiftMask, xK_c            ), kill                             )] 

settings = def {
  layoutHook = layouts,
  modMask = mod4Mask,
  keys = keybinds
}

"Proposed Solution"

Switch to the rightmost/topmost window on the other side of the border, instead of the one in the middle (where a gap might be).

"Proposed Solution" because I don't know what effects it would have or whether it's possible at all.

slotThe commented 2 years ago

The documentation mentions sideNavigation as "probably the most intuitive strategy for the tiled layer when using XMonad.Layout.Spacing"; does that fix your issue?

main :: IO ()
main = xmonad
     . withNavigation2DConfig def{ defaultTiledNavigation = sideNavigation }
     $ settings
Kncklcht commented 2 years ago

Oh, I didn't see that - it fixed my problem excellently! Also thanks for the help in integrating it!