当我使用F11键进入全屏模式,或点击Youtube或Netflix中的全屏按钮时,Chrome似乎会缩放页面以适应屏幕的大小,并且页面将被裁剪到其包含的窗口。但是,在使用mod + space切换布局后,它会进行缩放以正确匹配包含窗口。
首次进入全屏模式时,如何使Chrome的缩放适合其窗口而不是整个屏幕?
我尝试了XMonad.Hooks.EwmhDesktops
和XMonad.Layout.Fullscreen
中的函数,但仍然无法找到方法。
我在Arch上使用Google Chrome 57.0.2987.98和xmonad 0.13。谢谢!
这个问题一直困扰着我。我在我的xmonad配置文件中尝试了各种组合,但没有运气。但我最近发现了'Vivaldi',这是一款基于Chromium引擎的浏览器,由Opera浏览器的前首席执行官领导。它通过使用“切换UI”选项(默认情况下为Ctrl-F11)实现了您想要的效果。
我的解决方案是使用fullscreenEventHook
的EWMH
修改版本。
fullscreenEventHook :: Event -> Bool -> X All
fullscreenEventHook (ClientMessageEvent _ _ _ dpy win typ (action:dats)) isChrome = do
wmstate <- getAtom "_NET_WM_STATE"
fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN"
wstate <- fromMaybe [] `fmap` getProp32 wmstate win
let isFull = fromIntegral fullsc `elem` wstate
-- Constants for the _NET_WM_STATE protocol:
remove = 0
add = 1
toggle = 2
ptype = 4 -- The atom property type for changeProperty
chWstate f = io $ changeProperty32 dpy win wmstate ptype propModeReplace (f wstate)
uglyChromeHack x = do
when (not isChrome) x
when isChrome $ windows W.swapUp >> windows W.swapDown
when (typ == wmstate && fi fullsc `elem` dats) $ do
when (action == add || (action == toggle && not isFull)) $ do
chWstate (fi fullsc:)
uglyChromeHack $ windows $ W.float win $ W.RationalRect 0 0 1 1
when (action == remove || (action == toggle && isFull)) $ do
chWstate $ delete (fi fullsc)
uglyChromeHack $ windows $ W.sink win
return $ All True
fullscreenEventHook _ _ = return $ All True
butNotChrome :: Event -> X All
butNotChrome e@(ClientMessageEvent _ _ _ _ win _ _) = do
isChrome <- runQuery (appName =? "google-chrome") win
fullscreenEventHook e isChrome
butNotChrome _ = return $ All True
这一点windows W.swapUp >> windows W.swapDown
似乎足够硬踢铬。
您需要将以下内容添加到您的配置(xmonad.hs):
import XMonad.Hooks.EwmhDesktops
main = xmonad $ ewmh (yourExistingConfigValueGoesHereExample { handleEventHook =
handleEventHook def <+> fullscreenEventHook })
更多信息可以在这里找到:http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-EwmhDesktops.html
此功能也捆绑在desktopConfig中(xmonad的一种理智默认值)。 https://hackage.haskell.org/package/xmonad-contrib-0.13/docs/XMonad-Config-Desktop.html