diff options
Diffstat (limited to 'src/frame.c')
| -rw-r--r-- | src/frame.c | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/src/frame.c b/src/frame.c index 635996ca424..1db24cc80e7 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* Generic frame functions. | 1 | /* Generic frame functions. |
| 2 | 2 | ||
| 3 | Copyright (C) 1993-1995, 1997, 1999-2011 Free Software Foundation, Inc. | 3 | Copyright (C) 1993-1995, 1997, 1999-2012 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 6 | 6 | ||
| @@ -160,7 +160,7 @@ set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) | |||
| 160 | if (FRAME_MINIBUF_ONLY_P (f)) | 160 | if (FRAME_MINIBUF_ONLY_P (f)) |
| 161 | return; | 161 | return; |
| 162 | 162 | ||
| 163 | if (INTEGERP (value)) | 163 | if (TYPE_RANGED_INTEGERP (int, value)) |
| 164 | nlines = XINT (value); | 164 | nlines = XINT (value); |
| 165 | else | 165 | else |
| 166 | nlines = 0; | 166 | nlines = 0; |
| @@ -374,7 +374,7 @@ make_frame (int mini_p) | |||
| 374 | 374 | ||
| 375 | /* Use set_window_buffer, not Fset_window_buffer, and don't let | 375 | /* Use set_window_buffer, not Fset_window_buffer, and don't let |
| 376 | hooks be run by it. The reason is that the whole frame/window | 376 | hooks be run by it. The reason is that the whole frame/window |
| 377 | arrangement is not yet fully intialized at this point. Windows | 377 | arrangement is not yet fully initialized at this point. Windows |
| 378 | don't have the right size, glyph matrices aren't initialized | 378 | don't have the right size, glyph matrices aren't initialized |
| 379 | etc. Running Lisp functions at this point surely ends in a | 379 | etc. Running Lisp functions at this point surely ends in a |
| 380 | SEGV. */ | 380 | SEGV. */ |
| @@ -497,7 +497,7 @@ make_minibuffer_frame (void) | |||
| 497 | 497 | ||
| 498 | /* Construct a frame that refers to a terminal. */ | 498 | /* Construct a frame that refers to a terminal. */ |
| 499 | 499 | ||
| 500 | static int tty_frame_count; | 500 | static printmax_t tty_frame_count; |
| 501 | 501 | ||
| 502 | struct frame * | 502 | struct frame * |
| 503 | make_initial_frame (void) | 503 | make_initial_frame (void) |
| @@ -551,7 +551,7 @@ make_terminal_frame (struct terminal *terminal) | |||
| 551 | { | 551 | { |
| 552 | register struct frame *f; | 552 | register struct frame *f; |
| 553 | Lisp_Object frame; | 553 | Lisp_Object frame; |
| 554 | char name[20]; | 554 | char name[sizeof "F" + INT_STRLEN_BOUND (printmax_t)]; |
| 555 | 555 | ||
| 556 | if (!terminal->name) | 556 | if (!terminal->name) |
| 557 | error ("Terminal is not live, can't create new frames on it"); | 557 | error ("Terminal is not live, can't create new frames on it"); |
| @@ -562,7 +562,7 @@ make_terminal_frame (struct terminal *terminal) | |||
| 562 | Vframe_list = Fcons (frame, Vframe_list); | 562 | Vframe_list = Fcons (frame, Vframe_list); |
| 563 | 563 | ||
| 564 | tty_frame_count++; | 564 | tty_frame_count++; |
| 565 | sprintf (name, "F%d", tty_frame_count); | 565 | sprintf (name, "F%"pMd, tty_frame_count); |
| 566 | f->name = build_string (name); | 566 | f->name = build_string (name); |
| 567 | 567 | ||
| 568 | f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */ | 568 | f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */ |
| @@ -1118,52 +1118,32 @@ Otherwise, include all frames. */) | |||
| 1118 | static int | 1118 | static int |
| 1119 | other_visible_frames (FRAME_PTR f) | 1119 | other_visible_frames (FRAME_PTR f) |
| 1120 | { | 1120 | { |
| 1121 | /* We know the selected frame is visible, | 1121 | Lisp_Object frames; |
| 1122 | so if F is some other frame, it can't be the sole visible one. */ | ||
| 1123 | if (f == SELECTED_FRAME ()) | ||
| 1124 | { | ||
| 1125 | Lisp_Object frames; | ||
| 1126 | int count = 0; | ||
| 1127 | 1122 | ||
| 1128 | for (frames = Vframe_list; | 1123 | for (frames = Vframe_list; CONSP (frames); frames = XCDR (frames)) |
| 1129 | CONSP (frames); | 1124 | { |
| 1130 | frames = XCDR (frames)) | 1125 | Lisp_Object this = XCAR (frames); |
| 1131 | { | 1126 | if (f == XFRAME (this)) |
| 1132 | Lisp_Object this; | 1127 | continue; |
| 1133 | 1128 | ||
| 1134 | this = XCAR (frames); | 1129 | /* Verify that we can still talk to the frame's X window, |
| 1135 | /* Verify that the frame's window still exists | 1130 | and note any recent change in visibility. */ |
| 1136 | and we can still talk to it. And note any recent change | ||
| 1137 | in visibility. */ | ||
| 1138 | #ifdef HAVE_WINDOW_SYSTEM | 1131 | #ifdef HAVE_WINDOW_SYSTEM |
| 1139 | if (FRAME_WINDOW_P (XFRAME (this))) | 1132 | if (FRAME_WINDOW_P (XFRAME (this))) |
| 1140 | { | 1133 | { |
| 1141 | x_sync (XFRAME (this)); | 1134 | x_sync (XFRAME (this)); |
| 1142 | FRAME_SAMPLE_VISIBILITY (XFRAME (this)); | 1135 | FRAME_SAMPLE_VISIBILITY (XFRAME (this)); |
| 1143 | } | 1136 | } |
| 1144 | #endif | 1137 | #endif |
| 1145 | 1138 | ||
| 1146 | if (FRAME_VISIBLE_P (XFRAME (this)) | 1139 | if (FRAME_VISIBLE_P (XFRAME (this)) |
| 1147 | || FRAME_ICONIFIED_P (XFRAME (this)) | 1140 | || FRAME_ICONIFIED_P (XFRAME (this)) |
| 1148 | /* Allow deleting the terminal frame when at least | 1141 | /* Allow deleting the terminal frame when at least one X |
| 1149 | one X frame exists! */ | 1142 | frame exists. */ |
| 1150 | || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f))) | 1143 | || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f))) |
| 1151 | count++; | 1144 | return 1; |
| 1152 | } | ||
| 1153 | return count > 1; | ||
| 1154 | } | 1145 | } |
| 1155 | return 1; | 1146 | return 0; |
| 1156 | } | ||
| 1157 | |||
| 1158 | DEFUN ("other-visible-frames-p", Fother_visible_frames_p, Sother_visible_frames_p, 0, 1, 0, | ||
| 1159 | doc: /* Return t if there are other visible frames beside FRAME. | ||
| 1160 | FRAME defaults to the selected frame. */) | ||
| 1161 | (Lisp_Object frame) | ||
| 1162 | { | ||
| 1163 | if (NILP (frame)) | ||
| 1164 | frame = selected_frame; | ||
| 1165 | CHECK_LIVE_FRAME (frame); | ||
| 1166 | return other_visible_frames (XFRAME (frame)) ? Qt : Qnil; | ||
| 1167 | } | 1147 | } |
| 1168 | 1148 | ||
| 1169 | /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME | 1149 | /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME |
| @@ -1248,7 +1228,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) | |||
| 1248 | else | 1228 | else |
| 1249 | { | 1229 | { |
| 1250 | #ifdef HAVE_X_WINDOWS | 1230 | #ifdef HAVE_X_WINDOWS |
| 1251 | /* Also, save clipboard to the the clipboard manager. */ | 1231 | /* Also, save clipboard to the clipboard manager. */ |
| 1252 | x_clipboard_manager_save_frame (frame); | 1232 | x_clipboard_manager_save_frame (frame); |
| 1253 | #endif | 1233 | #endif |
| 1254 | 1234 | ||
| @@ -1331,7 +1311,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) | |||
| 1331 | 1311 | ||
| 1332 | /* Mark all the windows that used to be on FRAME as deleted, and then | 1312 | /* Mark all the windows that used to be on FRAME as deleted, and then |
| 1333 | remove the reference to them. */ | 1313 | remove the reference to them. */ |
| 1334 | delete_all_subwindows (f->root_window); | 1314 | delete_all_child_windows (f->root_window); |
| 1335 | f->root_window = Qnil; | 1315 | f->root_window = Qnil; |
| 1336 | 1316 | ||
| 1337 | Vframe_list = Fdelq (frame, Vframe_list); | 1317 | Vframe_list = Fdelq (frame, Vframe_list); |
| @@ -1370,6 +1350,13 @@ delete_frame (Lisp_Object frame, Lisp_Object force) | |||
| 1370 | /* If needed, delete the terminal that this frame was on. | 1350 | /* If needed, delete the terminal that this frame was on. |
| 1371 | (This must be done after the frame is killed.) */ | 1351 | (This must be done after the frame is killed.) */ |
| 1372 | terminal->reference_count--; | 1352 | terminal->reference_count--; |
| 1353 | #ifdef USE_GTK | ||
| 1354 | /* FIXME: Deleting the terminal crashes emacs because of a GTK | ||
| 1355 | bug. | ||
| 1356 | http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */ | ||
| 1357 | if (terminal->reference_count == 0 && terminal->type == output_x_window) | ||
| 1358 | terminal->reference_count = 1; | ||
| 1359 | #endif /* USE_GTK */ | ||
| 1373 | if (terminal->reference_count == 0) | 1360 | if (terminal->reference_count == 0) |
| 1374 | { | 1361 | { |
| 1375 | Lisp_Object tmp; | 1362 | Lisp_Object tmp; |
| @@ -1716,7 +1703,7 @@ If omitted, FRAME defaults to the currently selected frame. */) | |||
| 1716 | } | 1703 | } |
| 1717 | 1704 | ||
| 1718 | /* Update the display_time slot of the buffers shown in WINDOW | 1705 | /* Update the display_time slot of the buffers shown in WINDOW |
| 1719 | and all its descendents. */ | 1706 | and all its descendants. */ |
| 1720 | 1707 | ||
| 1721 | static void | 1708 | static void |
| 1722 | make_frame_visible_1 (Lisp_Object window) | 1709 | make_frame_visible_1 (Lisp_Object window) |
| @@ -1933,7 +1920,7 @@ request a switch to FOCUS-FRAME, and `last-event-frame' will be | |||
| 1933 | FOCUS-FRAME after reading an event typed at FRAME. | 1920 | FOCUS-FRAME after reading an event typed at FRAME. |
| 1934 | 1921 | ||
| 1935 | If FOCUS-FRAME is omitted or nil, any existing redirection is | 1922 | If FOCUS-FRAME is omitted or nil, any existing redirection is |
| 1936 | cancelled, and the frame again receives its own keystrokes. | 1923 | canceled, and the frame again receives its own keystrokes. |
| 1937 | 1924 | ||
| 1938 | Focus redirection is useful for temporarily redirecting keystrokes to | 1925 | Focus redirection is useful for temporarily redirecting keystrokes to |
| 1939 | a surrogate minibuffer frame when a frame doesn't have its own | 1926 | a surrogate minibuffer frame when a frame doesn't have its own |
| @@ -2074,7 +2061,7 @@ set_term_frame_name (struct frame *f, Lisp_Object name) | |||
| 2074 | /* If NAME is nil, set the name to F<num>. */ | 2061 | /* If NAME is nil, set the name to F<num>. */ |
| 2075 | if (NILP (name)) | 2062 | if (NILP (name)) |
| 2076 | { | 2063 | { |
| 2077 | char namebuf[20]; | 2064 | char namebuf[sizeof "F" + INT_STRLEN_BOUND (printmax_t)]; |
| 2078 | 2065 | ||
| 2079 | /* Check for no change needed in this very common case | 2066 | /* Check for no change needed in this very common case |
| 2080 | before we do any consing. */ | 2067 | before we do any consing. */ |
| @@ -2083,7 +2070,7 @@ set_term_frame_name (struct frame *f, Lisp_Object name) | |||
| 2083 | return; | 2070 | return; |
| 2084 | 2071 | ||
| 2085 | tty_frame_count++; | 2072 | tty_frame_count++; |
| 2086 | sprintf (namebuf, "F%d", tty_frame_count); | 2073 | sprintf (namebuf, "F%"pMd, tty_frame_count); |
| 2087 | name = build_string (namebuf); | 2074 | name = build_string (namebuf); |
| 2088 | } | 2075 | } |
| 2089 | else | 2076 | else |
| @@ -2437,11 +2424,9 @@ use is not recommended. Explicitly check for a frame-parameter instead. */) | |||
| 2437 | val = values[i]; | 2424 | val = values[i]; |
| 2438 | store_frame_param (f, prop, val); | 2425 | store_frame_param (f, prop, val); |
| 2439 | 2426 | ||
| 2440 | /* Changing the background color might change the background | 2427 | if (EQ (prop, Qforeground_color) |
| 2441 | mode, so that we have to load new defface specs. | 2428 | || EQ (prop, Qbackground_color)) |
| 2442 | Call frame-set-background-mode to do that. */ | 2429 | update_face_from_frame_parameter (f, prop, val); |
| 2443 | if (EQ (prop, Qbackground_color)) | ||
| 2444 | call1 (Qframe_set_background_mode, frame); | ||
| 2445 | } | 2430 | } |
| 2446 | } | 2431 | } |
| 2447 | return Qnil; | 2432 | return Qnil; |
| @@ -2500,7 +2485,7 @@ If FRAME is omitted, the selected frame is used. The exact value | |||
| 2500 | of the result depends on the window-system and toolkit in use: | 2485 | of the result depends on the window-system and toolkit in use: |
| 2501 | 2486 | ||
| 2502 | In the Gtk+ version of Emacs, it includes only any window (including | 2487 | In the Gtk+ version of Emacs, it includes only any window (including |
| 2503 | the minibuffer or eacho area), mode line, and header line. It does not | 2488 | the minibuffer or echo area), mode line, and header line. It does not |
| 2504 | include the tool bar or menu bar. | 2489 | include the tool bar or menu bar. |
| 2505 | 2490 | ||
| 2506 | With the Motif or Lucid toolkits, it also includes the tool bar (but | 2491 | With the Motif or Lucid toolkits, it also includes the tool bar (but |
| @@ -2994,7 +2979,7 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist) | |||
| 2994 | f->size_hint_flags &= ~ (XNegative | YNegative); | 2979 | f->size_hint_flags &= ~ (XNegative | YNegative); |
| 2995 | if (EQ (left, Qminus)) | 2980 | if (EQ (left, Qminus)) |
| 2996 | f->size_hint_flags |= XNegative; | 2981 | f->size_hint_flags |= XNegative; |
| 2997 | else if (INTEGERP (left)) | 2982 | else if (TYPE_RANGED_INTEGERP (int, left)) |
| 2998 | { | 2983 | { |
| 2999 | leftpos = XINT (left); | 2984 | leftpos = XINT (left); |
| 3000 | if (leftpos < 0) | 2985 | if (leftpos < 0) |
| @@ -3002,21 +2987,21 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist) | |||
| 3002 | } | 2987 | } |
| 3003 | else if (CONSP (left) && EQ (XCAR (left), Qminus) | 2988 | else if (CONSP (left) && EQ (XCAR (left), Qminus) |
| 3004 | && CONSP (XCDR (left)) | 2989 | && CONSP (XCDR (left)) |
| 3005 | && INTEGERP (XCAR (XCDR (left)))) | 2990 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (left)), INT_MAX)) |
| 3006 | { | 2991 | { |
| 3007 | leftpos = - XINT (XCAR (XCDR (left))); | 2992 | leftpos = - XINT (XCAR (XCDR (left))); |
| 3008 | f->size_hint_flags |= XNegative; | 2993 | f->size_hint_flags |= XNegative; |
| 3009 | } | 2994 | } |
| 3010 | else if (CONSP (left) && EQ (XCAR (left), Qplus) | 2995 | else if (CONSP (left) && EQ (XCAR (left), Qplus) |
| 3011 | && CONSP (XCDR (left)) | 2996 | && CONSP (XCDR (left)) |
| 3012 | && INTEGERP (XCAR (XCDR (left)))) | 2997 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left)))) |
| 3013 | { | 2998 | { |
| 3014 | leftpos = XINT (XCAR (XCDR (left))); | 2999 | leftpos = XINT (XCAR (XCDR (left))); |
| 3015 | } | 3000 | } |
| 3016 | 3001 | ||
| 3017 | if (EQ (top, Qminus)) | 3002 | if (EQ (top, Qminus)) |
| 3018 | f->size_hint_flags |= YNegative; | 3003 | f->size_hint_flags |= YNegative; |
| 3019 | else if (INTEGERP (top)) | 3004 | else if (TYPE_RANGED_INTEGERP (int, top)) |
| 3020 | { | 3005 | { |
| 3021 | toppos = XINT (top); | 3006 | toppos = XINT (top); |
| 3022 | if (toppos < 0) | 3007 | if (toppos < 0) |
| @@ -3024,14 +3009,14 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist) | |||
| 3024 | } | 3009 | } |
| 3025 | else if (CONSP (top) && EQ (XCAR (top), Qminus) | 3010 | else if (CONSP (top) && EQ (XCAR (top), Qminus) |
| 3026 | && CONSP (XCDR (top)) | 3011 | && CONSP (XCDR (top)) |
| 3027 | && INTEGERP (XCAR (XCDR (top)))) | 3012 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (top)), INT_MAX)) |
| 3028 | { | 3013 | { |
| 3029 | toppos = - XINT (XCAR (XCDR (top))); | 3014 | toppos = - XINT (XCAR (XCDR (top))); |
| 3030 | f->size_hint_flags |= YNegative; | 3015 | f->size_hint_flags |= YNegative; |
| 3031 | } | 3016 | } |
| 3032 | else if (CONSP (top) && EQ (XCAR (top), Qplus) | 3017 | else if (CONSP (top) && EQ (XCAR (top), Qplus) |
| 3033 | && CONSP (XCDR (top)) | 3018 | && CONSP (XCDR (top)) |
| 3034 | && INTEGERP (XCAR (XCDR (top)))) | 3019 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top)))) |
| 3035 | { | 3020 | { |
| 3036 | toppos = XINT (XCAR (XCDR (top))); | 3021 | toppos = XINT (XCAR (XCDR (top))); |
| 3037 | } | 3022 | } |
| @@ -3067,6 +3052,7 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) | |||
| 3067 | { | 3052 | { |
| 3068 | char buf[16]; | 3053 | char buf[16]; |
| 3069 | Lisp_Object tem; | 3054 | Lisp_Object tem; |
| 3055 | unsigned long w; | ||
| 3070 | 3056 | ||
| 3071 | /* Represent negative positions (off the top or left screen edge) | 3057 | /* Represent negative positions (off the top or left screen edge) |
| 3072 | in a way that Fmodify_frame_parameters will understand correctly. */ | 3058 | in a way that Fmodify_frame_parameters will understand correctly. */ |
| @@ -3099,7 +3085,12 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) | |||
| 3099 | for non-toolkit scroll bar. | 3085 | for non-toolkit scroll bar. |
| 3100 | ruler-mode.el depends on this. */ | 3086 | ruler-mode.el depends on this. */ |
| 3101 | : Qnil)); | 3087 | : Qnil)); |
| 3102 | sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f)); | 3088 | /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on |
| 3089 | MS-Windows it returns a value whose type is HANDLE, which is | ||
| 3090 | actually a pointer. Explicit casting avoids compiler | ||
| 3091 | warnings. */ | ||
| 3092 | w = (unsigned long) FRAME_X_WINDOW (f); | ||
| 3093 | sprintf (buf, "%lu", w); | ||
| 3103 | store_in_alist (alistptr, Qwindow_id, | 3094 | store_in_alist (alistptr, Qwindow_id, |
| 3104 | build_string (buf)); | 3095 | build_string (buf)); |
| 3105 | #ifdef HAVE_X_WINDOWS | 3096 | #ifdef HAVE_X_WINDOWS |
| @@ -3107,7 +3098,10 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) | |||
| 3107 | /* Tooltip frame may not have this widget. */ | 3098 | /* Tooltip frame may not have this widget. */ |
| 3108 | if (FRAME_X_OUTPUT (f)->widget) | 3099 | if (FRAME_X_OUTPUT (f)->widget) |
| 3109 | #endif | 3100 | #endif |
| 3110 | sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f)); | 3101 | { |
| 3102 | w = (unsigned long) FRAME_OUTER_WINDOW (f); | ||
| 3103 | sprintf (buf, "%lu", w); | ||
| 3104 | } | ||
| 3111 | store_in_alist (alistptr, Qouter_window_id, | 3105 | store_in_alist (alistptr, Qouter_window_id, |
| 3112 | build_string (buf)); | 3106 | build_string (buf)); |
| 3113 | #endif | 3107 | #endif |
| @@ -3483,7 +3477,7 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 3483 | x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); | 3477 | x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); |
| 3484 | do_pending_window_change (0); | 3478 | do_pending_window_change (0); |
| 3485 | } | 3479 | } |
| 3486 | else if (INTEGERP (arg) && XINT (arg) > 0 | 3480 | else if (RANGED_INTEGERP (1, arg, INT_MAX) |
| 3487 | && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) | 3481 | && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) |
| 3488 | { | 3482 | { |
| 3489 | if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM) | 3483 | if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM) |
| @@ -3522,7 +3516,7 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 3522 | { | 3516 | { |
| 3523 | double alpha = 1.0; | 3517 | double alpha = 1.0; |
| 3524 | double newval[2]; | 3518 | double newval[2]; |
| 3525 | int i, ialpha; | 3519 | int i; |
| 3526 | Lisp_Object item; | 3520 | Lisp_Object item; |
| 3527 | 3521 | ||
| 3528 | for (i = 0; i < 2; i++) | 3522 | for (i = 0; i < 2; i++) |
| @@ -3546,7 +3540,7 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 3546 | } | 3540 | } |
| 3547 | else if (INTEGERP (item)) | 3541 | else if (INTEGERP (item)) |
| 3548 | { | 3542 | { |
| 3549 | ialpha = XINT (item); | 3543 | EMACS_INT ialpha = XINT (item); |
| 3550 | if (ialpha < 0 || 100 < ialpha) | 3544 | if (ialpha < 0 || 100 < ialpha) |
| 3551 | args_out_of_range (make_number (0), make_number (100)); | 3545 | args_out_of_range (make_number (0), make_number (100)); |
| 3552 | else | 3546 | else |
| @@ -3578,13 +3572,13 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 3578 | void | 3572 | void |
| 3579 | validate_x_resource_name (void) | 3573 | validate_x_resource_name (void) |
| 3580 | { | 3574 | { |
| 3581 | int len = 0; | 3575 | ptrdiff_t len = 0; |
| 3582 | /* Number of valid characters in the resource name. */ | 3576 | /* Number of valid characters in the resource name. */ |
| 3583 | int good_count = 0; | 3577 | ptrdiff_t good_count = 0; |
| 3584 | /* Number of invalid characters in the resource name. */ | 3578 | /* Number of invalid characters in the resource name. */ |
| 3585 | int bad_count = 0; | 3579 | ptrdiff_t bad_count = 0; |
| 3586 | Lisp_Object new; | 3580 | Lisp_Object new; |
| 3587 | int i; | 3581 | ptrdiff_t i; |
| 3588 | 3582 | ||
| 3589 | if (!STRINGP (Vx_resource_class)) | 3583 | if (!STRINGP (Vx_resource_class)) |
| 3590 | Vx_resource_class = build_string (EMACS_CLASS); | 3584 | Vx_resource_class = build_string (EMACS_CLASS); |
| @@ -3617,8 +3611,9 @@ validate_x_resource_name (void) | |||
| 3617 | if (bad_count == 0) | 3611 | if (bad_count == 0) |
| 3618 | return; | 3612 | return; |
| 3619 | 3613 | ||
| 3620 | /* If name is entirely invalid, or nearly so, use `emacs'. */ | 3614 | /* If name is entirely invalid, or nearly so, or is so implausibly |
| 3621 | if (good_count < 2) | 3615 | large that alloca might not work, use `emacs'. */ |
| 3616 | if (good_count < 2 || MAX_ALLOCA - sizeof ".customization" < len) | ||
| 3622 | { | 3617 | { |
| 3623 | Vx_resource_name = build_string ("emacs"); | 3618 | Vx_resource_name = build_string ("emacs"); |
| 3624 | return; | 3619 | return; |
| @@ -3747,20 +3742,24 @@ x_get_resource_string (const char *attribute, const char *class) | |||
| 3747 | { | 3742 | { |
| 3748 | char *name_key; | 3743 | char *name_key; |
| 3749 | char *class_key; | 3744 | char *class_key; |
| 3745 | char *result; | ||
| 3750 | struct frame *sf = SELECTED_FRAME (); | 3746 | struct frame *sf = SELECTED_FRAME (); |
| 3747 | ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name); | ||
| 3748 | USE_SAFE_ALLOCA; | ||
| 3751 | 3749 | ||
| 3752 | /* Allocate space for the components, the dots which separate them, | 3750 | /* Allocate space for the components, the dots which separate them, |
| 3753 | and the final '\0'. */ | 3751 | and the final '\0'. */ |
| 3754 | name_key = (char *) alloca (SBYTES (Vinvocation_name) | 3752 | SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2); |
| 3755 | + strlen (attribute) + 2); | ||
| 3756 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) | 3753 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) |
| 3757 | + strlen (class) + 2); | 3754 | + strlen (class) + 2); |
| 3758 | 3755 | ||
| 3759 | sprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); | 3756 | esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); |
| 3760 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); | 3757 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); |
| 3761 | 3758 | ||
| 3762 | return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb, | 3759 | result = x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb, |
| 3763 | name_key, class_key); | 3760 | name_key, class_key); |
| 3761 | SAFE_FREE (); | ||
| 3762 | return result; | ||
| 3764 | } | 3763 | } |
| 3765 | #endif | 3764 | #endif |
| 3766 | 3765 | ||
| @@ -4033,11 +4032,15 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p) | |||
| 4033 | if (!EQ (tem0, Qunbound)) | 4032 | if (!EQ (tem0, Qunbound)) |
| 4034 | { | 4033 | { |
| 4035 | CHECK_NUMBER (tem0); | 4034 | CHECK_NUMBER (tem0); |
| 4035 | if (! (0 <= XINT (tem0) && XINT (tem0) <= INT_MAX)) | ||
| 4036 | xsignal1 (Qargs_out_of_range, tem0); | ||
| 4036 | FRAME_LINES (f) = XINT (tem0); | 4037 | FRAME_LINES (f) = XINT (tem0); |
| 4037 | } | 4038 | } |
| 4038 | if (!EQ (tem1, Qunbound)) | 4039 | if (!EQ (tem1, Qunbound)) |
| 4039 | { | 4040 | { |
| 4040 | CHECK_NUMBER (tem1); | 4041 | CHECK_NUMBER (tem1); |
| 4042 | if (! (0 <= XINT (tem1) && XINT (tem1) <= INT_MAX)) | ||
| 4043 | xsignal1 (Qargs_out_of_range, tem1); | ||
| 4041 | SET_FRAME_COLS (f, XINT (tem1)); | 4044 | SET_FRAME_COLS (f, XINT (tem1)); |
| 4042 | } | 4045 | } |
| 4043 | if (!NILP (tem2) && !EQ (tem2, Qunbound)) | 4046 | if (!NILP (tem2) && !EQ (tem2, Qunbound)) |
| @@ -4068,12 +4071,10 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p) | |||
| 4068 | ? tool_bar_button_relief | 4071 | ? tool_bar_button_relief |
| 4069 | : DEFAULT_TOOL_BAR_BUTTON_RELIEF); | 4072 | : DEFAULT_TOOL_BAR_BUTTON_RELIEF); |
| 4070 | 4073 | ||
| 4071 | if (INTEGERP (Vtool_bar_button_margin) | 4074 | if (RANGED_INTEGERP (1, Vtool_bar_button_margin, INT_MAX)) |
| 4072 | && XINT (Vtool_bar_button_margin) > 0) | ||
| 4073 | margin = XFASTINT (Vtool_bar_button_margin); | 4075 | margin = XFASTINT (Vtool_bar_button_margin); |
| 4074 | else if (CONSP (Vtool_bar_button_margin) | 4076 | else if (CONSP (Vtool_bar_button_margin) |
| 4075 | && INTEGERP (XCDR (Vtool_bar_button_margin)) | 4077 | && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin), INT_MAX)) |
| 4076 | && XINT (XCDR (Vtool_bar_button_margin)) > 0) | ||
| 4077 | margin = XFASTINT (XCDR (Vtool_bar_button_margin)); | 4078 | margin = XFASTINT (XCDR (Vtool_bar_button_margin)); |
| 4078 | else | 4079 | else |
| 4079 | margin = 0; | 4080 | margin = 0; |
| @@ -4099,14 +4100,14 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p) | |||
| 4099 | } | 4100 | } |
| 4100 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus) | 4101 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus) |
| 4101 | && CONSP (XCDR (tem0)) | 4102 | && CONSP (XCDR (tem0)) |
| 4102 | && INTEGERP (XCAR (XCDR (tem0)))) | 4103 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem0)), INT_MAX)) |
| 4103 | { | 4104 | { |
| 4104 | f->top_pos = - XINT (XCAR (XCDR (tem0))); | 4105 | f->top_pos = - XINT (XCAR (XCDR (tem0))); |
| 4105 | window_prompting |= YNegative; | 4106 | window_prompting |= YNegative; |
| 4106 | } | 4107 | } |
| 4107 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus) | 4108 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus) |
| 4108 | && CONSP (XCDR (tem0)) | 4109 | && CONSP (XCDR (tem0)) |
| 4109 | && INTEGERP (XCAR (XCDR (tem0)))) | 4110 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0)))) |
| 4110 | { | 4111 | { |
| 4111 | f->top_pos = XINT (XCAR (XCDR (tem0))); | 4112 | f->top_pos = XINT (XCAR (XCDR (tem0))); |
| 4112 | } | 4113 | } |
| @@ -4127,14 +4128,14 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p) | |||
| 4127 | } | 4128 | } |
| 4128 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus) | 4129 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus) |
| 4129 | && CONSP (XCDR (tem1)) | 4130 | && CONSP (XCDR (tem1)) |
| 4130 | && INTEGERP (XCAR (XCDR (tem1)))) | 4131 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem1)), INT_MAX)) |
| 4131 | { | 4132 | { |
| 4132 | f->left_pos = - XINT (XCAR (XCDR (tem1))); | 4133 | f->left_pos = - XINT (XCAR (XCDR (tem1))); |
| 4133 | window_prompting |= XNegative; | 4134 | window_prompting |= XNegative; |
| 4134 | } | 4135 | } |
| 4135 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus) | 4136 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus) |
| 4136 | && CONSP (XCDR (tem1)) | 4137 | && CONSP (XCDR (tem1)) |
| 4137 | && INTEGERP (XCAR (XCDR (tem1)))) | 4138 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1)))) |
| 4138 | { | 4139 | { |
| 4139 | f->left_pos = XINT (XCAR (XCDR (tem1))); | 4140 | f->left_pos = XINT (XCAR (XCDR (tem1))); |
| 4140 | } | 4141 | } |
| @@ -4360,7 +4361,7 @@ Setting this variable does not affect existing frames, only new ones. */); | |||
| 4360 | DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars, | 4361 | DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars, |
| 4361 | doc: /* Default position of scroll bars on this window-system. */); | 4362 | doc: /* Default position of scroll bars on this window-system. */); |
| 4362 | #ifdef HAVE_WINDOW_SYSTEM | 4363 | #ifdef HAVE_WINDOW_SYSTEM |
| 4363 | #if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS)) | 4364 | #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)) |
| 4364 | /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by | 4365 | /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by |
| 4365 | default. */ | 4366 | default. */ |
| 4366 | Vdefault_frame_scroll_bars = Qright; | 4367 | Vdefault_frame_scroll_bars = Qright; |
| @@ -4461,7 +4462,6 @@ automatically. See also `mouse-autoselect-window'. */); | |||
| 4461 | defsubr (&Sframe_list); | 4462 | defsubr (&Sframe_list); |
| 4462 | defsubr (&Snext_frame); | 4463 | defsubr (&Snext_frame); |
| 4463 | defsubr (&Sprevious_frame); | 4464 | defsubr (&Sprevious_frame); |
| 4464 | defsubr (&Sother_visible_frames_p); | ||
| 4465 | defsubr (&Sdelete_frame); | 4465 | defsubr (&Sdelete_frame); |
| 4466 | defsubr (&Smouse_position); | 4466 | defsubr (&Smouse_position); |
| 4467 | defsubr (&Smouse_pixel_position); | 4467 | defsubr (&Smouse_pixel_position); |