Mercurial > hg > xemacs-beta
comparison src/frame.c @ 5130:4f4672e2aa34 ben-lisp-object
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sun, 07 Mar 2010 06:20:19 -0600 |
parents | 7be849cb8828 c113da3e2f67 |
children | f965e31a35f0 |
comparison
equal
deleted
inserted
replaced
5129:ebd8cab8629f | 5130:4f4672e2aa34 |
---|---|
319 | 319 |
320 --ben | 320 --ben |
321 | 321 |
322 */ | 322 */ |
323 | 323 |
324 /* | |
325 About different types of units: | |
326 | |
327 (1) "Total pixels" measure the pixel size of the client area of the | |
328 frame (everything except the menubars and window-manager decorations; | |
329 see comment at top of file). | |
330 | |
331 (2) "Displayable pixels" measure the pixel size of the "displayable area" | |
332 of the frame, a convenient fiction that specifies which portion of | |
333 the frame "counts" for the purposes of determining the size of the | |
334 frame in character cells. Approximately speaking, the difference | |
335 between the client area and displayable area is that toolbars, | |
336 gutters, internal border width and bottom-most/right-most scrollbars | |
337 are inside the client area but outside the displayable area. See | |
338 comment at top of file for more discussion. | |
339 | |
340 (3) "Character-cell units" measure the frame size in "character cells", | |
341 which are fixed rectangles of a size meant to correspond with the | |
342 height and (average) width of the bounding box of a single character | |
343 in the default font. The size of a frame in character cells is | |
344 determined by computing the size in "displayable pixels" and dividing | |
345 by the pixel size of the default font as instantiated in the frame. | |
346 See comment at top of file under "displayable area" for more info. | |
347 | |
348 (4) In window-system "frame units" -- pixels on MS Windows, character | |
349 cells on X and GTK (on TTY's, pixels and character cells are the | |
350 same). Note that on MS Windows the pixels measure the size of the | |
351 displayable area, not the entire client area. | |
352 | |
353 This bogosity exists because MS Windows always reports frame sizes | |
354 in pixels, whereas X-Windows has a scheme whereby character-cell | |
355 sizes and extra sizes (e.g. for toolbars, menubars, etc.) can be | |
356 reported to the window manager, and the window manager displays | |
357 character-cell units when resizing, only allows resizing to integral | |
358 character-cell sizes, and reports back the size in character cells. | |
359 As a result, someone thought it was a good idea to make the | |
360 fundamental units for measuring frame size correspond to what the | |
361 window system "reports" and hence vary between pixels and character | |
362 cells, as described above. | |
363 | |
364 --ben | |
365 */ | |
366 | |
324 #include <config.h> | 367 #include <config.h> |
325 #include "lisp.h" | 368 #include "lisp.h" |
326 | 369 |
327 #include "buffer.h" /* for Vbuffer_alist */ | 370 #include "buffer.h" /* for Vbuffer_alist */ |
328 #include "console.h" | 371 #include "console.h" |
441 int source_width, int source_height, | 484 int source_width, int source_height, |
442 enum frame_size_type dest, | 485 enum frame_size_type dest, |
443 int *dest_width, int *dest_height); | 486 int *dest_width, int *dest_height); |
444 static void get_frame_char_size (struct frame *f, int *out_width, | 487 static void get_frame_char_size (struct frame *f, int *out_width, |
445 int *out_height); | 488 int *out_height); |
446 static void get_frame_displayable_pixel_size (struct frame *f, int *out_width, | 489 static void get_frame_new_displayable_pixel_size (struct frame *f, |
447 int *out_height); | 490 int *out_width, |
491 int *out_height); | |
492 static void get_frame_new_total_pixel_size (struct frame *f, | |
493 int *out_width, | |
494 int *out_height); | |
448 | 495 |
449 static struct display_line title_string_display_line; | 496 static struct display_line title_string_display_line; |
450 /* Used by generate_title_string. Global because they get used so much that | 497 /* Used by generate_title_string. Global because they get used so much that |
451 the dynamic allocation time adds up. */ | 498 the dynamic allocation time adds up. */ |
452 static Ichar_dynarr *title_string_ichar_dynarr; | 499 static Ichar_dynarr *title_string_ichar_dynarr; |
453 | 500 |
454 | 501 |
502 /**************************************************************************/ | |
503 /* */ | |
504 /* frame object */ | |
505 /* */ | |
506 /**************************************************************************/ | |
455 | 507 |
456 #ifndef NEW_GC | 508 #ifndef NEW_GC |
457 extern const struct sized_memory_description gtk_frame_data_description; | 509 extern const struct sized_memory_description gtk_frame_data_description; |
458 extern const struct sized_memory_description mswindows_frame_data_description; | 510 extern const struct sized_memory_description mswindows_frame_data_description; |
459 extern const struct sized_memory_description x_frame_data_description; | 511 extern const struct sized_memory_description x_frame_data_description; |
596 DEFINE_NODUMP_LISP_OBJECT ("frame", frame, | 648 DEFINE_NODUMP_LISP_OBJECT ("frame", frame, |
597 mark_frame, print_frame, 0, 0, 0, | 649 mark_frame, print_frame, 0, 0, 0, |
598 frame_description, | 650 frame_description, |
599 struct frame); | 651 struct frame); |
600 | 652 |
653 /**************************************************************************/ | |
654 /* */ | |
655 /* frame creation */ | |
656 /* */ | |
657 /**************************************************************************/ | |
658 | |
601 static void | 659 static void |
602 nuke_all_frame_slots (struct frame *f) | 660 nuke_all_frame_slots (struct frame *f) |
603 { | 661 { |
604 zero_nonsized_lisp_object (wrap_frame (f)); | 662 zero_nonsized_lisp_object (wrap_frame (f)); |
605 | 663 |
1032 | 1090 |
1033 return frame; | 1091 return frame; |
1034 } | 1092 } |
1035 | 1093 |
1036 | 1094 |
1095 /**************************************************************************/ | |
1096 /* */ | |
1097 /* validating a frame argument */ | |
1098 /* */ | |
1099 /**************************************************************************/ | |
1100 | |
1037 /* this function should be used in most cases when a Lisp function is passed | 1101 /* this function should be used in most cases when a Lisp function is passed |
1038 a FRAME argument. Use this unless you don't accept nil == current frame | 1102 a FRAME argument. Use this unless you don't accept nil == current frame |
1039 (in which case, do a CHECK_LIVE_FRAME() and then an XFRAME()) or you | 1103 (in which case, do a CHECK_LIVE_FRAME() and then an XFRAME()) or you |
1040 allow dead frames. Note that very few functions should accept dead | 1104 allow dead frames. Note that very few functions should accept dead |
1041 frames. It could be argued that functions should just do nothing when | 1105 frames. It could be argued that functions should just do nothing when |
1064 if (DEVICEP (cdf)) | 1128 if (DEVICEP (cdf)) |
1065 cdf = DEVICE_SELECTED_FRAME (decode_device (cdf)); | 1129 cdf = DEVICE_SELECTED_FRAME (decode_device (cdf)); |
1066 return decode_frame (cdf); | 1130 return decode_frame (cdf); |
1067 } | 1131 } |
1068 | 1132 |
1069 Lisp_Object | |
1070 frame_device (struct frame *f) | |
1071 { | |
1072 return FRAME_DEVICE (f); | |
1073 } | |
1074 | |
1075 int | 1133 int |
1076 frame_live_p (struct frame *f) | 1134 frame_live_p (struct frame *f) |
1077 { | 1135 { |
1078 return FRAME_LIVE_P (f); | 1136 return FRAME_LIVE_P (f); |
1079 } | 1137 } |
1080 | 1138 |
1081 | |
1082 void | |
1083 invalidate_vertical_divider_cache_in_frame (struct frame *f) | |
1084 { | |
1085 /* Invalidate cached value of needs_vertical_divider_p in | |
1086 every and all windows */ | |
1087 map_windows (f, invalidate_vertical_divider_cache_in_window, 0); | |
1088 } | |
1089 | |
1090 /* | |
1091 * Frame size may change due to changes in scrollbars, toolbars, | |
1092 * default font etc. These changes are applied early in redisplay | |
1093 * frame. | |
1094 */ | |
1095 void | |
1096 adjust_frame_size (struct frame *f) | |
1097 { | |
1098 /* This can call Lisp. */ | |
1099 int keep_char_size = 0; | |
1100 Lisp_Object frame = wrap_frame (f); | |
1101 | |
1102 if (!f->size_slipped) | |
1103 return; | |
1104 | |
1105 /* Don't adjust tty frames. #### May break when TTY have menubars. | |
1106 Then, write an Vadjust_frame_function which will return t for TTY | |
1107 frames. Another solution is frame_size_fixed_p method for TTYs, | |
1108 which always returned yes it's fixed. | |
1109 */ | |
1110 if (!FRAME_WIN_P (f)) | |
1111 { | |
1112 CLEAR_FRAME_SIZE_SLIPPED (f); | |
1113 return; | |
1114 } | |
1115 | |
1116 /* frame_size_fixed_p tells that frame size cannot currently | |
1117 be changed change due to external conditions */ | |
1118 if (!FRAMEMETH_OR_GIVEN (f, frame_size_fixed_p, (f), 0)) | |
1119 { | |
1120 if (NILP (Vadjust_frame_function)) | |
1121 keep_char_size = 1; | |
1122 else if (EQ (Vadjust_frame_function, Qt)) | |
1123 keep_char_size = 0; | |
1124 else | |
1125 keep_char_size = | |
1126 NILP (call1_trapping_problems ("Error in adjust-frame-function", | |
1127 Vadjust_frame_function, frame, | |
1128 0)); | |
1129 | |
1130 if (keep_char_size) | |
1131 Fset_frame_size (frame, make_int (FRAME_CHARWIDTH(f)), | |
1132 make_int (FRAME_CHARHEIGHT(f)), Qnil); | |
1133 } | |
1134 | |
1135 if (!keep_char_size) | |
1136 { | |
1137 int height, width; | |
1138 pixel_to_frame_unit_size (f, FRAME_PIXWIDTH(f), FRAME_PIXHEIGHT(f), | |
1139 &width, &height); | |
1140 change_frame_size (f, width, height, 0); | |
1141 CLEAR_FRAME_SIZE_SLIPPED (f); | |
1142 } | |
1143 } | |
1144 | |
1145 /* | |
1146 * This is a "specifier changed in frame" handler for various specifiers | |
1147 * changing which causes frame size adjustment | |
1148 */ | |
1149 void | |
1150 frame_size_slipped (Lisp_Object UNUSED (specifier), struct frame *f, | |
1151 Lisp_Object UNUSED (oldval)) | |
1152 { | |
1153 MARK_FRAME_SIZE_SLIPPED(f); | |
1154 } | |
1155 | |
1156 DEFUN ("framep", Fframep, 1, 1, 0, /* | 1139 DEFUN ("framep", Fframep, 1, 1, 0, /* |
1157 Return non-nil if OBJECT is a frame. | 1140 Return non-nil if OBJECT is a frame. |
1158 Also see `frame-live-p'. | 1141 Also see `frame-live-p'. |
1159 Note that FSF Emacs kludgily returns a value indicating what type of | 1142 Note that FSF Emacs kludgily returns a value indicating what type of |
1160 frame this is. Use the cleaner function `frame-type' for that. | 1143 frame this is. Use the cleaner function `frame-type' for that. |
1171 { | 1154 { |
1172 return FRAMEP (object) && FRAME_LIVE_P (XFRAME (object)) ? Qt : Qnil; | 1155 return FRAMEP (object) && FRAME_LIVE_P (XFRAME (object)) ? Qt : Qnil; |
1173 } | 1156 } |
1174 | 1157 |
1175 | 1158 |
1159 /**************************************************************************/ | |
1160 /* */ | |
1161 /* frame focus/selection */ | |
1162 /* */ | |
1163 /**************************************************************************/ | |
1164 | |
1165 Lisp_Object | |
1166 frame_device (struct frame *f) | |
1167 { | |
1168 return FRAME_DEVICE (f); | |
1169 } | |
1170 | |
1171 DEFUN ("frame-device", Fframe_device, 0, 1, 0, /* | |
1172 Return the device that FRAME is on. | |
1173 If omitted, FRAME defaults to the currently selected frame. | |
1174 */ | |
1175 (frame)) | |
1176 { | |
1177 return FRAME_DEVICE (decode_frame (frame)); | |
1178 } | |
1179 | |
1176 DEFUN ("focus-frame", Ffocus_frame, 1, 1, 0, /* | 1180 DEFUN ("focus-frame", Ffocus_frame, 1, 1, 0, /* |
1177 Select FRAME and give it the window system focus. | 1181 Select FRAME and give it the window system focus. |
1178 This function is not affected by the value of `focus-follows-mouse'. | 1182 This function is not affected by the value of `focus-follows-mouse'. |
1179 */ | 1183 */ |
1180 (frame)) | 1184 (frame)) |
1269 } | 1273 } |
1270 return XFRAME (frame); | 1274 return XFRAME (frame); |
1271 } | 1275 } |
1272 | 1276 |
1273 #if 0 /* FSFmacs */ | 1277 #if 0 /* FSFmacs */ |
1278 | |
1279 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus', | |
1280 crockish FSFmacs functions. See summary on focus in event-stream.c. */ | |
1274 | 1281 |
1275 DEFUN ("handle-switch-frame", Fhandle_switch_frame, 1, 2, "e", /* | 1282 DEFUN ("handle-switch-frame", Fhandle_switch_frame, 1, 2, "e", /* |
1276 Handle a switch-frame event EVENT. | 1283 Handle a switch-frame event EVENT. |
1277 Switch-frame events are usually bound to this function. | 1284 Switch-frame events are usually bound to this function. |
1278 A switch-frame event tells Emacs that the window manager has requested | 1285 A switch-frame event tells Emacs that the window manager has requested |
1421 | 1428 |
1422 set_frame_selected_window (XFRAME (frame), window); | 1429 set_frame_selected_window (XFRAME (frame), window); |
1423 return window; | 1430 return window; |
1424 } | 1431 } |
1425 | 1432 |
1433 DEFUN ("disable-frame", Fdisable_frame, 1, 1, 0, /* | |
1434 Disable frame FRAME, so that it cannot have the focus or receive user input. | |
1435 This is normally used during modal dialog boxes. | |
1436 WARNING: Be very careful not to wedge XEmacs! | |
1437 Use an `unwind-protect' that re-enables the frame to avoid this. | |
1438 */ | |
1439 (frame)) | |
1440 { | |
1441 struct frame *f = decode_frame (frame); | |
1442 | |
1443 f->disabled = 1; | |
1444 MAYBE_FRAMEMETH (f, disable_frame, (f)); | |
1445 return Qnil; | |
1446 } | |
1447 | |
1448 DEFUN ("enable-frame", Fenable_frame, 1, 1, 0, /* | |
1449 Enable frame FRAME, so that it can have the focus and receive user input. | |
1450 Frames are normally enabled, unless explicitly disabled using `disable-frame'. | |
1451 */ | |
1452 (frame)) | |
1453 { | |
1454 struct frame *f = decode_frame (frame); | |
1455 f->disabled = 0; | |
1456 MAYBE_FRAMEMETH (f, enable_frame, (f)); | |
1457 return Qnil; | |
1458 } | |
1426 | 1459 |
1427 DEFUN ("frame-device", Fframe_device, 0, 1, 0, /* | 1460 /**************************************************************************/ |
1428 Return the device that FRAME is on. | 1461 /* */ |
1429 If omitted, FRAME defaults to the currently selected frame. | 1462 /* traversing the list of frames */ |
1430 */ | 1463 /* */ |
1431 (frame)) | 1464 /**************************************************************************/ |
1432 { | |
1433 return FRAME_DEVICE (decode_frame (frame)); | |
1434 } | |
1435 | 1465 |
1436 int | 1466 int |
1437 is_surrogate_for_selected_frame (struct frame *f) | 1467 is_surrogate_for_selected_frame (struct frame *f) |
1438 { | 1468 { |
1439 struct device *d = XDEVICE (f->device); | 1469 struct device *d = XDEVICE (f->device); |
1723 | 1753 |
1724 return Qnil; | 1754 return Qnil; |
1725 } | 1755 } |
1726 | 1756 |
1727 | 1757 |
1758 /**************************************************************************/ | |
1759 /* */ | |
1760 /* frame deletion */ | |
1761 /* */ | |
1762 /**************************************************************************/ | |
1728 | 1763 |
1729 /* extern void free_line_insertion_deletion_costs (struct frame *f); */ | 1764 /* extern void free_line_insertion_deletion_costs (struct frame *f); */ |
1730 | 1765 |
1731 /* Return 1 if it is ok to delete frame F; | 1766 /* Return 1 if it is ok to delete frame F; |
1732 0 if all frames aside from F are invisible. | 1767 0 if all frames aside from F are invisible. |
2175 delete_frame_internal (f, !NILP (force), 0, 0); | 2210 delete_frame_internal (f, !NILP (force), 0, 0); |
2176 return Qnil; | 2211 return Qnil; |
2177 } | 2212 } |
2178 | 2213 |
2179 | 2214 |
2215 /**************************************************************************/ | |
2216 /* */ | |
2217 /* mouse position in frame */ | |
2218 /* */ | |
2219 /**************************************************************************/ | |
2220 | |
2180 /* Return mouse position in character cell units. */ | 2221 /* Return mouse position in character cell units. */ |
2181 | 2222 |
2182 static int | 2223 static int |
2183 mouse_pixel_position_1 (struct device *d, Lisp_Object *frame, | 2224 mouse_pixel_position_1 (struct device *d, Lisp_Object *frame, |
2184 int *x, int *y) | 2225 int *x, int *y) |
2362 FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, XINT (x), XINT (y))); | 2403 FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, XINT (x), XINT (y))); |
2363 | 2404 |
2364 return Qnil; | 2405 return Qnil; |
2365 } | 2406 } |
2366 | 2407 |
2408 /**************************************************************************/ | |
2409 /* */ | |
2410 /* frame visibility */ | |
2411 /* */ | |
2412 /**************************************************************************/ | |
2413 | |
2367 DEFUN ("make-frame-visible", Fmake_frame_visible, 0, 1, 0, /* | 2414 DEFUN ("make-frame-visible", Fmake_frame_visible, 0, 1, 0, /* |
2368 Make the frame FRAME visible (assuming it is an X-window). | 2415 Make the frame FRAME visible (assuming it is an X-window). |
2369 If omitted, FRAME defaults to the currently selected frame. | 2416 If omitted, FRAME defaults to the currently selected frame. |
2370 Also raises the frame so that nothing obscures it. | 2417 Also raises the frame so that nothing obscures it. |
2371 */ | 2418 */ |
2524 } | 2571 } |
2525 | 2572 |
2526 return value; | 2573 return value; |
2527 } | 2574 } |
2528 | 2575 |
2529 | |
2530 DEFUN ("raise-frame", Fraise_frame, 0, 1, "", /* | 2576 DEFUN ("raise-frame", Fraise_frame, 0, 1, "", /* |
2531 Bring FRAME to the front, so it occludes any frames it overlaps. | 2577 Bring FRAME to the front, so it occludes any frames it overlaps. |
2532 If omitted, FRAME defaults to the currently selected frame. | 2578 If omitted, FRAME defaults to the currently selected frame. |
2533 If FRAME is invisible, make it visible. | 2579 If FRAME is invisible, make it visible. |
2534 If Emacs is displaying on an ordinary terminal or some other device which | 2580 If Emacs is displaying on an ordinary terminal or some other device which |
2557 MAYBE_FRAMEMETH (f, lower_frame, (f)); | 2603 MAYBE_FRAMEMETH (f, lower_frame, (f)); |
2558 return Qnil; | 2604 return Qnil; |
2559 } | 2605 } |
2560 | 2606 |
2561 | 2607 |
2562 DEFUN ("disable-frame", Fdisable_frame, 1, 1, 0, /* | 2608 /***************************************************************************/ |
2563 Disable frame FRAME, so that it cannot have the focus or receive user input. | 2609 /* */ |
2564 This is normally used during modal dialog boxes. | 2610 /* print-related functions */ |
2565 WARNING: Be very careful not to wedge XEmacs! | 2611 /* */ |
2566 Use an `unwind-protect' that re-enables the frame to avoid this. | 2612 /***************************************************************************/ |
2567 */ | 2613 |
2568 (frame)) | |
2569 { | |
2570 struct frame *f = decode_frame (frame); | |
2571 | |
2572 f->disabled = 1; | |
2573 MAYBE_FRAMEMETH (f, disable_frame, (f)); | |
2574 return Qnil; | |
2575 } | |
2576 | |
2577 DEFUN ("enable-frame", Fenable_frame, 1, 1, 0, /* | |
2578 Enable frame FRAME, so that it can have the focus and receive user input. | |
2579 Frames are normally enabled, unless explicitly disabled using `disable-frame'. | |
2580 */ | |
2581 (frame)) | |
2582 { | |
2583 struct frame *f = decode_frame (frame); | |
2584 f->disabled = 0; | |
2585 MAYBE_FRAMEMETH (f, enable_frame, (f)); | |
2586 return Qnil; | |
2587 } | |
2588 | |
2589 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus', | |
2590 crockish FSFmacs functions. See summary on focus in event-stream.c. */ | |
2591 | |
2592 DEFUN ("print-job-page-number", Fprint_job_page_number, 1, 1, 0, /* | 2614 DEFUN ("print-job-page-number", Fprint_job_page_number, 1, 1, 0, /* |
2593 Return current page number for the print job FRAME. | 2615 Return current page number for the print job FRAME. |
2594 */ | 2616 */ |
2595 (frame)) | 2617 (frame)) |
2596 { | 2618 { |
2614 return Qnil; | 2636 return Qnil; |
2615 } | 2637 } |
2616 | 2638 |
2617 | 2639 |
2618 /***************************************************************************/ | 2640 /***************************************************************************/ |
2641 /* */ | |
2619 /* frame properties */ | 2642 /* frame properties */ |
2643 /* */ | |
2620 /***************************************************************************/ | 2644 /***************************************************************************/ |
2645 | |
2646 DEFUN ("frame-name", Fframe_name, 0, 1, 0, /* | |
2647 Return the name of FRAME (defaulting to the selected frame). | |
2648 This is not the same as the `title' of the frame. | |
2649 */ | |
2650 (frame)) | |
2651 { | |
2652 return decode_frame (frame)->name; | |
2653 } | |
2654 | |
2655 DEFUN ("frame-modified-tick", Fframe_modified_tick, 0, 1, 0, /* | |
2656 Return FRAME's tick counter, incremented for each change to the frame. | |
2657 Each frame has a tick counter which is incremented each time the frame | |
2658 is resized, a window is resized, added, or deleted, a face is changed, | |
2659 `set-window-buffer' or `select-window' is called on a window in the | |
2660 frame, the window-start of a window in the frame has changed, or | |
2661 anything else interesting has happened. It wraps around occasionally. | |
2662 No argument or nil as argument means use selected frame as FRAME. | |
2663 */ | |
2664 (frame)) | |
2665 { | |
2666 return make_int (decode_frame (frame)->modiff); | |
2667 } | |
2621 | 2668 |
2622 static void | 2669 static void |
2623 store_minibuf_frame_prop (struct frame *f, Lisp_Object val) | 2670 store_minibuf_frame_prop (struct frame *f, Lisp_Object val) |
2624 { | 2671 { |
2625 /* This can call Lisp. */ | 2672 /* This can call Lisp. */ |
3017 UNGCPRO; | 3064 UNGCPRO; |
3018 return result; | 3065 return result; |
3019 } | 3066 } |
3020 | 3067 |
3021 | 3068 |
3069 /**************************************************************************/ | |
3070 /* */ | |
3071 /* frame sizing (user functions) */ | |
3072 /* */ | |
3073 /**************************************************************************/ | |
3074 | |
3022 DEFUN ("frame-pixel-height", Fframe_pixel_height, 0, 1, 0, /* | 3075 DEFUN ("frame-pixel-height", Fframe_pixel_height, 0, 1, 0, /* |
3023 Return the total height in pixels of FRAME. | 3076 Return the total height in pixels of FRAME. |
3024 */ | 3077 */ |
3025 (frame)) | 3078 (frame)) |
3026 { | 3079 { |
3027 return make_int (decode_frame (frame)->pixheight); | 3080 struct frame *f = decode_frame (frame); |
3081 int width, height; | |
3082 | |
3083 get_frame_new_total_pixel_size (f, &width, &height); | |
3084 return make_int (height); | |
3028 } | 3085 } |
3029 | 3086 |
3030 DEFUN ("frame-displayable-pixel-height", Fframe_displayable_pixel_height, 0, 1, 0, /* | 3087 DEFUN ("frame-displayable-pixel-height", Fframe_displayable_pixel_height, 0, 1, 0, /* |
3031 Return the height of the displayable area in pixels of FRAME. | 3088 Return the height of the displayable area in pixels of FRAME. |
3032 */ | 3089 */ |
3033 (frame)) | 3090 (frame)) |
3034 { | 3091 { |
3035 struct frame *f = decode_frame (frame); | 3092 struct frame *f = decode_frame (frame); |
3036 int width, height; | 3093 int width, height; |
3037 | 3094 |
3038 get_frame_displayable_pixel_size (f, &width, &height); | 3095 get_frame_new_displayable_pixel_size (f, &width, &height); |
3039 return make_int (height); | 3096 return make_int (height); |
3040 } | 3097 } |
3041 | 3098 |
3042 DEFUN ("frame-pixel-width", Fframe_pixel_width, 0, 1, 0, /* | 3099 DEFUN ("frame-pixel-width", Fframe_pixel_width, 0, 1, 0, /* |
3043 Return the total width in pixels of FRAME. | 3100 Return the total width in pixels of FRAME. |
3044 */ | 3101 */ |
3045 (frame)) | 3102 (frame)) |
3046 { | 3103 { |
3047 return make_int (decode_frame (frame)->pixwidth); | 3104 struct frame *f = decode_frame (frame); |
3105 int width, height; | |
3106 | |
3107 get_frame_new_total_pixel_size (f, &width, &height); | |
3108 return make_int (width); | |
3048 } | 3109 } |
3049 | 3110 |
3050 DEFUN ("frame-displayable-pixel-width", Fframe_displayable_pixel_width, 0, 1, 0, /* | 3111 DEFUN ("frame-displayable-pixel-width", Fframe_displayable_pixel_width, 0, 1, 0, /* |
3051 Return the width of the displayable area in pixels of FRAME. | 3112 Return the width of the displayable area in pixels of FRAME. |
3052 */ | 3113 */ |
3053 (frame)) | 3114 (frame)) |
3054 { | 3115 { |
3055 struct frame *f = decode_frame (frame); | 3116 struct frame *f = decode_frame (frame); |
3056 int width, height; | 3117 int width, height; |
3057 | 3118 |
3058 get_frame_displayable_pixel_size (f, &width, &height); | 3119 get_frame_new_displayable_pixel_size (f, &width, &height); |
3059 return make_int (width); | 3120 return make_int (width); |
3060 } | |
3061 | |
3062 DEFUN ("frame-name", Fframe_name, 0, 1, 0, /* | |
3063 Return the name of FRAME (defaulting to the selected frame). | |
3064 This is not the same as the `title' of the frame. | |
3065 */ | |
3066 (frame)) | |
3067 { | |
3068 return decode_frame (frame)->name; | |
3069 } | |
3070 | |
3071 DEFUN ("frame-modified-tick", Fframe_modified_tick, 0, 1, 0, /* | |
3072 Return FRAME's tick counter, incremented for each change to the frame. | |
3073 Each frame has a tick counter which is incremented each time the frame | |
3074 is resized, a window is resized, added, or deleted, a face is changed, | |
3075 `set-window-buffer' or `select-window' is called on a window in the | |
3076 frame, the window-start of a window in the frame has changed, or | |
3077 anything else interesting has happened. It wraps around occasionally. | |
3078 No argument or nil as argument means use selected frame as FRAME. | |
3079 */ | |
3080 (frame)) | |
3081 { | |
3082 return make_int (decode_frame (frame)->modiff); | |
3083 } | |
3084 | |
3085 void | |
3086 internal_set_frame_size (struct frame *f, int cols, int rows, int pretend) | |
3087 { | |
3088 /* This can call Lisp. See mswindows_set_frame_size(). */ | |
3089 /* An explicit size change cancels any pending frame size adjustment */ | |
3090 CLEAR_FRAME_SIZE_SLIPPED (f); | |
3091 | |
3092 if (pretend || !HAS_FRAMEMETH_P (f, set_frame_size)) | |
3093 change_frame_size (f, cols, rows, 0); | |
3094 else | |
3095 FRAMEMETH (f, set_frame_size, (f, cols, rows)); | |
3096 } | 3121 } |
3097 | 3122 |
3098 DEFUN ("set-frame-height", Fset_frame_height, 2, 3, 0, /* | 3123 DEFUN ("set-frame-height", Fset_frame_height, 2, 3, 0, /* |
3099 Specify that the frame FRAME has LINES lines. | 3124 Specify that the frame FRAME has LINES lines. |
3100 Optional third arg non-nil means that redisplay should use LINES lines | 3125 Optional third arg non-nil means that redisplay should use LINES lines |
3127 struct frame *f = decode_frame (frame); | 3152 struct frame *f = decode_frame (frame); |
3128 int pwidth, pheight; | 3153 int pwidth, pheight; |
3129 int guwidth, guheight; | 3154 int guwidth, guheight; |
3130 | 3155 |
3131 CHECK_INT (height); | 3156 CHECK_INT (height); |
3157 get_frame_new_total_pixel_size (f, &pwidth, &pheight); | |
3132 pheight = XINT (height); | 3158 pheight = XINT (height); |
3133 pwidth = FRAME_PIXWIDTH (f); | |
3134 frame_conversion_internal (f, SIZE_TOTAL_PIXEL, pwidth, pheight, | 3159 frame_conversion_internal (f, SIZE_TOTAL_PIXEL, pwidth, pheight, |
3135 SIZE_FRAME_UNIT, &guwidth, &guheight); | 3160 SIZE_FRAME_UNIT, &guwidth, &guheight); |
3136 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | 3161 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); |
3137 return wrap_frame (f); | 3162 return wrap_frame (f); |
3138 } | 3163 } |
3148 struct frame *f = decode_frame (frame); | 3173 struct frame *f = decode_frame (frame); |
3149 int pwidth, pheight; | 3174 int pwidth, pheight; |
3150 int guwidth, guheight; | 3175 int guwidth, guheight; |
3151 | 3176 |
3152 CHECK_INT (height); | 3177 CHECK_INT (height); |
3153 get_frame_displayable_pixel_size (f, &pwidth, &pheight); | 3178 get_frame_new_displayable_pixel_size (f, &pwidth, &pheight); |
3154 pheight = XINT (height); | 3179 pheight = XINT (height); |
3155 frame_conversion_internal (f, SIZE_DISPLAYABLE_PIXEL, pwidth, pheight, | 3180 frame_conversion_internal (f, SIZE_DISPLAYABLE_PIXEL, pwidth, pheight, |
3156 SIZE_FRAME_UNIT, &guwidth, &guheight); | 3181 SIZE_FRAME_UNIT, &guwidth, &guheight); |
3157 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | 3182 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); |
3158 return wrap_frame (f); | 3183 return wrap_frame (f); |
3191 struct frame *f = decode_frame (frame); | 3216 struct frame *f = decode_frame (frame); |
3192 int pwidth, pheight; | 3217 int pwidth, pheight; |
3193 int guwidth, guheight; | 3218 int guwidth, guheight; |
3194 | 3219 |
3195 CHECK_INT (width); | 3220 CHECK_INT (width); |
3221 get_frame_new_total_pixel_size (f, &pwidth, &pheight); | |
3196 pwidth = XINT (width); | 3222 pwidth = XINT (width); |
3197 pheight = FRAME_PIXHEIGHT (f); | |
3198 frame_conversion_internal (f, SIZE_TOTAL_PIXEL, pwidth, pheight, | 3223 frame_conversion_internal (f, SIZE_TOTAL_PIXEL, pwidth, pheight, |
3199 SIZE_FRAME_UNIT, &guwidth, &guheight); | 3224 SIZE_FRAME_UNIT, &guwidth, &guheight); |
3200 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | 3225 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); |
3201 return wrap_frame (f); | 3226 return wrap_frame (f); |
3202 } | 3227 } |
3212 struct frame *f = decode_frame (frame); | 3237 struct frame *f = decode_frame (frame); |
3213 int pwidth, pheight; | 3238 int pwidth, pheight; |
3214 int guwidth, guheight; | 3239 int guwidth, guheight; |
3215 | 3240 |
3216 CHECK_INT (width); | 3241 CHECK_INT (width); |
3217 get_frame_displayable_pixel_size (f, &pwidth, &pheight); | 3242 get_frame_new_displayable_pixel_size (f, &pwidth, &pheight); |
3218 pwidth = XINT (width); | 3243 pwidth = XINT (width); |
3219 frame_conversion_internal (f, SIZE_DISPLAYABLE_PIXEL, pwidth, pheight, | 3244 frame_conversion_internal (f, SIZE_DISPLAYABLE_PIXEL, pwidth, pheight, |
3220 SIZE_FRAME_UNIT, &guwidth, &guheight); | 3245 SIZE_FRAME_UNIT, &guwidth, &guheight); |
3221 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | 3246 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); |
3222 return wrap_frame (f); | 3247 return wrap_frame (f); |
3296 | 3321 |
3297 return Qt; | 3322 return Qt; |
3298 } | 3323 } |
3299 | 3324 |
3300 | 3325 |
3326 /**************************************************************************/ | |
3327 /* */ | |
3328 /* various ways of measuring the frame size */ | |
3329 /* */ | |
3330 /**************************************************************************/ | |
3301 | 3331 |
3302 /* Frame size conversion functions moved here from EmacsFrame.c | 3332 /* Frame size conversion functions moved here from EmacsFrame.c |
3303 because they're generic and really don't belong in that file. | 3333 because they're generic and really don't belong in that file. |
3304 Function get_default_char_pixel_size() removed because it's | 3334 Function get_default_char_pixel_size() removed because it's |
3305 exactly the same as default_face_width_and_height(). | 3335 exactly the same as default_face_width_and_height(). |
3306 | 3336 |
3307 Convert between total pixel size, displayable pixel size and | 3337 Convert between total pixel size, displayable pixel size and |
3308 character-cell size. Variables are either "in" or "out" | 3338 character-cell size. Variables are either "in", "out" or unused, |
3309 depending on the value of PIXEL_TO_CHAR. | 3339 depending on the value of PIXEL_TO_CHAR, which indicates which units the |
3310 */ | 3340 source and destination values are measured in. |
3341 | |
3342 See frame_conversion_internal() for a discussion of the different | |
3343 types of units. */ | |
3344 | |
3311 static void | 3345 static void |
3312 frame_conversion_internal_1 (struct frame *f, | 3346 frame_conversion_internal_1 (struct frame *f, |
3313 pixel_to_char_mode_t pixel_to_char, | 3347 pixel_to_char_mode_t pixel_to_char, |
3314 int *total_pixel_width, int *total_pixel_height, | 3348 int *total_pixel_width, int *total_pixel_height, |
3315 int *disp_pixel_width, int *disp_pixel_height, | 3349 int *disp_pixel_width, int *disp_pixel_height, |
3410 return type; | 3444 return type; |
3411 } | 3445 } |
3412 | 3446 |
3413 /* Basic frame conversion function. Convert source size to destination | 3447 /* Basic frame conversion function. Convert source size to destination |
3414 size, where either of them can be in total pixels, displayable pixels, | 3448 size, where either of them can be in total pixels, displayable pixels, |
3415 frame units or character-cell units. */ | 3449 frame units or character-cell units. |
3450 | |
3451 See comment at top of file for discussion about different types of | |
3452 units. */ | |
3416 | 3453 |
3417 static void | 3454 static void |
3418 frame_conversion_internal (struct frame *f, | 3455 frame_conversion_internal (struct frame *f, |
3419 enum frame_size_type source, | 3456 enum frame_size_type source, |
3420 int source_width, int source_height, | 3457 int source_width, int source_height, |
3532 int char_height; | 3569 int char_height; |
3533 pixel_to_char_size (f, in_width, in_height, &char_width, &char_height); | 3570 pixel_to_char_size (f, in_width, in_height, &char_width, &char_height); |
3534 char_to_pixel_size (f, char_width, char_height, out_width, out_height); | 3571 char_to_pixel_size (f, char_width, char_height, out_width, out_height); |
3535 } | 3572 } |
3536 | 3573 |
3537 /* Get the frame size in character cells, recalculating on the fly. | |
3538 #### The logic of this function follows former logic elsewhere, | |
3539 which used FRAME_PIXWIDTH() on pixelated-geometry systems but | |
3540 FRAME_WIDTH() on non-pixelated-geometry systems. Not clear why not | |
3541 always just use one or the other. | |
3542 | |
3543 Why don't we just use FRAME_CHARWIDTH() etc. in get_frame_char_size()? | |
3544 That wouldn't work because change_frame_size_1() depends on the | |
3545 following function to *set* the values of FRAME_CHARWIDTH() etc. | |
3546 | |
3547 But elsewhere I suppose we could use it. | |
3548 */ | |
3549 | |
3550 static void | 3574 static void |
3551 get_frame_char_size (struct frame *f, int *out_width, int *out_height) | 3575 get_frame_char_size (struct frame *f, int *out_width, int *out_height) |
3552 { | 3576 { |
3553 if (window_system_pixelated_geometry (wrap_frame (f))) | 3577 *out_width = FRAME_CHARWIDTH (f); |
3554 pixel_to_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), | 3578 *out_height = FRAME_CHARHEIGHT (f); |
3555 out_width, out_height); | 3579 } |
3556 else | 3580 |
3557 { | 3581 /* Return the "new" frame size in displayable pixels, which will be |
3558 *out_width = FRAME_WIDTH (f); | 3582 accurate as of next redisplay. If we have changed the default font or |
3559 *out_height = FRAME_HEIGHT (f); | 3583 toolbar or scrollbar specifiers, the frame pixel size will change as of |
3560 } | 3584 next redisplay, but the frame character-cell size will remain the same. |
3561 } | 3585 So use those dimensions to compute the displayable-pixel size. */ |
3562 | 3586 |
3563 static void | 3587 static void |
3564 get_frame_displayable_pixel_size (struct frame *f, int *out_width, | 3588 get_frame_new_displayable_pixel_size (struct frame *f, int *out_width, |
3565 int *out_height) | 3589 int *out_height) |
3566 { | 3590 { |
3567 frame_conversion_internal (f, SIZE_FRAME_UNIT, FRAME_WIDTH (f), | 3591 frame_conversion_internal (f, SIZE_CHAR_CELL, FRAME_CHARWIDTH (f), |
3568 FRAME_HEIGHT (f), SIZE_DISPLAYABLE_PIXEL, | 3592 FRAME_CHARHEIGHT (f), SIZE_DISPLAYABLE_PIXEL, |
3569 out_width, out_height); | 3593 out_width, out_height); |
3570 } | 3594 } |
3595 | |
3596 /* Return the "new" frame size in total pixels, which will be | |
3597 accurate as of next redisplay. See get_frame_new_displayable_pixel_size(). | |
3598 */ | |
3599 | |
3600 | |
3601 static void | |
3602 get_frame_new_total_pixel_size (struct frame *f, int *out_width, | |
3603 int *out_height) | |
3604 { | |
3605 frame_conversion_internal (f, SIZE_CHAR_CELL, FRAME_CHARWIDTH (f), | |
3606 FRAME_CHARHEIGHT (f), SIZE_TOTAL_PIXEL, | |
3607 out_width, out_height); | |
3608 } | |
3609 | |
3610 | |
3611 /**************************************************************************/ | |
3612 /* */ | |
3613 /* frame resizing (implementation) */ | |
3614 /* */ | |
3615 /**************************************************************************/ | |
3571 | 3616 |
3572 /* Change the frame height and/or width. Values passed in are in | 3617 /* Change the frame height and/or width. Values passed in are in |
3573 frame units (character cells on X/GTK, displayable-area pixels | 3618 frame units (character cells on X/GTK, displayable-area pixels |
3574 on MS Windows or generally on pixelated-geometry window systems). */ | 3619 on MS Windows or generally on pixelated-geometry window systems). */ |
3575 static void | 3620 static void |
3576 change_frame_size_1 (struct frame *f, int newwidth, int newheight) | 3621 change_frame_size_1 (struct frame *f, int newwidth, int newheight) |
3577 { | 3622 { |
3578 int new_pixheight, new_pixwidth; | 3623 int new_pixheight, new_pixwidth; |
3624 int paned_pixheight, paned_pixwidth; | |
3579 int real_font_height, real_font_width; | 3625 int real_font_height, real_font_width; |
3580 | 3626 |
3581 /* #### Chuck -- shouldn't we be checking to see if the frame | 3627 /* #### Chuck -- shouldn't we be checking to see if the frame |
3582 is being "changed" to its existing size, and do nothing if so? */ | 3628 is being "changed" to its existing size, and do nothing if so? */ |
3583 /* No, because it would hose toolbar updates. The toolbar | 3629 /* No, because it would hose toolbar updates. The toolbar |
3602 FRAME_NEW_WIDTH (f) = 0; | 3648 FRAME_NEW_WIDTH (f) = 0; |
3603 | 3649 |
3604 /* We need to remove the boundaries of the paned area (see top of file) | 3650 /* We need to remove the boundaries of the paned area (see top of file) |
3605 from the total-area pixel size, which is what we have now. | 3651 from the total-area pixel size, which is what we have now. |
3606 */ | 3652 */ |
3607 new_pixheight -= | 3653 paned_pixheight = new_pixheight - |
3608 (FRAME_NONPANED_SIZE (f, TOP_EDGE) + FRAME_NONPANED_SIZE (f, BOTTOM_EDGE)); | 3654 (FRAME_NONPANED_SIZE (f, TOP_EDGE) + FRAME_NONPANED_SIZE (f, BOTTOM_EDGE)); |
3609 new_pixwidth -= | 3655 paned_pixwidth = new_pixwidth - |
3610 (FRAME_NONPANED_SIZE (f, LEFT_EDGE) + FRAME_NONPANED_SIZE (f, RIGHT_EDGE)); | 3656 (FRAME_NONPANED_SIZE (f, LEFT_EDGE) + FRAME_NONPANED_SIZE (f, RIGHT_EDGE)); |
3611 | 3657 |
3612 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top = FRAME_PANED_TOP_EDGE (f); | 3658 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top = FRAME_PANED_TOP_EDGE (f); |
3613 | 3659 |
3614 if (FRAME_HAS_MINIBUF_P (f) | 3660 if (FRAME_HAS_MINIBUF_P (f) |
3623 * default font height. This should cause the minibuffer | 3669 * default font height. This should cause the minibuffer |
3624 * height to be recomputed on font changes but not for | 3670 * height to be recomputed on font changes but not for |
3625 * other frame size changes, which seems reasonable. | 3671 * other frame size changes, which seems reasonable. |
3626 */ | 3672 */ |
3627 int old_minibuf_height = | 3673 int old_minibuf_height = |
3628 XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_height; | 3674 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_height; |
3629 int minibuf_height = | 3675 int minibuf_height = |
3630 f->init_finished && (old_minibuf_height % real_font_height) == 0 ? | 3676 f->init_finished && (old_minibuf_height % real_font_height) == 0 ? |
3631 max(old_minibuf_height, real_font_height) : | 3677 max (old_minibuf_height, real_font_height) : |
3632 real_font_height; | 3678 real_font_height; |
3633 set_window_pixheight (FRAME_ROOT_WINDOW (f), | 3679 set_window_pixheight (FRAME_ROOT_WINDOW (f), |
3634 /* - font_height for minibuffer */ | 3680 /* - font_height for minibuffer */ |
3635 new_pixheight - minibuf_height, 0); | 3681 paned_pixheight - minibuf_height, 0); |
3636 | 3682 |
3637 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_top = | 3683 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_top = |
3638 FRAME_PANED_TOP_EDGE (f) + | 3684 FRAME_PANED_TOP_EDGE (f) + |
3639 FRAME_BOTTOM_GUTTER_BOUNDS (f) + | 3685 FRAME_BOTTOM_GUTTER_BOUNDS (f) + |
3640 new_pixheight - minibuf_height; | 3686 paned_pixheight - minibuf_height; |
3641 | 3687 |
3642 set_window_pixheight (FRAME_MINIBUF_WINDOW (f), minibuf_height, 0); | 3688 set_window_pixheight (FRAME_MINIBUF_WINDOW (f), minibuf_height, 0); |
3643 } | 3689 } |
3644 else | 3690 else |
3645 /* Frame has just one top-level window. */ | 3691 /* Frame has just one top-level window. */ |
3646 set_window_pixheight (FRAME_ROOT_WINDOW (f), new_pixheight, 0); | 3692 set_window_pixheight (FRAME_ROOT_WINDOW (f), paned_pixheight, 0); |
3693 | |
3694 /* Set the value of FRAME_WIDTH/FRAME_HEIGHT and | |
3695 FRAME_CHARWIDTH/FRAME_CHARHEIGHT. | |
3696 | |
3697 Question: Where is FRAME_PIXWIDTH/FRAME_PIXHEIGHT set? | |
3698 Answer: In the device-specific code, as a result of a callback from | |
3699 the window system indicating that the frame has changed size. | |
3700 This happens: | |
3701 | |
3702 (1) in the WM_SIZE processing in event-msw.c | |
3703 (2) in update_various_frame_slots() called from EmacsFrameResize() | |
3704 (called from Xt when the frame is resized) in EmacsFrame.c for X | |
3705 (3) in resize_event_cb() in frame-gtk.c | |
3706 (4) For TTY's, there is no such callback, so we have to set it | |
3707 ourselves. | |
3708 */ | |
3647 | 3709 |
3648 FRAME_HEIGHT (f) = newheight; | 3710 FRAME_HEIGHT (f) = newheight; |
3649 if (FRAME_TTY_P (f)) | 3711 if (FRAME_TTY_P (f)) |
3650 f->pixheight = newheight; | 3712 f->pixheight = newheight; |
3651 | 3713 |
3652 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left = FRAME_PANED_LEFT_EDGE (f); | 3714 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left = FRAME_PANED_LEFT_EDGE (f); |
3653 set_window_pixwidth (FRAME_ROOT_WINDOW (f), new_pixwidth, 0); | 3715 set_window_pixwidth (FRAME_ROOT_WINDOW (f), paned_pixwidth, 0); |
3654 | 3716 |
3655 if (FRAME_HAS_MINIBUF_P (f)) | 3717 if (FRAME_HAS_MINIBUF_P (f)) |
3656 { | 3718 { |
3657 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_left = | 3719 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_left = |
3658 FRAME_PANED_LEFT_EDGE (f); | 3720 FRAME_PANED_LEFT_EDGE (f); |
3659 set_window_pixwidth (FRAME_MINIBUF_WINDOW (f), new_pixwidth, 0); | 3721 set_window_pixwidth (FRAME_MINIBUF_WINDOW (f), paned_pixwidth, 0); |
3660 } | 3722 } |
3661 | 3723 |
3662 FRAME_WIDTH (f) = newwidth; | 3724 FRAME_WIDTH (f) = newwidth; |
3663 if (FRAME_TTY_P (f)) | 3725 if (FRAME_TTY_P (f)) |
3664 f->pixwidth = newwidth; | 3726 f->pixwidth = newwidth; |
3665 | 3727 |
3666 /* #### On MS Windows, this references FRAME_PIXWIDTH() and | 3728 /* Set the frame character-cell width appropriately. */ |
3667 FRAME_PIXHEIGHT(). I'm not sure we can count on those values being | 3729 if (window_system_pixelated_geometry (wrap_frame (f))) |
3668 set. Instead we should use the total pixel size we got near the top | 3730 pixel_to_char_size (f, new_pixwidth, new_pixheight, |
3669 by calling frame_conversion_internal(). We should inline the logic in | 3731 &FRAME_CHARWIDTH (f), &FRAME_CHARHEIGHT (f)); |
3670 get_frame_char_size() here and change that function so it just looks | 3732 else |
3671 at FRAME_CHARWIDTH() and FRAME_CHARHEIGHT(). */ | 3733 { |
3672 get_frame_char_size (f, &FRAME_CHARWIDTH (f), &FRAME_CHARHEIGHT (f)); | 3734 FRAME_CHARWIDTH (f) = FRAME_WIDTH (f); |
3735 FRAME_CHARHEIGHT (f) = FRAME_HEIGHT (f); | |
3736 } | |
3673 | 3737 |
3674 MARK_FRAME_TOOLBARS_CHANGED (f); | 3738 MARK_FRAME_TOOLBARS_CHANGED (f); |
3675 MARK_FRAME_GUTTERS_CHANGED (f); | 3739 MARK_FRAME_GUTTERS_CHANGED (f); |
3676 MARK_FRAME_CHANGED (f); | 3740 MARK_FRAME_CHANGED (f); |
3677 f->echo_area_garbaged = 1; | 3741 f->echo_area_garbaged = 1; |
3678 } | 3742 } |
3743 | |
3744 /* This function is called to change the redisplay structures of a frame | |
3745 to correspond to a new width and height. IT DOES NOT CHANGE THE ACTUAL | |
3746 SIZE OF A FRAME. It is meant to be called after the frame has been | |
3747 resized, either as a result of user action or a call to a function | |
3748 such as `set-frame-size'. For example, under MS-Windows it is called | |
3749 from mswindows_wnd_proc() when a WM_SIZE message is received, indicating | |
3750 that the user resized the frame, and from mswindows_set_frame_size(), | |
3751 which is the device method that is called (from internal_set_frame_size()) | |
3752 when `set-frame-size' or similar function is called. | |
3753 | |
3754 Values passed in are in frame units (character cells on X/GTK, | |
3755 displayable-area pixels on MS Windows or generally on pixelated-geometry | |
3756 window systems). See discussion at top of file. | |
3757 | |
3758 See also internal_set_frame_size() and adjust_frame_size(). | |
3759 */ | |
3679 | 3760 |
3680 void | 3761 void |
3681 change_frame_size (struct frame *f, int newwidth, int newheight, int delay) | 3762 change_frame_size (struct frame *f, int newwidth, int newheight, int delay) |
3682 { | 3763 { |
3683 /* sometimes we get passed a size that's too small (esp. when a | 3764 /* sometimes we get passed a size that's too small (esp. when a |
3714 } | 3795 } |
3715 else | 3796 else |
3716 change_frame_size_1 (f, newwidth, newheight); | 3797 change_frame_size_1 (f, newwidth, newheight); |
3717 } | 3798 } |
3718 | 3799 |
3800 | |
3801 /* This function is called from `set-frame-size' or the like, to explicitly | |
3802 change the size of a frame. It calls the `set_frame_size' device | |
3803 method, which makes the necessary window-system-specific call to change | |
3804 the size of the frame and then calls change_frame_size() to change | |
3805 the redisplay structures appropriately. | |
3806 | |
3807 Values passed in are in frame units (character cells on X/GTK, | |
3808 displayable-area pixels on MS Windows or generally on pixelated-geometry | |
3809 window systems). See discussion at top of file. | |
3810 */ | |
3811 | |
3812 void | |
3813 internal_set_frame_size (struct frame *f, int cols, int rows, int pretend) | |
3814 { | |
3815 /* This can call Lisp. See mswindows_set_frame_size(). */ | |
3816 /* An explicit size change cancels any pending frame size adjustment */ | |
3817 CLEAR_FRAME_SIZE_SLIPPED (f); | |
3818 | |
3819 if (pretend || !HAS_FRAMEMETH_P (f, set_frame_size)) | |
3820 change_frame_size (f, cols, rows, 0); | |
3821 else | |
3822 FRAMEMETH (f, set_frame_size, (f, cols, rows)); | |
3823 } | |
3824 | |
3825 /* This function is called from redisplay_frame() as a result of the | |
3826 "frame_slipped" flag being set. This flag is set when the default font | |
3827 changes or when a change to scrollbar or toolbar visibility or size | |
3828 is made (e.g. when a specifier such as `scrollbar-width' is changed). | |
3829 Its purpose is to resize the frame so that its size in character-cell | |
3830 units stays the same. | |
3831 | |
3832 #### It should also be triggered by a change the gutter visibility or | |
3833 size. | |
3834 | |
3835 When a scrollbar or toolbar specifier is changed, the | |
3836 frame_size_slipped() function is called (this happens because the | |
3837 specifier's value_changed_in_frame() hook has been set to | |
3838 frame_size_slipped() by a call to set_specifier_caching()). | |
3839 All this does is call MARK_FRAME_SIZE_SLIPPED(), which sets the | |
3840 frame_slipped flag, which gets noticed by redisplay_frame(), as just | |
3841 discussed. | |
3842 | |
3843 The way things get triggered when a change is made to the default font | |
3844 is as follows: | |
3845 | |
3846 (1) The specifier for the default font, which is attached to the | |
3847 face named `default', has its "face" property set to the `default' | |
3848 face. | |
3849 | |
3850 (2) font_after_change() (the font specifier's after_changed() method) | |
3851 is called for the font specifier. | |
3852 | |
3853 | |
3854 (3) It in turn calls face_property_was_changed(), passing in the | |
3855 default face. | |
3856 | |
3857 (4) face_property_was_changed() notices that the default face is having | |
3858 a property set and calls update_EmacsFrame(). | |
3859 | |
3860 (5) This in turn notices that the default face's font is being changed | |
3861 and calls MARK_FRAME_SIZE_SLIPPED() -- see above. | |
3862 */ | |
3863 | |
3864 void | |
3865 adjust_frame_size (struct frame *f) | |
3866 { | |
3867 /* This can call Lisp. */ | |
3868 int keep_char_size = 0; | |
3869 Lisp_Object frame = wrap_frame (f); | |
3870 | |
3871 if (!f->size_slipped) | |
3872 return; | |
3873 | |
3874 /* Don't adjust tty frames. #### May break when TTY have menubars. | |
3875 Then, write an Vadjust_frame_function which will return t for TTY | |
3876 frames. Another solution is frame_size_fixed_p method for TTYs, | |
3877 which always returned yes it's fixed. | |
3878 */ | |
3879 if (!FRAME_WIN_P (f)) | |
3880 { | |
3881 CLEAR_FRAME_SIZE_SLIPPED (f); | |
3882 return; | |
3883 } | |
3884 | |
3885 /* frame_size_fixed_p tells that frame size cannot currently | |
3886 be changed change due to external conditions */ | |
3887 if (!FRAMEMETH_OR_GIVEN (f, frame_size_fixed_p, (f), 0)) | |
3888 { | |
3889 if (NILP (Vadjust_frame_function)) | |
3890 keep_char_size = 1; | |
3891 else if (EQ (Vadjust_frame_function, Qt)) | |
3892 keep_char_size = 0; | |
3893 else | |
3894 keep_char_size = | |
3895 NILP (call1_trapping_problems ("Error in adjust-frame-function", | |
3896 Vadjust_frame_function, frame, | |
3897 0)); | |
3898 | |
3899 if (keep_char_size) | |
3900 Fset_frame_size (frame, make_int (FRAME_CHARWIDTH(f)), | |
3901 make_int (FRAME_CHARHEIGHT(f)), Qnil); | |
3902 } | |
3903 | |
3904 if (!keep_char_size) | |
3905 { | |
3906 int height, width; | |
3907 pixel_to_frame_unit_size (f, FRAME_PIXWIDTH(f), FRAME_PIXHEIGHT(f), | |
3908 &width, &height); | |
3909 change_frame_size (f, width, height, 0); | |
3910 CLEAR_FRAME_SIZE_SLIPPED (f); | |
3911 } | |
3912 } | |
3913 | |
3914 /* This is a "specifier changed in frame" handler for various specifiers | |
3915 changing which causes frame size adjustment. See the discussion in | |
3916 adjust_frame_size(). | |
3917 */ | |
3918 | |
3919 void | |
3920 frame_size_slipped (Lisp_Object UNUSED (specifier), struct frame *f, | |
3921 Lisp_Object UNUSED (oldval)) | |
3922 { | |
3923 MARK_FRAME_SIZE_SLIPPED (f); | |
3924 } | |
3925 | |
3926 void | |
3927 invalidate_vertical_divider_cache_in_frame (struct frame *f) | |
3928 { | |
3929 /* Invalidate cached value of needs_vertical_divider_p in | |
3930 every and all windows */ | |
3931 map_windows (f, invalidate_vertical_divider_cache_in_window, 0); | |
3932 } | |
3933 | |
3719 | 3934 |
3935 /**************************************************************************/ | |
3936 /* */ | |
3937 /* frame title, icon, pointer */ | |
3938 /* */ | |
3939 /**************************************************************************/ | |
3940 | |
3720 /* The caller is responsible for freeing the returned string. */ | 3941 /* The caller is responsible for freeing the returned string. */ |
3721 static Ibyte * | 3942 static Ibyte * |
3722 generate_title_string (struct window *w, Lisp_Object format_str, | 3943 generate_title_string (struct window *w, Lisp_Object format_str, |
3723 face_index findex, int type) | 3944 face_index findex, int type) |
3724 { | 3945 { |