mirror of
https://github.com/xmonad/xmonad.git
synced 2025-05-19 08:30:21 -07:00
configurable border colors
This also fixes a bug where xmonad was assuming a 24-bit display, and just using, eg, 0xff0000 as an index into a colormap without querying the X server to determine the proper pixel value for "red".
This commit is contained in:
parent
8097060259
commit
bdbca84bcd
@ -106,6 +106,11 @@ defaultDelta = 3%100
|
||||
numlockMask :: KeyMask
|
||||
numlockMask = mod2Mask
|
||||
|
||||
-- Border colors for unfocused and focused windows, respectively.
|
||||
normalBorderColor, focusedBorderColor :: String
|
||||
normalBorderColor = "#dddddd"
|
||||
focusedBorderColor = "#ff0000"
|
||||
|
||||
-- What layout to start in, and what the default proportion for the
|
||||
-- left pane should be in the tiled layout. See LayoutDesc and
|
||||
-- friends in XMonad.hs for options.
|
||||
|
6
Main.hs
6
Main.hs
@ -35,10 +35,14 @@ main :: IO ()
|
||||
main = do
|
||||
dpy <- openDisplay ""
|
||||
let dflt = defaultScreen dpy
|
||||
initcolor c = fst `liftM` allocNamedColor dpy (defaultColormap dpy dflt) c
|
||||
|
||||
rootw <- rootWindow dpy dflt
|
||||
wmdelt <- internAtom dpy "WM_DELETE_WINDOW" False
|
||||
wmprot <- internAtom dpy "WM_PROTOCOLS" False
|
||||
xinesc <- getScreenInfo dpy
|
||||
nbc <- initcolor normalBorderColor
|
||||
fbc <- initcolor focusedBorderColor
|
||||
|
||||
let st = XState
|
||||
{ display = dpy
|
||||
@ -52,6 +56,8 @@ main = do
|
||||
, workspace = W.empty workspaces (length xinesc)
|
||||
, defaultLayoutDesc = startingLayoutDesc
|
||||
, layoutDescs = M.empty
|
||||
, normalBorder = nbc
|
||||
, focusedBorder = fbc
|
||||
}
|
||||
|
||||
xSetErrorHandler -- in C, I'm too lazy to write the binding
|
||||
|
@ -189,17 +189,18 @@ safeFocus w = do ws <- gets workspace
|
||||
-- | Explicitly set the keyboard focus to the given window
|
||||
setFocus :: Window -> X ()
|
||||
setFocus w = do
|
||||
ws <- gets workspace
|
||||
XState { workspace = ws, display = dpy
|
||||
, normalBorder = nbc, focusedBorder = fbc } <- get
|
||||
|
||||
-- clear mouse button grab and border on other windows
|
||||
flip mapM_ (W.visibleWorkspaces ws) $ \n -> do
|
||||
flip mapM_ (W.index n ws) $ \otherw -> do
|
||||
setButtonGrab True otherw
|
||||
setBorder otherw 0xdddddd
|
||||
io $ setWindowBorder dpy otherw (color_pixel nbc)
|
||||
|
||||
withDisplay $ \d -> io $ setInputFocus d w revertToPointerRoot 0
|
||||
setButtonGrab False w
|
||||
setBorder w 0xff0000 -- make this configurable
|
||||
io $ setWindowBorder dpy w (color_pixel fbc)
|
||||
|
||||
-- This does not use 'windows' intentionally. 'windows' calls refresh,
|
||||
-- which means infinite loops.
|
||||
@ -213,10 +214,6 @@ setTopFocus = do
|
||||
Just new -> setFocus new
|
||||
Nothing -> gets theRoot >>= setFocus
|
||||
|
||||
-- | Set the border color for a particular window.
|
||||
setBorder :: Window -> Pixel -> X ()
|
||||
setBorder w p = withDisplay $ \d -> io $ setWindowBorder d w p
|
||||
|
||||
-- | raise. focus to window at offset 'n' in list.
|
||||
-- The currently focused window is always the head of the list
|
||||
raise :: Ordering -> X ()
|
||||
|
@ -46,6 +46,8 @@ data XState = XState
|
||||
, defaultLayoutDesc :: !LayoutDesc -- ^ default layout
|
||||
, layoutDescs :: !(M.Map WorkspaceId LayoutDesc) -- ^ mapping of workspaces
|
||||
-- to descriptions of their layouts
|
||||
, normalBorder :: !Color -- ^ border color of unfocused windows
|
||||
, focusedBorder :: !Color -- ^ border color of the focused window
|
||||
}
|
||||
|
||||
type WindowSet = StackSet WorkspaceId ScreenId Window
|
||||
|
Loading…
x
Reference in New Issue
Block a user