comparison src/frame.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents bbff43aa5eb7
children a86b2b5e0111
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
32 #include "events.h" 32 #include "events.h"
33 #include "extents.h" 33 #include "extents.h"
34 #include "faces.h" 34 #include "faces.h"
35 #include "frame.h" 35 #include "frame.h"
36 #include "glyphs.h" 36 #include "glyphs.h"
37 #include "gutter.h"
37 #include "menubar.h" 38 #include "menubar.h"
38 #include "redisplay.h" 39 #include "redisplay.h"
39 #include "scrollbar.h" 40 #include "scrollbar.h"
40 #include "window.h" 41 #include "window.h"
41 42
83 Lisp_Object Quse_backing_store; 84 Lisp_Object Quse_backing_store;
84 Lisp_Object Qborder_color; 85 Lisp_Object Qborder_color;
85 Lisp_Object Qborder_width; 86 Lisp_Object Qborder_width;
86 87
87 Lisp_Object Qframep, Qframe_live_p; 88 Lisp_Object Qframep, Qframe_live_p;
88 Lisp_Object Qframe_x_p, Qframe_tty_p;
89 Lisp_Object Qdelete_frame; 89 Lisp_Object Qdelete_frame;
90 90
91 Lisp_Object Qframe_title_format, Vframe_title_format; 91 Lisp_Object Qframe_title_format, Vframe_title_format;
92 Lisp_Object Qframe_icon_title_format, Vframe_icon_title_format; 92 Lisp_Object Qframe_icon_title_format, Vframe_icon_title_format;
93 93
114 other way of getting it if it isn't the selected frame. */ 114 other way of getting it if it isn't the selected frame. */
115 Lisp_Object Vframe_being_created; 115 Lisp_Object Vframe_being_created;
116 Lisp_Object Qframe_being_created; 116 Lisp_Object Qframe_being_created;
117 117
118 static void store_minibuf_frame_prop (struct frame *f, Lisp_Object val); 118 static void store_minibuf_frame_prop (struct frame *f, Lisp_Object val);
119 119 static struct display_line title_string_display_line;
120 EXFUN (Fset_frame_properties, 2); 120 /* Used by generate_title_string. Global because they get used so much that
121 the dynamic allocation time adds up. */
122 static Emchar_dynarr *title_string_emchar_dynarr;
121 123
122 124
123 static Lisp_Object 125 static Lisp_Object
124 mark_frame (Lisp_Object obj, void (*markobj) (Lisp_Object)) 126 mark_frame (Lisp_Object obj)
125 { 127 {
126 struct frame *f = XFRAME (obj); 128 struct frame *f = XFRAME (obj);
127 129
128 #define MARKED_SLOT(x) ((void) (markobj (f->x))); 130 #define MARKED_SLOT(x) mark_object (f->x)
129 #include "frameslots.h" 131 #include "frameslots.h"
130 132
131 mark_subwindow_cachels (f->subwindow_cachels, markobj); 133 mark_subwindow_cachels (f->subwindow_cachels);
132 134
133 if (FRAME_LIVE_P (f)) /* device is nil for a dead frame */ 135 if (FRAME_LIVE_P (f)) /* device is nil for a dead frame */
134 MAYBE_FRAMEMETH (f, mark_frame, (f, markobj)); 136 MAYBE_FRAMEMETH (f, mark_frame, (f));
135 137
136 return Qnil; 138 return Qnil;
137 } 139 }
138 140
139 static void 141 static void
153 sprintf (buf, " 0x%x>", frm->header.uid); 155 sprintf (buf, " 0x%x>", frm->header.uid);
154 write_c_string (buf, printcharfun); 156 write_c_string (buf, printcharfun);
155 } 157 }
156 158
157 DEFINE_LRECORD_IMPLEMENTATION ("frame", frame, 159 DEFINE_LRECORD_IMPLEMENTATION ("frame", frame,
158 mark_frame, print_frame, 0, 0, 0, 160 mark_frame, print_frame, 0, 0, 0, 0,
159 struct frame); 161 struct frame);
160 162
161 static void 163 static void
162 nuke_all_frame_slots (struct frame *f) 164 nuke_all_frame_slots (struct frame *f)
163 { 165 {
164 #define MARKED_SLOT(x) f->x = Qnil; 166 #define MARKED_SLOT(x) f->x = Qnil
165 #include "frameslots.h" 167 #include "frameslots.h"
166 } 168 }
167 169
168 /* Allocate a new frame object and set all its fields to reasonable 170 /* Allocate a new frame object and set all its fields to reasonable
169 values. The root window is created but the minibuffer will be done 171 values. The root window is created but the minibuffer will be done
173 allocate_frame_core (Lisp_Object device) 175 allocate_frame_core (Lisp_Object device)
174 { 176 {
175 /* This function can GC */ 177 /* This function can GC */
176 Lisp_Object frame; 178 Lisp_Object frame;
177 Lisp_Object root_window; 179 Lisp_Object root_window;
178 struct frame *f = alloc_lcrecord_type (struct frame, lrecord_frame); 180 struct frame *f = alloc_lcrecord_type (struct frame, &lrecord_frame);
179 181
180 zero_lcrecord (f); 182 zero_lcrecord (f);
181 nuke_all_frame_slots (f); 183 nuke_all_frame_slots (f);
182 XSETFRAME (frame, f); 184 XSETFRAME (frame, f);
183 185
205 f->selected_window = root_window; 207 f->selected_window = root_window;
206 f->last_nonminibuf_window = root_window; 208 f->last_nonminibuf_window = root_window;
207 209
208 /* cache of subwindows visible on frame */ 210 /* cache of subwindows visible on frame */
209 f->subwindow_cachels = Dynarr_new (subwindow_cachel); 211 f->subwindow_cachels = Dynarr_new (subwindow_cachel);
212
213 /* associated exposure ignore list */
214 f->subwindow_exposures = 0;
215 f->subwindow_exposures_tail = 0;
216
217 FRAME_SET_PAGENUMBER (f, 1);
210 218
211 /* Choose a buffer for the frame's root window. */ 219 /* Choose a buffer for the frame's root window. */
212 XWINDOW (root_window)->buffer = Qt; 220 XWINDOW (root_window)->buffer = Qt;
213 { 221 {
214 Lisp_Object buf; 222 Lisp_Object buf;
216 buf = Fcurrent_buffer (); 224 buf = Fcurrent_buffer ();
217 /* If buf is a 'hidden' buffer (i.e. one whose name starts with 225 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
218 a space), try to find another one. */ 226 a space), try to find another one. */
219 if (string_char (XSTRING (Fbuffer_name (buf)), 0) == ' ') 227 if (string_char (XSTRING (Fbuffer_name (buf)), 0) == ' ')
220 buf = Fother_buffer (buf, Qnil, Qnil); 228 buf = Fother_buffer (buf, Qnil, Qnil);
221 Fset_window_buffer (root_window, buf); 229 Fset_window_buffer (root_window, buf, Qnil);
222 } 230 }
223 231
224 return f; 232 return f;
225 } 233 }
226 234
239 XWINDOW (mini_window)->frame = frame; 247 XWINDOW (mini_window)->frame = frame;
240 f->minibuffer_window = mini_window; 248 f->minibuffer_window = mini_window;
241 f->has_minibuffer = 1; 249 f->has_minibuffer = 1;
242 250
243 XWINDOW (mini_window)->buffer = Qt; 251 XWINDOW (mini_window)->buffer = Qt;
244 Fset_window_buffer (mini_window, Vminibuffer_zero); 252 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt);
245 } 253 }
246 254
247 /* Make a frame using a separate minibuffer window on another frame. 255 /* Make a frame using a separate minibuffer window on another frame.
248 MINI_WINDOW is the minibuffer window to use. nil means use the 256 MINI_WINDOW is the minibuffer window to use. nil means use the
249 default-minibuffer-frame. */ 257 default-minibuffer-frame. */
276 mini_window = XFRAME (con->default_minibuffer_frame)->minibuffer_window; 284 mini_window = XFRAME (con->default_minibuffer_frame)->minibuffer_window;
277 } 285 }
278 286
279 /* Install the chosen minibuffer window, with proper buffer. */ 287 /* Install the chosen minibuffer window, with proper buffer. */
280 store_minibuf_frame_prop (f, mini_window); 288 store_minibuf_frame_prop (f, mini_window);
281 Fset_window_buffer (mini_window, Vminibuffer_zero); 289 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt);
282 } 290 }
283 291
284 /* Make a frame containing only a minibuffer window. */ 292 /* Make a frame containing only a minibuffer window. */
285 293
286 static void 294 static void
306 XWINDOW (mini_window)->prev = Qnil; 314 XWINDOW (mini_window)->prev = Qnil;
307 XWINDOW (mini_window)->frame = frame; 315 XWINDOW (mini_window)->frame = frame;
308 316
309 /* Put the proper buffer in that window. */ 317 /* Put the proper buffer in that window. */
310 318
311 Fset_window_buffer (mini_window, Vminibuffer_zero); 319 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt);
312 } 320 }
313 321
314 static Lisp_Object 322 static Lisp_Object
315 make_sure_its_a_fresh_plist (Lisp_Object foolist) 323 make_sure_its_a_fresh_plist (Lisp_Object foolist)
316 { 324 {
370 else if (STRINGP (Vdefault_frame_name)) 378 else if (STRINGP (Vdefault_frame_name))
371 name = Vdefault_frame_name; 379 name = Vdefault_frame_name;
372 else 380 else
373 name = build_string ("emacs"); 381 name = build_string ("emacs");
374 382
375 if (!NILP (Fstring_match (make_string ((CONST Bufbyte *) "\\.", 2), name, 383 if (!NILP (Fstring_match (make_string ((const Bufbyte *) "\\.", 2), name,
376 Qnil, Qnil))) 384 Qnil, Qnil)))
377 signal_simple_error (". not allowed in frame names", name); 385 signal_simple_error (". not allowed in frame names", name);
378 386
379 f = allocate_frame_core (device); 387 f = allocate_frame_core (device);
380 XSETFRAME (frame, f); 388 XSETFRAME (frame, f);
407 else 415 else
408 signal_simple_error ("Invalid value for `minibuffer'", minibuf); 416 signal_simple_error ("Invalid value for `minibuffer'", minibuf);
409 417
410 update_frame_window_mirror (f); 418 update_frame_window_mirror (f);
411 419
412 if (initialized) 420 if (initialized && !DEVICE_STREAM_P (d))
413 { 421 {
414 if (!NILP (f->minibuffer_window)) 422 if (!NILP (f->minibuffer_window))
415 reset_face_cachels (XWINDOW (f->minibuffer_window)); 423 reset_face_cachels (XWINDOW (f->minibuffer_window));
416 reset_face_cachels (XWINDOW (f->root_window)); 424 reset_face_cachels (XWINDOW (f->root_window));
417 } 425 }
458 #endif 466 #endif
459 reset_face_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); 467 reset_face_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f)));
460 reset_glyph_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); 468 reset_glyph_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f)));
461 reset_subwindow_cachels (f); 469 reset_subwindow_cachels (f);
462 change_frame_size (f, f->height, f->width, 0); 470 change_frame_size (f, f->height, f->width, 0);
471
463 } 472 }
464 473
465 MAYBE_FRAMEMETH (f, init_frame_2, (f, props)); 474 MAYBE_FRAMEMETH (f, init_frame_2, (f, props));
466 Fset_frame_properties (frame, props); 475 Fset_frame_properties (frame, props);
467 MAYBE_FRAMEMETH (f, init_frame_3, (f)); 476 MAYBE_FRAMEMETH (f, init_frame_3, (f));
477
478 /* now initialise the gutters, this won't change the frame size
479 so is ok here. */
480 if (!DEVICE_STREAM_P (d))
481 init_frame_gutters (f);
468 482
469 /* Hallelujah, praise the lord. */ 483 /* Hallelujah, praise the lord. */
470 f->init_finished = 1; 484 f->init_finished = 1;
471 485
472 /* If this is the first frame on the device, make it the selected one. */ 486 /* If this is the first frame on the device, make it the selected one. */
891 f->selected_window = window; 905 f->selected_window = window;
892 if (!MINI_WINDOW_P (XWINDOW (window)) || FRAME_MINIBUF_ONLY_P (f)) 906 if (!MINI_WINDOW_P (XWINDOW (window)) || FRAME_MINIBUF_ONLY_P (f))
893 { 907 {
894 #ifdef HAVE_TOOLBARS 908 #ifdef HAVE_TOOLBARS
895 if (!EQ (f->last_nonminibuf_window, window)) 909 if (!EQ (f->last_nonminibuf_window, window))
896 MARK_TOOLBAR_CHANGED; 910 {
911 MARK_TOOLBAR_CHANGED;
912 MARK_GUTTER_CHANGED;
913 }
897 #endif 914 #endif
898 f->last_nonminibuf_window = window; 915 f->last_nonminibuf_window = window;
899 } 916 }
900 } 917 }
901 918
1303 device = FRAME_DEVICE (f); 1320 device = FRAME_DEVICE (f);
1304 d = XDEVICE (device); 1321 d = XDEVICE (device);
1305 console = DEVICE_CONSOLE (d); 1322 console = DEVICE_CONSOLE (d);
1306 con = XCONSOLE (console); 1323 con = XCONSOLE (console);
1307 1324
1308 if (!called_from_delete_device) 1325 if (!called_from_delete_device &&
1326 !(MAYBE_INT_DEVMETH (d, device_implementation_flags, ())
1327 & XDEVIMPF_FRAMELESS_OK))
1309 { 1328 {
1310 /* If we're deleting the only non-minibuffer frame on the 1329 /* If we're deleting the only non-minibuffer frame on the
1311 device, delete the device. */ 1330 device, delete the device. */
1312 if (EQ (frame, next_frame (frame, Qnomini, FRAME_DEVICE (f)))) 1331 if (EQ (frame, next_frame (frame, Qnomini, FRAME_DEVICE (f))))
1313 { 1332 {
1489 { 1508 {
1490 Lisp_Object next_f = 1509 Lisp_Object next_f =
1491 next_frame_internal (frame, Qt, device, 1510 next_frame_internal (frame, Qt, device,
1492 called_from_delete_device); 1511 called_from_delete_device);
1493 if (NILP (next_f) || EQ (next_f, frame)) 1512 if (NILP (next_f) || EQ (next_f, frame))
1494 ; 1513 set_device_selected_frame (d, Qnil);
1495 else 1514 else
1496 set_device_selected_frame (d, next_f); 1515 set_device_selected_frame (d, next_f);
1497 } 1516 }
1498 else if (! did_select) 1517 else if (! did_select)
1499 set_device_selected_frame (d, next); 1518 set_device_selected_frame (d, next);
1504 /* Don't allow minibuf_window to remain on a deleted frame. */ 1523 /* Don't allow minibuf_window to remain on a deleted frame. */
1505 if (EQ (f->minibuffer_window, minibuf_window)) 1524 if (EQ (f->minibuffer_window, minibuf_window))
1506 { 1525 {
1507 struct frame *sel_frame = selected_frame (); 1526 struct frame *sel_frame = selected_frame ();
1508 Fset_window_buffer (sel_frame->minibuffer_window, 1527 Fset_window_buffer (sel_frame->minibuffer_window,
1509 XWINDOW (minibuf_window)->buffer); 1528 XWINDOW (minibuf_window)->buffer, Qt);
1510 minibuf_window = sel_frame->minibuffer_window; 1529 minibuf_window = sel_frame->minibuffer_window;
1511 1530
1512 /* If the dying minibuffer window was selected, 1531 /* If the dying minibuffer window was selected,
1513 select the new one. */ 1532 select the new one. */
1514 if (minibuffer_selected) 1533 if (minibuffer_selected)
1524 free_frame_scrollbars (f); 1543 free_frame_scrollbars (f);
1525 #endif 1544 #endif
1526 #ifdef HAVE_TOOLBARS 1545 #ifdef HAVE_TOOLBARS
1527 free_frame_toolbars (f); 1546 free_frame_toolbars (f);
1528 #endif 1547 #endif
1548 free_frame_gutters (f);
1529 1549
1530 /* This must be done before the window and window_mirror structures 1550 /* This must be done before the window and window_mirror structures
1531 are freed. The scrollbar information is attached to them. */ 1551 are freed. The scrollbar information is attached to them. */
1532 MAYBE_FRAMEMETH (f, delete_frame, (f)); 1552 MAYBE_FRAMEMETH (f, delete_frame, (f));
1533 1553
1836 (window, x, y)) 1856 (window, x, y))
1837 { 1857 {
1838 struct window *w; 1858 struct window *w;
1839 int pix_x, pix_y; 1859 int pix_x, pix_y;
1840 1860
1841 CHECK_WINDOW (window); 1861 CHECK_LIVE_WINDOW (window);
1842 CHECK_INT (x); 1862 CHECK_INT (x);
1843 CHECK_INT (y); 1863 CHECK_INT (y);
1844 1864
1845 /* Warping the mouse will cause EnterNotify and Focus events under X. */ 1865 /* Warping the mouse will cause EnterNotify and Focus events under X. */
1846 w = XWINDOW (window); 1866 w = XWINDOW (window);
1860 */ 1880 */
1861 (window, x, y)) 1881 (window, x, y))
1862 { 1882 {
1863 struct window *w; 1883 struct window *w;
1864 1884
1865 CHECK_WINDOW (window); 1885 CHECK_LIVE_WINDOW (window);
1866 CHECK_INT (x); 1886 CHECK_INT (x);
1867 CHECK_INT (y); 1887 CHECK_INT (y);
1868 1888
1869 /* Warping the mouse will cause EnterNotify and Focus events under X. */ 1889 /* Warping the mouse will cause EnterNotify and Focus events under X. */
1870 w = XWINDOW (window); 1890 w = XWINDOW (window);
1909 1929
1910 /* Don't allow minibuf_window to remain on a deleted frame. */ 1930 /* Don't allow minibuf_window to remain on a deleted frame. */
1911 if (EQ (f->minibuffer_window, minibuf_window)) 1931 if (EQ (f->minibuffer_window, minibuf_window))
1912 { 1932 {
1913 Fset_window_buffer (sel_frame->minibuffer_window, 1933 Fset_window_buffer (sel_frame->minibuffer_window,
1914 XWINDOW (minibuf_window)->buffer); 1934 XWINDOW (minibuf_window)->buffer, Qt);
1915 minibuf_window = sel_frame->minibuffer_window; 1935 minibuf_window = sel_frame->minibuffer_window;
1916 } 1936 }
1917 1937
1918 MAYBE_FRAMEMETH (f, make_frame_invisible, (f)); 1938 MAYBE_FRAMEMETH (f, make_frame_invisible, (f));
1919 1939
1935 1955
1936 /* Don't allow minibuf_window to remain on a deleted frame. */ 1956 /* Don't allow minibuf_window to remain on a deleted frame. */
1937 if (EQ (f->minibuffer_window, minibuf_window)) 1957 if (EQ (f->minibuffer_window, minibuf_window))
1938 { 1958 {
1939 Fset_window_buffer (sel_frame->minibuffer_window, 1959 Fset_window_buffer (sel_frame->minibuffer_window,
1940 XWINDOW (minibuf_window)->buffer); 1960 XWINDOW (minibuf_window)->buffer, Qt);
1941 minibuf_window = sel_frame->minibuffer_window; 1961 minibuf_window = sel_frame->minibuffer_window;
1942 } 1962 }
1943 1963
1944 MAYBE_FRAMEMETH (f, iconify_frame, (f)); 1964 MAYBE_FRAMEMETH (f, iconify_frame, (f));
1945 1965
2067 return Qnil; 2087 return Qnil;
2068 } 2088 }
2069 2089
2070 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus', 2090 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus',
2071 crockish FSFmacs functions. See summary on focus in event-stream.c. */ 2091 crockish FSFmacs functions. See summary on focus in event-stream.c. */
2092
2093 DEFUN ("print-job-page-number", Fprint_job_page_number, 1, 1, 0, /*
2094 Return current page number for the print job FRAME.
2095 */
2096 (frame))
2097 {
2098 CHECK_PRINTER_FRAME (frame);
2099 return make_int (FRAME_PAGENUMBER (XFRAME (frame)));
2100 }
2101
2102 DEFUN ("print-job-eject-page", Fprint_job_eject_page, 1, 1, 0, /*
2103 Eject page in the print job FRAME.
2104 */
2105 (frame))
2106 {
2107 struct frame *f;
2108
2109 CHECK_PRINTER_FRAME (frame);
2110 f = XFRAME (frame);
2111 FRAMEMETH (f, eject_page, (f));
2112 FRAME_SET_PAGENUMBER (f, 1 + FRAME_PAGENUMBER (f));
2113 f->clear = 1;
2114
2115 return Qnil;
2116 }
2072 2117
2073 2118
2074 /***************************************************************************/ 2119 /***************************************************************************/
2075 /* frame properties */ 2120 /* frame properties */
2076 /***************************************************************************/ 2121 /***************************************************************************/
2122 static int 2167 static int
2123 dissect_as_face_setting (Lisp_Object sym, Lisp_Object *face_out, 2168 dissect_as_face_setting (Lisp_Object sym, Lisp_Object *face_out,
2124 Lisp_Object *face_prop_out) 2169 Lisp_Object *face_prop_out)
2125 { 2170 {
2126 Lisp_Object list = Vbuilt_in_face_specifiers; 2171 Lisp_Object list = Vbuilt_in_face_specifiers;
2127 struct Lisp_String *s; 2172 Lisp_String *s;
2128 2173
2129 if (!SYMBOLP (sym)) 2174 if (!SYMBOLP (sym))
2130 return 0; 2175 return 0;
2131 2176
2132 s = symbol_name (XSYMBOL (sym)); 2177 s = symbol_name (XSYMBOL (sym));
2133 2178
2134 while (!NILP (list)) 2179 while (!NILP (list))
2135 { 2180 {
2136 Lisp_Object prop = Fcar (list); 2181 Lisp_Object prop = Fcar (list);
2137 struct Lisp_String *prop_name; 2182 Lisp_String *prop_name;
2138 2183
2139 if (!SYMBOLP (prop)) 2184 if (!SYMBOLP (prop))
2140 continue; 2185 continue;
2141 prop_name = symbol_name (XSYMBOL (prop)); 2186 prop_name = symbol_name (XSYMBOL (prop));
2142 if (string_length (s) > string_length (prop_name) + 1 2187 if (string_length (s) > string_length (prop_name) + 1
2658 else 2703 else
2659 default_face_height_and_width_1 (frame, &cph, &cpw); 2704 default_face_height_and_width_1 (frame, &cph, &cpw);
2660 2705
2661 window = FRAME_SELECTED_WINDOW (f); 2706 window = FRAME_SELECTED_WINDOW (f);
2662 2707
2663 egw = max (glyph_width (Vcontinuation_glyph, Vdefault_face, 0, window), 2708 egw = max (glyph_width (Vcontinuation_glyph, window),
2664 glyph_width (Vtruncation_glyph, Vdefault_face, 0, window)); 2709 glyph_width (Vtruncation_glyph, window));
2665 egw = max (egw, cpw); 2710 egw = max (egw, cpw);
2666 bdr = 2 * f->internal_border_width; 2711 bdr = 2 * f->internal_border_width;
2667 obw = FRAME_SCROLLBAR_WIDTH (f) + FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH (f) + 2712 obw = FRAME_SCROLLBAR_WIDTH (f) + FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH (f) +
2668 FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH (f) + 2713 FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH (f) +
2669 2 * FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH (f) + 2714 2 * FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH (f) +
2834 /* Adjust the width for the end glyph which may be a different width 2879 /* Adjust the width for the end glyph which may be a different width
2835 than the default character width. */ 2880 than the default character width. */
2836 { 2881 {
2837 int adjustment, trunc_width, cont_width; 2882 int adjustment, trunc_width, cont_width;
2838 2883
2839 trunc_width = glyph_width (Vtruncation_glyph, Vdefault_face, 0, 2884 trunc_width = glyph_width (Vtruncation_glyph,
2840 FRAME_SELECTED_WINDOW (f)); 2885 FRAME_SELECTED_WINDOW (f));
2841 cont_width = glyph_width (Vcontinuation_glyph, Vdefault_face, 0, 2886 cont_width = glyph_width (Vcontinuation_glyph,
2842 FRAME_SELECTED_WINDOW (f)); 2887 FRAME_SELECTED_WINDOW (f));
2843 adjustment = max (trunc_width, cont_width); 2888 adjustment = max (trunc_width, cont_width);
2844 adjustment = max (adjustment, font_width); 2889 adjustment = max (adjustment, font_width);
2845 2890
2846 new_pixwidth += adjustment; 2891 new_pixwidth += adjustment;
2951 else 2996 else
2952 change_frame_size_1 (f, newheight, newwidth); 2997 change_frame_size_1 (f, newheight, newwidth);
2953 } 2998 }
2954 2999
2955 3000
3001 /* The caller is responsible for freeing the returned string. */
3002 static Bufbyte *
3003 generate_title_string (struct window *w, Lisp_Object format_str,
3004 face_index findex, int type)
3005 {
3006 struct display_line *dl;
3007 struct display_block *db;
3008 int elt = 0;
3009
3010 dl = &title_string_display_line;
3011 db = get_display_block_from_line (dl, TEXT);
3012 Dynarr_reset (db->runes);
3013
3014 generate_formatted_string_db (format_str, Qnil, w, dl, db, findex, 0,
3015 -1, type);
3016
3017 Dynarr_reset (title_string_emchar_dynarr);
3018 while (elt < Dynarr_length (db->runes))
3019 {
3020 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR)
3021 Dynarr_add (title_string_emchar_dynarr,
3022 Dynarr_atp (db->runes, elt)->object.chr.ch);
3023 elt++;
3024 }
3025
3026 return
3027 convert_emchar_string_into_malloced_string
3028 (Dynarr_atp (title_string_emchar_dynarr, 0),
3029 Dynarr_length (title_string_emchar_dynarr), 0);
3030 }
3031
2956 void 3032 void
2957 update_frame_title (struct frame *f) 3033 update_frame_title (struct frame *f)
2958 { 3034 {
2959 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); 3035 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
2960 Lisp_Object title_format; 3036 Lisp_Object title_format;
2974 title_format = symbol_value_in_buffer (Qframe_title_format, w->buffer); 3050 title_format = symbol_value_in_buffer (Qframe_title_format, w->buffer);
2975 icon_format = symbol_value_in_buffer (Qframe_icon_title_format, w->buffer); 3051 icon_format = symbol_value_in_buffer (Qframe_icon_title_format, w->buffer);
2976 3052
2977 if (HAS_FRAMEMETH_P (f, set_title_from_bufbyte)) 3053 if (HAS_FRAMEMETH_P (f, set_title_from_bufbyte))
2978 { 3054 {
2979 title = generate_formatted_string (w, title_format, Qnil, 3055 title = generate_title_string (w, title_format,
2980 DEFAULT_INDEX, CURRENT_DISP); 3056 DEFAULT_INDEX, CURRENT_DISP);
2981 FRAMEMETH (f, set_title_from_bufbyte, (f, title)); 3057 FRAMEMETH (f, set_title_from_bufbyte, (f, title));
2982 } 3058 }
2983 3059
2984 if (HAS_FRAMEMETH_P (f, set_icon_name_from_bufbyte)) 3060 if (HAS_FRAMEMETH_P (f, set_icon_name_from_bufbyte))
2985 { 3061 {
2986 if (!EQ (icon_format, title_format) || !title) 3062 if (!EQ (icon_format, title_format) || !title)
2987 { 3063 {
2988 if (title) 3064 if (title)
2989 xfree (title); 3065 xfree (title);
2990 3066
2991 title = generate_formatted_string (w, icon_format, Qnil, 3067 title = generate_title_string (w, icon_format,
2992 DEFAULT_INDEX, CURRENT_DISP); 3068 DEFAULT_INDEX, CURRENT_DISP);
2993 } 3069 }
2994 FRAMEMETH (f, set_icon_name_from_bufbyte, (f, title)); 3070 FRAMEMETH (f, set_icon_name_from_bufbyte, (f, title));
2995 } 3071 }
2996 3072
2997 if (title) 3073 if (title)
3046 { 3122 {
3047 MARK_ICON_CHANGED; 3123 MARK_ICON_CHANGED;
3048 } 3124 }
3049 3125
3050 3126
3127 /***************************************************************************/
3128 /* */
3129 /* initialization */
3130 /* */
3131 /***************************************************************************/
3132
3133 void
3134 init_frame (void)
3135 {
3136 #ifndef PDUMP
3137 if (!initialized)
3138 #endif
3139 {
3140 title_string_emchar_dynarr = Dynarr_new (Emchar);
3141 xzero (title_string_display_line);
3142 }
3143 }
3144
3051 void 3145 void
3052 syms_of_frame (void) 3146 syms_of_frame (void)
3053 { 3147 {
3054 defsymbol (&Qdelete_frame_hook, "delete-frame-hook"); 3148 defsymbol (&Qdelete_frame_hook, "delete-frame-hook");
3055 defsymbol (&Qselect_frame_hook, "select-frame-hook"); 3149 defsymbol (&Qselect_frame_hook, "select-frame-hook");
3061 defsymbol (&Qmap_frame_hook, "map-frame-hook"); 3155 defsymbol (&Qmap_frame_hook, "map-frame-hook");
3062 defsymbol (&Qunmap_frame_hook, "unmap-frame-hook"); 3156 defsymbol (&Qunmap_frame_hook, "unmap-frame-hook");
3063 3157
3064 defsymbol (&Qframep, "framep"); 3158 defsymbol (&Qframep, "framep");
3065 defsymbol (&Qframe_live_p, "frame-live-p"); 3159 defsymbol (&Qframe_live_p, "frame-live-p");
3066 defsymbol (&Qframe_x_p, "frame-x-p");
3067 defsymbol (&Qframe_tty_p, "frame-tty-p");
3068 defsymbol (&Qdelete_frame, "delete-frame"); 3160 defsymbol (&Qdelete_frame, "delete-frame");
3069 defsymbol (&Qsynchronize_minibuffers, "synchronize-minibuffers"); 3161 defsymbol (&Qsynchronize_minibuffers, "synchronize-minibuffers");
3070 defsymbol (&Qbuffer_predicate, "buffer-predicate"); 3162 defsymbol (&Qbuffer_predicate, "buffer-predicate");
3071 defsymbol (&Qframe_being_created, "frame-being-created"); 3163 defsymbol (&Qframe_being_created, "frame-being-created");
3072 defsymbol (&Qmake_initial_minibuffer_frame, "make-initial-minibuffer-frame"); 3164 defsymbol (&Qmake_initial_minibuffer_frame, "make-initial-minibuffer-frame");
3161 DEFSUBR (Fset_frame_height); 3253 DEFSUBR (Fset_frame_height);
3162 DEFSUBR (Fset_frame_width); 3254 DEFSUBR (Fset_frame_width);
3163 DEFSUBR (Fset_frame_size); 3255 DEFSUBR (Fset_frame_size);
3164 DEFSUBR (Fset_frame_position); 3256 DEFSUBR (Fset_frame_position);
3165 DEFSUBR (Fset_frame_pointer); 3257 DEFSUBR (Fset_frame_pointer);
3258 DEFSUBR (Fprint_job_page_number);
3259 DEFSUBR (Fprint_job_eject_page);
3166 } 3260 }
3167 3261
3168 void 3262 void
3169 vars_of_frame (void) 3263 vars_of_frame (void)
3170 { 3264 {
3278 DEFVAR_LISP ("frame-title-format", &Vframe_title_format /* 3372 DEFVAR_LISP ("frame-title-format", &Vframe_title_format /*
3279 Controls the title of the X window corresponding to the selected frame. 3373 Controls the title of the X window corresponding to the selected frame.
3280 This is the same format as `modeline-format' with the exception that 3374 This is the same format as `modeline-format' with the exception that
3281 %- is ignored. 3375 %- is ignored.
3282 */ ); 3376 */ );
3283 Vframe_title_format = Fpurecopy (build_string ("%S: %b")); 3377 Vframe_title_format = build_string ("%S: %b");
3284 3378
3285 DEFVAR_LISP ("frame-icon-title-format", &Vframe_icon_title_format /* 3379 DEFVAR_LISP ("frame-icon-title-format", &Vframe_icon_title_format /*
3286 Controls the title of the icon corresponding to the selected frame. 3380 Controls the title of the icon corresponding to the selected frame.
3287 See also the variable `frame-title-format'. 3381 See also the variable `frame-title-format'.
3288 */ ); 3382 */ );
3289 Vframe_icon_title_format = Fpurecopy (build_string ("%b")); 3383 Vframe_icon_title_format = build_string ("%b");
3290 3384
3291 DEFVAR_LISP ("default-frame-name", &Vdefault_frame_name /* 3385 DEFVAR_LISP ("default-frame-name", &Vdefault_frame_name /*
3292 The default name to assign to newly-created frames. 3386 The default name to assign to newly-created frames.
3293 This can be overridden by arguments to `make-frame'. 3387 This can be overridden by arguments to `make-frame'.
3294 This must be a string. 3388 This must be a string.
3295 */ ); 3389 */ );
3296 #ifndef INFODOCK 3390 #ifndef INFODOCK
3297 Vdefault_frame_name = Fpurecopy (build_string ("emacs")); 3391 Vdefault_frame_name = build_string ("emacs");
3298 #else 3392 #else
3299 Vdefault_frame_name = Fpurecopy (build_string ("InfoDock")); 3393 Vdefault_frame_name = build_string ("InfoDock");
3300 #endif 3394 #endif
3301 3395
3302 DEFVAR_LISP ("default-frame-plist", &Vdefault_frame_plist /* 3396 DEFVAR_LISP ("default-frame-plist", &Vdefault_frame_plist /*
3303 Plist of default values for frame creation, other than the first one. 3397 Plist of default values for frame creation, other than the first one.
3304 These may be set in your init file, like this: 3398 These may be set in your init file, like this: