Xmonad:浮动窗口时,移动或调整其大小

发布于 2025-01-03 04:22:42 字数 605 浏览 3 评论 0原文

我更喜欢使用键盘来浮动或下沉窗口。不幸的是,当浮动时,窗口不会移动或调整大小,因此几乎没有视觉迹象表明它们尚未平铺。理想情况下,在转移到浮动层后,我会让它们移动到屏幕中心和/或调整大小。

最好的解决方案将与下面的功能(或类似的功能)一起使用,我用键绑定调用它 - 我希望通过鼠标单击浮动以仍然正常工作。

toggleFloat = withFocused (\windowId -> do
                              { floats <- gets (W.floating . windowset);
                                if windowId `M.member` floats
                                then withFocused $ windows . W.sink
                                else float windowId })

(代码被盗,我仍然没有掌握Haskell:c)

编辑:下面修改后的代码中的keysMoveWindowTo内容实际上可以替换“float windowId”,这使得它变得多余。

I prefer to use the keyboard to float or sink windows. Unfortunately, when floated, windows aren't moved or resized, so there is little visual indication that they aren't still tiled. Ideally, upon shifting to the float layer, I'd have them move to the center of the screen and/or resize.

The best solution would work together with the function below (or something similar), which I call with a keybind -- I'd like floating via mouse click to still work normally.

toggleFloat = withFocused (\windowId -> do
                              { floats <- gets (W.floating . windowset);
                                if windowId `M.member` floats
                                then withFocused $ windows . W.sink
                                else float windowId })

(Code stolen, I still have no grasp of Haskell :c)

Edit: the keysMoveWindowTo stuff in the modified code below can actually just replace "float windowId", which it makes superfluous.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆离笙 2025-01-10 04:22:42

我想您已经安装了 xmonad-contrib 软件包。那么你应该看看 XMonad.Actions.FloatKeys

将是:

...
import XMonad.Actions.FloatKeys
...

toggleFloat = withFocused (\windowId -> do
                              { floats <- gets (W.floating . windowset);
                                if windowId `M.member` floats
                                then withFocused $ windows . W.sink
                                else do
                                     keysMoveWindowTo (x, y) (gx1, gy1) windowId
                                     keysResizeWindow (dx, dy) (gx2, gy2) windowId
                              }
                          ) 

我猜修改后的函数 x,y,dx,dy,gx1,gy1< /code>,gx2,gy2 是您的设置。
文档中提到的运算符%来自于Data.Ratioa % b 表示分子 a 和分母 b 的有理数。如果你想使用它,你必须导入:

import Data.Ratio ((%))

I suppose you've xmonad-contrib package installed. Then you should take a look at XMonad.Actions.FloatKeys

I guess modified function will be:

...
import XMonad.Actions.FloatKeys
...

toggleFloat = withFocused (\windowId -> do
                              { floats <- gets (W.floating . windowset);
                                if windowId `M.member` floats
                                then withFocused $ windows . W.sink
                                else do
                                     keysMoveWindowTo (x, y) (gx1, gy1) windowId
                                     keysResizeWindow (dx, dy) (gx2, gy2) windowId
                              }
                          ) 

where x,y,dx,dy,gx1,gy1,gx2,gy2 are your settings.
Operator % mentioned in docs is from Data.Ratio; a % b means rational number with numerator a and denominator b. You have to import if you want to use it:

import Data.Ratio ((%))
淡水深流 2025-01-10 04:22:42

使用 mod+左拖动浮动窗口,使用 mod+右拖动调整其大小。

Float window with mod+left dragging, resize it with mod+right dragging.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文