aboutsummaryrefslogtreecommitdiffstats
path: root/src/frame.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/frame.c')
-rw-r--r--src/frame.c137
1 files changed, 57 insertions, 80 deletions
diff --git a/src/frame.c b/src/frame.c
index 501f01a3122..8fac06e2af7 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -219,21 +219,6 @@ frame_inhibit_resize (struct frame *f, bool horizontal)
219 || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)); 219 || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f));
220} 220}
221 221
222#if 0
223bool
224frame_inhibit_resize (struct frame *f, bool horizontal)
225{
226 Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
227
228 return (frame_inhibit_implied_resize
229 || EQ (fullscreen, Qfullboth)
230 || EQ (fullscreen, Qfullscreen)
231 || EQ (fullscreen, Qmaximized)
232 || (horizontal && EQ (fullscreen, Qfullwidth))
233 || (!horizontal && EQ (fullscreen, Qfullheight)));
234}
235#endif
236
237static void 222static void
238set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) 223set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
239{ 224{
@@ -351,7 +336,7 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, Lisp_Object p
351 336
352/* Make sure windows sizes of frame F are OK. new_width and new_height 337/* Make sure windows sizes of frame F are OK. new_width and new_height
353 are in pixels. A value of -1 means no change is requested for that 338 are in pixels. A value of -1 means no change is requested for that
354 size (but the frame may still have to be resized to accomodate 339 size (but the frame may still have to be resized to accommodate
355 windows with their minimum sizes. 340 windows with their minimum sizes.
356 341
357 The argument INHIBIT can assume the following values: 342 The argument INHIBIT can assume the following values:
@@ -979,7 +964,7 @@ affects all frames on the same terminal device. */)
979 if (CONSP (terminal)) 964 if (CONSP (terminal))
980 { 965 {
981 terminal = XCDR (terminal); 966 terminal = XCDR (terminal);
982 t = get_terminal (terminal, 1); 967 t = decode_live_terminal (terminal);
983 } 968 }
984#ifdef MSDOS 969#ifdef MSDOS
985 if (t && t != the_only_display_info.terminal) 970 if (t && t != the_only_display_info.terminal)
@@ -994,22 +979,24 @@ affects all frames on the same terminal device. */)
994 { 979 {
995 char *name = 0, *type = 0; 980 char *name = 0, *type = 0;
996 Lisp_Object tty, tty_type; 981 Lisp_Object tty, tty_type;
982 USE_SAFE_ALLOCA;
997 983
998 tty = get_future_frame_param 984 tty = get_future_frame_param
999 (Qtty, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame)) 985 (Qtty, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
1000 ? FRAME_TTY (XFRAME (selected_frame))->name 986 ? FRAME_TTY (XFRAME (selected_frame))->name
1001 : NULL)); 987 : NULL));
1002 if (!NILP (tty)) 988 if (!NILP (tty))
1003 name = xlispstrdupa (tty); 989 SAFE_ALLOCA_STRING (name, tty);
1004 990
1005 tty_type = get_future_frame_param 991 tty_type = get_future_frame_param
1006 (Qtty_type, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame)) 992 (Qtty_type, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
1007 ? FRAME_TTY (XFRAME (selected_frame))->type 993 ? FRAME_TTY (XFRAME (selected_frame))->type
1008 : NULL)); 994 : NULL));
1009 if (!NILP (tty_type)) 995 if (!NILP (tty_type))
1010 type = xlispstrdupa (tty_type); 996 SAFE_ALLOCA_STRING (type, tty_type);
1011 997
1012 t = init_tty (name, type, 0); /* Errors are not fatal. */ 998 t = init_tty (name, type, 0); /* Errors are not fatal. */
999 SAFE_FREE ();
1013 } 1000 }
1014 1001
1015 f = make_terminal_frame (t); 1002 f = make_terminal_frame (t);
@@ -1804,9 +1791,9 @@ The functions are run with one argument, the frame to be deleted. */)
1804 1791
1805DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0, 1792DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
1806 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position. 1793 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1807The position is given in character cells, where (0, 0) is the 1794The position is given in canonical character cells, where (0, 0) is the
1808upper-left corner of the frame, X is the horizontal offset, and Y is 1795upper-left corner of the frame, X is the horizontal offset, and Y is the
1809the vertical offset. 1796vertical offset, measured in units of the frame's default character size.
1810If Emacs is running on a mouseless terminal or hasn't been programmed 1797If Emacs is running on a mouseless terminal or hasn't been programmed
1811to read the mouse position, it returns the selected frame for FRAME 1798to read the mouse position, it returns the selected frame for FRAME
1812and nil for X and Y. 1799and nil for X and Y.
@@ -1863,7 +1850,8 @@ and nil for X and Y. */)
1863{ 1850{
1864 struct frame *f; 1851 struct frame *f;
1865 Lisp_Object lispy_dummy; 1852 Lisp_Object lispy_dummy;
1866 Lisp_Object x, y; 1853 Lisp_Object x, y, retval;
1854 struct gcpro gcpro1;
1867 1855
1868 f = SELECTED_FRAME (); 1856 f = SELECTED_FRAME ();
1869 x = y = Qnil; 1857 x = y = Qnil;
@@ -1880,7 +1868,11 @@ and nil for X and Y. */)
1880 } 1868 }
1881 1869
1882 XSETFRAME (lispy_dummy, f); 1870 XSETFRAME (lispy_dummy, f);
1883 return Fcons (lispy_dummy, Fcons (x, y)); 1871 retval = Fcons (lispy_dummy, Fcons (x, y));
1872 GCPRO1 (retval);
1873 if (!NILP (Vmouse_position_function))
1874 retval = call1 (Vmouse_position_function, retval);
1875 RETURN_UNGCPRO (retval);
1884} 1876}
1885 1877
1886#ifdef HAVE_WINDOW_SYSTEM 1878#ifdef HAVE_WINDOW_SYSTEM
@@ -1925,9 +1917,10 @@ Coordinates are relative to the frame, not a window,
1925so the coordinates of the top left character in the frame 1917so the coordinates of the top left character in the frame
1926may be nonzero due to left-hand scroll bars or the menu bar. 1918may be nonzero due to left-hand scroll bars or the menu bar.
1927 1919
1928The position is given in character cells, where (0, 0) is the 1920The position is given in canonical character cells, where (0, 0) is
1929upper-left corner of the frame, X is the horizontal offset, and Y is 1921the upper-left corner of the frame, X is the horizontal offset, and
1930the vertical offset. 1922Y is the vertical offset, measured in units of the frame's default
1923character size.
1931 1924
1932This function is a no-op for an X frame that is not visible. 1925This function is a no-op for an X frame that is not visible.
1933If you have just created a frame, you must wait for it to become visible 1926If you have just created a frame, you must wait for it to become visible
@@ -3000,7 +2993,7 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3000 /* If both of these parameters are present, it's more efficient to 2993 /* If both of these parameters are present, it's more efficient to
3001 set them both at once. So we wait until we've looked at the 2994 set them both at once. So we wait until we've looked at the
3002 entire list before we set them. */ 2995 entire list before we set them. */
3003 int width, height; 2996 int width IF_LINT (= 0), height IF_LINT (= 0);
3004 bool width_change = 0, height_change = 0; 2997 bool width_change = 0, height_change = 0;
3005 2998
3006 /* Same here. */ 2999 /* Same here. */
@@ -3017,14 +3010,14 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3017#ifdef HAVE_X_WINDOWS 3010#ifdef HAVE_X_WINDOWS
3018 bool icon_left_no_change = 0, icon_top_no_change = 0; 3011 bool icon_left_no_change = 0, icon_top_no_change = 0;
3019#endif 3012#endif
3020 struct gcpro gcpro1, gcpro2;
3021 3013
3022 i = 0; 3014 i = 0;
3023 for (tail = alist; CONSP (tail); tail = XCDR (tail)) 3015 for (tail = alist; CONSP (tail); tail = XCDR (tail))
3024 i++; 3016 i++;
3025 3017
3026 parms = alloca (i * sizeof *parms); 3018 USE_SAFE_ALLOCA;
3027 values = alloca (i * sizeof *values); 3019 SAFE_ALLOCA_LISP (parms, 2 * i);
3020 values = parms + i;
3028 3021
3029 /* Extract parm names and values into those vectors. */ 3022 /* Extract parm names and values into those vectors. */
3030 3023
@@ -3041,10 +3034,6 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3041 /* TAIL and ALIST are not used again below here. */ 3034 /* TAIL and ALIST are not used again below here. */
3042 alist = tail = Qnil; 3035 alist = tail = Qnil;
3043 3036
3044 GCPRO2 (*parms, *values);
3045 gcpro1.nvars = i;
3046 gcpro2.nvars = i;
3047
3048 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP, 3037 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
3049 because their values appear in VALUES and strings are not valid. */ 3038 because their values appear in VALUES and strings are not valid. */
3050 top = left = Qunbound; 3039 top = left = Qunbound;
@@ -3273,7 +3262,7 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3273#endif /* HAVE_X_WINDOWS */ 3262#endif /* HAVE_X_WINDOWS */
3274 } 3263 }
3275 3264
3276 UNGCPRO; 3265 SAFE_FREE ();
3277} 3266}
3278 3267
3279 3268
@@ -3773,9 +3762,7 @@ x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval
3773void 3762void
3774x_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 3763x_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3775{ 3764{
3776#if (defined (HAVE_WINDOW_SYSTEM) \ 3765#if USE_HORIZONTAL_SCROLL_BARS
3777 && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS)) \
3778 || defined (HAVE_NTGUI)))
3779 if ((NILP (arg) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f)) 3766 if ((NILP (arg) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f))
3780 || (!NILP (arg) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f))) 3767 || (!NILP (arg) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f)))
3781 { 3768 {
@@ -3825,9 +3812,7 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3825void 3812void
3826x_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 3813x_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3827{ 3814{
3828#if (defined (HAVE_WINDOW_SYSTEM) \ 3815#if USE_HORIZONTAL_SCROLL_BARS
3829 && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS)) \
3830 || defined (HAVE_NTGUI)))
3831 int unit = FRAME_LINE_HEIGHT (f); 3816 int unit = FRAME_LINE_HEIGHT (f);
3832 3817
3833 if (NILP (arg)) 3818 if (NILP (arg))
@@ -4010,10 +3995,6 @@ validate_x_resource_name (void)
4010static Lisp_Object 3995static Lisp_Object
4011xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Lisp_Object component, Lisp_Object subclass) 3996xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Lisp_Object component, Lisp_Object subclass)
4012{ 3997{
4013 register char *value;
4014 char *name_key;
4015 char *class_key;
4016
4017 CHECK_STRING (attribute); 3998 CHECK_STRING (attribute);
4018 CHECK_STRING (class); 3999 CHECK_STRING (class);
4019 4000
@@ -4028,22 +4009,25 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li
4028 4009
4029 /* Allocate space for the components, the dots which separate them, 4010 /* Allocate space for the components, the dots which separate them,
4030 and the final '\0'. Make them big enough for the worst case. */ 4011 and the final '\0'. Make them big enough for the worst case. */
4031 name_key = alloca (SBYTES (Vx_resource_name) 4012 ptrdiff_t name_keysize = (SBYTES (Vx_resource_name)
4032 + (STRINGP (component) 4013 + (STRINGP (component)
4033 ? SBYTES (component) : 0) 4014 ? SBYTES (component) : 0)
4034 + SBYTES (attribute) 4015 + SBYTES (attribute)
4035 + 3); 4016 + 3);
4036 4017
4037 class_key = alloca (SBYTES (Vx_resource_class) 4018 ptrdiff_t class_keysize = (SBYTES (Vx_resource_class)
4038 + SBYTES (class) 4019 + SBYTES (class)
4039 + (STRINGP (subclass) 4020 + (STRINGP (subclass)
4040 ? SBYTES (subclass) : 0) 4021 ? SBYTES (subclass) : 0)
4041 + 3); 4022 + 3);
4023 USE_SAFE_ALLOCA;
4024 char *name_key = SAFE_ALLOCA (name_keysize + class_keysize);
4025 char *class_key = name_key + name_keysize;
4042 4026
4043 /* Start with emacs.FRAMENAME for the name (the specific one) 4027 /* Start with emacs.FRAMENAME for the name (the specific one)
4044 and with `Emacs' for the class key (the general one). */ 4028 and with `Emacs' for the class key (the general one). */
4045 strcpy (name_key, SSDATA (Vx_resource_name)); 4029 lispstpcpy (name_key, Vx_resource_name);
4046 strcpy (class_key, SSDATA (Vx_resource_class)); 4030 lispstpcpy (class_key, Vx_resource_class);
4047 4031
4048 strcat (class_key, "."); 4032 strcat (class_key, ".");
4049 strcat (class_key, SSDATA (class)); 4033 strcat (class_key, SSDATA (class));
@@ -4060,7 +4044,8 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li
4060 strcat (name_key, "."); 4044 strcat (name_key, ".");
4061 strcat (name_key, SSDATA (attribute)); 4045 strcat (name_key, SSDATA (attribute));
4062 4046
4063 value = x_get_string_resource (rdb, name_key, class_key); 4047 char *value = x_get_string_resource (rdb, name_key, class_key);
4048 SAFE_FREE();
4064 4049
4065 if (value && *value) 4050 if (value && *value)
4066 return build_string (value); 4051 return build_string (value);
@@ -4112,8 +4097,10 @@ x_get_resource_string (const char *attribute, const char *class)
4112 4097
4113 /* Allocate space for the components, the dots which separate them, 4098 /* Allocate space for the components, the dots which separate them,
4114 and the final '\0'. */ 4099 and the final '\0'. */
4115 char *name_key = SAFE_ALLOCA (invocation_namelen + strlen (attribute) + 2); 4100 ptrdiff_t name_keysize = invocation_namelen + strlen (attribute) + 2;
4116 char *class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2); 4101 ptrdiff_t class_keysize = sizeof (EMACS_CLASS) - 1 + strlen (class) + 2;
4102 char *name_key = SAFE_ALLOCA (name_keysize + class_keysize);
4103 char *class_key = name_key + name_keysize;
4117 4104
4118 esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); 4105 esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
4119 sprintf (class_key, "%s.%s", EMACS_CLASS, class); 4106 sprintf (class_key, "%s.%s", EMACS_CLASS, class);
@@ -4140,7 +4127,7 @@ Lisp_Object
4140x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, 4127x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
4141 const char *attribute, const char *class, enum resource_types type) 4128 const char *attribute, const char *class, enum resource_types type)
4142{ 4129{
4143 register Lisp_Object tem; 4130 Lisp_Object tem;
4144 4131
4145 tem = Fassq (param, alist); 4132 tem = Fassq (param, alist);
4146 4133
@@ -4166,10 +4153,9 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
4166 { 4153 {
4167 if (attribute && dpyinfo) 4154 if (attribute && dpyinfo)
4168 { 4155 {
4169 tem = display_x_get_resource (dpyinfo, 4156 AUTO_STRING (at, attribute);
4170 build_string (attribute), 4157 AUTO_STRING (cl, class);
4171 build_string (class), 4158 tem = display_x_get_resource (dpyinfo, at, cl, Qnil, Qnil);
4172 Qnil, Qnil);
4173 4159
4174 if (NILP (tem)) 4160 if (NILP (tem))
4175 return Qunbound; 4161 return Qunbound;
@@ -4279,7 +4265,8 @@ x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop,
4279 tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type); 4265 tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type);
4280 if (EQ (tem, Qunbound)) 4266 if (EQ (tem, Qunbound))
4281 tem = deflt; 4267 tem = deflt;
4282 x_set_frame_parameters (f, list1 (Fcons (prop, tem))); 4268 AUTO_FRAME_ARG (arg, prop, tem);
4269 x_set_frame_parameters (f, arg);
4283 return tem; 4270 return tem;
4284} 4271}
4285 4272
@@ -4872,16 +4859,6 @@ Setting this variable does not affect existing frames, only new ones. */);
4872 Vdefault_frame_scroll_bars = Qnil; 4859 Vdefault_frame_scroll_bars = Qnil;
4873#endif 4860#endif
4874 4861
4875 DEFVAR_LISP ("default-frame-horizontal-scroll-bars", Vdefault_frame_horizontal_scroll_bars,
4876 doc: /* Default value for horizontal scroll bars on this window-system. */);
4877#if (defined (HAVE_WINDOW_SYSTEM) \
4878 && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS)) \
4879 || defined (HAVE_NTGUI)))
4880 Vdefault_frame_horizontal_scroll_bars = Qt;
4881#else
4882 Vdefault_frame_horizontal_scroll_bars = Qnil;
4883#endif
4884
4885 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion", 4862 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4886 scroll_bar_adjust_thumb_portion_p, 4863 scroll_bar_adjust_thumb_portion_p,
4887 doc: /* Adjust thumb for overscrolling for Gtk+ and MOTIF. 4864 doc: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
@@ -4897,8 +4874,8 @@ is visible. In this case you can not overscroll. */);
4897 4874
4898 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function, 4875 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function,
4899 doc: /* If non-nil, function to transform normal value of `mouse-position'. 4876 doc: /* If non-nil, function to transform normal value of `mouse-position'.
4900`mouse-position' calls this function, passing its usual return value as 4877`mouse-position' and `mouse-pixel-position' call this function, passing their
4901argument, and returns whatever this function returns. 4878usual return value as argument, and return whatever this function returns.
4902This abnormal hook exists for the benefit of packages like `xt-mouse.el' 4879This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4903which need to do mouse handling at the Lisp level. */); 4880which need to do mouse handling at the Lisp level. */);
4904 Vmouse_position_function = Qnil; 4881 Vmouse_position_function = Qnil;