aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2015-08-21 11:00:59 +0200
committerMartin Rudalics2015-08-21 11:00:59 +0200
commitdf9b29eda0ba1ec7f751dfd538eefbfe56b2c043 (patch)
treec3797cfe3d7c8596438a88502838652f14703582
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.
-rw-r--r--lisp/frame.el120
-rw-r--r--src/nsfns.m8
-rw-r--r--src/w32fns.c20
3 files changed, 130 insertions, 18 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.
diff --git a/src/nsfns.m b/src/nsfns.m
index e9453604592..d317d48608c 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2906,7 +2906,7 @@ frame_geometry (Lisp_Object frame, Lisp_Object attribute)
2906 make_number (internal_border_width))); 2906 make_number (internal_border_width)));
2907} 2907}
2908 2908
2909DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0, 2909DEFUN ("ns-frame-geometry", Fns_frame_geometry, Sns_frame_geometry, 0, 1, 0,
2910 doc: /* Return geometric attributes of FRAME. 2910 doc: /* Return geometric attributes of FRAME.
2911FRAME must be a live frame and defaults to the selected one. The return 2911FRAME must be a live frame and defaults to the selected one. The return
2912value is an association list of the attributes listed below. All height 2912value is an association list of the attributes listed below. All height
@@ -2950,7 +2950,7 @@ and width values are in pixels.
2950 return frame_geometry (frame, Qnil); 2950 return frame_geometry (frame, Qnil);
2951} 2951}
2952 2952
2953DEFUN ("x-frame-edges", Fx_frame_edges, Sx_frame_edges, 0, 2, 0, 2953DEFUN ("ns-frame-edges", Fns_frame_edges, Sns_frame_edges, 0, 2, 0,
2954 doc: /* Return edge coordinates of FRAME. 2954 doc: /* Return edge coordinates of FRAME.
2955FRAME must be a live frame and defaults to the selected one. The return 2955FRAME must be a live frame and defaults to the selected one. The return
2956value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are 2956value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are
@@ -3156,8 +3156,8 @@ be used as the image of the icon representing the frame. */);
3156 defsubr (&Sx_display_pixel_width); 3156 defsubr (&Sx_display_pixel_width);
3157 defsubr (&Sx_display_pixel_height); 3157 defsubr (&Sx_display_pixel_height);
3158 defsubr (&Sns_display_monitor_attributes_list); 3158 defsubr (&Sns_display_monitor_attributes_list);
3159 defsubr (&Sx_frame_geometry); 3159 defsubr (&Sns_frame_geometry);
3160 defsubr (&Sx_frame_edges); 3160 defsubr (&Sns_frame_edges);
3161 defsubr (&Sx_display_mm_width); 3161 defsubr (&Sx_display_mm_width);
3162 defsubr (&Sx_display_mm_height); 3162 defsubr (&Sx_display_mm_height);
3163 defsubr (&Sx_display_screens); 3163 defsubr (&Sx_display_screens);
diff --git a/src/w32fns.c b/src/w32fns.c
index a47f3f9a8dc..f16bf762127 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -8002,7 +8002,7 @@ This is a direct interface to the Windows API FindWindow function. */)
8002 return Qt; 8002 return Qt;
8003} 8003}
8004 8004
8005DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0, 8005DEFUN ("w32-frame-geometry", Fw32_frame_geometry, Sw32_frame_geometry, 0, 1, 0,
8006 doc: /* Return geometric attributes of FRAME. 8006 doc: /* Return geometric attributes of FRAME.
8007FRAME must be a live frame and defaults to the selected one. The return 8007FRAME must be a live frame and defaults to the selected one. The return
8008value is an association list of the attributes listed below. All height 8008value is an association list of the attributes listed below. All height
@@ -8138,7 +8138,7 @@ and width values are in pixels.
8138 make_number (internal_border_width))); 8138 make_number (internal_border_width)));
8139} 8139}
8140 8140
8141DEFUN ("x-frame-edges", Fx_frame_edges, Sx_frame_edges, 0, 2, 0, 8141DEFUN ("w32-frame-edges", Fw32_frame_edges, Sw32_frame_edges, 0, 2, 0,
8142 doc: /* Return edge coordinates of FRAME. 8142 doc: /* Return edge coordinates of FRAME.
8143FRAME must be a live frame and defaults to the selected one. The return 8143FRAME must be a live frame and defaults to the selected one. The return
8144value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are 8144value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are
@@ -8213,8 +8213,8 @@ menu bar or tool bar of FRAME. */)
8213 } 8213 }
8214} 8214}
8215 8215
8216DEFUN ("x-mouse-absolute-pixel-position", Fx_mouse_absolute_pixel_position, 8216DEFUN ("w32-mouse-absolute-pixel-position", Fw32_mouse_absolute_pixel_position,
8217 Sx_mouse_absolute_pixel_position, 0, 0, 0, 8217 Sw32_mouse_absolute_pixel_position, 0, 0, 0,
8218 doc: /* Return absolute position of mouse cursor in pixels. 8218 doc: /* Return absolute position of mouse cursor in pixels.
8219The position is returned as a cons cell (X . Y) of the coordinates of 8219The position is returned as a cons cell (X . Y) of the coordinates of
8220the mouse cursor position in pixels relative to a position (0, 0) of the 8220the mouse cursor position in pixels relative to a position (0, 0) of the
@@ -8230,8 +8230,8 @@ selected frame's display. */)
8230 return Fcons (make_number (pt.x), make_number (pt.y)); 8230 return Fcons (make_number (pt.x), make_number (pt.y));
8231} 8231}
8232 8232
8233DEFUN ("x-set-mouse-absolute-pixel-position", Fx_set_mouse_absolute_pixel_position, 8233DEFUN ("w32-set-mouse-absolute-pixel-position", Fw32_set_mouse_absolute_pixel_position,
8234 Sx_set_mouse_absolute_pixel_position, 2, 2, 0, 8234 Sw32_set_mouse_absolute_pixel_position, 2, 2, 0,
8235 doc: /* Move mouse pointer to absolute pixel position (X, Y). 8235 doc: /* Move mouse pointer to absolute pixel position (X, Y).
8236The coordinates X and Y are interpreted in pixels relative to a position 8236The coordinates X and Y are interpreted in pixels relative to a position
8237(0, 0) of the selected frame's display. */) 8237(0, 0) of the selected frame's display. */)
@@ -9280,10 +9280,10 @@ This variable has effect only on Windows Vista and later. */);
9280 defsubr (&Sx_open_connection); 9280 defsubr (&Sx_open_connection);
9281 defsubr (&Sx_close_connection); 9281 defsubr (&Sx_close_connection);
9282 defsubr (&Sx_display_list); 9282 defsubr (&Sx_display_list);
9283 defsubr (&Sx_frame_geometry); 9283 defsubr (&Sw32_frame_geometry);
9284 defsubr (&Sx_frame_edges); 9284 defsubr (&Sw32_frame_edges);
9285 defsubr (&Sx_mouse_absolute_pixel_position); 9285 defsubr (&Sw32_mouse_absolute_pixel_position);
9286 defsubr (&Sx_set_mouse_absolute_pixel_position); 9286 defsubr (&Sw32_set_mouse_absolute_pixel_position);
9287 defsubr (&Sx_synchronize); 9287 defsubr (&Sx_synchronize);
9288 9288
9289 /* W32 specific functions */ 9289 /* W32 specific functions */