diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/frame.el | 120 |
1 files changed, 116 insertions, 4 deletions
diff --git a/lisp/frame.el b/lisp/frame.el index 391f23922f8..3abb72cb859 100644 --- a/lisp/frame.el +++ b/lisp/frame.el | |||
| @@ -1312,6 +1312,80 @@ live frame and defaults to the selected one." | |||
| 1312 | (setq vertical default-frame-scroll-bars)) | 1312 | (setq vertical default-frame-scroll-bars)) |
| 1313 | (cons vertical (and horizontal 'bottom)))) | 1313 | (cons vertical (and horizontal 'bottom)))) |
| 1314 | 1314 | ||
| 1315 | (declare-function x-frame-geometry "xfns.c" (&optional frame)) | ||
| 1316 | (declare-function w32-frame-geometry "w32fns.c" (&optional frame)) | ||
| 1317 | (declare-function ns-frame-geometry "nsfns.m" (&optional frame)) | ||
| 1318 | |||
| 1319 | (defun frame-geometry (&optional frame) | ||
| 1320 | "Return geometric attributes of FRAME. | ||
| 1321 | FRAME must be a live frame and defaults to the selected one. The return | ||
| 1322 | value is an association list of the attributes listed below. All height | ||
| 1323 | and width values are in pixels. | ||
| 1324 | |||
| 1325 | `outer-position' is a cons of the outer left and top edges of FRAME | ||
| 1326 | relative to the origin - the position (0, 0) - of FRAME's display. | ||
| 1327 | |||
| 1328 | `outer-size' is a cons of the outer width and height of FRAME. The | ||
| 1329 | outer size includes the title bar and the external borders as well as | ||
| 1330 | any menu and/or tool bar of frame. | ||
| 1331 | |||
| 1332 | `external-border-size' is a cons of the horizontal and vertical width of | ||
| 1333 | FRAME's external borders as supplied by the window manager. | ||
| 1334 | |||
| 1335 | `title-bar-size' is a cons of the width and height of the title bar of | ||
| 1336 | FRAME as supplied by the window manager. If both of them are zero, | ||
| 1337 | FRAME has no title bar. If only the width is zero, Emacs was not | ||
| 1338 | able to retrieve the width information. | ||
| 1339 | |||
| 1340 | `menu-bar-external', if non-nil, means the menu bar is external (never | ||
| 1341 | included in the inner edges of FRAME). | ||
| 1342 | |||
| 1343 | `menu-bar-size' is a cons of the width and height of the menu bar of | ||
| 1344 | FRAME. | ||
| 1345 | |||
| 1346 | `tool-bar-external', if non-nil, means the tool bar is external (never | ||
| 1347 | included in the inner edges of FRAME). | ||
| 1348 | |||
| 1349 | `tool-bar-position' tells on which side the tool bar on FRAME is and can | ||
| 1350 | be one of `left', `top', `right' or `bottom'. If this is nil, FRAME | ||
| 1351 | has no tool bar. | ||
| 1352 | |||
| 1353 | `tool-bar-size' is a cons of the width and height of the tool bar of | ||
| 1354 | FRAME. | ||
| 1355 | |||
| 1356 | `internal-border-width' is the width of the internal border of | ||
| 1357 | FRAME." | ||
| 1358 | (let* ((frame (window-normalize-frame frame)) | ||
| 1359 | (frame-type (framep-on-display frame))) | ||
| 1360 | (cond | ||
| 1361 | ((eq frame-type 'x) | ||
| 1362 | (x-frame-geometry frame)) | ||
| 1363 | ((eq frame-type 'w32) | ||
| 1364 | (w32-frame-geometry frame)) | ||
| 1365 | ((eq frame-type 'ns) | ||
| 1366 | (ns-frame-geometry frame)) | ||
| 1367 | (t | ||
| 1368 | (list | ||
| 1369 | '(outer-position 0 . 0) | ||
| 1370 | (cons 'outer-size (cons (frame-width frame) (frame-height frame))) | ||
| 1371 | '(external-border-size 0 . 0) | ||
| 1372 | '(title-bar-size 0 . 0) | ||
| 1373 | '(menu-bar-external . nil) | ||
| 1374 | (let ((menu-bar-lines (frame-parameter frame 'menu-bar-lines))) | ||
| 1375 | (cons 'menu-bar-size | ||
| 1376 | (if menu-bar-lines | ||
| 1377 | (cons (frame-width frame) 1) | ||
| 1378 | 1 0))) | ||
| 1379 | '(tool-bar-external . nil) | ||
| 1380 | '(tool-bar-position . nil) | ||
| 1381 | '(tool-bar-size 0 . 0) | ||
| 1382 | (cons 'internal-border-width | ||
| 1383 | (frame-parameter frame 'internal-border-width))))))) | ||
| 1384 | |||
| 1385 | (declare-function x-frame-edges "xfns.c" (&optional frame type)) | ||
| 1386 | (declare-function w32-frame-edges "w32fns.c" (&optional frame type)) | ||
| 1387 | (declare-function ns-frame-edges "nsfns.m" (&optional frame type)) | ||
| 1388 | |||
| 1315 | (defun frame-edges (&optional frame type) | 1389 | (defun frame-edges (&optional frame type) |
| 1316 | "Return coordinates of FRAME's edges. | 1390 | "Return coordinates of FRAME's edges. |
| 1317 | FRAME must be a live frame and defaults to the selected one. The | 1391 | FRAME must be a live frame and defaults to the selected one. The |
| @@ -1325,10 +1399,48 @@ Optional argument TYPE specifies the type of the edges. TYPE | |||
| 1325 | `native-edges' (or nil) means to return the native edges of | 1399 | `native-edges' (or nil) means to return the native edges of |
| 1326 | FRAME. TYPE `inner-edges' means to return the inner edges of | 1400 | FRAME. TYPE `inner-edges' means to return the inner edges of |
| 1327 | FRAME." | 1401 | FRAME." |
| 1328 | (let ((frame (window-normalize-frame frame))) | 1402 | (let* ((frame (window-normalize-frame frame)) |
| 1329 | (if (display-graphic-p (frame-parameter nil 'display)) | 1403 | (frame-type (framep-on-display frame))) |
| 1330 | (x-frame-edges frame (or type 'native-edges)) | 1404 | (cond |
| 1331 | (list 0 0 (frame-width frame) (frame-height frame))))) | 1405 | ((eq frame-type 'x) |
| 1406 | (x-frame-edges frame type)) | ||
| 1407 | ((eq frame-type 'w32) | ||
| 1408 | (w32-frame-edges frame type)) | ||
| 1409 | ((eq frame-type 'ns) | ||
| 1410 | (ns-frame-edges frame type)) | ||
| 1411 | (t | ||
| 1412 | (list 0 0 (frame-width frame) (frame-height frame)))))) | ||
| 1413 | |||
| 1414 | (declare-function w32-mouse-absolute-pixel-position "w32fns.c") | ||
| 1415 | (declare-function x-mouse-absolute-pixel-position "xfns.c") | ||
| 1416 | |||
| 1417 | (defun mouse-absolute-pixel-position () | ||
| 1418 | "Return absolute position of mouse cursor in pixels. | ||
| 1419 | The position is returned as a cons cell (X . Y) of the | ||
| 1420 | coordinates of the mouse cursor position in pixels relative to a | ||
| 1421 | position (0, 0) of the selected frame's terminal." | ||
| 1422 | (let ((frame-type (framep-on-display))) | ||
| 1423 | (cond | ||
| 1424 | ((eq frame-type 'x) | ||
| 1425 | (x-mouse-absolute-pixel-position)) | ||
| 1426 | ((eq frame-type 'w32) | ||
| 1427 | (w32-mouse-absolute-pixel-position)) | ||
| 1428 | (t | ||
| 1429 | (cons 0 0))))) | ||
| 1430 | |||
| 1431 | (declare-function w32-set-mouse-absolute-pixel-position "w32fns.c" (x y)) | ||
| 1432 | (declare-function x-set-mouse-absolute-pixel-position "xfns.c" (x y)) | ||
| 1433 | |||
| 1434 | (defun set-mouse-absolute-pixel-position (x y) | ||
| 1435 | "Move mouse pointer to absolute pixel position (X, Y). | ||
| 1436 | The coordinates X and Y are interpreted in pixels relative to a | ||
| 1437 | position (0, 0) of the selected frame's terminal." | ||
| 1438 | (let ((frame-type (framep-on-display))) | ||
| 1439 | (cond | ||
| 1440 | ((eq frame-type 'x) | ||
| 1441 | (x-set-mouse-absolute-pixel-position x y)) | ||
| 1442 | ((eq frame-type 'w32) | ||
| 1443 | (w32-set-mouse-absolute-pixel-position x y))))) | ||
| 1332 | 1444 | ||
| 1333 | (defun frame-monitor-attributes (&optional frame) | 1445 | (defun frame-monitor-attributes (&optional frame) |
| 1334 | "Return the attributes of the physical monitor dominating FRAME. | 1446 | "Return the attributes of the physical monitor dominating FRAME. |