Mercurial > hg > xemacs-beta
comparison src/frame.c @ 5104:868a5349acee
add documentation to frame.c, rearrange some functions to consolidate in related areas
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* frame.c:
* frame.c (frame_live_p):
* frame.c (Fframep):
* frame.c (Fdisable_frame):
* frame.c (Fenable_frame):
* frame.c (Fraise_frame):
* frame.c (Fframe_name):
* frame.c (Fset_frame_height):
* frame.c (internal_set_frame_size):
* frame.c (adjust_frame_size):
Add documentation on the different types of units used to measure
frame size.
Add section headers to the various sections.
Rearrange the location of some functions in the file to keep
related functions together. This especially goes for frame-sizing
functions (internal_set_frame_size() and adjust_frame_size()),
which have been moved so that they form a group with
change_frame_size() and change_frame_size_1().
No functionality should change.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 05 Mar 2010 22:50:27 -0600 |
parents | 0ca81354c4c7 |
children | d76a51b29d91 |
comparison
equal
deleted
inserted
replaced
5103:4129013a3954 | 5104:868a5349acee |
---|---|
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" |
450 /* Used by generate_title_string. Global because they get used so much that | 493 /* Used by generate_title_string. Global because they get used so much that |
451 the dynamic allocation time adds up. */ | 494 the dynamic allocation time adds up. */ |
452 static Ichar_dynarr *title_string_ichar_dynarr; | 495 static Ichar_dynarr *title_string_ichar_dynarr; |
453 | 496 |
454 | 497 |
498 /**************************************************************************/ | |
499 /* */ | |
500 /* frame object */ | |
501 /* */ | |
502 /**************************************************************************/ | |
455 | 503 |
456 #ifndef NEW_GC | 504 #ifndef NEW_GC |
457 extern const struct sized_memory_description gtk_frame_data_description; | 505 extern const struct sized_memory_description gtk_frame_data_description; |
458 extern const struct sized_memory_description mswindows_frame_data_description; | 506 extern const struct sized_memory_description mswindows_frame_data_description; |
459 extern const struct sized_memory_description x_frame_data_description; | 507 extern const struct sized_memory_description x_frame_data_description; |
600 0, /*dumpable-flag*/ | 648 0, /*dumpable-flag*/ |
601 mark_frame, print_frame, 0, 0, 0, | 649 mark_frame, print_frame, 0, 0, 0, |
602 frame_description, | 650 frame_description, |
603 struct frame); | 651 struct frame); |
604 | 652 |
653 /**************************************************************************/ | |
654 /* */ | |
655 /* frame creation */ | |
656 /* */ | |
657 /**************************************************************************/ | |
658 | |
605 static void | 659 static void |
606 nuke_all_frame_slots (struct frame *f) | 660 nuke_all_frame_slots (struct frame *f) |
607 { | 661 { |
608 ZERO_LCRECORD (f); | 662 ZERO_LCRECORD (f); |
609 | 663 |
1037 | 1091 |
1038 return frame; | 1092 return frame; |
1039 } | 1093 } |
1040 | 1094 |
1041 | 1095 |
1096 /**************************************************************************/ | |
1097 /* */ | |
1098 /* validating a frame argument */ | |
1099 /* */ | |
1100 /**************************************************************************/ | |
1101 | |
1042 /* this function should be used in most cases when a Lisp function is passed | 1102 /* this function should be used in most cases when a Lisp function is passed |
1043 a FRAME argument. Use this unless you don't accept nil == current frame | 1103 a FRAME argument. Use this unless you don't accept nil == current frame |
1044 (in which case, do a CHECK_LIVE_FRAME() and then an XFRAME()) or you | 1104 (in which case, do a CHECK_LIVE_FRAME() and then an XFRAME()) or you |
1045 allow dead frames. Note that very few functions should accept dead | 1105 allow dead frames. Note that very few functions should accept dead |
1046 frames. It could be argued that functions should just do nothing when | 1106 frames. It could be argued that functions should just do nothing when |
1069 if (DEVICEP (cdf)) | 1129 if (DEVICEP (cdf)) |
1070 cdf = DEVICE_SELECTED_FRAME (decode_device (cdf)); | 1130 cdf = DEVICE_SELECTED_FRAME (decode_device (cdf)); |
1071 return decode_frame (cdf); | 1131 return decode_frame (cdf); |
1072 } | 1132 } |
1073 | 1133 |
1074 Lisp_Object | |
1075 frame_device (struct frame *f) | |
1076 { | |
1077 return FRAME_DEVICE (f); | |
1078 } | |
1079 | |
1080 int | 1134 int |
1081 frame_live_p (struct frame *f) | 1135 frame_live_p (struct frame *f) |
1082 { | 1136 { |
1083 return FRAME_LIVE_P (f); | 1137 return FRAME_LIVE_P (f); |
1084 } | 1138 } |
1085 | 1139 |
1086 | |
1087 void | |
1088 invalidate_vertical_divider_cache_in_frame (struct frame *f) | |
1089 { | |
1090 /* Invalidate cached value of needs_vertical_divider_p in | |
1091 every and all windows */ | |
1092 map_windows (f, invalidate_vertical_divider_cache_in_window, 0); | |
1093 } | |
1094 | |
1095 /* | |
1096 * Frame size may change due to changes in scrollbars, toolbars, | |
1097 * default font etc. These changes are applied early in redisplay | |
1098 * frame. | |
1099 */ | |
1100 void | |
1101 adjust_frame_size (struct frame *f) | |
1102 { | |
1103 /* This can call Lisp. */ | |
1104 int keep_char_size = 0; | |
1105 Lisp_Object frame = wrap_frame (f); | |
1106 | |
1107 if (!f->size_slipped) | |
1108 return; | |
1109 | |
1110 /* Don't adjust tty frames. #### May break when TTY have menubars. | |
1111 Then, write an Vadjust_frame_function which will return t for TTY | |
1112 frames. Another solution is frame_size_fixed_p method for TTYs, | |
1113 which always returned yes it's fixed. | |
1114 */ | |
1115 if (!FRAME_WIN_P (f)) | |
1116 { | |
1117 CLEAR_FRAME_SIZE_SLIPPED (f); | |
1118 return; | |
1119 } | |
1120 | |
1121 /* frame_size_fixed_p tells that frame size cannot currently | |
1122 be changed change due to external conditions */ | |
1123 if (!FRAMEMETH_OR_GIVEN (f, frame_size_fixed_p, (f), 0)) | |
1124 { | |
1125 if (NILP (Vadjust_frame_function)) | |
1126 keep_char_size = 1; | |
1127 else if (EQ (Vadjust_frame_function, Qt)) | |
1128 keep_char_size = 0; | |
1129 else | |
1130 keep_char_size = | |
1131 NILP (call1_trapping_problems ("Error in adjust-frame-function", | |
1132 Vadjust_frame_function, frame, | |
1133 0)); | |
1134 | |
1135 if (keep_char_size) | |
1136 Fset_frame_size (frame, make_int (FRAME_CHARWIDTH(f)), | |
1137 make_int (FRAME_CHARHEIGHT(f)), Qnil); | |
1138 } | |
1139 | |
1140 if (!keep_char_size) | |
1141 { | |
1142 int height, width; | |
1143 pixel_to_frame_unit_size (f, FRAME_PIXWIDTH(f), FRAME_PIXHEIGHT(f), | |
1144 &width, &height); | |
1145 change_frame_size (f, width, height, 0); | |
1146 CLEAR_FRAME_SIZE_SLIPPED (f); | |
1147 } | |
1148 } | |
1149 | |
1150 /* | |
1151 * This is a "specifier changed in frame" handler for various specifiers | |
1152 * changing which causes frame size adjustment | |
1153 */ | |
1154 void | |
1155 frame_size_slipped (Lisp_Object UNUSED (specifier), struct frame *f, | |
1156 Lisp_Object UNUSED (oldval)) | |
1157 { | |
1158 MARK_FRAME_SIZE_SLIPPED(f); | |
1159 } | |
1160 | |
1161 DEFUN ("framep", Fframep, 1, 1, 0, /* | 1140 DEFUN ("framep", Fframep, 1, 1, 0, /* |
1162 Return non-nil if OBJECT is a frame. | 1141 Return non-nil if OBJECT is a frame. |
1163 Also see `frame-live-p'. | 1142 Also see `frame-live-p'. |
1164 Note that FSF Emacs kludgily returns a value indicating what type of | 1143 Note that FSF Emacs kludgily returns a value indicating what type of |
1165 frame this is. Use the cleaner function `frame-type' for that. | 1144 frame this is. Use the cleaner function `frame-type' for that. |
1176 { | 1155 { |
1177 return FRAMEP (object) && FRAME_LIVE_P (XFRAME (object)) ? Qt : Qnil; | 1156 return FRAMEP (object) && FRAME_LIVE_P (XFRAME (object)) ? Qt : Qnil; |
1178 } | 1157 } |
1179 | 1158 |
1180 | 1159 |
1160 /**************************************************************************/ | |
1161 /* */ | |
1162 /* frame focus/selection */ | |
1163 /* */ | |
1164 /**************************************************************************/ | |
1165 | |
1166 Lisp_Object | |
1167 frame_device (struct frame *f) | |
1168 { | |
1169 return FRAME_DEVICE (f); | |
1170 } | |
1171 | |
1172 DEFUN ("frame-device", Fframe_device, 0, 1, 0, /* | |
1173 Return the device that FRAME is on. | |
1174 If omitted, FRAME defaults to the currently selected frame. | |
1175 */ | |
1176 (frame)) | |
1177 { | |
1178 return FRAME_DEVICE (decode_frame (frame)); | |
1179 } | |
1180 | |
1181 DEFUN ("focus-frame", Ffocus_frame, 1, 1, 0, /* | 1181 DEFUN ("focus-frame", Ffocus_frame, 1, 1, 0, /* |
1182 Select FRAME and give it the window system focus. | 1182 Select FRAME and give it the window system focus. |
1183 This function is not affected by the value of `focus-follows-mouse'. | 1183 This function is not affected by the value of `focus-follows-mouse'. |
1184 */ | 1184 */ |
1185 (frame)) | 1185 (frame)) |
1274 } | 1274 } |
1275 return XFRAME (frame); | 1275 return XFRAME (frame); |
1276 } | 1276 } |
1277 | 1277 |
1278 #if 0 /* FSFmacs */ | 1278 #if 0 /* FSFmacs */ |
1279 | |
1280 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus', | |
1281 crockish FSFmacs functions. See summary on focus in event-stream.c. */ | |
1279 | 1282 |
1280 DEFUN ("handle-switch-frame", Fhandle_switch_frame, 1, 2, "e", /* | 1283 DEFUN ("handle-switch-frame", Fhandle_switch_frame, 1, 2, "e", /* |
1281 Handle a switch-frame event EVENT. | 1284 Handle a switch-frame event EVENT. |
1282 Switch-frame events are usually bound to this function. | 1285 Switch-frame events are usually bound to this function. |
1283 A switch-frame event tells Emacs that the window manager has requested | 1286 A switch-frame event tells Emacs that the window manager has requested |
1426 | 1429 |
1427 set_frame_selected_window (XFRAME (frame), window); | 1430 set_frame_selected_window (XFRAME (frame), window); |
1428 return window; | 1431 return window; |
1429 } | 1432 } |
1430 | 1433 |
1434 DEFUN ("disable-frame", Fdisable_frame, 1, 1, 0, /* | |
1435 Disable frame FRAME, so that it cannot have the focus or receive user input. | |
1436 This is normally used during modal dialog boxes. | |
1437 WARNING: Be very careful not to wedge XEmacs! | |
1438 Use an `unwind-protect' that re-enables the frame to avoid this. | |
1439 */ | |
1440 (frame)) | |
1441 { | |
1442 struct frame *f = decode_frame (frame); | |
1443 | |
1444 f->disabled = 1; | |
1445 MAYBE_FRAMEMETH (f, disable_frame, (f)); | |
1446 return Qnil; | |
1447 } | |
1448 | |
1449 DEFUN ("enable-frame", Fenable_frame, 1, 1, 0, /* | |
1450 Enable frame FRAME, so that it can have the focus and receive user input. | |
1451 Frames are normally enabled, unless explicitly disabled using `disable-frame'. | |
1452 */ | |
1453 (frame)) | |
1454 { | |
1455 struct frame *f = decode_frame (frame); | |
1456 f->disabled = 0; | |
1457 MAYBE_FRAMEMETH (f, enable_frame, (f)); | |
1458 return Qnil; | |
1459 } | |
1431 | 1460 |
1432 DEFUN ("frame-device", Fframe_device, 0, 1, 0, /* | 1461 /**************************************************************************/ |
1433 Return the device that FRAME is on. | 1462 /* */ |
1434 If omitted, FRAME defaults to the currently selected frame. | 1463 /* traversing the list of frames */ |
1435 */ | 1464 /* */ |
1436 (frame)) | 1465 /**************************************************************************/ |
1437 { | |
1438 return FRAME_DEVICE (decode_frame (frame)); | |
1439 } | |
1440 | 1466 |
1441 int | 1467 int |
1442 is_surrogate_for_selected_frame (struct frame *f) | 1468 is_surrogate_for_selected_frame (struct frame *f) |
1443 { | 1469 { |
1444 struct device *d = XDEVICE (f->device); | 1470 struct device *d = XDEVICE (f->device); |
1728 | 1754 |
1729 return Qnil; | 1755 return Qnil; |
1730 } | 1756 } |
1731 | 1757 |
1732 | 1758 |
1759 /**************************************************************************/ | |
1760 /* */ | |
1761 /* frame deletion */ | |
1762 /* */ | |
1763 /**************************************************************************/ | |
1733 | 1764 |
1734 /* extern void free_line_insertion_deletion_costs (struct frame *f); */ | 1765 /* extern void free_line_insertion_deletion_costs (struct frame *f); */ |
1735 | 1766 |
1736 /* Return 1 if it is ok to delete frame F; | 1767 /* Return 1 if it is ok to delete frame F; |
1737 0 if all frames aside from F are invisible. | 1768 0 if all frames aside from F are invisible. |
2180 delete_frame_internal (f, !NILP (force), 0, 0); | 2211 delete_frame_internal (f, !NILP (force), 0, 0); |
2181 return Qnil; | 2212 return Qnil; |
2182 } | 2213 } |
2183 | 2214 |
2184 | 2215 |
2216 /**************************************************************************/ | |
2217 /* */ | |
2218 /* mouse position in frame */ | |
2219 /* */ | |
2220 /**************************************************************************/ | |
2221 | |
2185 /* Return mouse position in character cell units. */ | 2222 /* Return mouse position in character cell units. */ |
2186 | 2223 |
2187 static int | 2224 static int |
2188 mouse_pixel_position_1 (struct device *d, Lisp_Object *frame, | 2225 mouse_pixel_position_1 (struct device *d, Lisp_Object *frame, |
2189 int *x, int *y) | 2226 int *x, int *y) |
2367 FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, XINT (x), XINT (y))); | 2404 FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, XINT (x), XINT (y))); |
2368 | 2405 |
2369 return Qnil; | 2406 return Qnil; |
2370 } | 2407 } |
2371 | 2408 |
2409 /**************************************************************************/ | |
2410 /* */ | |
2411 /* frame visibility */ | |
2412 /* */ | |
2413 /**************************************************************************/ | |
2414 | |
2372 DEFUN ("make-frame-visible", Fmake_frame_visible, 0, 1, 0, /* | 2415 DEFUN ("make-frame-visible", Fmake_frame_visible, 0, 1, 0, /* |
2373 Make the frame FRAME visible (assuming it is an X-window). | 2416 Make the frame FRAME visible (assuming it is an X-window). |
2374 If omitted, FRAME defaults to the currently selected frame. | 2417 If omitted, FRAME defaults to the currently selected frame. |
2375 Also raises the frame so that nothing obscures it. | 2418 Also raises the frame so that nothing obscures it. |
2376 */ | 2419 */ |
2529 } | 2572 } |
2530 | 2573 |
2531 return value; | 2574 return value; |
2532 } | 2575 } |
2533 | 2576 |
2534 | |
2535 DEFUN ("raise-frame", Fraise_frame, 0, 1, "", /* | 2577 DEFUN ("raise-frame", Fraise_frame, 0, 1, "", /* |
2536 Bring FRAME to the front, so it occludes any frames it overlaps. | 2578 Bring FRAME to the front, so it occludes any frames it overlaps. |
2537 If omitted, FRAME defaults to the currently selected frame. | 2579 If omitted, FRAME defaults to the currently selected frame. |
2538 If FRAME is invisible, make it visible. | 2580 If FRAME is invisible, make it visible. |
2539 If Emacs is displaying on an ordinary terminal or some other device which | 2581 If Emacs is displaying on an ordinary terminal or some other device which |
2562 MAYBE_FRAMEMETH (f, lower_frame, (f)); | 2604 MAYBE_FRAMEMETH (f, lower_frame, (f)); |
2563 return Qnil; | 2605 return Qnil; |
2564 } | 2606 } |
2565 | 2607 |
2566 | 2608 |
2567 DEFUN ("disable-frame", Fdisable_frame, 1, 1, 0, /* | 2609 /***************************************************************************/ |
2568 Disable frame FRAME, so that it cannot have the focus or receive user input. | 2610 /* */ |
2569 This is normally used during modal dialog boxes. | 2611 /* print-related functions */ |
2570 WARNING: Be very careful not to wedge XEmacs! | 2612 /* */ |
2571 Use an `unwind-protect' that re-enables the frame to avoid this. | 2613 /***************************************************************************/ |
2572 */ | 2614 |
2573 (frame)) | |
2574 { | |
2575 struct frame *f = decode_frame (frame); | |
2576 | |
2577 f->disabled = 1; | |
2578 MAYBE_FRAMEMETH (f, disable_frame, (f)); | |
2579 return Qnil; | |
2580 } | |
2581 | |
2582 DEFUN ("enable-frame", Fenable_frame, 1, 1, 0, /* | |
2583 Enable frame FRAME, so that it can have the focus and receive user input. | |
2584 Frames are normally enabled, unless explicitly disabled using `disable-frame'. | |
2585 */ | |
2586 (frame)) | |
2587 { | |
2588 struct frame *f = decode_frame (frame); | |
2589 f->disabled = 0; | |
2590 MAYBE_FRAMEMETH (f, enable_frame, (f)); | |
2591 return Qnil; | |
2592 } | |
2593 | |
2594 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus', | |
2595 crockish FSFmacs functions. See summary on focus in event-stream.c. */ | |
2596 | |
2597 DEFUN ("print-job-page-number", Fprint_job_page_number, 1, 1, 0, /* | 2615 DEFUN ("print-job-page-number", Fprint_job_page_number, 1, 1, 0, /* |
2598 Return current page number for the print job FRAME. | 2616 Return current page number for the print job FRAME. |
2599 */ | 2617 */ |
2600 (frame)) | 2618 (frame)) |
2601 { | 2619 { |
2619 return Qnil; | 2637 return Qnil; |
2620 } | 2638 } |
2621 | 2639 |
2622 | 2640 |
2623 /***************************************************************************/ | 2641 /***************************************************************************/ |
2642 /* */ | |
2624 /* frame properties */ | 2643 /* frame properties */ |
2644 /* */ | |
2625 /***************************************************************************/ | 2645 /***************************************************************************/ |
2646 | |
2647 DEFUN ("frame-name", Fframe_name, 0, 1, 0, /* | |
2648 Return the name of FRAME (defaulting to the selected frame). | |
2649 This is not the same as the `title' of the frame. | |
2650 */ | |
2651 (frame)) | |
2652 { | |
2653 return decode_frame (frame)->name; | |
2654 } | |
2655 | |
2656 DEFUN ("frame-modified-tick", Fframe_modified_tick, 0, 1, 0, /* | |
2657 Return FRAME's tick counter, incremented for each change to the frame. | |
2658 Each frame has a tick counter which is incremented each time the frame | |
2659 is resized, a window is resized, added, or deleted, a face is changed, | |
2660 `set-window-buffer' or `select-window' is called on a window in the | |
2661 frame, the window-start of a window in the frame has changed, or | |
2662 anything else interesting has happened. It wraps around occasionally. | |
2663 No argument or nil as argument means use selected frame as FRAME. | |
2664 */ | |
2665 (frame)) | |
2666 { | |
2667 return make_int (decode_frame (frame)->modiff); | |
2668 } | |
2626 | 2669 |
2627 static void | 2670 static void |
2628 store_minibuf_frame_prop (struct frame *f, Lisp_Object val) | 2671 store_minibuf_frame_prop (struct frame *f, Lisp_Object val) |
2629 { | 2672 { |
2630 /* This can call Lisp. */ | 2673 /* This can call Lisp. */ |
3022 UNGCPRO; | 3065 UNGCPRO; |
3023 return result; | 3066 return result; |
3024 } | 3067 } |
3025 | 3068 |
3026 | 3069 |
3070 /**************************************************************************/ | |
3071 /* */ | |
3072 /* frame sizing (user functions) */ | |
3073 /* */ | |
3074 /**************************************************************************/ | |
3075 | |
3027 DEFUN ("frame-pixel-height", Fframe_pixel_height, 0, 1, 0, /* | 3076 DEFUN ("frame-pixel-height", Fframe_pixel_height, 0, 1, 0, /* |
3028 Return the total height in pixels of FRAME. | 3077 Return the total height in pixels of FRAME. |
3029 */ | 3078 */ |
3030 (frame)) | 3079 (frame)) |
3031 { | 3080 { |
3060 struct frame *f = decode_frame (frame); | 3109 struct frame *f = decode_frame (frame); |
3061 int width, height; | 3110 int width, height; |
3062 | 3111 |
3063 get_frame_displayable_pixel_size (f, &width, &height); | 3112 get_frame_displayable_pixel_size (f, &width, &height); |
3064 return make_int (width); | 3113 return make_int (width); |
3065 } | |
3066 | |
3067 DEFUN ("frame-name", Fframe_name, 0, 1, 0, /* | |
3068 Return the name of FRAME (defaulting to the selected frame). | |
3069 This is not the same as the `title' of the frame. | |
3070 */ | |
3071 (frame)) | |
3072 { | |
3073 return decode_frame (frame)->name; | |
3074 } | |
3075 | |
3076 DEFUN ("frame-modified-tick", Fframe_modified_tick, 0, 1, 0, /* | |
3077 Return FRAME's tick counter, incremented for each change to the frame. | |
3078 Each frame has a tick counter which is incremented each time the frame | |
3079 is resized, a window is resized, added, or deleted, a face is changed, | |
3080 `set-window-buffer' or `select-window' is called on a window in the | |
3081 frame, the window-start of a window in the frame has changed, or | |
3082 anything else interesting has happened. It wraps around occasionally. | |
3083 No argument or nil as argument means use selected frame as FRAME. | |
3084 */ | |
3085 (frame)) | |
3086 { | |
3087 return make_int (decode_frame (frame)->modiff); | |
3088 } | |
3089 | |
3090 void | |
3091 internal_set_frame_size (struct frame *f, int cols, int rows, int pretend) | |
3092 { | |
3093 /* This can call Lisp. See mswindows_set_frame_size(). */ | |
3094 /* An explicit size change cancels any pending frame size adjustment */ | |
3095 CLEAR_FRAME_SIZE_SLIPPED (f); | |
3096 | |
3097 if (pretend || !HAS_FRAMEMETH_P (f, set_frame_size)) | |
3098 change_frame_size (f, cols, rows, 0); | |
3099 else | |
3100 FRAMEMETH (f, set_frame_size, (f, cols, rows)); | |
3101 } | 3114 } |
3102 | 3115 |
3103 DEFUN ("set-frame-height", Fset_frame_height, 2, 3, 0, /* | 3116 DEFUN ("set-frame-height", Fset_frame_height, 2, 3, 0, /* |
3104 Specify that the frame FRAME has LINES lines. | 3117 Specify that the frame FRAME has LINES lines. |
3105 Optional third arg non-nil means that redisplay should use LINES lines | 3118 Optional third arg non-nil means that redisplay should use LINES lines |
3301 | 3314 |
3302 return Qt; | 3315 return Qt; |
3303 } | 3316 } |
3304 | 3317 |
3305 | 3318 |
3319 /**************************************************************************/ | |
3320 /* */ | |
3321 /* various ways of measuring the frame size */ | |
3322 /* */ | |
3323 /**************************************************************************/ | |
3306 | 3324 |
3307 /* Frame size conversion functions moved here from EmacsFrame.c | 3325 /* Frame size conversion functions moved here from EmacsFrame.c |
3308 because they're generic and really don't belong in that file. | 3326 because they're generic and really don't belong in that file. |
3309 Function get_default_char_pixel_size() removed because it's | 3327 Function get_default_char_pixel_size() removed because it's |
3310 exactly the same as default_face_width_and_height(). | 3328 exactly the same as default_face_width_and_height(). |
3311 | 3329 |
3312 Convert between total pixel size, displayable pixel size and | 3330 Convert between total pixel size, displayable pixel size and |
3313 character-cell size. Variables are either "in" or "out" | 3331 character-cell size. Variables are either "in", "out" or unused, |
3314 depending on the value of PIXEL_TO_CHAR. | 3332 depending on the value of PIXEL_TO_CHAR, which indicates which units the |
3315 */ | 3333 source and destination values are measured in. |
3334 | |
3335 See frame_conversion_internal() for a discussion of the different | |
3336 types of units. */ | |
3337 | |
3316 static void | 3338 static void |
3317 frame_conversion_internal_1 (struct frame *f, | 3339 frame_conversion_internal_1 (struct frame *f, |
3318 pixel_to_char_mode_t pixel_to_char, | 3340 pixel_to_char_mode_t pixel_to_char, |
3319 int *total_pixel_width, int *total_pixel_height, | 3341 int *total_pixel_width, int *total_pixel_height, |
3320 int *disp_pixel_width, int *disp_pixel_height, | 3342 int *disp_pixel_width, int *disp_pixel_height, |
3415 return type; | 3437 return type; |
3416 } | 3438 } |
3417 | 3439 |
3418 /* Basic frame conversion function. Convert source size to destination | 3440 /* Basic frame conversion function. Convert source size to destination |
3419 size, where either of them can be in total pixels, displayable pixels, | 3441 size, where either of them can be in total pixels, displayable pixels, |
3420 frame units or character-cell units. */ | 3442 frame units or character-cell units. |
3443 | |
3444 See comment at top of file for discussion about different types of | |
3445 units. */ | |
3421 | 3446 |
3422 static void | 3447 static void |
3423 frame_conversion_internal (struct frame *f, | 3448 frame_conversion_internal (struct frame *f, |
3424 enum frame_size_type source, | 3449 enum frame_size_type source, |
3425 int source_width, int source_height, | 3450 int source_width, int source_height, |
3572 frame_conversion_internal (f, SIZE_FRAME_UNIT, FRAME_WIDTH (f), | 3597 frame_conversion_internal (f, SIZE_FRAME_UNIT, FRAME_WIDTH (f), |
3573 FRAME_HEIGHT (f), SIZE_DISPLAYABLE_PIXEL, | 3598 FRAME_HEIGHT (f), SIZE_DISPLAYABLE_PIXEL, |
3574 out_width, out_height); | 3599 out_width, out_height); |
3575 } | 3600 } |
3576 | 3601 |
3602 | |
3603 /**************************************************************************/ | |
3604 /* */ | |
3605 /* frame resizing (implementation) */ | |
3606 /* */ | |
3607 /**************************************************************************/ | |
3608 | |
3577 /* Change the frame height and/or width. Values passed in are in | 3609 /* Change the frame height and/or width. Values passed in are in |
3578 frame units (character cells on X/GTK, displayable-area pixels | 3610 frame units (character cells on X/GTK, displayable-area pixels |
3579 on MS Windows or generally on pixelated-geometry window systems). */ | 3611 on MS Windows or generally on pixelated-geometry window systems). */ |
3580 static void | 3612 static void |
3581 change_frame_size_1 (struct frame *f, int newwidth, int newheight) | 3613 change_frame_size_1 (struct frame *f, int newwidth, int newheight) |
3680 MARK_FRAME_GUTTERS_CHANGED (f); | 3712 MARK_FRAME_GUTTERS_CHANGED (f); |
3681 MARK_FRAME_CHANGED (f); | 3713 MARK_FRAME_CHANGED (f); |
3682 f->echo_area_garbaged = 1; | 3714 f->echo_area_garbaged = 1; |
3683 } | 3715 } |
3684 | 3716 |
3717 /* This function is called to change the redisplay structures of a frame | |
3718 to correspond to a new width and height. IT DOES NOT CHANGE THE ACTUAL | |
3719 SIZE OF A FRAME. It is meant to be called after the frame has been | |
3720 resized, either as a result of user action or a call to a function | |
3721 such as `set-frame-size'. For example, under MS-Windows it is called | |
3722 from mswindows_wnd_proc() when a WM_SIZE message is received, indicating | |
3723 that the user resized the frame, and from mswindows_set_frame_size(), | |
3724 which is the device method that is called (from internal_set_frame_size()) | |
3725 when `set-frame-size' or similar function is called. | |
3726 | |
3727 Values passed in are in frame units (character cells on X/GTK, | |
3728 displayable-area pixels on MS Windows or generally on pixelated-geometry | |
3729 window systems). See discussion at top of file. | |
3730 | |
3731 See also internal_set_frame_size() and adjust_frame_size(). | |
3732 */ | |
3733 | |
3685 void | 3734 void |
3686 change_frame_size (struct frame *f, int newwidth, int newheight, int delay) | 3735 change_frame_size (struct frame *f, int newwidth, int newheight, int delay) |
3687 { | 3736 { |
3688 /* sometimes we get passed a size that's too small (esp. when a | 3737 /* sometimes we get passed a size that's too small (esp. when a |
3689 client widget gets resized, since we have no control over this). | 3738 client widget gets resized, since we have no control over this). |
3719 } | 3768 } |
3720 else | 3769 else |
3721 change_frame_size_1 (f, newwidth, newheight); | 3770 change_frame_size_1 (f, newwidth, newheight); |
3722 } | 3771 } |
3723 | 3772 |
3773 | |
3774 /* This function is called from `set-frame-size' or the like, to explicitly | |
3775 change the size of a frame. It calls the `set_frame_size' device | |
3776 method, which makes the necessary window-system-specific call to change | |
3777 the size of the frame and then calls change_frame_size() to change | |
3778 the redisplay structures appropriately. | |
3779 | |
3780 Values passed in are in frame units (character cells on X/GTK, | |
3781 displayable-area pixels on MS Windows or generally on pixelated-geometry | |
3782 window systems). See discussion at top of file. | |
3783 */ | |
3784 | |
3785 void | |
3786 internal_set_frame_size (struct frame *f, int cols, int rows, int pretend) | |
3787 { | |
3788 /* This can call Lisp. See mswindows_set_frame_size(). */ | |
3789 /* An explicit size change cancels any pending frame size adjustment */ | |
3790 CLEAR_FRAME_SIZE_SLIPPED (f); | |
3791 | |
3792 if (pretend || !HAS_FRAMEMETH_P (f, set_frame_size)) | |
3793 change_frame_size (f, cols, rows, 0); | |
3794 else | |
3795 FRAMEMETH (f, set_frame_size, (f, cols, rows)); | |
3796 } | |
3797 | |
3798 /* This function is called from redisplay_frame() as a result of the | |
3799 "frame_slipped" flag being set. This flag is set when the default font | |
3800 changes or when a change to scrollbar or toolbar visibility or size | |
3801 is made (e.g. when a specifier such as `scrollbar-width' is changed). | |
3802 Its purpose is to resize the frame so that its size in character-cell | |
3803 units stays the same. | |
3804 | |
3805 #### It should also be triggered by a change the gutter visibility or | |
3806 size. | |
3807 | |
3808 When a scrollbar or toolbar specifier is changed, the | |
3809 frame_size_slipped() function is called (this happens because the | |
3810 specifier's value_changed_in_frame() hook has been set to | |
3811 frame_size_slipped() by a call to set_specifier_caching()). | |
3812 All this does is call MARK_FRAME_SIZE_SLIPPED(), which sets the | |
3813 frame_slipped flag, which gets noticed by redisplay_frame(), as just | |
3814 discussed. | |
3815 | |
3816 The way things get triggered when a change is made to the default font | |
3817 is as follows: | |
3818 | |
3819 (1) The specifier for the default font, which is attached to the | |
3820 face named `default', has its "face" property set to the `default' | |
3821 face. | |
3822 | |
3823 (2) font_after_change() (the font specifier's after_changed() method) | |
3824 is called for the font specifier. | |
3825 | |
3826 | |
3827 (3) It in turn calls face_property_was_changed(), passing in the | |
3828 default face. | |
3829 | |
3830 (4) face_property_was_changed() notices that the default face is having | |
3831 a property set and calls update_EmacsFrame(). | |
3832 | |
3833 (5) This in turn notices that the default face's font is being changed | |
3834 and calls MARK_FRAME_SIZE_SLIPPED() -- see above. | |
3835 */ | |
3836 | |
3837 void | |
3838 adjust_frame_size (struct frame *f) | |
3839 { | |
3840 /* This can call Lisp. */ | |
3841 int keep_char_size = 0; | |
3842 Lisp_Object frame = wrap_frame (f); | |
3843 | |
3844 if (!f->size_slipped) | |
3845 return; | |
3846 | |
3847 /* Don't adjust tty frames. #### May break when TTY have menubars. | |
3848 Then, write an Vadjust_frame_function which will return t for TTY | |
3849 frames. Another solution is frame_size_fixed_p method for TTYs, | |
3850 which always returned yes it's fixed. | |
3851 */ | |
3852 if (!FRAME_WIN_P (f)) | |
3853 { | |
3854 CLEAR_FRAME_SIZE_SLIPPED (f); | |
3855 return; | |
3856 } | |
3857 | |
3858 /* frame_size_fixed_p tells that frame size cannot currently | |
3859 be changed change due to external conditions */ | |
3860 if (!FRAMEMETH_OR_GIVEN (f, frame_size_fixed_p, (f), 0)) | |
3861 { | |
3862 if (NILP (Vadjust_frame_function)) | |
3863 keep_char_size = 1; | |
3864 else if (EQ (Vadjust_frame_function, Qt)) | |
3865 keep_char_size = 0; | |
3866 else | |
3867 keep_char_size = | |
3868 NILP (call1_trapping_problems ("Error in adjust-frame-function", | |
3869 Vadjust_frame_function, frame, | |
3870 0)); | |
3871 | |
3872 if (keep_char_size) | |
3873 Fset_frame_size (frame, make_int (FRAME_CHARWIDTH(f)), | |
3874 make_int (FRAME_CHARHEIGHT(f)), Qnil); | |
3875 } | |
3876 | |
3877 if (!keep_char_size) | |
3878 { | |
3879 int height, width; | |
3880 pixel_to_frame_unit_size (f, FRAME_PIXWIDTH(f), FRAME_PIXHEIGHT(f), | |
3881 &width, &height); | |
3882 change_frame_size (f, width, height, 0); | |
3883 CLEAR_FRAME_SIZE_SLIPPED (f); | |
3884 } | |
3885 } | |
3886 | |
3887 /* This is a "specifier changed in frame" handler for various specifiers | |
3888 changing which causes frame size adjustment. See the discussion in | |
3889 adjust_frame_size(). | |
3890 */ | |
3891 | |
3892 void | |
3893 frame_size_slipped (Lisp_Object UNUSED (specifier), struct frame *f, | |
3894 Lisp_Object UNUSED (oldval)) | |
3895 { | |
3896 MARK_FRAME_SIZE_SLIPPED (f); | |
3897 } | |
3898 | |
3899 void | |
3900 invalidate_vertical_divider_cache_in_frame (struct frame *f) | |
3901 { | |
3902 /* Invalidate cached value of needs_vertical_divider_p in | |
3903 every and all windows */ | |
3904 map_windows (f, invalidate_vertical_divider_cache_in_window, 0); | |
3905 } | |
3906 | |
3724 | 3907 |
3908 /**************************************************************************/ | |
3909 /* */ | |
3910 /* frame title, icon, pointer */ | |
3911 /* */ | |
3912 /**************************************************************************/ | |
3913 | |
3725 /* The caller is responsible for freeing the returned string. */ | 3914 /* The caller is responsible for freeing the returned string. */ |
3726 static Ibyte * | 3915 static Ibyte * |
3727 generate_title_string (struct window *w, Lisp_Object format_str, | 3916 generate_title_string (struct window *w, Lisp_Object format_str, |
3728 face_index findex, int type) | 3917 face_index findex, int type) |
3729 { | 3918 { |