Search code examples
haskellxmonad

XMonad: How can I again re-insert a window back into the tiling layout after having it made floating?


I use the below binding to make a window floating and draggable:

myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
  [
    -- mod-button1, Set the window to floating mode and move by dragging
    ((modMask, button1),
     (\w -> focus w >> mouseMoveWindow w))

    -- mod-button2, Raise the window to the top of the stack
    , ((modMask, button2),
       (\w -> focus w >> windows W.swapMaster))

    -- mod-button3, Set the window to floating mode and resize by dragging
    , ((modMask, button3),
       (\w -> focus w >> mouseResizeWindow w))

    -- you may also bind events to the mouse scroll wheel (button4 and button5)
  ]

This is very useful, however sometimes I want to reinsert the window back into the tiling layout. Is there a mechanism in XMonad to do this? Some function funcThatInsertWindowBack:

((modMask .|. shiftMask, button1),
     (\w -> focus w >> funcThatInsertWindowBack w))

Solution

  • The standard config already had this binding:

    ((modMask, xK_t), withFocused $ windows . W.sink)