简体   繁体   English

从Emacs 23中的x-display-pixel-width到Emacs 24中的display-monitor-attributes-list

[英]From x-display-pixel-width in Emacs 23 to display-monitor-attributes-list in Emacs 24

In Emacs 23, evaluating 在Emacs 23中,评估

(x-display-pixel-width)

yielded the width of the current window. 产生当前窗口的宽度。

In Emacs 24 the same expression returns the combined width of all windows. 在Emacs 24中,相同的表达式返回所有窗口的合并宽度。

How does one return the width of just the main/current window while evaluating the related, but new and improved, function 在评估相关但新的和改进的功能时,如何只返回主窗口/当前窗口的宽度

(display-monitor-attributes-list)

?

Take a look at display-monitor-attribute-list : 看一下display-monitor-attribute-list

(display-monitor-attributes-list &optional DISPLAY) (显示监视器属性列表和可选的显示)

Return a list of physical monitor attributes on DISPLAY. 返回DISPLAY上物理监视器属性的列表。 Each element of the list represents the attributes of each physical monitor. 列表中的每个元素代表每个物理监视器的属性。 The first element corresponds to the primary monitor. 第一个元素对应于主监视器。

Attributes for a physical monitor is represented as an alist of attribute keys and values as follows: 物理监视器的属性表示为属性键和值的列表,如下所示:

geometry -- Position and size in pixels in the form of (XY WIDTH HEIGHT) workarea -- Position and size of the workarea in pixels in the form of (XY WIDTH HEIGHT) mm-size -- Width and height in millimeters in the form of (WIDTH HEIGHT) frames -- List of frames dominated by the physical monitor name (*) -- Name of the physical monitor as a string 几何-(XY宽度高度)工作区形式的像素位置和大小-(XY宽度高度)形式的工作区像素位置和大小mm尺寸-毫米形式的宽度和高度(WIDTH HEIGHT)帧数-以物理监视器名称(*)为主的帧列表-物理监视器的名称为字符串

where X, Y, WIDTH, and HEIGHT are integers. 其中X,Y,WIDTH和HEIGHT是整数。 Keys labeled with (*) are optional. 标有(*)的键是可选的。

A frame is dominated by a physical monitor when either the largest area of the frame resides in the monitor, or the monitor is the closest to the frame if the frame does not intersect any physical monitors. 当框架中最大的区域位于监视器中时,则该框架由物理监视器控制;如果框架不与任何物理监视器相交,则该监视器最接近该框架。 Every non-tip frame (including invisible one) in a graphical display is dominated by exactly one physical monitor at a time, though it can span multiple (or no) physical monitors. 图形显示中的每个非提示帧(包括不可见的帧)一次仅由一个物理监视器控制,尽管它可以跨越多个(或没有)物理监视器。 If DISPLAY is omitted or nil, it defaults to the selected frame's display. 如果省略DISPLAY或nil,则默认为所选帧的显示。

For example, to find the width of the first monitor, you could use: 例如,要查找第一个监视器的宽度,可以使用:

(nth 4 (assq 'geometry (car (display-monitor-attributes-list))))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM