aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMartin Rudalics2015-08-21 11:00:59 +0200
committerMartin Rudalics2015-08-21 11:00:59 +0200
commitdf9b29eda0ba1ec7f751dfd538eefbfe56b2c043 (patch)
treec3797cfe3d7c8596438a88502838652f14703582 /lisp
parent092e17b1978d804df99fae9436f24c0ea0d7e034 (diff)
downloademacs-df9b29eda0ba1ec7f751dfd538eefbfe56b2c043.tar.gz
emacs-df9b29eda0ba1ec7f751dfd538eefbfe56b2c043.zip
Sanitize frame geometry related functions
* src/nsfns.m (Fx_frame_geometry): Rename to Fns_frame_geometry. (Fx_frame_edges): Rename to Fns_frame_edges. * src/w32fns.c (Fx_frame_geometry): Rename to Fw32_frame_geometry. (Fx_frame_edges): Rename to Fw32_frame_edges. (Fx_mouse_absolute_pixel_position): Rename to Fw32_mouse_absolute_pixel_position. (Fx_set_mouse_absolute_pixel_position): Rename to Fw32_set_mouse_absolute_pixel_position. * lisp/frame.el (x-frame-geometry, w32-frame-geometry) (ns-frame-geometry, x-frame-edges, w32-frame-edges) (ns-frame-edges, w32-mouse-absolute-pixel-position) (x-mouse-absolute-pixel-position) (w32-set-mouse-absolute-pixel-position) (x-set-mouse-absolute-pixel-position): Declare. (frame-geometry, mouse-absolute-pixel-position) (set-mouse-absolute-pixel-position): New functions. (frame-edges): Rewrite in terms of x-/w32-/ns-frame-edges.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/frame.el120
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.
1321FRAME must be a live frame and defaults to the selected one. The return
1322value is an association list of the attributes listed below. All height
1323and 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.
1317FRAME must be a live frame and defaults to the selected one. The 1391FRAME 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
1326FRAME. TYPE `inner-edges' means to return the inner edges of 1400FRAME. TYPE `inner-edges' means to return the inner edges of
1327FRAME." 1401FRAME."
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.
1419The position is returned as a cons cell (X . Y) of the
1420coordinates of the mouse cursor position in pixels relative to a
1421position (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).
1436The coordinates X and Y are interpreted in pixels relative to a
1437position (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.