「FVWM」- FvwmButtons @20210123

FvwmButtons,FVWM的按钮盒子。可以在其中创建各种按钮,也可以”吞并“(Swallow)各种窗口。所谓吞并就是把某个程序窗口包含在FvwmButtons中。如下截图:

pasted_image.png

上面的截图中,包含了几个普通的按钮,还吞并了任务栏窗口

模块语法格式

Module FvwmButtons [-g geometry] [-transient | -transientpanel] [name [configfile]]

模块描述

FvwmButtons只能由fvwm产生,命令行调用FvwmButtons模块是无效的。

FvwmButtons模块提供了一个按钮窗口,这个窗口可以包含很多的按钮,位于X的根窗口上的。用户可以随时按下按钮,并由窗口管理器触发用户指定的命令调用。FvwmButtons仅在使用fvwm作为窗口管理器时才有效。

buttonbox可以是任何配置和形状,并可以用单色或彩色图标来表示将被调用的动作,甚至其他应用程序也可以被按钮栏“吞并”,即包含到按钮栏中。

在点击按钮时打开面板也是可以的。有关详细信息,请参阅创建面板(CREATING PANELS)部分。

选项

-g
该选项指定主窗口的几何形状。命令行选项优先于配置文件中的其他几何设置。

-transient
告诉FvwmButtons在遇到子面板已关闭、收到第一个键或按钮按下、重新生成的情况下,关闭自己,但为了打开子面板而按下的不算。 这对于想要选择单个按钮并自动关闭的子面板特别有用。它可以用来创建二维图形菜单。由于-transient是一个选项,不是一个配置命令,你可以使用相同的配置暂时和非暂时的按钮栏。

-transientpanel
与-transient选项大致相同,但不是关闭整个按钮栏,而是隐藏窗口。如果按钮栏作为另一个按钮栏的子面板启动,这非常有用,因为它避免了在选择某些按钮时它必须重新启动。

调用(INVOCATION)

FvwmButton必须由fvwm产生,在命令行直接运行是无效的。可以通过在配置文件中使用'Module FvwmButtons OptionalName'来调用FvwmButtons。如果FvwmButtons在fvwm的初始化过程中产生,这应该放在StartFunction中。 也可以绑定到一个菜单或鼠标按钮或手势来自动。

当使用OptionalName参数调用时,OptionalName用于查找配置命令。例如:

AddToFunc StartFunction Module FvwmButtons MyButtonBox

FvwmButtons将只使用以“*MyButtonBox”开头的行,而不是默认的“*FvwmButtons”。

配置文件中的配置选项

FvwmButtons支持的命令可以分为三类:

(1)用于控制FvwmButtons样式、大小、字体的命令;
(2)用于控制FvwmButtons中按钮外观的命令;
(3)用于在FvwmButtons中定义按钮以及这些按钮行为的命令;

下面将围绕这三类命令进行介绍。

控制FvwmButtons的选项

这些选项用于控制FvwmButtons的整体样式及行为:

*FvwmButtons: BoxSize algorithm

此选项指定FvwmButtons如何使用Rows和Columns选项(请参见下文)。它可以是dump、fixed、smart。

如果使用了fixed,并且Rows和Columns都已指定,并且非零,则FvwmButtons使用的是指定的Rows和Columns。如果该框太小以至于无法容纳所有按钮,则该模块将启动失败。

如果使用了smart,FvwmButtons将会放大框,以使所有的按钮可以适应。列的数量会增加到至少最宽按钮的宽度,并添加新的行直到可以放置所有的按钮。为了最好的容错建议使用smart选项。

选项dumb既不fixed也不smart,它是默认的。

*FvwmButtons: Rows rows

指定按钮的行数。默认为2行。

*FvwmButtons: Columns columns

指定要创建的按钮的列数。
如果未指定,则列数设置为请求的按钮数量除以行数。
如果同时指定了行和列,但按钮的数量多于行和列所允许的数量,则除非BoxSize选项fixed(即产生错误),否则将忽略columns值。

*FvwmButtons: Geometry geometry

指定FvwmButtons窗口的位置和大小。geometry值的格式是一个标准的X11中使用的格式。

*FvwmButtons: Colorset colorset

告诉模块使用colorset作为窗口的背景色。有关colorset的详细信息,请参阅FvwmTheme手册页。

*FvwmButtons: File filename

指定在文件filename中找到此按钮的配置。文件名可以是完整的路径名,或者假定是在fvwm的启动目录中。
配置文件的格式与fvwm的配置文件相同,但每一行读起来都像前缀“*FvwmButtons”一样。
注释以“#”开头;使用“\”延续当前行到下一行。

*FvwmButtons: Pixmap pixmapfile

指定要使用的背景像素图。如果想使用透明背景,则指定none

控制按钮的选项

这些选项用于控制FvwmButtons中的按钮的公共行为和样式:

*FvwmButtons: Back color

指定按钮的背景色。浮雕和阴的影颜色是从背景色中计算的。

*FvwmButtons: ActiveColorset colorset

当鼠标悬停在按钮上方时,指示模块使用colorset作为按钮的背景色和背景图,或者作为标题颜色。

*FvwmButtons: PressColorset colorset

在按下模块的按钮时,指示模块使用colorset作为按钮的背景色和背景图,或者作为标题颜色。

*FvwmButtons: Font font

指定用于按钮的字体,或者为None。

*FvwmButtons: Fore color

指定用于按钮文本和单色图标的颜色。

*FvwmButtons: Frame width

指定每个按钮周围的浮雕的宽度。如果这是一个负数,浮雕向内显示,使按钮看起来下沉。在激活时,按钮会抬起。

*FvwmButtons: ButtonGeometry geometry

此选项与“Geometry”选项类似,只不过尺寸是单个按钮的大小。整个FvwmButtons窗口的大小是通过将按钮尺寸乘行数和列数来计算的。

*FvwmButtons: Padding width height

此选项指定默认水平填充为width像素、垂直填充为heigh像素。除非使用了这个选项,否则根本不填充的窗口和容器除外,按钮的浮雕和按钮的其内容之间的空间通常是2像素、上下4px。

如何定义一个按钮?

下面的这条命令:

* FvwmButtons: (options) [title icon command]

用于向FvwmButtons中添加按钮,并控制按钮的内容、行为、样式等等。

[title icon command]
其中的[title icon command]字段是为了与以前版本的FvwmButtons兼容,不推荐使用

  • title与选项Title name类似,如果标题字段是“-”,则不显示标题。
  • icon与Icon filename选项类似,如果icon字段是“-”,则不显示图标。
  • command与Action command选项类似,或者替代Swallow “hangon”命令。

鉴于此,配置文件中有关FvwmButtons的配置的格式通常为:*FvwmButtons: (options)。因此,以下介绍的选项主要针对options字段。

注意,包裹options的括号是必须的。如果有多个options,它们之间使用逗号或空格分隔。

<geometry>

指定FvwmButtons窗口或容器中按钮的大小和位置。<geometry>格式与X11中的geometry相同(<width>x<height>[+|-]<x>[+|-]<y>)。按钮的宽度为<width>乘以普通按钮的宽度、按钮的高度为<height>乘以普通按钮的高度用于指定宽高。如果给出了x和y的值,如果x(y)为正值,按钮从容器的左边(顶部)开始放置,如果x(y)是负值的,按钮从容器的右边(底部)开始放置。带有位置参数(x和y)的按钮会被放置在没有位置参数的按钮之前。如果两个或多个按钮被强制重叠,FvwmButtons将退出并显示错误消息。

Action [(options)] command

用于指定在按下Enter或Mouse时,要执行的fvwm命令command。如果command包含逗号或右括号,则需要进行引用。

Action的当前options是:Mouse n。该动作仅对鼠标按钮n执行。除了一般操作之外,还可以为每个鼠标按钮定义一个动作。

在command部分,可以使用一些预定义的变量:$left、$right、$top、$bottom,这些变量会被所按下的按钮的左、右、上、下的坐标替代。$-left、$-right、$-top、$-bottom同样会被替换,但坐标是从屏幕底部或者右边缘计算出来的(对于距右边屏幕边界5个像素的按钮, $-right将是5)。 $width和$height被按钮的宽度或高度替换。变量$fg和$bg被用Back或Fore选项设置的前景色或背景色替换(见下文)。所有这些都是无视引用字符的。字符串'$$'表示'$'。看下面的示例:

* FvwmButtons: (Title xload, Action (Mouse 1) `Exec exec xload -fg $fg -bg $bg -geometry -3000-3000`)

注意:对于2.5.0之前的fvwm版本,无法将action分配给吞并应用程序窗口的按钮(请参阅Swallow选项),只有当按钮周围的边框被点击时,这些操作才起作用。现在可以这样做了,但为了恢复旧的行为,可以在按钮上使用ActionIgnoresClientWindow:

* FvwmButtons: (Action beep, ActionIgnoresClientWindow, Swallow xeyes "Exec exec xeyes")

在这个例子中,只有当你点击按钮的边框或者Xeyes窗口的透明部分,而不是在Xeyes窗口本身时,才会执行该动作。

ActionIgnoresClientWindow

参见Action命令中的说明。

ActionOnPress

除了Popup动作之外,通常操作在按钮释放时执行。这个选项改变了这个行为,这个动作在按钮按下时执行。
例如,使用Menu或SendToModule生成弹出窗口时,是很好的。或者当Frame为0时使用,否则按钮看起来没有响应。

Back color

指定绘制此框的要使用的背景色。该值用于计算浮雕颜色及阴影颜色。

Center

按钮的内容在按钮上居中显示。这是默认的,但可以通过Left或Right改变。

Top

按钮的内容垂直方向上显示在按钮的顶部。默认是垂直居中。

Colorset colorset

给定用于容器、一个吞并的应用程序、一个简单的按钮的颜色。要将其应用于按钮或容器,只需将该选项与按钮或容器说明放在一行中即可。单个按钮及带颜色容器的绘制背景需要与X Server进行大量的通信。所以如果你不满足几十个带有色彩背景的按钮的绘制速度,就不要在这里使用colorset。将colortset设置为被吞并应用程序的背景色则没有此限制,但这完全取决于吞并的应用程序。它可以按照你的意愿工作,但是由于它涉及到其他应用程序的窗口,所以不能保证任何东西。我已经测试了三个应用程序:xosview可以很好地处理色彩背景;xload只能用于VGradient或纯色背景,而模拟xclock会在其处理后留下背景色。

如果吞并的窗口是fvwm模块(请参阅Swallow的(No)FvwmModule选项),则colorset不会应用于吞并的模块,应该在模块配置中使用colorset。如果吞并模块具有透明色背景,则通过吞服模块的背景的透明度显示FvwmButtons背景(而不是按钮色彩集)。有关colorset的详细信息,请参阅FvwmTheme模块的手册页。

ActiveColorset colorset

当鼠标悬停在按钮上方时,使用colorset作为按钮的背景色或背景图像及标题颜色。

PressColorset colorset

当按下按钮时,使用colorset作为按钮的背景色或背景图像及标题颜色。

Container [(options)]

指定此按钮将包含一个微型的按钮框,相当于吞并另一个FvwmButtons模块。options与单个按钮的options相同,但是Container中的options会影响包含的所有按钮。可用的options有Back、Font、Fore、Frame、Padding。 Title和Swallow选项的Flags可以设置Title(flags)和Swallow(flags)。还应该指定“Columns width”或“Rows height”,或默认“Columns 2”。有关示例,请参阅Sample configuration部分。

Container按钮本身(与内容分离)可以采用Frame和Padding等格式选项,所以可以在Container上绑定命令,这表示你可以在Container周围加一个敏感区,用作执行Action,比如:

* FvwmButtons: (2x2, Frame 5, Padding 2 2, Action Beep, Container(Frame 1))

通常你会希望至少给容器的大小设置<width>x<height>。

End

表示Container结束,后续的按钮定义不再放入Container中,而放入容器的父级中。该选项应该单独给出:

* FvwmButtons: (End)

Font fontname

按钮文本使用的字体。

Fore color

设置标题和单色图标的前景色。

Frame width

按钮的浮雕的宽度,单位:px。如果宽度是负数,浮雕是向内凹陷的。激活时,按钮会抬起来。

Left

按钮的内容与左侧对齐。默认是将内容置于按钮上。

NoSize

此选项指定在进行按钮大小的初始计算时不会考虑此按钮。有用的奇怪的按钮,只是几个像素太大,保持在一行,因此炸毁你的整个buttonbox。 “NoSize”相当于“Size 0 0”。

Padding width height

    除了吞并的窗户和容器之外,按钮的浮雕与其内容之间的自由空间量通常是2像素,上下4像素,默认情况下根本不填充。此选项将水平填充设置为宽度,将垂直填充设置为高度。

Icon filename

要在按钮上显示的图标的图像文件名。FvwmButtons搜索fvwm中ImagePath配置项指定的路径来查找图标文件。

ActiveIcon filename

图像文件的名称。当鼠标悬停在按钮上方时按钮上显示的图标。如果没有指定ActiveIcon,将显示由Icon指定的图像(如果有的话)。

PressIcon filename

图像文件的名称。在按钮按下时按钮上显示的图标。如果没有指定PressIcon,将显示由Icon指定的图像(如果有的话)。

Id id

id用来标识这个按钮。id的第一个字符应该是字母。另见“DYNAMICAL ACTIONS”部分。

Left

按钮的内容左对其。默认是居中的。

NoSize

此选项指定在进行按钮大小的初始计算时不会考虑此按钮。对奇怪的按钮由于,只是几个像素太大,无法保持在一行,因此弄乱整个buttonbox。“NoSize”相当于“Size 0 0”。

Padding width height

除了吞并的窗户和容器之外,按钮的浮雕与其内容之间的空间,通常是2px,上下4px,默认情况下根本不填充。此选项将水平填充设置为width,将垂直填充设置为height。

Right

该按钮的内容与右侧对齐。默认居中。

Size width height

指定按钮内容的宽高,单位像素,而忽略FvwmButton从图标和标题计算的大小。如果没有指定此选项,只有吞咽窗口的按钮栏不会变得很大,因为FvwmButtons不考虑吞咽按钮的大小。请注意,这个选项可以保证最小的空间;其他按钮可能需要buttonbox使用更大的尺寸。

Swallow [(flags)] hangon command

窗口吞并。遍历所有窗口,当遇到第一个窗口的Name、Class、Resource之一与hangon匹配时,FvwmButtons会捕获该窗口,并将该窗口显示在FvwmButtons中。

下面是一个使用Swallow的例子:

* FvwmButtons: (Swallow XClock 'Exec xclock -geometry -3000-3000 &')

如上示例,遍历所有窗口,在遇到Name、Class、Resource之一为“XClock”的的第一个窗口时,将该窗口显示FvwmButtons中。如果找不到匹配的窗口,则执行后面的“Exec”命令来创建一个。xclock命令的参数“-geometry -3000-3000”使窗口在被FvwmButtons吞并之前显示在屏幕之外,否则的话你会看到一个窗口闪过。

hangon:用于匹配窗口的Name、Class、Resource,当它们之一与hangon匹配时,将FvwmButtons会捕获该窗口,并将窗口吞入到该按钮中。hangon可以包含通配符星号('*'),用于匹配任何子字符串。
command:如果找不到与hangon匹配的窗口时,则执行command命令来创建一个。注意,Exec命令所创建的窗口的Name、Class、Resource之一也必须与hangon匹配。与上面Action选项中描述的一样,Swallow也会替换command中的$fg和$bg变量。但是注意,如果使用UseOld和NoClose选项时,在FvwmButtons重新启动时,被吞并的应用程序是不会重新启动的。在这种情况下,如果更改了command,重启FvwmButtons时,应用是不会发生变化的。
flags:用于控制Swallow的行为。

也可以被吞并FVWM模块。如下示例:

* FvwmButtons: (Swallow "FvwmPager" "FvwmPager 0 0")

可用的flags如下:

NoClose / Close - 当FvwmButtons完全退出(比如,重启)时,此按钮中被吞并的程序是否被”吐出来“或者关闭。默认值是“Close”。“NoClose”可以与“UseOld”组合时,会使被吞并的窗口在FVWM重新启动的情况下依旧存在。
NoHints / Hints - 是否忽略该按钮中被吞并程序的提示。这有助于窗口调整其自身大小,以适应按钮。默认值是“Hints”。
NoKill / Kill - 指定吞并的程序是通过被杀死来关闭,还是通过发送消息来关闭。在结束不接受窗口管理器协议的程序时非常有用。默认值是“NoKill”。如果指定了“NoClose”,则”Kill“不起作用。
NoRespawn / Respawn / SwallowNew - 如果被吞并的程序死了,是否要重新启动。默认值是”NoRespawn“。如果指定了“Respawn”,则使用原始命令重新启动程序。小心使用这个选项,程序可能有自己退出的合理理由。如果给出了“SwallowNew”,则程序不会重新生成,但是如果出现具有 hangon名称的新窗口,则会被立即吞并。
NoOld / UseOld - 指定在使用command产生一个新窗口之前,按钮是否会尝试吞并一个与hangon匹配的、已经存在的窗口。缺省值是“NoOld”。“UseOld”与“NoKill”组合,使窗口可以在窗口管理器的重新启动中存活下来。如果你想让FvwmButtons吞并一个旧窗口,但失败时又不会自己产生一个,可指定command为“Nop”,如下示例:
* FvwmButtons: (Swallow (UseOld) "Console" Nop)
如果你想通过自己点击当前按钮来启动它,将它与一个Action结合起来:
* FvwmButtons: (Swallow (UseOld) "Console" Nop, Action `Exec "Console" console &`)
NoTitle / UseTitle - 指定是否从被吞并的窗口标题中获取按钮的标题。如果给出“UseTitle”,则按钮上的标题会动态变化,以反映窗口名称。默认是“NoTitle”。
NoFvwmModule / FvwmModule - 默认情况下,如果command的前4个字母是“Fvwm”,或者命令的前6个字母是“Module”,则FvwmButtons将吞并的窗口视为FVWM模块窗口。使用NoFvwmModule和FvwmModule来覆盖这个逻辑。

Panel [ (options) ] hangon command

命令Panel与Swallow命令非常相似,都可以吞并窗口,但是Panel命令不会将吞并的窗口显示出来,直到用户按下Panel按钮时,Panel才以滑动动画打开被吞并的窗口。

参数(options)可以是:

  • 用于Swallow命令中描述的任何flags参数。
  • 除此之外,还包含了“left”、“right”、“up”、“down”选项来指定滑动方向。
  • 选项steps animation-steps定义了动画步骤的数量。
  • 选项delay ms设置动画步之间的延迟,以毫秒为单位。值ms为”0“表示不延迟。最大延迟时间是10秒(10000)。不使用smooth选项时使用delay选项没有任何意义。
  • 选项smooth会使Panel在动画的各个步之间重绘。这样滑动动画可能会更平滑,这取决于应用程序、显示速度。应用程序可能会增长,而不是滑出。动画可能会变慢。
  • 选项Hints会导致FvwmButtons使用应用程序大小提示来计算动画步骤的大小。Hints是默认的。如果步数不是您想要的,请尝试使用NoHints
  • 选项noborder告诉FvwmButtons在计算动画的位置(相当于在position选项中设置noplr和noptb)时,忽略窗口的边界。
  • 选项indicator如果设置了,FvwmButtons将在按钮中绘制一个小三角形,用于打开一个面板。三角形指向面板将弹出的方向。关键字indicator后可跟一个正整数,指定indicator的最大宽度和高度,如果没有这个大小FvwmButtons将使indicator适合按钮。您可能会想要使用“Padding”选项在indicator和按钮的边框之间留下几个像素。
  • 选项position允许放置面板。语法是position [context-window] [pos] [x y] [border-opts]。参数context-window指的是用于从中计算Panel百分比偏移量的窗口。可以是Button、Module、Root之一:Button指定面板的按钮;Module指定FvwmButtons本身;Root指定一个虚拟屏幕。context-window与滑动方向一起定义一个线段,该线段是context-window的边界之一:用于上/下/左/右滑动的上/下/左/右边界。参数pos可以是:center、left/right (用于上下滑动)、top/bottom (用于左右滑动)中的一个。它定义线段上的面板的垂直(向上和向下滑动)或水平(向左和向右滑动)位置。例如,如果pos使用left,则向上滑动,则面板的左侧边界和context-window的左侧边界将对齐。偏移值xy指定面板从默认位置移动多远。默认情况下,给定的数值被解释为context-window的宽度(高度)的百分比。以“p”结尾将数值解释为“像素”。即使使用Root为上下文,所有偏移量的计算都是相对于按钮位置的。border-opts可用的值为:mlr、mtb、noplr、noptb。用于定义包含哪些边界的宽度。默认情况下,不考虑FvwmButtons的边界。mlr改变左侧和右侧边界的默认值,mtb改变顶部和底部边界的默认值。相反,默认情况下,Panel的边界被考虑在内。noplr改变默认的左边界和右边界,noptb改变顶部和底部边界的默认值。

默认向上滑动5毫秒,动画共12步骤。要在没有任何动画的情况下显示面板,请将step设置为零。默认位置是“Button center”。

有关面板的更多信息,请参阅“CREATING PANELS”部分。

示例如下:

# To include the panel in a button
* FvwmButtons: (Panel(down, delay 0, steps 16) SubPanel "Module FvwmButtons SubPanel")
# To define the panel as an instance of
# FvwmButtons with a different name:
* SubPanel: (Icon my_lock.xpm, Action Exec xlock)
* SubPanel: (Icon my_move.xpm, Action Move)
...

Title [(options)] name

指定按钮上的标题。空格可以通过引用来包含在标题中。如果一个标题在任何时候对于按钮来说都太长,超出的字符会被截断。 如果justify是“Right”,头部被移除,否则尾部被移除。options取值如下:

Center - 标题水平居中。 这是默认的。
Left - 标题在左侧是合理的。
Right - 居右。
Side - 使标题出现在任何图标或吞咽窗口的右侧,而不是默认的下面。如果使用小图标,并将其与“Left”或“Right”选项相结合,可以使其看起来类似于fvwm的菜单。

ActiveTitle name

鼠标悬停在按钮上方时,显示的标题。如果没有指定ActiveTitle,则显示由Title指定的文本(如果有的话)。

PressTitle name

按下按钮时,显示的标题。如果没有指定PressTitle,则显示由Title指定的文本(如果有的话)。

关于command的内容
任何fvwm命令都被FvwmButtons识别。有关更多信息,请参见fvwm(1)。
Exec命令用在Actions中时有一个小扩展,其语法是:

Exec ["hangon"] command

比如:

* FvwmButtons: (Action Exec "xload" xload)

hangon字符串必须用双引号括起来。当FvwmButtons找到这样一个Exec命令时,该按钮保持推入状态,直到遇到Name、Class、Resource与命令引用部分相匹配的窗口。这是为了向用户反馈当前操作正在执行而给出的视觉反馈。hangon字符串可能包含匹配任何子字符串的通配符('*')。 如果引用的部分不包含字符(""),则该按钮将立即弹出。请注意,即使按钮看起来被按下了,但用户可以继续按下按钮,并重新执行该命令。

Quoting
任何包含空格的字符串都必须加引号。与早期版本相反的是命令不再需要引用。在这种情况下,任何引用字符都将被传递给应用程序。 只有逗号','和右括号')'必须在命令中进行引用。引用可以用三个引号字符中的任何一个来完成:

  • 单引号:'Thisisa“引号”'
  • 双引号:"It'sanother`quote'"
  • 反引号:`Thisisastrangequote`

反引号使用并不常见,但会有目的地使用,如果你使用像FvwmCpp这样的预处理器,并希望它进入你的命令,像这样:

#define BG gray60
* FvwmButtons:(Swallow "xload" `Exec xload -bg BG&`)

任何单个字符都可以用前面的反斜杠“\”来引用。

创建面板(CREATING PANELS)

前版本的FvwmButtons(fvwm 2.0.46到2.3.6)有不同的处理面板的方法。新面板功能中不能使用旧面板配置。阅读“CONVERTING OLD PANEL CONFIGURATIONS”以获取更多信息。

如何创建一个新的面板(HOW TO CREATE NEW PANELS)

这里侧重讲解Panel的使用。

任何可以在fvwm中启动的有窗口的程序都可以用作面板。一个终端窗口可能是你的面板,或者一些应用程序(如xload、xosview),另一个fvwm模块,包括FvwmButtons本身。所有你需要知道的是如何从fvwm中启动你的应用程序。

调用面板的按钮与其他按钮一样易于配置。本质上你只需要Panel选项:

* FvwmButtons: (Panel my_first_panel "Module FvwmButtons -g -30000-30000 my_first_panel")
* FvwmButtons: (Panel my_second_panel "Exec exec xterm -g -30000-30000 -n my_second_panel")

这与Swallow选项类似。不同之处在于应用程序在启动时没有放入按钮,而是隐藏起来。当您按下面板按钮时,窗口会滑入视图中。 '-g -30000-30000'选项告诉应用程序应该在可见屏幕的顶部和左边很远的地方创建它。否则,当FvwmButtons启动时,您会看到它闪烁一会儿。有些应用程序不适合这种语法,所以你可能不得不忍受短暂的窗口闪烁。如果你想从另外一个FvwmButton实例中创建一个面板,你可以这样做,但是你必须给它一个不同的名字(上面例子中的'my_first_panel')。如果在相同名称下运行FvwmButtons,则会递归地创建新面板,直到系统资源耗尽并且FvwmButtons崩溃!要使用不同的名称配置第二个按钮栏,只需在配置文件中将“*new_name”替换为“*FvwmButtons”。如果您不熟悉Swallow选项,或者想要了解更多关于吞咽面板的工作原理,请参阅Swallow选项的说明。

现在,面板基本上可以工作,你需要将需要调整一下。如果不需要面板上的窗口标题,使用fvwm的Style命令。如果按钮栏是“粘”住的,你可能还想使面板也粘住。可能面板窗口不应该由图标,以防止其图标化。Style的配置如下:

Style <name_of_panel_window> NoTitle, Sitcky, NoIcon

你可能希望你的面板保持打开状态,直到你选择了一些东西,可以在命令中的-g选项之后为FvwmButtons提供-transientpanel选项。FvwmPager有一个类似的选项“-transient”。

最后但并非最不重要的是,现在可以在按钮中放置一个图标、一个标题、一个小箭头,以便可以看到它的作用。标题或图标可以照常指定。 要激活箭头,只需在上面的示例中的“Panel”关键字后面添加“(indicator)”,并使用“Padding”选项在箭头和按钮边框之间留下几个像素。面板打开时的可选方向也可以一并给出:

* FvwmButtons: (Padding 2, Panel(down, indicator) my_first_panel \
"Module FvwmButtons -g -30000-30000 -transientpanel my_first_panel")

还有几个选项可以用于配置面板如何工作,例如滑动动画的速度和平滑度。有关更多详细信息,请参阅Panel选项的说明。

旧配置文件的转换(CONVERTING OLD PANEL CONFIGURATIONS)

This section describes how to convert a pretty old syntax used in 2.2.x
versions. You may skip it if your syntax is more recent.
With the old panel feature you first had one or more lines defining panels in
your main FvwmButtons configuration:

...
*FvwmButtons(Title WinOps,Panel WinOps)
*FvwmButtons(Title Tools ,Panel Tools)
...
After the last configuration line for the main panel the configuration of the
first panel followed, introduced with a line beginning with *FvwmButtonsPanel:

*FvwmButtonsPanel WinOps
*FvwmButtonsBack bisque2
...

*FvwmButtonsPanel Tools
*FvwmButtonsBack bisque2
...
And perhaps you had style commands for you panels:

Style FvwmButtonsPanel Title, NoHandles, BorderWidth 0
Style FvwmButtonsPanel NoButton 2, NoButton 4, Sticky
The new configuration looks much the same, but now the configuration of the
main panel is independent of the configuration of the sub panels. The lines
invoking the panels use the same syntax as the Swallow option, so you simply
add the name of the window to use as a panel and the command to execute instead
of the panel name. Note that you give the new instance of FvwmButtons a
different name.

*FvwmButtons: (Title WinOps, Panel WinOps \
"Module FvwmButtons WinOps")
*FvwmButtons: (Title Tools , Panel Tools \
"Module FvwmButtons Tools")
If you used something like 'Panel-d' you now have to use 'Panel(down)' instead.
To make the new panel vanish as soon as a button was selected start FvwmButtons
with the '-transientpanel' option:

*FvwmButtons: (Title Tools , Panel(down) Tools \
"Module FvwmButtons -transientpanel Tools")
The rest of the configuration is very easy to change. Delete the lines
'*FvwmButtonsPanel <name>' and add <name> to all of the following configuration
lines for the panel instead. Use the same name in your Style commands:

*WinOps: Back bisque2
...
*Tools: Back bisque2
...
Style "WinOps" Title, NoHandles, BorderWidth 0
Style "WinOps" NoButton 2, NoButton 4, Sticky
Style "Tools" Title, NoHandles, BorderWidth 0
Style "Tools" NoButton 2, NoButton 4, Sticky
That's it. The new panels are much more flexible. Please refer to other parts
of this documentation for details.

WHY WAS THE PANEL FEATURE REWRITTEN?

有几个原因。 其中最重要的一点是执行面板的程序代码非常具有破坏性,造成了很多问题。 同时它也使得FvwmButtons的编写新功能变得困难。 第二个原因是大多数用户根本无法使其工作 - 这太复杂了。 即使我(新代码的作者)在第一次工作之前也要花费几个小时的时间。 第三个原因是新面板更通用。 任何应用程序都可以是FvwmButtons中的一个面板,而不仅仅是FvwmButtons本身的其他实例。 所以我衷心希望没有人为这个变化而生气。 是的 - 你必须改变你的配置,但新功能配置起来要容易得多,特别是如果你已经知道Swallow选项的工作方式。

排列算法(ARRANGEMENT ALGORITHM)

FvwmButtons试图通过递归地在包括buttonbox本身的每个容器上使用以下的算法来尽可能地安排它的按钮:

Getting the size right
首先,通过将每个按钮的width*height相加来获得需要的按钮单元区域。容器暂时被认为是一个正常的按钮。然后它使用给定的Rows和Columns参数。如果给出的Rows,它将计算需要多少列(Columns),并使用该Columns值,除非Columns较大,在这种情况下,会在buttonbox的底部得到一些空的空间。如果给出了Columns的数量,它会计算出所有按钮需要多少行(Rows)。如果Rows和Columns都没有给出,它假定你想要Rows为2,并计算出Columns的值。如果将BoxSize选项设置为smart,则至少使用最高/最宽按钮的高度/宽度,而fixed值可防止在行和列都设置为非零时重新调整框的大小。

Shuffling buttons
现在它有一个足够大的区域放置按钮,剩下的就是把它们放在正确的位置。有两种按钮:固定按钮和浮动按钮。 通过x/y参数将固定按钮强制放到按钮框中的特定槽中。所有其他按钮被认为是浮动的。固定的按钮首先被放置。如果一个固定的按钮与另一个按钮重叠,或者应该放在按钮窗口之外,则FvwmButtons会退出并显示一条错误消息。之后,浮动按钮被放置。 该算法试图将按钮从左到右,从上到下的风格。如果按钮位于建议的位置,则放置在该位置,否则当前插槽保持空白,并且将考虑右侧的插槽。 在按钮被放置后,下一个按钮被尝试放置在下一个槽中,依此类推,直到所有的按钮被放置。如果使用BoxSize选项smart,则在按钮底部的行下方会添加其他行,直到所有按钮都被放置为止。

Containers
Containers按照相同的算法进行排列,实际上它们是在算法找到它们时递归地进行混洗的。

Clarifying example
一个例子:假设你有6个按钮,所有的大小都为单位大小,除了第二个是2×2,即5*1+1*4=9,9个单位按钮面积。假设已经要求Columns为3。摆放次序如下:

 1) +---+---+---+   2) +---+---+---+   3) +---+---+---+
	| 1 |       |      | 1 |       |      | 1 |       |
	+---+       +      +---+   2   +      +---+   2   +
	|           |      |   |       |      | 3 |       |
	+           +      +   +---+---+      +---+---+---+
	|           |      |           |      |   |   |   |
	+-----------+      +---+-------+      +---+---+---+

 4) +---+---+---+   5) +---+-------+   6) +---+-------+
	| 1 |       |      | 1 |       |      | 1 |       |
	+---+   2   +      +---+   2   |      +---+   2   |
	| 3 |       |      | 3 |       |      | 3 |       |
	+---+---+---+      +---+---+---+      +---+-------+
	| 4 |       |      | 4 | 5 |   |      | 4 | 5 | 6 |
	+---+---+---+      +---+---+---+      +---+---+---+

What size will the buttons be?
当FvwmButtons读取其配置所需的图标和字体时,可以找出每个非吞咽按钮所需的大小。容器的单位按钮的尺寸被设置为足够大以容纳最大的按钮而不挤压它。简单地说,吞并的窗户对于从这个方案中得到的按钮大小来说是舒适的。 如果一个特定的配置需要更多的空间来放置一个被吞并的窗口,可以使用选项“Size width height”来设置该按钮。这将告诉FvwmButtons给这个按钮在浮雕和填充中至少宽度、高度的像素。

DYNAMICAL ACTIONS

A running FvwmButtons instance may receive some commands at run time. This is
achieved using the fvwm command

SendToModule FvwmButtons-Alias <action> <params>
Supported actions:
ChangeButton button_id options

can be used to change the title or icon of a button at run time.
button_id is the id of the button to change as specified using the Id
button option. It may also be a number, in this case the button with the
given number is assumed. And finally, button_id may be in the form +x+y,
where x and y are a column number and a row number of the button to be
changed. It is possible to specify multiple option pairs (name with
value) by delimiting them using comma. Currently options include Title,
ActiveTitle, PressTitle, Colorset, Icon, ActiveIcon and PressIcon. These
options work like the configuration options of the same name.
ExpandButtonVars button_id command
replaces variables present in the command exactly like in the Action
button option and then sends the command back to fvwm. button_id has the
same syntax as described in ChangeButton above.
PressButton button_id [mouse_button]
simulates a mouse click on a button. button_id is the id of the button to
press as specified using the Id button option and mouse_button is the
number of mouse button used to click on the button e.g "1" for the left
mouse button etc. Quotes around the number are not necessary. If
mouse_button option is omitted, mouse button 1 is assumed. This command
behaves exactly as if the mouse button was pressed and released on the
button on in question.
Silent
This prefix may be specified before other actions. It disables all
possible error and warning messages.
Example:
*FvwmButtons: (Id note1, Title "13:30 - Dinner", Icon clock1.xpm)
SendToModule FvwmButtons Silent \
ChangeButton note1 Icon clock2.xpm, Title "18:00 - Go Home"

简单的配置示例(SAMPLE CONFIGURATION)

以下是描述FvwmButtons初始化命令,摘录自.fvwm2rc文件:

##########################################################
# Load any modules which should be started during fvwm
# initialization

# Make sure FvwmButtons is always there.
AddToFunc StartFunction  "I" Module FvwmButtons

# Make it titlebar-less, sticky, and give it an icon
Style "FvwmButtons"     Icon toolbox.xpm, NoTitle, Sticky

# Make the menu/panel look like CDE
Style "WinOps" Title, NoHandles, BorderWidth 0
Style "WinOps" NoButton 2, NoButton 4, Sticky
Style "Tools" Title, NoHandles, BorderWidth 0
Style "Tools" NoButton 2, NoButton 4, Sticky

##########################################################
DestroyModuleConfig FvwmButtons: *
*FvwmButtons: Fore Black
*FvwmButtons: Back rgb:90/80/90
*FvwmButtons: Geometry -135-5
*FvwmButtons: Rows 1
*FvwmButtons: BoxSize smart
*FvwmButtons: Font -*-helvetica-medium-r-*-*-12-*
*FvwmButtons: Padding 2 2

*FvwmButtons: (Title WinOps, Panel WinOps "Module FvwmButtons -transientpanel WinOps")
*FvwmButtons: (Title Tools, Panel Tools "Module FvwmButtons -transientpanel Tools")

*FvwmButtons: (Title Resize, Icon resize.xpm,  Action Resize)
*FvwmButtons: (Title Move,   Icon arrows2.xpm, Action Move  )
*FvwmButtons: (Title Lower,  Icon Down,        Action Lower )
*FvwmButtons: (Title Raise,  Icon Up,          Action Raise )
*FvwmButtons: (Title Kill,   Icon bomb.xpm,    Action Destroy)

*FvwmButtons: (1x1,Container(Rows 3,Frame 1))
*FvwmButtons: (Title Dopey ,Action `Exec "big_win" xterm -T big_win -geometry 80x50 &`)
*FvwmButtons: (Title Snoopy, Font fixed, Action `Exec "small_win" xterm -T small_win &`)
*FvwmButtons: (Title Smokin')
*FvwmButtons: (End)

*FvwmButtons: (Title Xcalc, Icon rcalc.xpm, Action `Exec "Calculator" xcalc &`)
*FvwmButtons: (Title XMag, Icon magnifying_glass2.xpm, Action `Exec "xmag" xmag &`)
*FvwmButtons: (Title Mail, Icon mail2.xpm, Action `Exec "xmh" xmh &`)
*FvwmButtons: (4x1, Swallow "FvwmPager" `FvwmPager 0 3` Frame 3)

*FvwmButtons: (Swallow(UseOld,NoKill) "xload15" `Exec xload \
 -title xload15 -nolabel -bg rgb:90/80/90 -update 15    \
 -geometry -3000-3000 &`)

倒数第二行,作用是一个产生一个FvwmPager模块,并将它显示在一个四倍宽度的按钮中。被使用时,Pager将尽可能的填满按钮。

最后一行更神奇。注意UseOld和NoKill的组合,当启动时,它会试图“吞并”名为“xload15”的现有窗口,如果失败了,则使用指定的命令启动一个名为xload15的窗口,当结束FvwmButtons时,该窗口会被“吐”出来。吞并的应用程序以“-geometry -3000-3000”启动,以便在“吞并”之前不可见。

其他面板在root面板之后指定:

########## PANEL WinOps
DestroyModuleConfig WinOps: *
*WinOps: Back bisque2
*WinOps: Geometry -3-3
*WinOps: Columns 1

*WinOps: (Title Resize, Icon resize.xpm,  Action Resize)
*WinOps: (Title Move,   Icon arrows2.xpm, Action Move  )
*WinOps: (Title Lower,  Icon Down,        Action Lower )
*WinOps: (Title Raise,  Icon Up,          Action Raise )

########## PANEL Tools
DestroyModuleConfig Tools: *
*Tools: Back bisque2
*Tools: Geometry -1-1
*Tools: Columns 1

*Tools: (Title Kill,    Icon bomb.xpm,    Action Destroy)

颜色规范中rgb:90/80/90是X中指定独立颜色的正确方法,而不应该使用旧的#908090。 如果在你的配置文件中使用了后面的规范,那么应该使用反斜线(\)对井号(#)进行转义,否则剩下部分会被解析成注释。

请注意,使用x/y几何图形规格,可以轻松地构建带间隙的按钮窗口。下面是另一个例子。如果没有按钮的几何规格,则无法完成此操作:

##########################################################
# Another example
##########################################################

# Make it titlebar-less, sticky, and give it an icon
Style "FvwmButtons"     Icon toolbox.xpm, NoTitle, Sticky

DestroyModuleConfig FvwmButtons: *
*FvwmButtons: Font        5x7
*FvwmButtons: Back rgb:90/80/90
*FvwmButtons: Fore        black
*FvwmButtons: Frame       1
# 9x11 pixels per button, 4x4 pixels for the frame
*FvwmButtons: Geometry    580x59+0-0
*FvwmButtons: Rows        5
*FvwmButtons: Columns     64
*FvwmButtons: BoxSize     fixed
*FvwmButtons: Padding     1 1

# Pop up a module menu directly above the button.
*FvwmButtons: (9x1+3+0, Padding 0, Title "Modules",   \
  Action `Menu Modulepopup rectangle $widthx$height+$lleft+$top o+50 -100m`)

# first row of buttons from left to right:
*FvwmButtons: (3x2+0+1, Icon my_lock.xpm, Action `Exec xlock`)
*FvwmButtons: (3x2+3+1, Icon my_recapture.xpm, Action Recapture)
*FvwmButtons: (3x2+6+1, Icon my_resize.xpm, Action Resize)
*FvwmButtons: (3x2+9+1, Icon my_move.xpm, Action Move)
*FvwmButtons: (3x2+12+1, Icon my_fvwmconsole.xpm, Action 'Module FvwmConsole')

# second row of buttons from left to right:
*FvwmButtons: (3x2+0+3, Icon my_exit.xpm, Action QuitSave)
*FvwmButtons: (3x2+3+3, Icon my_restart.xpm, Action Restart)
*FvwmButtons: (3x2+6+3, Icon my_kill.xpm, Action Destroy)
*FvwmButtons: (3x2+9+3, Icon my_shell.xpm, Action 'Exec rxvt')

# big items
*FvwmButtons: (10x5, Swallow (NoKill, NoCLose) "FvwmPager" 'FvwmPager * * -geometry 40x40-1024-1024')
*FvwmButtons: (6x5, Swallow "FvwmXclock" `Exec xclock \
  -name FvwmXclock -geometry 40x40+0-3000 -padding 1  \
  -analog -chime -bg rgb:90/80/90`)
*FvwmButtons: (13x5, Swallow (NoClose) "FvwmIconMan" 'Module FvwmIconMan')
*FvwmButtons: (20x5, Padding 0, Swallow "xosview"     \
  `Exec /usr/X11R6/bin/xosview -cpu -int -page -net   \
  -geometry 100x50+0-3000 -font 5x7`)

存在的问题(BUGS)

Swallow选项的动作(action)部分如果包含了空格,则必须进行引用。

参考文献

猜你喜欢

转载自blog.csdn.net/u013670453/article/details/113028971