aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2016-06-30 09:21:07 +0300
committerDmitry Antipov2016-06-30 09:21:07 +0300
commit3aeb7c35edf3ae4042717889d8bdd40e1b861be0 (patch)
tree6959a380ff3648b9e2aad6428c6ee1732757f439 /src
parent4bd3503991e501690b30c3415d4641efb6e1de3a (diff)
downloademacs-3aeb7c35edf3ae4042717889d8bdd40e1b861be0.tar.gz
emacs-3aeb7c35edf3ae4042717889d8bdd40e1b861be0.zip
Simplify handling of frame parameters
* src/frame.c (x_set_frame_parameters): Avoid extra loop processing foreground color, background color and font parameters. Adjust comments.
Diffstat (limited to 'src')
-rw-r--r--src/frame.c79
1 files changed, 31 insertions, 48 deletions
diff --git a/src/frame.c b/src/frame.c
index aa06a381108..540b69f9c3d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -3110,70 +3110,58 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3110 /* Record in these vectors all the parms specified. */ 3110 /* Record in these vectors all the parms specified. */
3111 Lisp_Object *parms; 3111 Lisp_Object *parms;
3112 Lisp_Object *values; 3112 Lisp_Object *values;
3113 ptrdiff_t i, p; 3113 ptrdiff_t i, j, size;
3114 bool left_no_change = 0, top_no_change = 0; 3114 bool left_no_change = 0, top_no_change = 0;
3115#ifdef HAVE_X_WINDOWS 3115#ifdef HAVE_X_WINDOWS
3116 bool icon_left_no_change = 0, icon_top_no_change = 0; 3116 bool icon_left_no_change = 0, icon_top_no_change = 0;
3117#endif 3117#endif
3118 3118
3119 i = 0; 3119 for (size = 0, tail = alist; CONSP (tail); tail = XCDR (tail))
3120 for (tail = alist; CONSP (tail); tail = XCDR (tail)) 3120 size++;
3121 i++;
3122 3121
3123 USE_SAFE_ALLOCA; 3122 USE_SAFE_ALLOCA;
3124 SAFE_ALLOCA_LISP (parms, 2 * i); 3123 SAFE_ALLOCA_LISP (parms, 2 * size);
3125 values = parms + i; 3124 values = parms + size;
3126 3125
3127 /* Extract parm names and values into those vectors. */ 3126 /* Extract parm names and values into those vectors. */
3128 3127
3129 i = 0; 3128 i = 0, j = size - 1;
3130 for (tail = alist; CONSP (tail); tail = XCDR (tail)) 3129 for (tail = alist; CONSP (tail); tail = XCDR (tail))
3131 { 3130 {
3132 Lisp_Object elt; 3131 Lisp_Object elt = XCAR (tail), prop = Fcar (elt), val = Fcdr (elt);
3133
3134 elt = XCAR (tail);
3135 parms[i] = Fcar (elt);
3136 values[i] = Fcdr (elt);
3137 i++;
3138 }
3139 /* TAIL and ALIST are not used again below here. */
3140 alist = tail = Qnil;
3141
3142 top = left = Qunbound;
3143 icon_left = icon_top = Qunbound;
3144 3132
3145 /* Process foreground_color and background_color before anything else. 3133 /* Some properties are independent of other properties, but other
3146 They are independent of other properties, but other properties (e.g., 3134 properties are dependent upon them. These special properties
3147 cursor_color) are dependent upon them. */ 3135 are foreground_color, background_color (affects cursor_color)
3148 /* Process default font as well, since fringe widths depends on it. */ 3136 and font (affects fringe widths); they're recorded starting
3149 for (p = 0; p < i; p++) 3137 from the end of PARMS and VALUES to process them first by using
3150 { 3138 reverse iteration. */
3151 Lisp_Object prop, val;
3152 3139
3153 prop = parms[p];
3154 val = values[p];
3155 if (EQ (prop, Qforeground_color) 3140 if (EQ (prop, Qforeground_color)
3156 || EQ (prop, Qbackground_color) 3141 || EQ (prop, Qbackground_color)
3157 || EQ (prop, Qfont)) 3142 || EQ (prop, Qfont))
3158 { 3143 {
3159 register Lisp_Object param_index, old_value; 3144 parms[j] = prop;
3160 3145 values[j] = val;
3161 old_value = get_frame_param (f, prop); 3146 j--;
3162 if (NILP (Fequal (val, old_value))) 3147 }
3163 { 3148 else
3164 store_frame_param (f, prop, val); 3149 {
3165 3150 parms[i] = prop;
3166 param_index = Fget (prop, Qx_frame_parameter); 3151 values[i] = val;
3167 if (NATNUMP (param_index) 3152 i++;
3168 && XFASTINT (param_index) < ARRAYELTS (frame_parms)
3169 && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])
3170 (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
3171 }
3172 } 3153 }
3173 } 3154 }
3174 3155
3175 /* Now process them in reverse of specified order. */ 3156 /* TAIL and ALIST are not used again below here. */
3176 while (i-- != 0) 3157 alist = tail = Qnil;
3158
3159 top = left = Qunbound;
3160 icon_left = icon_top = Qunbound;
3161
3162 /* Reverse order is used to make sure that special
3163 properties noticed above are processed first. */
3164 for (i = size - 1; i >= 0; i--)
3177 { 3165 {
3178 Lisp_Object prop, val; 3166 Lisp_Object prop, val;
3179 3167
@@ -3221,11 +3209,6 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3221 fullscreen = val; 3209 fullscreen = val;
3222 fullscreen_change = true; 3210 fullscreen_change = true;
3223 } 3211 }
3224 else if (EQ (prop, Qforeground_color)
3225 || EQ (prop, Qbackground_color)
3226 || EQ (prop, Qfont))
3227 /* Processed above. */
3228 continue;
3229 else 3212 else
3230 { 3213 {
3231 register Lisp_Object param_index, old_value; 3214 register Lisp_Object param_index, old_value;