aboutsummaryrefslogtreecommitdiffstats
path: root/src/frame.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/frame.c')
-rw-r--r--src/frame.c208
1 files changed, 146 insertions, 62 deletions
diff --git a/src/frame.c b/src/frame.c
index 890e8972617..92b6b7c73ba 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -149,6 +149,32 @@ get_frame_param (register struct frame *frame, Lisp_Object prop)
149 return Fcdr (tem); 149 return Fcdr (tem);
150} 150}
151 151
152
153void
154frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
155 int width, int height, Lisp_Object rest)
156{
157 Lisp_Object frame;
158
159 XSETFRAME (frame, f);
160 if (CONSP (frame_size_history)
161 && INTEGERP (XCAR (frame_size_history))
162 && 0 < XINT (XCAR (frame_size_history)))
163 frame_size_history =
164 Fcons (make_number (XINT (XCAR (frame_size_history)) - 1),
165 Fcons (list4
166 (frame, fun_symbol,
167 ((width > 0)
168 ? list4 (make_number (FRAME_TEXT_WIDTH (f)),
169 make_number (FRAME_TEXT_HEIGHT (f)),
170 make_number (width),
171 make_number (height))
172 : Qnil),
173 rest),
174 XCDR (frame_size_history)));
175}
176
177
152/* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen 178/* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
153 state of frame F would be affected by a vertical (horizontal if 179 state of frame F would be affected by a vertical (horizontal if
154 HORIZONTAL is true) resize. PARAMETER is the symbol of the frame 180 HORIZONTAL is true) resize. PARAMETER is the symbol of the frame
@@ -156,11 +182,27 @@ get_frame_param (register struct frame *frame, Lisp_Object prop)
156bool 182bool
157frame_inhibit_resize (struct frame *f, bool horizontal, Lisp_Object parameter) 183frame_inhibit_resize (struct frame *f, bool horizontal, Lisp_Object parameter)
158{ 184{
159 return (EQ (frame_inhibit_implied_resize, Qt) 185 Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
160 || (CONSP (frame_inhibit_implied_resize) 186 bool inhibit
161 && !NILP (Fmemq (parameter, frame_inhibit_implied_resize))) 187 = ((f->after_make_frame
162 || !NILP (get_frame_param (f, Qfullscreen)) 188 && (EQ (frame_inhibit_implied_resize, Qt)
163 || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)); 189 || (CONSP (frame_inhibit_implied_resize)
190 && !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))))
191 || (horizontal
192 && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullheight))
193 || (!horizontal
194 && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullwidth))
195 || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f));
196
197 if (inhibit && !FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f))
198 frame_size_history_add
199 (f, Qframe_inhibit_resize, 0, 0,
200 list5 (horizontal ? Qt : Qnil, parameter,
201 f->after_make_frame ? Qt : Qnil,
202 frame_inhibit_implied_resize,
203 fullscreen));
204
205 return inhibit;
164} 206}
165 207
166static void 208static void
@@ -369,18 +411,9 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
369 411
370 XSETFRAME (frame, f); 412 XSETFRAME (frame, f);
371 413
372 /* `make-frame' initializes Vframe_adjust_size_history to (Qt) and 414 frame_size_history_add
373 strips its car when exiting. Just in case make sure its size never 415 (f, Qadjust_frame_size_1, new_text_width, new_text_height,
374 exceeds 100. */ 416 list2 (parameter, make_number (inhibit)));
375 if (!NILP (Fconsp (Vframe_adjust_size_history))
376 && EQ (Fcar (Vframe_adjust_size_history), Qt)
377 && XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100)
378 Vframe_adjust_size_history =
379 Fcons (Qt, Fcons (list5 (make_number (0),
380 make_number (new_text_width),
381 make_number (new_text_height),
382 make_number (inhibit), parameter),
383 Fcdr (Vframe_adjust_size_history)));
384 417
385 /* The following two values are calculated from the old window body 418 /* The following two values are calculated from the old window body
386 sizes and any "new" settings for scroll bars, dividers, fringes and 419 sizes and any "new" settings for scroll bars, dividers, fringes and
@@ -391,7 +424,7 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
391 = frame_windows_min_size (frame, Qnil, (inhibit == 5) ? Qt : Qnil, Qt); 424 = frame_windows_min_size (frame, Qnil, (inhibit == 5) ? Qt : Qnil, Qt);
392 425
393 if (inhibit >= 2 && inhibit <= 4) 426 if (inhibit >= 2 && inhibit <= 4)
394 /* If INHIBIT is in [2..4] inhibit if the "old" window sizes stay 427 /* When INHIBIT is in [2..4] inhibit if the "old" window sizes stay
395 within the limits and either frame_inhibit_resize tells us to do 428 within the limits and either frame_inhibit_resize tells us to do
396 so or INHIBIT equals 4. */ 429 so or INHIBIT equals 4. */
397 { 430 {
@@ -449,16 +482,10 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
449 else if (inhibit_vertical) 482 else if (inhibit_vertical)
450 new_text_height = old_text_height; 483 new_text_height = old_text_height;
451 484
452 if (!NILP (Fconsp (Vframe_adjust_size_history)) 485 frame_size_history_add
453 && EQ (Fcar (Vframe_adjust_size_history), Qt) 486 (f, Qadjust_frame_size_2, new_text_width, new_text_height,
454 && XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100) 487 list2 (inhibit_horizontal ? Qt : Qnil,
455 Vframe_adjust_size_history = 488 inhibit_vertical ? Qt : Qnil));
456 Fcons (Qt, Fcons (list5 (make_number (1),
457 make_number (new_text_width),
458 make_number (new_text_height),
459 make_number (new_cols),
460 make_number (new_lines)),
461 Fcdr (Vframe_adjust_size_history)));
462 489
463 x_set_window_size (f, 0, new_text_width, new_text_height, 1); 490 x_set_window_size (f, 0, new_text_width, new_text_height, 1);
464 f->resized_p = true; 491 f->resized_p = true;
@@ -525,6 +552,11 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
525 FrameRows (FRAME_TTY (f)) = new_lines + FRAME_TOP_MARGIN (f); 552 FrameRows (FRAME_TTY (f)) = new_lines + FRAME_TOP_MARGIN (f);
526 } 553 }
527 554
555 frame_size_history_add
556 (f, Qadjust_frame_size_3, new_text_width, new_text_height,
557 list4 (make_number (old_pixel_width), make_number (old_pixel_height),
558 make_number (new_pixel_width), make_number (new_pixel_height)));
559
528 /* Assign new sizes. */ 560 /* Assign new sizes. */
529 FRAME_TEXT_WIDTH (f) = new_text_width; 561 FRAME_TEXT_WIDTH (f) = new_text_width;
530 FRAME_TEXT_HEIGHT (f) = new_text_height; 562 FRAME_TEXT_HEIGHT (f) = new_text_height;
@@ -533,17 +565,6 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
533 SET_FRAME_COLS (f, new_cols); 565 SET_FRAME_COLS (f, new_cols);
534 SET_FRAME_LINES (f, new_lines); 566 SET_FRAME_LINES (f, new_lines);
535 567
536 if (!NILP (Fconsp (Vframe_adjust_size_history))
537 && EQ (Fcar (Vframe_adjust_size_history), Qt)
538 && XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100)
539 Vframe_adjust_size_history =
540 Fcons (Qt, Fcons (list5 (make_number (2),
541 make_number (new_text_width),
542 make_number (new_text_height),
543 make_number (new_cols),
544 make_number (new_lines)),
545 Fcdr (Vframe_adjust_size_history)));
546
547 { 568 {
548 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); 569 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
549 int text_area_x, text_area_y, text_area_width, text_area_height; 570 int text_area_x, text_area_y, text_area_width, text_area_height;
@@ -608,7 +629,7 @@ make_frame (bool mini_p)
608 f->redisplay = true; 629 f->redisplay = true;
609 f->garbaged = true; 630 f->garbaged = true;
610 f->can_x_set_window_size = false; 631 f->can_x_set_window_size = false;
611 f->can_run_window_configuration_change_hook = false; 632 f->after_make_frame = false;
612 f->tool_bar_redisplayed_once = false; 633 f->tool_bar_redisplayed_once = false;
613 f->column_width = 1; /* !FRAME_WINDOW_P value. */ 634 f->column_width = 1; /* !FRAME_WINDOW_P value. */
614 f->line_height = 1; /* !FRAME_WINDOW_P value. */ 635 f->line_height = 1; /* !FRAME_WINDOW_P value. */
@@ -1020,7 +1041,8 @@ affects all frames on the same terminal device. */)
1020 { 1041 {
1021 int width, height; 1042 int width, height;
1022 get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height); 1043 get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height);
1023 adjust_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f), 5, 0, Qnil); 1044 adjust_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f),
1045 5, 0, Qterminal_frame);
1024 } 1046 }
1025 1047
1026 adjust_frame_glyphs (f); 1048 adjust_frame_glyphs (f);
@@ -2260,24 +2282,23 @@ If there is no window system support, this function does nothing. */)
2260 return Qnil; 2282 return Qnil;
2261} 2283}
2262 2284
2263DEFUN ("frame-can-run-window-configuration-change-hook", 2285DEFUN ("frame-after-make-frame",
2264 Fcan_run_window_configuration_change_hook, 2286 Fframe_after_make_frame,
2265 Scan_run_window_configuration_change_hook, 2, 2, 0, 2287 Sframe_after_make_frame, 2, 2, 0,
2266 doc: /* Whether `window-configuration-change-hook' is run for frame FRAME. 2288 doc: /* Mark FRAME as made.
2267FRAME nil means use the selected frame. Second argument ALLOW non-nil 2289FRAME nil means use the selected frame. Second argument MADE non-nil
2268means functions on `window-configuration-change-hook' are called 2290means functions on `window-configuration-change-hook' are called
2269whenever the window configuration of FRAME changes. ALLOW nil means 2291whenever the window configuration of FRAME changes. MADE nil means
2270these functions are not called. 2292these functions are not called.
2271 2293
2272This function is currently called by `face-set-after-frame-default' only 2294This function is currently called by `make-frame' only and should be
2273and should be otherwise used with utter care to avoid that running 2295otherwise used with utter care to avoid that running functions on
2274functions on `window-configuration-change-hook' is impeded forever. */) 2296`window-configuration-change-hook' is impeded forever. */)
2275 (Lisp_Object frame, Lisp_Object allow) 2297 (Lisp_Object frame, Lisp_Object made)
2276{ 2298{
2277 struct frame *f = decode_live_frame (frame); 2299 struct frame *f = decode_live_frame (frame);
2278 2300 f->after_make_frame = !NILP (made);
2279 f->can_run_window_configuration_change_hook = NILP (allow) ? false : true; 2301 return made;
2280 return Qnil;
2281} 2302}
2282 2303
2283 2304
@@ -2591,7 +2612,12 @@ If FRAME is nil, describe the currently selected frame. */)
2591 important when param_alist's notion of colors is 2612 important when param_alist's notion of colors is
2592 "unspecified". We need to do the same here. */ 2613 "unspecified". We need to do the same here. */
2593 if (STRINGP (value) && !FRAME_WINDOW_P (f)) 2614 if (STRINGP (value) && !FRAME_WINDOW_P (f))
2594 value = frame_unspecified_color (f, value); 2615 {
2616 Lisp_Object tem = frame_unspecified_color (f, value);
2617
2618 if (!NILP (tem))
2619 value = tem;
2620 }
2595 } 2621 }
2596 else 2622 else
2597 value = Fcdr (Fassq (parameter, Fframe_parameters (frame))); 2623 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
@@ -3037,7 +3063,7 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3037 set them both at once. So we wait until we've looked at the 3063 set them both at once. So we wait until we've looked at the
3038 entire list before we set them. */ 3064 entire list before we set them. */
3039 int width IF_LINT (= 0), height IF_LINT (= 0); 3065 int width IF_LINT (= 0), height IF_LINT (= 0);
3040 bool width_change = 0, height_change = 0; 3066 bool width_change = false, height_change = false;
3041 3067
3042 /* Same here. */ 3068 /* Same here. */
3043 Lisp_Object left, top; 3069 Lisp_Object left, top;
@@ -3045,6 +3071,10 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3045 /* Same with these. */ 3071 /* Same with these. */
3046 Lisp_Object icon_left, icon_top; 3072 Lisp_Object icon_left, icon_top;
3047 3073
3074 /* And with this. */
3075 Lisp_Object fullscreen;
3076 bool fullscreen_change = false;
3077
3048 /* Record in these vectors all the parms specified. */ 3078 /* Record in these vectors all the parms specified. */
3049 Lisp_Object *parms; 3079 Lisp_Object *parms;
3050 Lisp_Object *values; 3080 Lisp_Object *values;
@@ -3138,6 +3168,11 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3138 icon_top = val; 3168 icon_top = val;
3139 else if (EQ (prop, Qicon_left)) 3169 else if (EQ (prop, Qicon_left))
3140 icon_left = val; 3170 icon_left = val;
3171 else if (EQ (prop, Qfullscreen))
3172 {
3173 fullscreen = val;
3174 fullscreen_change = true;
3175 }
3141 else if (EQ (prop, Qforeground_color) 3176 else if (EQ (prop, Qforeground_color)
3142 || EQ (prop, Qbackground_color) 3177 || EQ (prop, Qbackground_color)
3143 || EQ (prop, Qfont)) 3178 || EQ (prop, Qfont))
@@ -3218,14 +3253,14 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3218 that here since otherwise a size change implied by an 3253 that here since otherwise a size change implied by an
3219 intermittent font change may get lost as in Bug#17142. */ 3254 intermittent font change may get lost as in Bug#17142. */
3220 if (!width_change) 3255 if (!width_change)
3221 width = (f->new_width 3256 width = ((f->can_x_set_window_size && f->new_width)
3222 ? (f->new_pixelwise 3257 ? (f->new_pixelwise
3223 ? f->new_width 3258 ? f->new_width
3224 : (f->new_width * FRAME_COLUMN_WIDTH (f))) 3259 : (f->new_width * FRAME_COLUMN_WIDTH (f)))
3225 : FRAME_TEXT_WIDTH (f)); 3260 : FRAME_TEXT_WIDTH (f));
3226 3261
3227 if (!height_change) 3262 if (!height_change)
3228 height = (f->new_height 3263 height = ((f->can_x_set_window_size && f->new_height)
3229 ? (f->new_pixelwise 3264 ? (f->new_pixelwise
3230 ? f->new_height 3265 ? f->new_height
3231 : (f->new_height * FRAME_LINE_HEIGHT (f))) 3266 : (f->new_height * FRAME_LINE_HEIGHT (f)))
@@ -3298,6 +3333,20 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3298 /* Actually set that position, and convert to absolute. */ 3333 /* Actually set that position, and convert to absolute. */
3299 x_set_offset (f, leftpos, toppos, -1); 3334 x_set_offset (f, leftpos, toppos, -1);
3300 } 3335 }
3336
3337 if (fullscreen_change)
3338 {
3339 Lisp_Object old_value = get_frame_param (f, Qfullscreen);
3340
3341 frame_size_history_add
3342 (f, Qx_set_fullscreen, 0, 0, list2 (old_value, fullscreen));
3343
3344 store_frame_param (f, Qfullscreen, fullscreen);
3345 if (!EQ (fullscreen, old_value))
3346 x_set_fullscreen (f, fullscreen, old_value);
3347 }
3348
3349
3301#ifdef HAVE_X_WINDOWS 3350#ifdef HAVE_X_WINDOWS
3302 if ((!NILP (icon_left) || !NILP (icon_top)) 3351 if ((!NILP (icon_left) || !NILP (icon_top))
3303 && ! (icon_left_no_change && icon_top_no_change)) 3352 && ! (icon_left_no_change && icon_top_no_change))
@@ -4834,11 +4883,33 @@ syms_of_frame (void)
4834 DEFSYM (Qtool_bar_external, "tool-bar-external"); 4883 DEFSYM (Qtool_bar_external, "tool-bar-external");
4835 DEFSYM (Qtool_bar_size, "tool-bar-size"); 4884 DEFSYM (Qtool_bar_size, "tool-bar-size");
4836 DEFSYM (Qframe_inner_size, "frame-inner-size"); 4885 DEFSYM (Qframe_inner_size, "frame-inner-size");
4886 /* The following are used for frame_size_history. */
4887 DEFSYM (Qadjust_frame_size_1, "adjust-frame-size-1");
4888 DEFSYM (Qadjust_frame_size_2, "adjust-frame-size-2");
4889 DEFSYM (Qadjust_frame_size_3, "adjust-frame-size-3");
4890 DEFSYM (QEmacsFrameResize, "EmacsFrameResize");
4891 DEFSYM (Qframe_inhibit_resize, "frame-inhibit-resize");
4892 DEFSYM (Qx_set_fullscreen, "x-set-fullscreen");
4893 DEFSYM (Qx_check_fullscreen, "x-check-fullscreen");
4894 DEFSYM (Qx_set_window_size_1, "x-set-window-size-1");
4895 DEFSYM (Qxg_frame_resized, "xg-frame-resized");
4896 DEFSYM (Qxg_frame_set_char_size_1, "xg-frame-set-char-size-1");
4897 DEFSYM (Qxg_frame_set_char_size_2, "xg-frame-set-char-size-2");
4898 DEFSYM (Qxg_frame_set_char_size_3, "xg-frame-set-char-size-3");
4899 DEFSYM (Qxg_change_toolbar_position, "xg-change-toolbar-position");
4900 DEFSYM (Qx_net_wm_state, "x-net-wm-state");
4901 DEFSYM (Qx_handle_net_wm_state, "x-handle-net-wm-state");
4902 DEFSYM (Qtb_size_cb, "tb-size-cb");
4903 DEFSYM (Qupdate_frame_tool_bar, "update-frame-tool-bar");
4904 DEFSYM (Qfree_frame_tool_bar, "free-frame-tool-bar");
4905
4837 DEFSYM (Qchange_frame_size, "change-frame-size"); 4906 DEFSYM (Qchange_frame_size, "change-frame-size");
4838 DEFSYM (Qxg_frame_set_char_size, "xg-frame-set-char-size"); 4907 DEFSYM (Qxg_frame_set_char_size, "xg-frame-set-char-size");
4839 DEFSYM (Qset_window_configuration, "set-window-configuration"); 4908 DEFSYM (Qset_window_configuration, "set-window-configuration");
4840 DEFSYM (Qx_create_frame_1, "x-create-frame-1"); 4909 DEFSYM (Qx_create_frame_1, "x-create-frame-1");
4841 DEFSYM (Qx_create_frame_2, "x-create-frame-2"); 4910 DEFSYM (Qx_create_frame_2, "x-create-frame-2");
4911 DEFSYM (Qtip_frame, "tip-frame");
4912 DEFSYM (Qterminal_frame, "terminal-frame");
4842 4913
4843#ifdef HAVE_NS 4914#ifdef HAVE_NS
4844 DEFSYM (Qns_parse_geometry, "ns-parse-geometry"); 4915 DEFSYM (Qns_parse_geometry, "ns-parse-geometry");
@@ -5106,9 +5177,22 @@ even if this option is non-nil. */);
5106 frame_inhibit_implied_resize = Qt; 5177 frame_inhibit_implied_resize = Qt;
5107#endif 5178#endif
5108 5179
5109 DEFVAR_LISP ("frame-adjust-size-history", Vframe_adjust_size_history, 5180 DEFVAR_LISP ("frame-size-history", frame_size_history,
5110 doc: /* History of frame size adjustments. */); 5181 doc: /* History of frame size adjustments.
5111 Vframe_adjust_size_history = Qnil; 5182If non-nil, list recording frame size adjustment. Adjustments are
5183recorded only if the first element of this list is a positive number.
5184Adding an adjustment decrements that number by one.
5185
5186The remaining elements are the adjustments. Each adjustment is a list
5187of four elements `frame', `function', `sizes' and `more'. `frame' is
5188the affected frame and `function' the invoking function. `sizes' is
5189usually a list of four elements `old-width', `old-height', `new-width'
5190and `new-height' representing the old and new sizes recorded/requested
5191by `function'. `more' is a list with additional information.
5192
5193The function `frame--size-history' displays the value of this variable
5194in a more readable form. */);
5195 frame_size_history = Qnil;
5112 5196
5113 staticpro (&Vframe_list); 5197 staticpro (&Vframe_list);
5114 5198
@@ -5141,7 +5225,7 @@ even if this option is non-nil. */);
5141 defsubr (&Sraise_frame); 5225 defsubr (&Sraise_frame);
5142 defsubr (&Slower_frame); 5226 defsubr (&Slower_frame);
5143 defsubr (&Sx_focus_frame); 5227 defsubr (&Sx_focus_frame);
5144 defsubr (&Scan_run_window_configuration_change_hook); 5228 defsubr (&Sframe_after_make_frame);
5145 defsubr (&Sredirect_frame_focus); 5229 defsubr (&Sredirect_frame_focus);
5146 defsubr (&Sframe_focus); 5230 defsubr (&Sframe_focus);
5147 defsubr (&Sframe_parameters); 5231 defsubr (&Sframe_parameters);