aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Rudalics2015-08-18 16:45:27 +0200
committerMartin Rudalics2015-08-18 16:45:27 +0200
commitc29a51df2de7eb800edf8e2235ee6c34bd1c9562 (patch)
tree6565569f905ccf1ea699f90f0390b43ed2c2b38b /src
parentab759c2241e759ba7783323bbfef137bc0a08634 (diff)
downloademacs-c29a51df2de7eb800edf8e2235ee6c34bd1c9562.tar.gz
emacs-c29a51df2de7eb800edf8e2235ee6c34bd1c9562.zip
Rewrite and add frame geometry related functions.
* src/frame.c (Fframe_position): New function. (Fset_frame_position): Rename parameters and rewrite doc-string. (syms_of_frame): Remove Qframe_position, Qframe_outer_size, Qtitle_height and Qframe_inner_size. Add Qouter_edges, Qouter_position, Qouter_size, Qnative_edges, Qinner_edges, Qtitle_bar_size. * src/nsfns.m (frame_geometry): New function. (Fx_frame_geometry): Call frame_geometry. (Fx_frame_edges): New function. * src/w32fns.c (C_CHILDREN_TITLEBAR, TITLEBAR_INFO) (GetTitleBarInfo_Proc): Define these so we can use the GetTitleBarInfo API. (Fw32_frame_menu_bar_size, Fw32_frame_rect): Remove. (Fx_frame_geometry): Rewrite. (Fx_frame_edges, Fx_mouse_absolute_pixel_position) (Fx_set_mouse_absolute_pixel_position): New functions. * src/xfns.c (frame_geometry): New function. (Fx_frame_geometry): Call frame_geometry. (Fx_frame_edges, Fx_mouse_absolute_pixel_position) (Fx_set_mouse_absolute_pixel_position): New functions.
Diffstat (limited to 'src')
-rw-r--r--src/frame.c45
-rw-r--r--src/nsfns.m186
-rw-r--r--src/w32fns.c348
-rw-r--r--src/xfns.c325
4 files changed, 594 insertions, 310 deletions
diff --git a/src/frame.c b/src/frame.c
index 9e695982d2b..20440489381 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2977,24 +2977,40 @@ font height. */)
2977 return Qnil; 2977 return Qnil;
2978} 2978}
2979 2979
2980DEFUN ("frame-position", Fframe_position,
2981 Sframe_position, 0, 1, 0,
2982 doc: /* Return top left corner of FRAME in pixels.
2983FRAME must be a live frame and defaults to the selected one. The return
2984value is a cons (x, y) of the coordinates of the top left corner of
2985FRAME's outer frame, in pixels relative to an origin (0, 0) of FRAME's
2986display. */)
2987 (Lisp_Object frame)
2988{
2989 register struct frame *f = decode_live_frame (frame);
2990
2991 return Fcons (make_number (f->left_pos), make_number (f->top_pos));
2992}
2993
2980DEFUN ("set-frame-position", Fset_frame_position, 2994DEFUN ("set-frame-position", Fset_frame_position,
2981 Sset_frame_position, 3, 3, 0, 2995 Sset_frame_position, 3, 3, 0,
2982 doc: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET. 2996 doc: /* Set position of FRAME to (X, Y).
2983If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are 2997FRAME must be a live frame and defaults to the selected one. X and Y,
2984actually the position of the upper left corner of the frame. Negative 2998if positive, specify the coordinate of the left and top edge of FRAME's
2985values for XOFFSET or YOFFSET are interpreted relative to the rightmost 2999outer frame in pixels relative to an origin (0, 0) of FRAME's display.
2986or bottommost possible position (that stays within the screen). */) 3000If any of X or Y is negative, it specifies the coordinates of the right
2987 (Lisp_Object frame, Lisp_Object xoffset, Lisp_Object yoffset) 3001or bottom edge of the outer frame of FRAME relative to the right or
3002bottom edge of FRAME's display. */)
3003 (Lisp_Object frame, Lisp_Object x, Lisp_Object y)
2988{ 3004{
2989 register struct frame *f = decode_live_frame (frame); 3005 register struct frame *f = decode_live_frame (frame);
2990 3006
2991 CHECK_TYPE_RANGED_INTEGER (int, xoffset); 3007 CHECK_TYPE_RANGED_INTEGER (int, x);
2992 CHECK_TYPE_RANGED_INTEGER (int, yoffset); 3008 CHECK_TYPE_RANGED_INTEGER (int, y);
2993 3009
2994 /* I think this should be done with a hook. */ 3010 /* I think this should be done with a hook. */
2995#ifdef HAVE_WINDOW_SYSTEM 3011#ifdef HAVE_WINDOW_SYSTEM
2996 if (FRAME_WINDOW_P (f)) 3012 if (FRAME_WINDOW_P (f))
2997 x_set_offset (f, XINT (xoffset), XINT (yoffset), 1); 3013 x_set_offset (f, XINT (x), XINT (y), 1);
2998#endif 3014#endif
2999 3015
3000 return Qt; 3016 return Qt;
@@ -4890,15 +4906,17 @@ syms_of_frame (void)
4890 DEFSYM (Qframes, "frames"); 4906 DEFSYM (Qframes, "frames");
4891 DEFSYM (Qsource, "source"); 4907 DEFSYM (Qsource, "source");
4892 4908
4893 DEFSYM (Qframe_position, "frame-position"); 4909 DEFSYM (Qouter_edges, "outer-edges");
4894 DEFSYM (Qframe_outer_size, "frame-outer-size"); 4910 DEFSYM (Qouter_position, "outer-position");
4911 DEFSYM (Qouter_size, "outer-size");
4912 DEFSYM (Qnative_edges, "native-edges");
4913 DEFSYM (Qinner_edges, "inner-edges");
4895 DEFSYM (Qexternal_border_size, "external-border-size"); 4914 DEFSYM (Qexternal_border_size, "external-border-size");
4896 DEFSYM (Qtitle_height, "title-height"); 4915 DEFSYM (Qtitle_bar_size, "title-bar-size");
4897 DEFSYM (Qmenu_bar_external, "menu-bar-external"); 4916 DEFSYM (Qmenu_bar_external, "menu-bar-external");
4898 DEFSYM (Qmenu_bar_size, "menu-bar-size"); 4917 DEFSYM (Qmenu_bar_size, "menu-bar-size");
4899 DEFSYM (Qtool_bar_external, "tool-bar-external"); 4918 DEFSYM (Qtool_bar_external, "tool-bar-external");
4900 DEFSYM (Qtool_bar_size, "tool-bar-size"); 4919 DEFSYM (Qtool_bar_size, "tool-bar-size");
4901 DEFSYM (Qframe_inner_size, "frame-inner-size");
4902 /* The following are used for frame_size_history. */ 4920 /* The following are used for frame_size_history. */
4903 DEFSYM (Qadjust_frame_size_1, "adjust-frame-size-1"); 4921 DEFSYM (Qadjust_frame_size_1, "adjust-frame-size-1");
4904 DEFSYM (Qadjust_frame_size_2, "adjust-frame-size-2"); 4922 DEFSYM (Qadjust_frame_size_2, "adjust-frame-size-2");
@@ -5263,6 +5281,7 @@ in a more readable form. */);
5263 defsubr (&Sset_frame_height); 5281 defsubr (&Sset_frame_height);
5264 defsubr (&Sset_frame_width); 5282 defsubr (&Sset_frame_width);
5265 defsubr (&Sset_frame_size); 5283 defsubr (&Sset_frame_size);
5284 defsubr (&Sframe_position);
5266 defsubr (&Sset_frame_position); 5285 defsubr (&Sset_frame_position);
5267 defsubr (&Sframe_pointer_visible_p); 5286 defsubr (&Sframe_pointer_visible_p);
5268 5287
diff --git a/src/nsfns.m b/src/nsfns.m
index 0fc867c1ebb..e9453604592 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2836,91 +2836,142 @@ Value is t if tooltip was open, nil otherwise. */)
2836 return Qt; 2836 return Qt;
2837} 2837}
2838 2838
2839DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0, 2839/* Return geometric attributes of FRAME. According to the value of
2840 doc: /* Return geometric attributes of frame FRAME. 2840 ATTRIBUTES return the outer edges of FRAME (Qouter_edges), the inner
2841 edges of FRAME, the root window edges of frame (Qroot_edges). Any
2842 other value means to return the geometry as returned by
2843 Fx_frame_geometry. */
2844static Lisp_Object
2845frame_geometry (Lisp_Object frame, Lisp_Object attribute)
2846{
2847 struct frame *f = decode_live_frame (frame);
2848 Lisp_Object fullscreen_symbol = Fframe_parameter (frame, Qfullscreen);
2849 bool fullscreen = (EQ (fullscreen_symbol, Qfullboth)
2850 || EQ (fullscreen_symbol, Qfullscreen));
2851 int border = fullscreen ? 0 : f->border_width;
2852 int title_height = fullscreen ? 0 : FRAME_NS_TITLEBAR_HEIGHT (f);
2853 int native_width = FRAME_PIXEL_WIDTH (f);
2854 int native_height = FRAME_PIXEL_HEIGHT (f);
2855 int outer_width = native_width + 2 * border;
2856 int outer_height = native_height + 2 * border + title_height;
2857 int native_left = f->left_pos + border;
2858 int native_top = f->top_pos + border + title_height;
2859 int native_right = f->left_pos + outer_width - border;
2860 int native_bottom = f->top_pos + outer_height - border;
2861 int internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f);
2862 int tool_bar_height = FRAME_TOOLBAR_HEIGHT (f);
2863 int tool_bar_width = (tool_bar_height
2864 ? outer_width - 2 * internal_border_width
2865 : 0);
2866
2867 /* Construct list. */
2868 if (EQ (attribute, Qouter_edges))
2869 return list4 (make_number (f->left_pos), make_number (f->top_pos),
2870 make_number (f->left_pos + outer_width),
2871 make_number (f->top_pos + outer_height));
2872 else if (EQ (attribute, Qnative_edges))
2873 return list4 (make_number (native_left), make_number (native_top),
2874 make_number (native_right), make_number (native_bottom));
2875 else if (EQ (attribute, Qinner_edges))
2876 return list4 (make_number (native_left + internal_border_width),
2877 make_number (native_top
2878 + tool_bar_height
2879 + internal_border_width),
2880 make_number (native_right - internal_border_width),
2881 make_number (native_bottom - internal_border_width));
2882 else
2883 return
2884 listn (CONSTYPE_HEAP, 10,
2885 Fcons (Qouter_position,
2886 Fcons (make_number (f->left_pos),
2887 make_number (f->top_pos))),
2888 Fcons (Qouter_size,
2889 Fcons (make_number (outer_width),
2890 make_number (outer_height))),
2891 Fcons (Qexternal_border_size,
2892 (fullscreen
2893 ? Fcons (make_number (0), make_number (0))
2894 : Fcons (make_number (border), make_number (border)))),
2895 Fcons (Qtitle_bar_size,
2896 Fcons (make_number (0), make_number (title_height))),
2897 Fcons (Qmenu_bar_external, Qnil),
2898 Fcons (Qmenu_bar_size, Fcons (make_number (0), make_number (0))),
2899 Fcons (Qtool_bar_external,
2900 FRAME_EXTERNAL_TOOL_BAR (f) ? Qt : Qnil),
2901 Fcons (Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f)),
2902 Fcons (Qtool_bar_size,
2903 Fcons (make_number (tool_bar_width),
2904 make_number (tool_bar_height))),
2905 Fcons (Qinternal_border_width,
2906 make_number (internal_border_width)));
2907}
2841 2908
2842FRAME must be a live frame and defaults to the selected one. 2909DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0,
2910 doc: /* Return geometric attributes of FRAME.
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
2913and width values are in pixels.
2843 2914
2844The return value is an association list containing the following 2915`outer-position' is a cons of the outer left and top edges of FRAME
2845elements (all size values are in pixels). 2916 relative to the origin - the position (0, 0) - of FRAME's display.
2846 2917
2847- `frame-outer-size' is a cons of the outer width and height of FRAME. 2918`outer-size' is a cons of the outer width and height of FRAME. The
2848 The outer size include the title bar and the external borders as well 2919 outer size includes the title bar and the external borders as well as
2849 as any menu and/or tool bar of frame. 2920 any menu and/or tool bar of frame.
2850 2921
2851- `border' is a cons of the horizontal and vertical width of FRAME's 2922`external-border-size' is a cons of the horizontal and vertical width of
2852 external borders. 2923 FRAME's external borders as supplied by the window manager.
2853 2924
2854- `title-bar-height' is the height of the title bar of FRAME. 2925`title-bar-size' is a cons of the width and height of the title bar of
2926 FRAME as supplied by the window manager. If both of them are zero,
2927 FRAME has no title bar. If only the width is zero, Emacs was not
2928 able to retrieve the width information.
2855 2929
2856- `menu-bar-external' if t means the menu bar is external (not 2930`menu-bar-external', if non-nil, means the menu bar is external (never
2857 included in the inner edges of FRAME). 2931 included in the inner edges of FRAME).
2858 2932
2859- `menu-bar-size' is a cons of the width and height of the menu bar of 2933`menu-bar-size' is a cons of the width and height of the menu bar of
2860 FRAME. 2934 FRAME.
2861 2935
2862- `tool-bar-external' if t means the tool bar is external (not 2936`tool-bar-external', if non-nil, means the tool bar is external (never
2863 included in the inner edges of FRAME). 2937 included in the inner edges of FRAME).
2864 2938
2865- `tool-bar-side' tells tells on which side the tool bar on FRAME is and 2939`tool-bar-position' tells on which side the tool bar on FRAME is and can
2866 can be one of `left', `top', `right' or `bottom'. 2940 be one of `left', `top', `right' or `bottom'. If this is nil, FRAME
2941 has no tool bar.
2867 2942
2868- `tool-bar-size' is a cons of the width and height of the tool bar of 2943`tool-bar-size' is a cons of the width and height of the tool bar of
2869 FRAME. 2944 FRAME.
2870 2945
2871- `frame-inner-size' is a cons of the inner width and height of FRAME. 2946`internal-border-width' is the width of the internal border of
2872 This excludes FRAME's title bar and external border as well as any 2947 FRAME. */)
2873 external menu and/or tool bar. */)
2874 (Lisp_Object frame) 2948 (Lisp_Object frame)
2875{ 2949{
2876 struct frame *f = decode_live_frame (frame); 2950 return frame_geometry (frame, Qnil);
2877 int inner_width = FRAME_PIXEL_WIDTH (f); 2951}
2878 int inner_height = FRAME_PIXEL_HEIGHT (f); 2952
2879 Lisp_Object fullscreen = Fframe_parameter (frame, Qfullscreen); 2953DEFUN ("x-frame-edges", Fx_frame_edges, Sx_frame_edges, 0, 2, 0,
2880 int border, title, outer_width, outer_height; 2954 doc: /* Return edge coordinates of FRAME.
2881 int tool_bar_height, tool_bar_width; 2955FRAME must be a live frame and defaults to the selected one. The return
2882 // Always 0 on NS. 2956value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are
2883 int menu_bar_height = 0; 2957in pixels relative to the origin - the position (0, 0) - of FRAME's
2884 int menu_bar_width = 0; 2958display.
2885
2886 if (FRAME_INITIAL_P (f) || !FRAME_NS_P (f))
2887 return Qnil;
2888 2959
2889 border = f->border_width; 2960If optional argument TYPE is the symbol `outer-edges', return the outer
2890 title = FRAME_NS_TITLEBAR_HEIGHT (f); 2961edges of FRAME. The outer edges comprise the decorations of the window
2891 outer_width = FRAME_PIXEL_WIDTH (f) + 2 * border; 2962manager (like the title bar or external borders) as well as any external
2892 outer_height = FRAME_PIXEL_HEIGHT (f) + 2 * border; 2963menu or tool bar of FRAME. If optional argument TYPE is the symbol
2893 tool_bar_height = FRAME_TOOLBAR_HEIGHT (f); 2964`native-edges' or nil, return the native edges of FRAME. The native
2894 tool_bar_width = tool_bar_height > 0 2965edges exclude the decorations of the window manager and any external
2895 ? outer_width - 2 * FRAME_INTERNAL_BORDER_WIDTH (f) 2966menu or tool bar of FRAME. If TYPE is the symbol `inner-edges', return
2896 : 0; 2967the inner edges of FRAME. These edges exclude title bar, any borders,
2897 2968menu bar or tool bar of FRAME. */)
2898 return 2969 (Lisp_Object frame, Lisp_Object type)
2899 listn (CONSTYPE_HEAP, 10, 2970{
2900 Fcons (Qframe_position, 2971 return frame_geometry (frame, ((EQ (type, Qouter_edges)
2901 Fcons (make_number (f->left_pos), make_number (f->top_pos))), 2972 || EQ (type, Qinner_edges))
2902 Fcons (Qframe_outer_size, 2973 ? type
2903 Fcons (make_number (outer_width), make_number (outer_height))), 2974 : Qnative_edges));
2904 Fcons (Qexternal_border_size,
2905 ((EQ (fullscreen, Qfullboth) || EQ (fullscreen, Qfullscreen))
2906 ? Fcons (make_number (0), make_number (0))
2907 : Fcons (make_number (border), make_number (border)))),
2908 Fcons (Qtitle_height,
2909 ((EQ (fullscreen, Qfullboth) || EQ (fullscreen, Qfullscreen))
2910 ? make_number (0)
2911 : make_number (title))),
2912 Fcons (Qmenu_bar_external, FRAME_EXTERNAL_MENU_BAR (f) ? Qt : Qnil),
2913 Fcons (Qmenu_bar_size,
2914 Fcons (make_number (menu_bar_width),
2915 make_number (menu_bar_height))),
2916 Fcons (Qtool_bar_external, FRAME_EXTERNAL_TOOL_BAR (f) ? Qt : Qnil),
2917 Fcons (Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f)),
2918 Fcons (Qtool_bar_size,
2919 Fcons (make_number (tool_bar_width),
2920 make_number (tool_bar_height))),
2921 Fcons (Qframe_inner_size,
2922 Fcons (make_number (inner_width),
2923 make_number (inner_height))));
2924} 2975}
2925 2976
2926/* ========================================================================== 2977/* ==========================================================================
@@ -3106,6 +3157,7 @@ be used as the image of the icon representing the frame. */);
3106 defsubr (&Sx_display_pixel_height); 3157 defsubr (&Sx_display_pixel_height);
3107 defsubr (&Sns_display_monitor_attributes_list); 3158 defsubr (&Sns_display_monitor_attributes_list);
3108 defsubr (&Sx_frame_geometry); 3159 defsubr (&Sx_frame_geometry);
3160 defsubr (&Sx_frame_edges);
3109 defsubr (&Sx_display_mm_width); 3161 defsubr (&Sx_display_mm_width);
3110 defsubr (&Sx_display_mm_height); 3162 defsubr (&Sx_display_mm_height);
3111 defsubr (&Sx_display_screens); 3163 defsubr (&Sx_display_screens);
diff --git a/src/w32fns.c b/src/w32fns.c
index 2cb99c90057..8f0bde70875 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -138,6 +138,14 @@ struct MONITOR_INFO
138 DWORD dwFlags; 138 DWORD dwFlags;
139}; 139};
140 140
141#define C_CHILDREN_TITLEBAR 5
142struct TITLEBAR_INFO
143{
144 DWORD cbSize;
145 RECT rcTitleBar;
146 DWORD rgstate[C_CHILDREN_TITLEBAR+1];
147};
148
141#ifndef CCHDEVICENAME 149#ifndef CCHDEVICENAME
142#define CCHDEVICENAME 32 150#define CCHDEVICENAME 32
143#endif 151#endif
@@ -172,6 +180,8 @@ typedef BOOL CALLBACK (* MonitorEnum_Proc)
172 (IN HMONITOR monitor, IN HDC hdc, IN RECT *rcMonitor, IN LPARAM dwData); 180 (IN HMONITOR monitor, IN HDC hdc, IN RECT *rcMonitor, IN LPARAM dwData);
173typedef BOOL (WINAPI * EnumDisplayMonitors_Proc) 181typedef BOOL (WINAPI * EnumDisplayMonitors_Proc)
174 (IN HDC hdc, IN RECT *rcClip, IN MonitorEnum_Proc fnEnum, IN LPARAM dwData); 182 (IN HDC hdc, IN RECT *rcClip, IN MonitorEnum_Proc fnEnum, IN LPARAM dwData);
183typedef BOOL (WINAPI * GetTitleBarInfo_Proc)
184 (IN HWND hwnd, OUT struct TITLEBAR_INFO* info);
175 185
176TrackMouseEvent_Proc track_mouse_event_fn = NULL; 186TrackMouseEvent_Proc track_mouse_event_fn = NULL;
177ImmGetCompositionString_Proc get_composition_string_fn = NULL; 187ImmGetCompositionString_Proc get_composition_string_fn = NULL;
@@ -182,6 +192,7 @@ MonitorFromPoint_Proc monitor_from_point_fn = NULL;
182GetMonitorInfo_Proc get_monitor_info_fn = NULL; 192GetMonitorInfo_Proc get_monitor_info_fn = NULL;
183MonitorFromWindow_Proc monitor_from_window_fn = NULL; 193MonitorFromWindow_Proc monitor_from_window_fn = NULL;
184EnumDisplayMonitors_Proc enum_display_monitors_fn = NULL; 194EnumDisplayMonitors_Proc enum_display_monitors_fn = NULL;
195GetTitleBarInfo_Proc get_title_bar_info_fn = NULL;
185 196
186#ifdef NTGUI_UNICODE 197#ifdef NTGUI_UNICODE
187#define unicode_append_menu AppendMenuW 198#define unicode_append_menu AppendMenuW
@@ -7986,183 +7997,247 @@ This is a direct interface to the Windows API FindWindow function. */)
7986 return Qt; 7997 return Qt;
7987} 7998}
7988 7999
7989DEFUN ("w32-frame-menu-bar-size", Fw32_frame_menu_bar_size, Sw32_frame_menu_bar_size, 0, 1, 0,
7990 doc: /* Return sizes of menu bar on frame FRAME.
7991The return value is a list of four elements: The current width and
7992height of FRAME's menu bar in pixels, the height of one menu bar line in
7993a wrapped menu bar in pixels, and the height of a single line menu bar
7994in pixels.
7995
7996If FRAME is omitted or nil, the selected frame is used. */)
7997 (Lisp_Object frame)
7998{
7999 struct frame *f = decode_any_frame (frame);
8000 MENUBARINFO menu_bar;
8001 int width, height, single_height, wrapped_height;
8002
8003 if (FRAME_INITIAL_P (f) || !FRAME_W32_P (f))
8004 return Qnil;
8005
8006 block_input ();
8007
8008 single_height = GetSystemMetrics (SM_CYMENU);
8009 wrapped_height = GetSystemMetrics (SM_CYMENUSIZE);
8010 menu_bar.cbSize = sizeof (menu_bar);
8011 menu_bar.rcBar.right = menu_bar.rcBar.left = 0;
8012 menu_bar.rcBar.top = menu_bar.rcBar.bottom = 0;
8013 GetMenuBarInfo (FRAME_W32_WINDOW (f), 0xFFFFFFFD, 0, &menu_bar);
8014 width = menu_bar.rcBar.right - menu_bar.rcBar.left;
8015 height = menu_bar.rcBar.bottom - menu_bar.rcBar.top;
8016
8017 unblock_input ();
8018
8019 return list4 (make_number (width), make_number (height),
8020 make_number (wrapped_height), make_number (single_height));
8021}
8022
8023DEFUN ("w32-frame-rect", Fw32_frame_rect, Sw32_frame_rect, 0, 2, 0,
8024 doc: /* Return boundary rectangle of FRAME in screen coordinates.
8025FRAME must be a live frame and defaults to the selected one.
8026
8027The boundary rectangle is a list of four elements, specifying the left,
8028top, right and bottom screen coordinates of FRAME including menu and
8029title bar and decorations. Optional argument CLIENT non-nil means to
8030return the boundaries of the client rectangle which excludes menu and
8031title bar and decorations. */)
8032 (Lisp_Object frame, Lisp_Object client)
8033{
8034 struct frame *f = decode_live_frame (frame);
8035 RECT rect;
8036
8037 if (FRAME_INITIAL_P (f) || !FRAME_W32_P (f))
8038 return Qnil;
8039
8040 block_input ();
8041
8042 if (!NILP (client))
8043 GetClientRect (FRAME_W32_WINDOW (f), &rect);
8044 else
8045 GetWindowRect (FRAME_W32_WINDOW (f), &rect);
8046
8047 unblock_input ();
8048
8049 return list4 (make_number (rect.left), make_number (rect.top),
8050 make_number (rect.right), make_number (rect.bottom));
8051}
8052
8053DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0, 8000DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0,
8054 doc: /* Return geometric attributes of frame FRAME. 8001 doc: /* Return geometric attributes of FRAME.
8055FRAME must be a live frame and defaults to the selected one. 8002FRAME must be a live frame and defaults to the selected one. The return
8003value is an association list of the attributes listed below. All height
8004and width values are in pixels.
8056 8005
8057The return value is an association list containing the following 8006`outer-position' is a cons of the outer left and top edges of FRAME
8058elements (all size values are in pixels). 8007 relative to the origin - the position (0, 0) - of FRAME's display.
8059 8008
8060- `frame-outer-size' is a cons of the outer width and height of FRAME. 8009`outer-size' is a cons of the outer width and height of FRAME. The
8061 The outer size includes the title bar and the external borders as well 8010 outer size includes the title bar and the external borders as well as
8062 as any menu and/or tool bar of frame. 8011 any menu and/or tool bar of frame.
8063 8012
8064- `border' is a cons of the horizontal and vertical width of FRAME's 8013`external-border-size' is a cons of the horizontal and vertical width of
8065 external borders. 8014 FRAME's external borders as supplied by the window manager.
8066 8015
8067- `title-bar-height' is the height of the title bar of FRAME. 8016`title-bar-size' is a cons of the width and height of the title bar of
8017 FRAME as supplied by the window manager. If both of them are zero,
8018 FRAME has no title bar. If only the width is zero, Emacs was not
8019 able to retrieve the width information.
8068 8020
8069- `menu-bar-external' if t means the menu bar is by default external 8021`menu-bar-external', if non-nil, means the menu bar is external (never
8070 (not included in the inner size of FRAME). 8022 included in the inner edges of FRAME).
8071 8023
8072- `menu-bar-size' is a cons of the width and height of the menu bar of 8024`menu-bar-size' is a cons of the width and height of the menu bar of
8073 FRAME. 8025 FRAME.
8074 8026
8075- `tool-bar-external' if t means the tool bar is by default external 8027`tool-bar-external', if non-nil, means the tool bar is external (never
8076 (not included in the inner size of FRAME). 8028 included in the inner edges of FRAME).
8077 8029
8078- `tool-bar-side' tells tells on which side the tool bar on FRAME is by 8030`tool-bar-position' tells on which side the tool bar on FRAME is and can
8079 default and can be one of `left', `top', `right' or `bottom'. 8031 be one of `left', `top', `right' or `bottom'. If this is nil, FRAME
8032 has no tool bar.
8080 8033
8081- `tool-bar-size' is a cons of the width and height of the tool bar of 8034`tool-bar-size' is a cons of the width and height of the tool bar of
8082 FRAME. 8035 FRAME.
8083 8036
8084- `frame-inner-size' is a cons of the inner width and height of FRAME. 8037`internal-border-width' is the width of the internal border of
8085 This excludes FRAME's title bar and external border as well as any 8038 FRAME. */)
8086 external menu and/or tool bar. */)
8087 (Lisp_Object frame) 8039 (Lisp_Object frame)
8088{ 8040{
8089 struct frame *f = decode_live_frame (frame); 8041 struct frame *f = decode_live_frame (frame);
8090 Lisp_Object geometry = Qnil; 8042
8091 RECT frame_outer_edges, frame_inner_edges;
8092 MENUBARINFO menu_bar; 8043 MENUBARINFO menu_bar;
8093 int border_width, border_height, title_height; 8044 WINDOWINFO window;
8094 int single_bar_height, wrapped_bar_height, menu_bar_height; 8045 int left, top, right, bottom;
8095 Lisp_Object fullscreen = Fframe_parameter (frame, Qfullscreen); 8046 unsigned int external_border_width, external_border_height;
8047 int title_bar_width = 0, title_bar_height = 0;
8048 int single_menu_bar_height, wrapped_menu_bar_height, menu_bar_height;
8049 int tool_bar_height = FRAME_TOOL_BAR_HEIGHT (f);
8050 int internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f);
8051 bool fullboth = EQ (get_frame_param (f, Qfullscreen), Qfullboth);
8096 8052
8097 if (FRAME_INITIAL_P (f) || !FRAME_W32_P (f)) 8053 if (FRAME_INITIAL_P (f) || !FRAME_W32_P (f))
8098 return Qnil; 8054 return Qnil;
8099 8055
8100 block_input (); 8056 block_input ();
8101 8057 /* Outer rectangle and borders. */
8102 /* Outer frame rectangle, including outer borders and title bar. */ 8058 window.cbSize = sizeof (window);
8103 GetWindowRect (FRAME_W32_WINDOW (f), &frame_outer_edges); 8059 GetWindowInfo (FRAME_W32_WINDOW (f), &window);
8104 /* Inner frame rectangle, excluding borders and title bar. */ 8060 external_border_width = window.cxWindowBorders;
8105 GetClientRect (FRAME_W32_WINDOW (f), &frame_inner_edges); 8061 external_border_height = window.cyWindowBorders;
8106 /* Outer border. */
8107 border_width = GetSystemMetrics (SM_CXFRAME);
8108 border_height = GetSystemMetrics (SM_CYFRAME);
8109 /* Title bar. */ 8062 /* Title bar. */
8110 title_height = GetSystemMetrics (SM_CYCAPTION); 8063 if ((window.dwStyle & WS_CAPTION) == WS_CAPTION)
8064 {
8065 if (get_title_bar_info_fn)
8066 {
8067 struct TITLEBAR_INFO title_bar;
8068
8069 title_bar.cbSize = sizeof (title_bar);
8070 title_bar.rcTitleBar.left = title_bar.rcTitleBar.right = 0;
8071 title_bar.rcTitleBar.top = title_bar.rcTitleBar.bottom = 0;
8072 get_title_bar_info_fn (FRAME_W32_WINDOW (f), &title_bar);
8073 title_bar_width
8074 = title_bar.rcTitleBar.right - title_bar.rcTitleBar.left;
8075 title_bar_height
8076 = title_bar.rcTitleBar.bottom - title_bar.rcTitleBar.top;
8077 }
8078 else
8079 title_bar_height = GetSystemMetrics (SM_CYCAPTION);
8080 }
8111 /* Menu bar. */ 8081 /* Menu bar. */
8112 menu_bar.cbSize = sizeof (menu_bar); 8082 menu_bar.cbSize = sizeof (menu_bar);
8113 menu_bar.rcBar.right = menu_bar.rcBar.left = 0; 8083 menu_bar.rcBar.right = menu_bar.rcBar.left = 0;
8114 menu_bar.rcBar.top = menu_bar.rcBar.bottom = 0; 8084 menu_bar.rcBar.top = menu_bar.rcBar.bottom = 0;
8115 GetMenuBarInfo (FRAME_W32_WINDOW (f), 0xFFFFFFFD, 0, &menu_bar); 8085 GetMenuBarInfo (FRAME_W32_WINDOW (f), 0xFFFFFFFD, 0, &menu_bar);
8116 single_bar_height = GetSystemMetrics (SM_CYMENU); 8086 single_menu_bar_height = GetSystemMetrics (SM_CYMENU);
8117 wrapped_bar_height = GetSystemMetrics (SM_CYMENUSIZE); 8087 wrapped_menu_bar_height = GetSystemMetrics (SM_CYMENUSIZE);
8118 unblock_input (); 8088 unblock_input ();
8119 8089
8090 left = window.rcWindow.left;
8091 top = window.rcWindow.top;
8092 right = window.rcWindow.right;
8093 bottom = window.rcWindow.bottom;
8094
8095 /* Menu bar. */
8120 menu_bar_height = menu_bar.rcBar.bottom - menu_bar.rcBar.top; 8096 menu_bar_height = menu_bar.rcBar.bottom - menu_bar.rcBar.top;
8121 /* Fix menu bar height reported by GetMenuBarInfo. */ 8097 /* Fix menu bar height reported by GetMenuBarInfo. */
8122 if (menu_bar_height > single_bar_height) 8098 if (menu_bar_height > single_menu_bar_height)
8123 /* A wrapped menu bar. */ 8099 /* A wrapped menu bar. */
8124 menu_bar_height += single_bar_height - wrapped_bar_height; 8100 menu_bar_height += single_menu_bar_height - wrapped_menu_bar_height;
8125 else if (menu_bar_height > 0) 8101 else if (menu_bar_height > 0)
8126 /* A single line menu bar. */ 8102 /* A single line menu bar. */
8127 menu_bar_height = single_bar_height; 8103 menu_bar_height = single_menu_bar_height;
8128 8104
8129 return 8105 return listn (CONSTYPE_HEAP, 10,
8130 listn (CONSTYPE_HEAP, 10, 8106 Fcons (Qouter_position,
8131 Fcons (Qframe_position, 8107 Fcons (make_number (left), make_number (top))),
8132 Fcons (make_number (frame_outer_edges.left), 8108 Fcons (Qouter_size,
8133 make_number (frame_outer_edges.top))), 8109 Fcons (make_number (right - left),
8134 Fcons (Qframe_outer_size, 8110 make_number (bottom - top))),
8135 Fcons (make_number
8136 (frame_outer_edges.right - frame_outer_edges.left),
8137 make_number
8138 (frame_outer_edges.bottom - frame_outer_edges.top))),
8139 Fcons (Qexternal_border_size, 8111 Fcons (Qexternal_border_size,
8140 ((EQ (fullscreen, Qfullboth) || EQ (fullscreen, Qfullscreen)) 8112 Fcons (make_number (external_border_width),
8141 ? Fcons (make_number (0), make_number (0)) 8113 make_number (external_border_height))),
8142 : Fcons (make_number (border_width), 8114 Fcons (Qtitle_bar_size,
8143 make_number (border_height)))), 8115 Fcons (make_number (title_bar_width),
8144 Fcons (Qtitle_height, 8116 make_number (title_bar_height))),
8145 ((EQ (fullscreen, Qfullboth) || EQ (fullscreen, Qfullscreen))
8146 ? make_number (0)
8147 : make_number (title_height))),
8148 Fcons (Qmenu_bar_external, Qt), 8117 Fcons (Qmenu_bar_external, Qt),
8149 Fcons (Qmenu_bar_size, 8118 Fcons (Qmenu_bar_size,
8150 Fcons (make_number 8119 Fcons (make_number
8151 (menu_bar.rcBar.right - menu_bar.rcBar.left), 8120 (menu_bar.rcBar.right - menu_bar.rcBar.left),
8152 make_number (menu_bar_height))), 8121 make_number (menu_bar_height))),
8153 Fcons (Qtool_bar_external, Qnil), 8122 Fcons (Qtool_bar_external, Qnil),
8154 Fcons (Qtool_bar_position, Qtop), 8123 Fcons (Qtool_bar_position, tool_bar_height ? Qtop : Qnil),
8155 Fcons (Qtool_bar_size, 8124 Fcons (Qtool_bar_size,
8156 Fcons (make_number (FRAME_TOOL_BAR_LINES (f) 8125 Fcons (make_number
8157 ? (FRAME_PIXEL_WIDTH (f) 8126 (tool_bar_height
8158 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) 8127 ? right - left - 2 * internal_border_width
8159 : 0), 8128 : 0),
8160 make_number (FRAME_TOOL_BAR_HEIGHT (f)))), 8129 make_number (tool_bar_height))),
8161 Fcons (Qframe_inner_size, 8130 Fcons (Qinternal_border_width,
8162 Fcons (make_number 8131 make_number (internal_border_width)));
8163 (frame_inner_edges.right - frame_inner_edges.left), 8132}
8164 make_number 8133
8165 (frame_inner_edges.bottom - frame_inner_edges.top)))); 8134DEFUN ("x-frame-edges", Fx_frame_edges, Sx_frame_edges, 0, 2, 0,
8135 doc: /* Return edge coordinates of FRAME.
8136FRAME must be a live frame and defaults to the selected one. The return
8137value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are
8138in pixels relative to the origin - the position (0, 0) - of FRAME's
8139display.
8140
8141If optional argument TYPE is the symbol `outer-edges', return the outer
8142edges of FRAME. The outer edges comprise the decorations of the window
8143manager (like the title bar or external borders) as well as any external
8144menu or tool bar of FRAME. If optional argument TYPE is the symbol
8145`native-edges' or nil, return the native edges of FRAME. The native
8146edges exclude the decorations of the window manager and any external
8147menu or tool bar of FRAME. If TYPE is the symbol `inner-edges', return
8148the inner edges of FRAME. These edges exclude title bar, any borders,
8149menu bar or tool bar of FRAME. */)
8150 (Lisp_Object frame, Lisp_Object type)
8151{
8152 struct frame *f = decode_live_frame (frame);
8153
8154 if (FRAME_INITIAL_P (f) || !FRAME_W32_P (f))
8155 return Qnil;
8156
8157 if (EQ (type, Qouter_edges))
8158 {
8159 RECT rectangle;
8160
8161 block_input ();
8162 /* Outer frame rectangle, including outer borders and title bar. */
8163 GetWindowRect (FRAME_W32_WINDOW (f), &rectangle);
8164 unblock_input ();
8165
8166 return list4 (make_number (rectangle.left),
8167 make_number (rectangle.top),
8168 make_number (rectangle.right),
8169 make_number (rectangle.bottom));
8170 }
8171 else
8172 {
8173 RECT rectangle;
8174 POINT pt;
8175 int left, top, right, bottom;
8176
8177 block_input ();
8178 /* Inner frame rectangle, excluding borders and title bar. */
8179 GetClientRect (FRAME_W32_WINDOW (f), &rectangle);
8180 /* Get top-left corner of native rectangle in screen
8181 coordinates. */
8182 pt.x = 0;
8183 pt.y = 0;
8184 ClientToScreen (FRAME_W32_WINDOW (f), &pt);
8185 unblock_input ();
8186
8187 left = pt.x;
8188 top = pt.y;
8189 right = left + rectangle.right;
8190 bottom = top + rectangle.bottom;
8191
8192 if (EQ (type, Qinner_edges))
8193 {
8194 int internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f);
8195
8196 return list4 (make_number (left + internal_border_width),
8197 make_number (top
8198 + FRAME_TOOL_BAR_HEIGHT (f)
8199 + internal_border_width),
8200 make_number (right - internal_border_width),
8201 make_number (bottom - internal_border_width));
8202 }
8203 else
8204 return list4 (make_number (left), make_number (top),
8205 make_number (right), make_number (bottom));
8206 }
8207}
8208
8209DEFUN ("x-mouse-absolute-pixel-position", Fx_mouse_absolute_pixel_position,
8210 Sx_mouse_absolute_pixel_position, 0, 0, 0,
8211 doc: /* Return absolute position of mouse cursor in pixels.
8212The position is returned as a cons cell (X . Y) of the coordinates of
8213the mouse cursor position in pixels relative to a position (0, 0) of the
8214selected frame's display. */)
8215 (void)
8216{
8217 POINT pt;
8218
8219 block_input ();
8220 GetCursorPos (&pt);
8221 unblock_input ();
8222
8223 return Fcons (make_number (pt.x), make_number (pt.y));
8224}
8225
8226DEFUN ("x-set-mouse-absolute-pixel-position", Fx_set_mouse_absolute_pixel_position,
8227 Sx_set_mouse_absolute_pixel_position, 2, 2, 0,
8228 doc: /* Move mouse pointer to absolute pixel position (X, Y).
8229The coordinates X and Y are interpreted in pixels relative to a position
8230(0, 0) of the selected frame's display. */)
8231 (Lisp_Object x, Lisp_Object y)
8232{
8233 CHECK_TYPE_RANGED_INTEGER (int, x);
8234 CHECK_TYPE_RANGED_INTEGER (int, y);
8235
8236 block_input ();
8237 SetCursorPos (XINT (x), XINT (y));
8238 unblock_input ();
8239
8240 return Qnil;
8166} 8241}
8167 8242
8168DEFUN ("w32-battery-status", Fw32_battery_status, Sw32_battery_status, 0, 0, 0, 8243DEFUN ("w32-battery-status", Fw32_battery_status, Sw32_battery_status, 0, 0, 0,
@@ -9189,6 +9264,9 @@ This variable has effect only on NT family of systems, not on Windows 9X. */);
9189 defsubr (&Sx_close_connection); 9264 defsubr (&Sx_close_connection);
9190 defsubr (&Sx_display_list); 9265 defsubr (&Sx_display_list);
9191 defsubr (&Sx_frame_geometry); 9266 defsubr (&Sx_frame_geometry);
9267 defsubr (&Sx_frame_edges);
9268 defsubr (&Sx_mouse_absolute_pixel_position);
9269 defsubr (&Sx_set_mouse_absolute_pixel_position);
9192 defsubr (&Sx_synchronize); 9270 defsubr (&Sx_synchronize);
9193 9271
9194 /* W32 specific functions */ 9272 /* W32 specific functions */
@@ -9204,8 +9282,6 @@ This variable has effect only on NT family of systems, not on Windows 9X. */);
9204 defsubr (&Sw32_reconstruct_hot_key); 9282 defsubr (&Sw32_reconstruct_hot_key);
9205 defsubr (&Sw32_toggle_lock_key); 9283 defsubr (&Sw32_toggle_lock_key);
9206 defsubr (&Sw32_window_exists_p); 9284 defsubr (&Sw32_window_exists_p);
9207 defsubr (&Sw32_frame_rect);
9208 defsubr (&Sw32_frame_menu_bar_size);
9209 defsubr (&Sw32_battery_status); 9285 defsubr (&Sw32_battery_status);
9210 defsubr (&Sw32__menu_bar_in_use); 9286 defsubr (&Sw32__menu_bar_in_use);
9211 9287
@@ -9470,6 +9546,8 @@ globals_of_w32fns (void)
9470 GetProcAddress (user32_lib, "MonitorFromWindow"); 9546 GetProcAddress (user32_lib, "MonitorFromWindow");
9471 enum_display_monitors_fn = (EnumDisplayMonitors_Proc) 9547 enum_display_monitors_fn = (EnumDisplayMonitors_Proc)
9472 GetProcAddress (user32_lib, "EnumDisplayMonitors"); 9548 GetProcAddress (user32_lib, "EnumDisplayMonitors");
9549 get_title_bar_info_fn = (GetTitleBarInfo_Proc)
9550 GetProcAddress (user32_lib, "GetTitleBarInfo");
9473 9551
9474 { 9552 {
9475 HMODULE imm32_lib = GetModuleHandle ("imm32.dll"); 9553 HMODULE imm32_lib = GetModuleHandle ("imm32.dll");
diff --git a/src/xfns.c b/src/xfns.c
index 8137ceacb88..18fb343efd6 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4312,130 +4312,262 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
4312 return attributes_list; 4312 return attributes_list;
4313} 4313}
4314 4314
4315DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0, 4315/* Return geometric attributes of FRAME. According to the value of
4316 doc: /* Return geometric attributes of frame FRAME. 4316 ATTRIBUTES return the outer edges of FRAME (Qouter_edges), the native
4317 edges of FRAME (Qnative_edges), or the inner edges of frame
4318 (Qinner_edges). Any other value means to return the geometry as
4319 returned by Fx_frame_geometry. */
4320static Lisp_Object
4321frame_geometry (Lisp_Object frame, Lisp_Object attribute)
4322{
4323 struct frame *f = decode_live_frame (frame);
4324 /** XWindowAttributes atts; **/
4325 Window rootw;
4326 unsigned int ign, native_width, native_height;
4327 int xy_ign, xptr, yptr;
4328 int left_off, right_off, top_off, bottom_off;
4329 int outer_left, outer_top, outer_right, outer_bottom;
4330 int native_left, native_top, native_right, native_bottom;
4331 int inner_left, inner_top, inner_right, inner_bottom;
4332 int internal_border_width;
4333 bool menu_bar_external = false, tool_bar_external = false;
4334 int menu_bar_height = 0, menu_bar_width = 0;
4335 int tool_bar_height = 0, tool_bar_width = 0;
4336
4337 if (FRAME_INITIAL_P (f) || !FRAME_X_P (f))
4338 return Qnil;
4339
4340 block_input ();
4341 XGetGeometry (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
4342 &rootw, &xy_ign, &xy_ign, &native_width, &native_height,
4343 &ign, &ign);
4344 /** XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &atts); **/
4345 x_real_pos_and_offsets (f, &left_off, &right_off, &top_off, &bottom_off,
4346 NULL, NULL, &xptr, &yptr, NULL);
4347 unblock_input ();
4348
4349 /** native_width = atts.width; **/
4350 /** native_height = atts.height; **/
4351
4352 outer_left = xptr;
4353 outer_top = yptr;
4354 outer_right = outer_left + left_off + native_width + right_off;
4355 outer_bottom = outer_top + top_off + native_height + bottom_off;
4356
4357 native_left = outer_left + left_off;
4358 native_top = outer_top + top_off;
4359 native_right = native_left + native_width;
4360 native_bottom = native_top + native_height;
4361
4362 internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f);
4363 inner_left = native_left + internal_border_width;
4364 inner_top = native_top + internal_border_width;
4365 inner_right = native_right - internal_border_width;
4366 inner_bottom = native_bottom - internal_border_width;
4367
4368#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
4369 menu_bar_external = true;
4370 menu_bar_height = FRAME_MENUBAR_HEIGHT (f);
4371 native_top += menu_bar_height;
4372 inner_top += menu_bar_height;
4373#else
4374 menu_bar_height = FRAME_MENU_BAR_HEIGHT (f);
4375 inner_top += menu_bar_height;
4376#endif
4377 menu_bar_width = menu_bar_height ? native_width : 0;
4378
4379#if defined (USE_GTK)
4380 tool_bar_external = true;
4381 if (EQ (FRAME_TOOL_BAR_POSITION (f), Qleft))
4382 {
4383 tool_bar_width = FRAME_TOOLBAR_WIDTH (f);
4384 native_left += tool_bar_width;
4385 inner_left += tool_bar_width;
4386 tool_bar_height
4387 = tool_bar_width ? native_height - menu_bar_height : 0;
4388 }
4389 else if (EQ (FRAME_TOOL_BAR_POSITION (f), Qtop))
4390 {
4391 tool_bar_height = FRAME_TOOLBAR_HEIGHT (f);
4392 native_top += tool_bar_height;
4393 inner_top += tool_bar_height;
4394 tool_bar_width = tool_bar_height ? native_width : 0;
4395 }
4396 else if (EQ (FRAME_TOOL_BAR_POSITION (f), Qright))
4397 {
4398 tool_bar_width = FRAME_TOOLBAR_WIDTH (f);
4399 native_right -= tool_bar_width;
4400 inner_right -= tool_bar_width;
4401 tool_bar_height
4402 = tool_bar_width ? native_height - menu_bar_height : 0;
4403 }
4404 else
4405 {
4406 tool_bar_height = FRAME_TOOLBAR_HEIGHT (f);
4407 native_bottom -= tool_bar_height;
4408 inner_bottom -= tool_bar_height;
4409 tool_bar_width = tool_bar_height ? native_width : 0;
4410 }
4411#else
4412 tool_bar_height = FRAME_TOOL_BAR_HEIGHT (f);
4413 tool_bar_width = tool_bar_height ? native_width : 0;
4414 inner_top += tool_bar_height;
4415#endif
4416
4417 /* Construct list. */
4418 if (EQ (attribute, Qouter_edges))
4419 return list4 (make_number (outer_left), make_number (outer_top),
4420 make_number (outer_right), make_number (outer_bottom));
4421 else if (EQ (attribute, Qnative_edges))
4422 return list4 (make_number (native_left), make_number (native_top),
4423 make_number (native_right), make_number (native_bottom));
4424 else if (EQ (attribute, Qinner_edges))
4425 return list4 (make_number (inner_left), make_number (inner_top),
4426 make_number (inner_right), make_number (inner_bottom));
4427 else
4428 return
4429 listn (CONSTYPE_HEAP, 10,
4430 Fcons (Qouter_position,
4431 Fcons (make_number (outer_left),
4432 make_number (outer_top))),
4433 Fcons (Qouter_size,
4434 Fcons (make_number (outer_right - outer_left),
4435 make_number (outer_bottom - outer_top))),
4436 /* Approximate. */
4437 Fcons (Qexternal_border_size,
4438 Fcons (make_number (right_off),
4439 make_number (bottom_off))),
4440 /* Approximate. */
4441 Fcons (Qtitle_bar_size,
4442 Fcons (make_number (0),
4443 make_number (top_off - bottom_off))),
4444 Fcons (Qmenu_bar_external, menu_bar_external ? Qt : Qnil),
4445 Fcons (Qmenu_bar_size,
4446 Fcons (make_number (menu_bar_width),
4447 make_number (menu_bar_height))),
4448 Fcons (Qtool_bar_external, tool_bar_external ? Qt : Qnil),
4449 Fcons (Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f)),
4450 Fcons (Qtool_bar_size,
4451 Fcons (make_number (tool_bar_width),
4452 make_number (tool_bar_height))),
4453 Fcons (Qinternal_border_width,
4454 make_number (internal_border_width)));
4455}
4317 4456
4318FRAME must be a live frame and defaults to the selected one. 4457DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0,
4458 doc: /* Return geometric attributes of FRAME.
4459FRAME must be a live frame and defaults to the selected one. The return
4460value is an association list of the attributes listed below. All height
4461and width values are in pixels.
4319 4462
4320The return value is an association list containing the following 4463`outer-position' is a cons of the outer left and top edges of FRAME
4321elements (all size values are in pixels). 4464 relative to the origin - the position (0, 0) - of FRAME's display.
4322 4465
4323- `frame-outer-size' is a cons of the outer width and height of FRAME. 4466`outer-size' is a cons of the outer width and height of FRAME. The
4324 The outer size include the title bar and the external borders as well 4467 outer size includes the title bar and the external borders as well as
4325 as any menu and/or tool bar of frame. 4468 any menu and/or tool bar of frame.
4326 4469
4327- `border' is a cons of the horizontal and vertical width of FRAME's 4470`external-border-size' is a cons of the horizontal and vertical width of
4328 external borders. 4471 FRAME's external borders as supplied by the window manager.
4329 4472
4330- `title-bar-height' is the height of the title bar of FRAME. 4473`title-bar-size' is a cons of the width and height of the title bar of
4474 FRAME as supplied by the window manager. If both of them are zero,
4475 FRAME has no title bar. If only the width is zero, Emacs was not
4476 able to retrieve the width information.
4331 4477
4332- `menu-bar-external' if t means the menu bar is external (not 4478`menu-bar-external', if non-nil, means the menu bar is external (never
4333 included in the inner edges of FRAME). 4479 included in the inner edges of FRAME).
4334 4480
4335- `menu-bar-size' is a cons of the width and height of the menu bar of 4481`menu-bar-size' is a cons of the width and height of the menu bar of
4336 FRAME. 4482 FRAME.
4337 4483
4338- `tool-bar-external' if t means the tool bar is external (not 4484`tool-bar-external', if non-nil, means the tool bar is external (never
4339 included in the inner edges of FRAME). 4485 included in the inner edges of FRAME).
4340 4486
4341- `tool-bar-side' tells tells on which side the tool bar on FRAME is and 4487`tool-bar-position' tells on which side the tool bar on FRAME is and can
4342 can be one of `left', `top', `right' or `bottom'. 4488 be one of `left', `top', `right' or `bottom'. If this is nil, FRAME
4489 has no tool bar.
4343 4490
4344- `tool-bar-size' is a cons of the width and height of the tool bar of 4491`tool-bar-size' is a cons of the width and height of the tool bar of
4345 FRAME. 4492 FRAME.
4346 4493
4347- `frame-inner-size' is a cons of the inner width and height of FRAME. 4494`internal-border-width' is the width of the internal border of
4348 This excludes FRAME's title bar and external border as well as any 4495 FRAME. */)
4349 external menu and/or tool bar. */)
4350 (Lisp_Object frame) 4496 (Lisp_Object frame)
4351{ 4497{
4352 struct frame *f = decode_live_frame (frame); 4498 return frame_geometry (frame, Qnil);
4353 int inner_width = FRAME_PIXEL_WIDTH (f); 4499}
4354 int inner_height = FRAME_PIXEL_HEIGHT (f); 4500
4355 int outer_width, outer_height, border, title; 4501DEFUN ("x-frame-edges", Fx_frame_edges, Sx_frame_edges, 0, 2, 0,
4356 Lisp_Object fullscreen = Fframe_parameter (frame, Qfullscreen); 4502 doc: /* Return edge coordinates of FRAME.
4357 int menu_bar_height, menu_bar_width, tool_bar_height, tool_bar_width; 4503FRAME must be a live frame and defaults to the selected one. The return
4504value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are
4505in pixels relative to the origin - the position (0, 0) - of FRAME's
4506display.
4507
4508If optional argument TYPE is the symbol `outer-edges', return the outer
4509edges of FRAME. The outer edges comprise the decorations of the window
4510manager (like the title bar or external borders) as well as any external
4511menu or tool bar of FRAME. If optional argument TYPE is the symbol
4512`native-edges' or nil, return the native edges of FRAME. The native
4513edges exclude the decorations of the window manager and any external
4514menu or tool bar of FRAME. If TYPE is the symbol `inner-edges', return
4515the inner edges of FRAME. These edges exclude title bar, any borders,
4516menu bar or tool bar of FRAME. */)
4517 (Lisp_Object frame, Lisp_Object type)
4518{
4519 return frame_geometry (frame, ((EQ (type, Qouter_edges)
4520 || EQ (type, Qinner_edges))
4521 ? type
4522 : Qnative_edges));
4523}
4358 4524
4359 int left_off, right_off, top_off, bottom_off, outer_border; 4525DEFUN ("x-mouse-absolute-pixel-position", Fx_mouse_absolute_pixel_position,
4360 XWindowAttributes atts; 4526 Sx_mouse_absolute_pixel_position, 0, 0, 0,
4527 doc: /* Return absolute position of mouse cursor in pixels.
4528The position is returned as a cons cell (X . Y) of the coordinates of
4529the mouse cursor position in pixels relative to a position (0, 0) of the
4530selected frame's display. */)
4531 (void)
4532{
4533 struct frame *f = SELECTED_FRAME ();
4534 Window root, dummy_window;
4535 int x, y, dummy;
4361 4536
4362 if (FRAME_INITIAL_P (f) || !FRAME_X_P (f)) 4537 if (FRAME_INITIAL_P (f) || !FRAME_X_P (f))
4363 return Qnil; 4538 return Qnil;
4364 4539
4365 block_input (); 4540 block_input ();
4366 4541 XQueryPointer (FRAME_X_DISPLAY (f),
4367 XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &atts); 4542 DefaultRootWindow (FRAME_X_DISPLAY (f)),
4368 4543 &root, &dummy_window, &x, &y, &dummy, &dummy,
4369 x_real_pos_and_offsets (f, &left_off, &right_off, &top_off, &bottom_off, 4544 (unsigned int *) &dummy);
4370 NULL, NULL, NULL, NULL, &outer_border);
4371
4372
4373 unblock_input (); 4545 unblock_input ();
4374 4546
4375 border = atts.border_width; 4547 return Fcons (make_number (x), make_number (y));
4376 title = top_off; 4548}
4377
4378 outer_width = atts.width + 2 * border + right_off + left_off
4379 + 2 * outer_border;
4380 outer_height = atts.height + 2 * border + top_off + bottom_off
4381 + 2 * outer_border;
4382 4549
4383#if defined (USE_GTK) 4550DEFUN ("x-set-mouse-absolute-pixel-position", Fx_set_mouse_absolute_pixel_position,
4551 Sx_set_mouse_absolute_pixel_position, 2, 2, 0,
4552 doc: /* Move mouse pointer to absolute pixel position (X, Y).
4553The coordinates X and Y are interpreted in pixels relative to a position
4554(0, 0) of the selected frame's display. */)
4555 (Lisp_Object x, Lisp_Object y)
4384 { 4556 {
4385 bool tool_bar_left_right = (EQ (FRAME_TOOL_BAR_POSITION (f), Qleft) 4557 struct frame *f = SELECTED_FRAME ();
4386 || EQ (FRAME_TOOL_BAR_POSITION (f), Qright));
4387
4388 tool_bar_width = (tool_bar_left_right
4389 ? FRAME_TOOLBAR_WIDTH (f)
4390 : FRAME_PIXEL_WIDTH (f));
4391 tool_bar_height = (tool_bar_left_right
4392 ? FRAME_PIXEL_HEIGHT (f)
4393 : FRAME_TOOLBAR_HEIGHT (f));
4394 }
4395#else
4396 tool_bar_height = FRAME_TOOL_BAR_HEIGHT (f);
4397 tool_bar_width = tool_bar_height > 0 ? FRAME_PIXEL_WIDTH (f) : 0;
4398#endif
4399 4558
4400#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 4559 if (FRAME_INITIAL_P (f) || !FRAME_X_P (f))
4401 menu_bar_height = FRAME_MENUBAR_HEIGHT (f); 4560 return Qnil;
4402#else 4561
4403 menu_bar_height = FRAME_MENU_BAR_HEIGHT (f); 4562 CHECK_TYPE_RANGED_INTEGER (int, x);
4404#endif 4563 CHECK_TYPE_RANGED_INTEGER (int, y);
4405 4564
4406 menu_bar_width = menu_bar_height > 0 ? FRAME_PIXEL_WIDTH (f) : 0; 4565 block_input ();
4407 4566 XWarpPointer (FRAME_X_DISPLAY (f), None, DefaultRootWindow (FRAME_X_DISPLAY (f)),
4408 if (!FRAME_EXTERNAL_MENU_BAR (f)) 4567 0, 0, 0, 0, XINT (x), XINT (y));
4409 inner_height -= menu_bar_height; 4568 unblock_input ();
4410 if (!FRAME_EXTERNAL_TOOL_BAR (f)) 4569
4411 inner_height -= tool_bar_height; 4570 return Qnil;
4412
4413 return
4414 listn (CONSTYPE_HEAP, 10,
4415 Fcons (Qframe_position,
4416 Fcons (make_number (f->left_pos), make_number (f->top_pos))),
4417 Fcons (Qframe_outer_size,
4418 Fcons (make_number (outer_width), make_number (outer_height))),
4419 Fcons (Qexternal_border_size,
4420 ((EQ (fullscreen, Qfullboth) || EQ (fullscreen, Qfullscreen))
4421 ? Fcons (make_number (0), make_number (0))
4422 : Fcons (make_number (border), make_number (border)))),
4423 Fcons (Qtitle_height,
4424 ((EQ (fullscreen, Qfullboth) || EQ (fullscreen, Qfullscreen))
4425 ? make_number (0)
4426 : make_number (title))),
4427 Fcons (Qmenu_bar_external, FRAME_EXTERNAL_MENU_BAR (f) ? Qt : Qnil),
4428 Fcons (Qmenu_bar_size,
4429 Fcons (make_number (menu_bar_width),
4430 make_number (menu_bar_height))),
4431 Fcons (Qtool_bar_external, FRAME_EXTERNAL_TOOL_BAR (f) ? Qt : Qnil),
4432 Fcons (Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f)),
4433 Fcons (Qtool_bar_size,
4434 Fcons (make_number (tool_bar_width),
4435 make_number (tool_bar_height))),
4436 Fcons (Qframe_inner_size,
4437 Fcons (make_number (inner_width),
4438 make_number (inner_height))));
4439} 4571}
4440 4572
4441/************************************************************************ 4573/************************************************************************
@@ -6639,6 +6771,9 @@ When using Gtk+ tooltips, the tooltip face is not used. */);
6639 defsubr (&Sx_display_save_under); 6771 defsubr (&Sx_display_save_under);
6640 defsubr (&Sx_display_monitor_attributes_list); 6772 defsubr (&Sx_display_monitor_attributes_list);
6641 defsubr (&Sx_frame_geometry); 6773 defsubr (&Sx_frame_geometry);
6774 defsubr (&Sx_frame_edges);
6775 defsubr (&Sx_mouse_absolute_pixel_position);
6776 defsubr (&Sx_set_mouse_absolute_pixel_position);
6642 defsubr (&Sx_wm_set_size_hint); 6777 defsubr (&Sx_wm_set_size_hint);
6643 defsubr (&Sx_create_frame); 6778 defsubr (&Sx_create_frame);
6644 defsubr (&Sx_open_connection); 6779 defsubr (&Sx_open_connection);