From 980d05929791e5f9920294f937cbeaa5e6bd31ba Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 4 May 2018 13:07:56 +0200 Subject: Hide screen boundary facing window borders --- conf/xmonad/xmonad.hs | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'conf/xmonad/xmonad.hs') diff --git a/conf/xmonad/xmonad.hs b/conf/xmonad/xmonad.hs index 86b92e6..bea9bd2 100644 --- a/conf/xmonad/xmonad.hs +++ b/conf/xmonad/xmonad.hs @@ -48,13 +48,13 @@ availableLayouts = smartBorders $ tabs ||| tilesLM ||| tilesRM ||| tilesTM ||| t windowBringerDmenuConfig = def { menuCommand = "rofi" , menuArgs = [ "-p", "win", "-dmenu", "-i" ] } -floatRectFull = RationalRect 0 0 1 1 -floatRectLarge = RationalRect (1/20) (1/20) (18/20) (18/20) -floatRectCenter = RationalRect (1/6) (1/6) (2/3) (2/3) -floatRectBottom = RationalRect (1/20) (1/3) (18/20) (2/3) -floatRectTop = RationalRect (1/20) 0 (18/20) (2/3) -floatRectLeft = RationalRect 0 (1/20) (1/2) (18/20) -floatRectRight = RationalRect (1/2) (1/20) (1/2) (18/20) +floatRectFull = hideScreenBorder $ RationalRect 0 0 1 1 +floatRectLarge = hideScreenBorder $ RationalRect (1/20) (1/20) (18/20) (18/20) +floatRectCenter = hideScreenBorder $ RationalRect (1/6) (1/6) (2/3) (2/3) +floatRectBottom = hideScreenBorder $ RationalRect (1/20) (1/3) (18/20) (2/3) +floatRectTop = hideScreenBorder $ RationalRect (1/20) 0 (18/20) (2/3) +floatRectLeft = hideScreenBorder $ RationalRect 0 (1/20) (1/2) (18/20) +floatRectRight = hideScreenBorder $ RationalRect (1/2) (1/20) (1/2) (18/20) scratchpads = [ NS "terminal" "kitty --class=scratchterm" (className =? "scratchterm") (customFloating floatRectTop) @@ -63,7 +63,7 @@ scratchpads = [ NS "terminal" "kitty --class=scratchterm" (className =? "scratch , NS "documentation" "zeal" (className =? "Zeal") (customFloating floatRectLarge) , NS "messaging" "telegram-desktop" (className =? "TelegramDesktop") - (customFloating floatRectTop) ] + (customFloating floatRectRight) ] keybindings = -- xmonad session control @@ -106,14 +106,10 @@ keybindings = , ("M-w f" , withFocused $ placeFloating floatRectFull ) , ("M-w S-c" , withFocused $ placeFloating floatRectLarge) , ("M-w c" , withFocused $ placeFloating floatRectCenter) - , ("M-w j" , do withFocused $ placeFloating floatRectBottom - withFocused $ keysMoveWindow (0, 7)) - , ("M-w k" , do withFocused $ placeFloating floatRectTop - withFocused $ keysMoveWindow (0,-6)) - , ("M-w h" , do withFocused $ placeFloating floatRectLeft - withFocused $ keysMoveWindow (-6,0)) - , ("M-w l" , do withFocused $ placeFloating floatRectRight - withFocused $ keysMoveWindow ( 7,0)) + , ("M-w j" , withFocused $ placeFloating floatRectBottom) + , ("M-w k" , withFocused $ placeFloating floatRectTop) + , ("M-w h" , withFocused $ placeFloating floatRectLeft) + , ("M-w l" , withFocused $ placeFloating floatRectRight) -- system control , ("M-c " , spawn "amixer sset Master 10%+") , ("M-c " , spawn "amixer sset Master 10%-") @@ -149,11 +145,19 @@ nonEmptyWS = WSIs $ return (\w -> nonNSP w && nonEmpty w) placeFloating :: RationalRect -> Window -> X () placeFloating rect = windows . (flip XMonad.StackSet.float $ rect) +windowSize w = do + r <- withDisplay $ (\d -> io $ getWindowAttributes d w) + return (fromIntegral $ wa_width r, fromIntegral $ wa_height r) + +withCurrentScreen f = withWindowSet $ \ws -> f (current ws) +withCurrentScreenRect f = withCurrentScreen $ \s -> f (screenRect (screenDetail s)) + +screenResolution = withCurrentScreenRect $ \r -> return (rect_width r, rect_height r) + isNotFullscreen :: Query Bool -isNotFullscreen = ask >>= (\w -> liftX $ do wa <- withDisplay $ (\d -> io $ getWindowAttributes d w) - sr <- fmap (screenRect . screenDetail . current) (gets windowset) - return $ not (fromIntegral (wa_width wa) == rect_width sr && - fromIntegral (wa_height wa) == rect_height sr)) +isNotFullscreen = ask >>= (\w -> liftX $ do (ww, wh) <- windowSize w + (sw, sh) <- screenResolution + return $ not (ww == sw && wh == sh)) isFloat :: Query Bool isFloat = ask >>= (\w -> liftX $ withWindowSet $ \ws -> return $ (M.member w (floating ws))) @@ -167,3 +171,10 @@ setWindowBorder' color width window = do ~(Just pixel) <- io $ initColor d color io $ setWindowBorder d window pixel io $ setWindowBorderWidth d window width + +-- ugly hack to hide window border at screen boundary +hideScreenBorder :: RationalRect -> RationalRect +hideScreenBorder (RationalRect x0 y0 w h) = RationalRect (x0-(bw/sw)) (y0-(bw/sh)) (w+((2*bw)/sw)) (h+((2*bw+1)/sh)) + where bw = 6 + sw = 1280 + sh = 1024 -- cgit v1.2.3