mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
Put a cap on window names
It turns out qutebrowser will place an entire `data:` URL in `_NET_WM_NAME`, up to at least 389K characters including newlines and possibly binary characters. Clamping window titles to the first line, and to 2K chars because `defaultShrinker` is quadratic in the title length.
This commit is contained in:
parent
673de11ca8
commit
87ae269b82
@ -400,7 +400,11 @@ updateDecos s t f = mapM_ $ updateDeco s t f
|
|||||||
-- structure and the needed 'Rectangle's
|
-- structure and the needed 'Rectangle's
|
||||||
updateDeco :: Shrinker s => s -> Theme -> XMonadFont -> (OrigWin,DecoWin) -> X ()
|
updateDeco :: Shrinker s => s -> Theme -> XMonadFont -> (OrigWin,DecoWin) -> X ()
|
||||||
updateDeco sh t fs ((w,_),(Just dw,Just (Rectangle _ _ wh ht))) = do
|
updateDeco sh t fs ((w,_),(Just dw,Just (Rectangle _ _ wh ht))) = do
|
||||||
nw <- getName w
|
-- xmonad-contrib #809
|
||||||
|
-- qutebrowser will happily shovel a 389K multiline string into @_NET_WM_NAME@
|
||||||
|
-- and the 'defaultShrinker' (a) doesn't handle multiline strings well (b) is
|
||||||
|
-- quadratic due to using 'init'
|
||||||
|
nw <- fmap (take 2048 . takeWhile (/= '\n') . show) (getName w)
|
||||||
ur <- readUrgents
|
ur <- readUrgents
|
||||||
dpy <- asks display
|
dpy <- asks display
|
||||||
let focusColor win ic ac uc = maybe ic (\focusw -> case () of
|
let focusColor win ic ac uc = maybe ic (\focusw -> case () of
|
||||||
@ -414,7 +418,7 @@ updateDeco sh t fs ((w,_),(Just dw,Just (Rectangle _ _ wh ht))) = do
|
|||||||
(urgentColor t, urgentBorderColor t, urgentBorderWidth t, urgentTextColor t)
|
(urgentColor t, urgentBorderColor t, urgentBorderWidth t, urgentTextColor t)
|
||||||
let s = shrinkIt sh
|
let s = shrinkIt sh
|
||||||
name <- shrinkWhile s (\n -> do size <- io $ textWidthXMF dpy fs n
|
name <- shrinkWhile s (\n -> do size <- io $ textWidthXMF dpy fs n
|
||||||
return $ size > fromIntegral wh - fromIntegral (ht `div` 2)) (show nw)
|
return $ size > fromIntegral wh - fromIntegral (ht `div` 2)) nw
|
||||||
let als = AlignCenter : map snd (windowTitleAddons t)
|
let als = AlignCenter : map snd (windowTitleAddons t)
|
||||||
strs = name : map fst (windowTitleAddons t)
|
strs = name : map fst (windowTitleAddons t)
|
||||||
i_als = map snd (windowTitleIcons t)
|
i_als = map snd (windowTitleIcons t)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user