comparison src/frame.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents de805c49cfc1
children da8ed4261e83
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
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"
38 #include "menubar.h" 37 #include "menubar.h"
39 #include "redisplay.h" 38 #include "redisplay.h"
40 #include "scrollbar.h" 39 #include "scrollbar.h"
41 #include "window.h" 40 #include "window.h"
42 41
84 Lisp_Object Quse_backing_store; 83 Lisp_Object Quse_backing_store;
85 Lisp_Object Qborder_color; 84 Lisp_Object Qborder_color;
86 Lisp_Object Qborder_width; 85 Lisp_Object Qborder_width;
87 86
88 Lisp_Object Qframep, Qframe_live_p; 87 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 static struct display_line title_string_display_line; 119
120 /* Used by generate_title_string. Global because they get used so much that 120 EXFUN (Fset_frame_properties, 2);
121 the dynamic allocation time adds up. */
122 static Emchar_dynarr *title_string_emchar_dynarr;
123 121
124 122
125 static Lisp_Object 123 static Lisp_Object
126 mark_frame (Lisp_Object obj) 124 mark_frame (Lisp_Object obj, void (*markobj) (Lisp_Object))
127 { 125 {
128 struct frame *f = XFRAME (obj); 126 struct frame *f = XFRAME (obj);
129 127
130 #define MARKED_SLOT(x) mark_object (f->x) 128 #define MARKED_SLOT(x) ((void) (markobj (f->x)));
131 #include "frameslots.h" 129 #include "frameslots.h"
132 130
131 mark_subwindow_cachels (f->subwindow_cachels, markobj);
132
133 if (FRAME_LIVE_P (f)) /* device is nil for a dead frame */ 133 if (FRAME_LIVE_P (f)) /* device is nil for a dead frame */
134 MAYBE_FRAMEMETH (f, mark_frame, (f)); 134 MAYBE_FRAMEMETH (f, mark_frame, (f, markobj));
135 135
136 return Qnil; 136 return Qnil;
137 } 137 }
138 138
139 static void 139 static void
153 sprintf (buf, " 0x%x>", frm->header.uid); 153 sprintf (buf, " 0x%x>", frm->header.uid);
154 write_c_string (buf, printcharfun); 154 write_c_string (buf, printcharfun);
155 } 155 }
156 156
157 DEFINE_LRECORD_IMPLEMENTATION ("frame", frame, 157 DEFINE_LRECORD_IMPLEMENTATION ("frame", frame,
158 mark_frame, print_frame, 0, 0, 0, 0, 158 mark_frame, print_frame, 0, 0, 0,
159 struct frame); 159 struct frame);
160 160
161 static void 161 static void
162 nuke_all_frame_slots (struct frame *f) 162 nuke_all_frame_slots (struct frame *f)
163 { 163 {
164 #define MARKED_SLOT(x) f->x = Qnil 164 #define MARKED_SLOT(x) f->x = Qnil;
165 #include "frameslots.h" 165 #include "frameslots.h"
166 } 166 }
167 167
168 /* Allocate a new frame object and set all its fields to reasonable 168 /* 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 169 values. The root window is created but the minibuffer will be done
204 f->root_window = root_window; 204 f->root_window = root_window;
205 f->selected_window = root_window; 205 f->selected_window = root_window;
206 f->last_nonminibuf_window = root_window; 206 f->last_nonminibuf_window = root_window;
207 207
208 /* cache of subwindows visible on frame */ 208 /* cache of subwindows visible on frame */
209 f->subwindow_instance_cache = make_weak_list (WEAK_LIST_SIMPLE); 209 f->subwindow_cachels = Dynarr_new (subwindow_cachel);
210
211 /* associated exposure ignore list */
212 f->subwindow_exposures = 0;
213 f->subwindow_exposures_tail = 0;
214
215 FRAME_SET_PAGENUMBER (f, 1);
216 210
217 /* Choose a buffer for the frame's root window. */ 211 /* Choose a buffer for the frame's root window. */
218 XWINDOW (root_window)->buffer = Qt; 212 XWINDOW (root_window)->buffer = Qt;
219 { 213 {
220 Lisp_Object buf; 214 Lisp_Object buf;
222 buf = Fcurrent_buffer (); 216 buf = Fcurrent_buffer ();
223 /* If buf is a 'hidden' buffer (i.e. one whose name starts with 217 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
224 a space), try to find another one. */ 218 a space), try to find another one. */
225 if (string_char (XSTRING (Fbuffer_name (buf)), 0) == ' ') 219 if (string_char (XSTRING (Fbuffer_name (buf)), 0) == ' ')
226 buf = Fother_buffer (buf, Qnil, Qnil); 220 buf = Fother_buffer (buf, Qnil, Qnil);
227 Fset_window_buffer (root_window, buf, Qnil); 221 Fset_window_buffer (root_window, buf);
228 } 222 }
229 223
230 return f; 224 return f;
231 } 225 }
232 226
245 XWINDOW (mini_window)->frame = frame; 239 XWINDOW (mini_window)->frame = frame;
246 f->minibuffer_window = mini_window; 240 f->minibuffer_window = mini_window;
247 f->has_minibuffer = 1; 241 f->has_minibuffer = 1;
248 242
249 XWINDOW (mini_window)->buffer = Qt; 243 XWINDOW (mini_window)->buffer = Qt;
250 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); 244 Fset_window_buffer (mini_window, Vminibuffer_zero);
251 } 245 }
252 246
253 /* Make a frame using a separate minibuffer window on another frame. 247 /* Make a frame using a separate minibuffer window on another frame.
254 MINI_WINDOW is the minibuffer window to use. nil means use the 248 MINI_WINDOW is the minibuffer window to use. nil means use the
255 default-minibuffer-frame. */ 249 default-minibuffer-frame. */
266 if (!NILP (mini_window) 260 if (!NILP (mini_window)
267 && !EQ (DEVICE_CONSOLE (XDEVICE (device)), 261 && !EQ (DEVICE_CONSOLE (XDEVICE (device)),
268 FRAME_CONSOLE (XFRAME (XWINDOW (mini_window)->frame)))) 262 FRAME_CONSOLE (XFRAME (XWINDOW (mini_window)->frame))))
269 error ("frame and minibuffer must be on the same console"); 263 error ("frame and minibuffer must be on the same console");
270 264
271 /* Do not create a default minibuffer frame on printer devices. */ 265 if (NILP (mini_window))
272 if (NILP (mini_window)
273 && DEVICE_DISPLAY_P (XDEVICE (FRAME_DEVICE (f))))
274 { 266 {
275 struct console *con = XCONSOLE (FRAME_CONSOLE (f)); 267 struct console *con = XCONSOLE (FRAME_CONSOLE (f));
276 /* Use default-minibuffer-frame if possible. */ 268 /* Use default-minibuffer-frame if possible. */
277 if (!FRAMEP (con->default_minibuffer_frame) 269 if (!FRAMEP (con->default_minibuffer_frame)
278 || ! FRAME_LIVE_P (XFRAME (con->default_minibuffer_frame))) 270 || ! FRAME_LIVE_P (XFRAME (con->default_minibuffer_frame)))
283 } 275 }
284 mini_window = XFRAME (con->default_minibuffer_frame)->minibuffer_window; 276 mini_window = XFRAME (con->default_minibuffer_frame)->minibuffer_window;
285 } 277 }
286 278
287 /* Install the chosen minibuffer window, with proper buffer. */ 279 /* Install the chosen minibuffer window, with proper buffer. */
288 if (!NILP (mini_window)) 280 store_minibuf_frame_prop (f, mini_window);
289 { 281 Fset_window_buffer (mini_window, Vminibuffer_zero);
290 store_minibuf_frame_prop (f, mini_window);
291 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt);
292 }
293 else
294 f->minibuffer_window = Qnil;
295 } 282 }
296 283
297 /* Make a frame containing only a minibuffer window. */ 284 /* Make a frame containing only a minibuffer window. */
298 285
299 static void 286 static void
319 XWINDOW (mini_window)->prev = Qnil; 306 XWINDOW (mini_window)->prev = Qnil;
320 XWINDOW (mini_window)->frame = frame; 307 XWINDOW (mini_window)->frame = frame;
321 308
322 /* Put the proper buffer in that window. */ 309 /* Put the proper buffer in that window. */
323 310
324 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); 311 Fset_window_buffer (mini_window, Vminibuffer_zero);
325 } 312 }
326 313
327 static Lisp_Object 314 static Lisp_Object
328 make_sure_its_a_fresh_plist (Lisp_Object foolist) 315 make_sure_its_a_fresh_plist (Lisp_Object foolist)
329 { 316 {
383 else if (STRINGP (Vdefault_frame_name)) 370 else if (STRINGP (Vdefault_frame_name))
384 name = Vdefault_frame_name; 371 name = Vdefault_frame_name;
385 else 372 else
386 name = build_string ("emacs"); 373 name = build_string ("emacs");
387 374
388 if (!NILP (Fstring_match (make_string ((const Bufbyte *) "\\.", 2), name, 375 if (!NILP (Fstring_match (make_string ((CONST Bufbyte *) "\\.", 2), name,
389 Qnil, Qnil))) 376 Qnil, Qnil)))
390 signal_simple_error (". not allowed in frame names", name); 377 signal_simple_error (". not allowed in frame names", name);
391 378
392 f = allocate_frame_core (device); 379 f = allocate_frame_core (device);
393 XSETFRAME (frame, f); 380 XSETFRAME (frame, f);
420 else 407 else
421 signal_simple_error ("Invalid value for `minibuffer'", minibuf); 408 signal_simple_error ("Invalid value for `minibuffer'", minibuf);
422 409
423 update_frame_window_mirror (f); 410 update_frame_window_mirror (f);
424 411
425 if (initialized && !DEVICE_STREAM_P (d)) 412 if (initialized)
426 { 413 {
427 if (!NILP (f->minibuffer_window)) 414 if (!NILP (f->minibuffer_window))
428 reset_face_cachels (XWINDOW (f->minibuffer_window)); 415 reset_face_cachels (XWINDOW (f->minibuffer_window));
429 reset_face_cachels (XWINDOW (f->root_window)); 416 reset_face_cachels (XWINDOW (f->root_window));
430 } 417 }
469 things. */ 456 things. */
470 init_frame_toolbars (f); 457 init_frame_toolbars (f);
471 #endif 458 #endif
472 reset_face_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); 459 reset_face_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f)));
473 reset_glyph_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); 460 reset_glyph_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f)));
474 461 reset_subwindow_cachels (f);
475 change_frame_size (f, f->height, f->width, 0); 462 change_frame_size (f, f->height, f->width, 0);
476 } 463 }
477 464
478 MAYBE_FRAMEMETH (f, init_frame_2, (f, props)); 465 MAYBE_FRAMEMETH (f, init_frame_2, (f, props));
479 Fset_frame_properties (frame, props); 466 Fset_frame_properties (frame, props);
501 /* #### all this calling of frame methods at various odd times 488 /* #### all this calling of frame methods at various odd times
502 is somewhat of a mess. It's necessary to do it this way due 489 is somewhat of a mess. It's necessary to do it this way due
503 to strange console-type-specific things that need to be done. */ 490 to strange console-type-specific things that need to be done. */
504 MAYBE_FRAMEMETH (f, after_init_frame, (f, first_frame_on_device, 491 MAYBE_FRAMEMETH (f, after_init_frame, (f, first_frame_on_device,
505 first_frame_on_console)); 492 first_frame_on_console));
506
507 if (!DEVICE_STREAM_P (d))
508 {
509 /* Now initialise the gutters. This won't change the frame size,
510 but is needed as input to the layout that change_frame_size
511 will eventually do. Unfortunately gutter sizing code relies
512 on the frame in question being visible so we can't do this
513 earlier. */
514 init_frame_gutters (f);
515
516 change_frame_size (f, f->height, f->width, 0);
517 }
518 493
519 if (first_frame_on_device) 494 if (first_frame_on_device)
520 { 495 {
521 if (first_frame_on_console) 496 if (first_frame_on_console)
522 va_run_hook_with_args (Qcreate_console_hook, 1, DEVICE_CONSOLE (d)); 497 va_run_hook_with_args (Qcreate_console_hook, 1, DEVICE_CONSOLE (d));
914 { 889 {
915 assert (XFRAME (WINDOW_FRAME (XWINDOW (window))) == f); 890 assert (XFRAME (WINDOW_FRAME (XWINDOW (window))) == f);
916 f->selected_window = window; 891 f->selected_window = window;
917 if (!MINI_WINDOW_P (XWINDOW (window)) || FRAME_MINIBUF_ONLY_P (f)) 892 if (!MINI_WINDOW_P (XWINDOW (window)) || FRAME_MINIBUF_ONLY_P (f))
918 { 893 {
894 #ifdef HAVE_TOOLBARS
919 if (!EQ (f->last_nonminibuf_window, window)) 895 if (!EQ (f->last_nonminibuf_window, window))
920 { 896 MARK_TOOLBAR_CHANGED;
921 #ifdef HAVE_TOOLBARS
922 MARK_TOOLBAR_CHANGED;
923 #endif 897 #endif
924 MARK_GUTTER_CHANGED;
925 }
926 f->last_nonminibuf_window = window; 898 f->last_nonminibuf_window = window;
927 } 899 }
928 } 900 }
929 901
930 DEFUN ("set-frame-selected-window", Fset_frame_selected_window, 2, 2, 0, /* 902 DEFUN ("set-frame-selected-window", Fset_frame_selected_window, 2, 2, 0, /*
1331 device = FRAME_DEVICE (f); 1303 device = FRAME_DEVICE (f);
1332 d = XDEVICE (device); 1304 d = XDEVICE (device);
1333 console = DEVICE_CONSOLE (d); 1305 console = DEVICE_CONSOLE (d);
1334 con = XCONSOLE (console); 1306 con = XCONSOLE (console);
1335 1307
1336 if (!called_from_delete_device && 1308 if (!called_from_delete_device)
1337 !(MAYBE_INT_DEVMETH (d, device_implementation_flags, ())
1338 & XDEVIMPF_FRAMELESS_OK))
1339 { 1309 {
1340 /* If we're deleting the only non-minibuffer frame on the 1310 /* If we're deleting the only non-minibuffer frame on the
1341 device, delete the device. */ 1311 device, delete the device. */
1342 if (EQ (frame, next_frame (frame, Qnomini, FRAME_DEVICE (f)))) 1312 if (EQ (frame, next_frame (frame, Qnomini, FRAME_DEVICE (f))))
1343 { 1313 {
1519 { 1489 {
1520 Lisp_Object next_f = 1490 Lisp_Object next_f =
1521 next_frame_internal (frame, Qt, device, 1491 next_frame_internal (frame, Qt, device,
1522 called_from_delete_device); 1492 called_from_delete_device);
1523 if (NILP (next_f) || EQ (next_f, frame)) 1493 if (NILP (next_f) || EQ (next_f, frame))
1524 set_device_selected_frame (d, Qnil); 1494 ;
1525 else 1495 else
1526 set_device_selected_frame (d, next_f); 1496 set_device_selected_frame (d, next_f);
1527 } 1497 }
1528 else if (! did_select) 1498 else if (! did_select)
1529 set_device_selected_frame (d, next); 1499 set_device_selected_frame (d, next);
1534 /* Don't allow minibuf_window to remain on a deleted frame. */ 1504 /* Don't allow minibuf_window to remain on a deleted frame. */
1535 if (EQ (f->minibuffer_window, minibuf_window)) 1505 if (EQ (f->minibuffer_window, minibuf_window))
1536 { 1506 {
1537 struct frame *sel_frame = selected_frame (); 1507 struct frame *sel_frame = selected_frame ();
1538 Fset_window_buffer (sel_frame->minibuffer_window, 1508 Fset_window_buffer (sel_frame->minibuffer_window,
1539 XWINDOW (minibuf_window)->buffer, Qt); 1509 XWINDOW (minibuf_window)->buffer);
1540 minibuf_window = sel_frame->minibuffer_window; 1510 minibuf_window = sel_frame->minibuffer_window;
1541 1511
1542 /* If the dying minibuffer window was selected, 1512 /* If the dying minibuffer window was selected,
1543 select the new one. */ 1513 select the new one. */
1544 if (minibuffer_selected) 1514 if (minibuffer_selected)
1554 free_frame_scrollbars (f); 1524 free_frame_scrollbars (f);
1555 #endif 1525 #endif
1556 #ifdef HAVE_TOOLBARS 1526 #ifdef HAVE_TOOLBARS
1557 free_frame_toolbars (f); 1527 free_frame_toolbars (f);
1558 #endif 1528 #endif
1559 free_frame_gutters (f);
1560 /* Unfortunately deleting the frame will also delete the parent of
1561 all of the subwindow instances current on the frame. I think this
1562 can lead to bad things when trying to finalize the
1563 instances. Thus we loop over the instance cache calling the
1564 finalize method for each instance. */
1565 free_frame_subwindow_instance_cache (f);
1566 1529
1567 /* This must be done before the window and window_mirror structures 1530 /* This must be done before the window and window_mirror structures
1568 are freed. The scrollbar information is attached to them. */ 1531 are freed. The scrollbar information is attached to them. */
1569 MAYBE_FRAMEMETH (f, delete_frame, (f)); 1532 MAYBE_FRAMEMETH (f, delete_frame, (f));
1570 1533
1572 remove the reference to them. */ 1535 remove the reference to them. */
1573 delete_all_subwindows (XWINDOW (f->root_window)); 1536 delete_all_subwindows (XWINDOW (f->root_window));
1574 f->root_window = Qnil; 1537 f->root_window = Qnil;
1575 1538
1576 /* clear out the cached glyph information */ 1539 /* clear out the cached glyph information */
1577 f->subwindow_instance_cache = Qnil; 1540 if (f->subwindow_cachels)
1541 {
1542 Dynarr_free (f->subwindow_cachels);
1543 f->subwindow_cachels = 0;
1544 }
1578 1545
1579 /* Remove the frame now from the list. This way, any events generated 1546 /* Remove the frame now from the list. This way, any events generated
1580 on this frame by the maneuvers below will disperse themselves. */ 1547 on this frame by the maneuvers below will disperse themselves. */
1581 1548
1582 /* This used to be Fdelq(), but that will cause a seg fault if the 1549 /* This used to be Fdelq(), but that will cause a seg fault if the
1869 (window, x, y)) 1836 (window, x, y))
1870 { 1837 {
1871 struct window *w; 1838 struct window *w;
1872 int pix_x, pix_y; 1839 int pix_x, pix_y;
1873 1840
1874 CHECK_LIVE_WINDOW (window); 1841 CHECK_WINDOW (window);
1875 CHECK_INT (x); 1842 CHECK_INT (x);
1876 CHECK_INT (y); 1843 CHECK_INT (y);
1877 1844
1878 /* Warping the mouse will cause EnterNotify and Focus events under X. */ 1845 /* Warping the mouse will cause EnterNotify and Focus events under X. */
1879 w = XWINDOW (window); 1846 w = XWINDOW (window);
1893 */ 1860 */
1894 (window, x, y)) 1861 (window, x, y))
1895 { 1862 {
1896 struct window *w; 1863 struct window *w;
1897 1864
1898 CHECK_LIVE_WINDOW (window); 1865 CHECK_WINDOW (window);
1899 CHECK_INT (x); 1866 CHECK_INT (x);
1900 CHECK_INT (y); 1867 CHECK_INT (y);
1901 1868
1902 /* Warping the mouse will cause EnterNotify and Focus events under X. */ 1869 /* Warping the mouse will cause EnterNotify and Focus events under X. */
1903 w = XWINDOW (window); 1870 w = XWINDOW (window);
1942 1909
1943 /* Don't allow minibuf_window to remain on a deleted frame. */ 1910 /* Don't allow minibuf_window to remain on a deleted frame. */
1944 if (EQ (f->minibuffer_window, minibuf_window)) 1911 if (EQ (f->minibuffer_window, minibuf_window))
1945 { 1912 {
1946 Fset_window_buffer (sel_frame->minibuffer_window, 1913 Fset_window_buffer (sel_frame->minibuffer_window,
1947 XWINDOW (minibuf_window)->buffer, Qt); 1914 XWINDOW (minibuf_window)->buffer);
1948 minibuf_window = sel_frame->minibuffer_window; 1915 minibuf_window = sel_frame->minibuffer_window;
1949 } 1916 }
1950 1917
1951 MAYBE_FRAMEMETH (f, make_frame_invisible, (f)); 1918 MAYBE_FRAMEMETH (f, make_frame_invisible, (f));
1952 1919
1968 1935
1969 /* Don't allow minibuf_window to remain on a deleted frame. */ 1936 /* Don't allow minibuf_window to remain on a deleted frame. */
1970 if (EQ (f->minibuffer_window, minibuf_window)) 1937 if (EQ (f->minibuffer_window, minibuf_window))
1971 { 1938 {
1972 Fset_window_buffer (sel_frame->minibuffer_window, 1939 Fset_window_buffer (sel_frame->minibuffer_window,
1973 XWINDOW (minibuf_window)->buffer, Qt); 1940 XWINDOW (minibuf_window)->buffer);
1974 minibuf_window = sel_frame->minibuffer_window; 1941 minibuf_window = sel_frame->minibuffer_window;
1975 } 1942 }
1976 1943
1977 MAYBE_FRAMEMETH (f, iconify_frame, (f)); 1944 MAYBE_FRAMEMETH (f, iconify_frame, (f));
1978 1945
2100 return Qnil; 2067 return Qnil;
2101 } 2068 }
2102 2069
2103 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus', 2070 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus',
2104 crockish FSFmacs functions. See summary on focus in event-stream.c. */ 2071 crockish FSFmacs functions. See summary on focus in event-stream.c. */
2105
2106 DEFUN ("print-job-page-number", Fprint_job_page_number, 1, 1, 0, /*
2107 Return current page number for the print job FRAME.
2108 */
2109 (frame))
2110 {
2111 CHECK_PRINTER_FRAME (frame);
2112 return make_int (FRAME_PAGENUMBER (XFRAME (frame)));
2113 }
2114
2115 DEFUN ("print-job-eject-page", Fprint_job_eject_page, 1, 1, 0, /*
2116 Eject page in the print job FRAME.
2117 */
2118 (frame))
2119 {
2120 struct frame *f;
2121
2122 CHECK_PRINTER_FRAME (frame);
2123 f = XFRAME (frame);
2124 FRAMEMETH (f, eject_page, (f));
2125 FRAME_SET_PAGENUMBER (f, 1 + FRAME_PAGENUMBER (f));
2126 f->clear = 1;
2127
2128 return Qnil;
2129 }
2130 2072
2131 2073
2132 /***************************************************************************/ 2074 /***************************************************************************/
2133 /* frame properties */ 2075 /* frame properties */
2134 /***************************************************************************/ 2076 /***************************************************************************/
2180 static int 2122 static int
2181 dissect_as_face_setting (Lisp_Object sym, Lisp_Object *face_out, 2123 dissect_as_face_setting (Lisp_Object sym, Lisp_Object *face_out,
2182 Lisp_Object *face_prop_out) 2124 Lisp_Object *face_prop_out)
2183 { 2125 {
2184 Lisp_Object list = Vbuilt_in_face_specifiers; 2126 Lisp_Object list = Vbuilt_in_face_specifiers;
2185 Lisp_String *s; 2127 struct Lisp_String *s;
2186 2128
2187 if (!SYMBOLP (sym)) 2129 if (!SYMBOLP (sym))
2188 return 0; 2130 return 0;
2189 2131
2190 s = symbol_name (XSYMBOL (sym)); 2132 s = symbol_name (XSYMBOL (sym));
2191 2133
2192 while (!NILP (list)) 2134 while (!NILP (list))
2193 { 2135 {
2194 Lisp_Object prop = Fcar (list); 2136 Lisp_Object prop = Fcar (list);
2195 Lisp_String *prop_name; 2137 struct Lisp_String *prop_name;
2196 2138
2197 if (!SYMBOLP (prop)) 2139 if (!SYMBOLP (prop))
2198 continue; 2140 continue;
2199 prop_name = symbol_name (XSYMBOL (prop)); 2141 prop_name = symbol_name (XSYMBOL (prop));
2200 if (string_length (s) > string_length (prop_name) + 1 2142 if (string_length (s) > string_length (prop_name) + 1
2268 2210
2269 width Width of the frame, in characters. 2211 width Width of the frame, in characters.
2270 2212
2271 minibuffer Gives the minibuffer behavior for this frame. Either 2213 minibuffer Gives the minibuffer behavior for this frame. Either
2272 t (frame has its own minibuffer), `only' (frame is 2214 t (frame has its own minibuffer), `only' (frame is
2273 a minibuffer-only frame), `none' (frame has no minibuffer) 2215 a minibuffer-only frame), or a window (frame uses that
2274 or a window (frame uses that window, which is on another 2216 window, which is on another frame, as the minibuffer).
2275 frame, as the minibuffer).
2276 2217
2277 unsplittable If non-nil, frame cannot be split by `display-buffer'. 2218 unsplittable If non-nil, frame cannot be split by `display-buffer'.
2278 2219
2279 current-display-table, menubar-visible-p, left-margin-width, 2220 current-display-table, menubar-visible-p, left-margin-width,
2280 right-margin-width, minimum-line-ascent, minimum-line-descent, 2221 right-margin-width, minimum-line-ascent, minimum-line-descent,
2284 bottom-toolbar-height, left-toolbar-width, right-toolbar-width, 2225 bottom-toolbar-height, left-toolbar-width, right-toolbar-width,
2285 default-toolbar-visible-p, top-toolbar-visible-p, bottom-toolbar-visible-p, 2226 default-toolbar-visible-p, top-toolbar-visible-p, bottom-toolbar-visible-p,
2286 left-toolbar-visible-p, right-toolbar-visible-p, toolbar-buttons-captioned-p, 2227 left-toolbar-visible-p, right-toolbar-visible-p, toolbar-buttons-captioned-p,
2287 top-toolbar-border-width, bottom-toolbar-border-width, 2228 top-toolbar-border-width, bottom-toolbar-border-width,
2288 left-toolbar-border-width, right-toolbar-border-width, 2229 left-toolbar-border-width, right-toolbar-border-width,
2289 modeline-shadow-thickness, has-modeline-p, 2230 modeline-shadow-thickness, has-modeline-p
2290 default-gutter, top-gutter, bottom-gutter, left-gutter, right-gutter,
2291 default-gutter-height, default-gutter-width, top-gutter-height,
2292 bottom-gutter-height, left-gutter-width, right-gutter-width,
2293 default-gutter-visible-p, top-gutter-visible-p, bottom-gutter-visible-p,
2294 left-gutter-visible-p, right-gutter-visible-p, top-gutter-border-width,
2295 bottom-gutter-border-width, left-gutter-border-width, right-gutter-border-width,
2296 [Giving the name of any built-in specifier variable is 2231 [Giving the name of any built-in specifier variable is
2297 equivalent to calling `set-specifier' on the specifier, 2232 equivalent to calling `set-specifier' on the specifier,
2298 with a locale of FRAME. Giving the name to `frame-property' 2233 with a locale of FRAME. Giving the name to `frame-property'
2299 calls `specifier-instance' on the specifier.] 2234 calls `specifier-instance' on the specifier.]
2300 2235
2723 else 2658 else
2724 default_face_height_and_width_1 (frame, &cph, &cpw); 2659 default_face_height_and_width_1 (frame, &cph, &cpw);
2725 2660
2726 window = FRAME_SELECTED_WINDOW (f); 2661 window = FRAME_SELECTED_WINDOW (f);
2727 2662
2728 egw = max (glyph_width (Vcontinuation_glyph, window), 2663 egw = max (glyph_width (Vcontinuation_glyph, Vdefault_face, 0, window),
2729 glyph_width (Vtruncation_glyph, window)); 2664 glyph_width (Vtruncation_glyph, Vdefault_face, 0, window));
2730 egw = max (egw, cpw); 2665 egw = max (egw, cpw);
2731 bdr = 2 * f->internal_border_width; 2666 bdr = 2 * f->internal_border_width;
2732 obw = FRAME_SCROLLBAR_WIDTH (f) + FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH (f) + 2667 obw = FRAME_SCROLLBAR_WIDTH (f) + FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH (f) +
2733 FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH (f) + 2668 FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH (f) +
2734 2 * FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH (f) + 2669 2 * FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH (f) +
2899 /* Adjust the width for the end glyph which may be a different width 2834 /* Adjust the width for the end glyph which may be a different width
2900 than the default character width. */ 2835 than the default character width. */
2901 { 2836 {
2902 int adjustment, trunc_width, cont_width; 2837 int adjustment, trunc_width, cont_width;
2903 2838
2904 trunc_width = glyph_width (Vtruncation_glyph, 2839 trunc_width = glyph_width (Vtruncation_glyph, Vdefault_face, 0,
2905 FRAME_SELECTED_WINDOW (f)); 2840 FRAME_SELECTED_WINDOW (f));
2906 cont_width = glyph_width (Vcontinuation_glyph, 2841 cont_width = glyph_width (Vcontinuation_glyph, Vdefault_face, 0,
2907 FRAME_SELECTED_WINDOW (f)); 2842 FRAME_SELECTED_WINDOW (f));
2908 adjustment = max (trunc_width, cont_width); 2843 adjustment = max (trunc_width, cont_width);
2909 adjustment = max (adjustment, font_width); 2844 adjustment = max (adjustment, font_width);
2910 2845
2911 new_pixwidth += adjustment; 2846 new_pixwidth += adjustment;
2915 if (!new_pixheight && !new_pixwidth) 2850 if (!new_pixheight && !new_pixwidth)
2916 return; 2851 return;
2917 2852
2918 if (new_pixheight) 2853 if (new_pixheight)
2919 { 2854 {
2920 /* Adjust for gutters here so that we always get set 2855 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top = FRAME_TOP_BORDER_END (f);
2921 properly. */
2922 new_pixheight -=
2923 (FRAME_TOP_GUTTER_BOUNDS (f)
2924 + FRAME_BOTTOM_GUTTER_BOUNDS (f));
2925
2926 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top
2927 = FRAME_TOP_BORDER_END (f) + FRAME_TOP_GUTTER_BOUNDS (f);
2928 2856
2929 if (FRAME_HAS_MINIBUF_P (f) 2857 if (FRAME_HAS_MINIBUF_P (f)
2930 && ! FRAME_MINIBUF_ONLY_P (f)) 2858 && ! FRAME_MINIBUF_ONLY_P (f))
2931 /* Frame has both root and minibuffer. */ 2859 /* Frame has both root and minibuffer. */
2932 { 2860 {
2948 set_window_pixheight (FRAME_ROOT_WINDOW (f), 2876 set_window_pixheight (FRAME_ROOT_WINDOW (f),
2949 /* - font_height for minibuffer */ 2877 /* - font_height for minibuffer */
2950 new_pixheight - minibuf_height, 0); 2878 new_pixheight - minibuf_height, 0);
2951 2879
2952 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_top = 2880 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_top =
2953 FRAME_TOP_BORDER_END (f) + 2881 new_pixheight - minibuf_height + FRAME_TOP_BORDER_END (f);
2954 FRAME_TOP_GUTTER_BOUNDS (f) +
2955 FRAME_BOTTOM_GUTTER_BOUNDS (f) +
2956 new_pixheight - minibuf_height;
2957 2882
2958 set_window_pixheight (FRAME_MINIBUF_WINDOW (f), minibuf_height, 0); 2883 set_window_pixheight (FRAME_MINIBUF_WINDOW (f), minibuf_height, 0);
2959 } 2884 }
2960 else 2885 else
2961 /* Frame has just one top-level window. */ 2886 /* Frame has just one top-level window. */
2966 f->pixheight = newheight; 2891 f->pixheight = newheight;
2967 } 2892 }
2968 2893
2969 if (new_pixwidth) 2894 if (new_pixwidth)
2970 { 2895 {
2971 /* Adjust for gutters here so that we always get set 2896 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left = FRAME_LEFT_BORDER_END (f);
2972 properly. */
2973 new_pixwidth -=
2974 (FRAME_LEFT_GUTTER_BOUNDS (f)
2975 + FRAME_RIGHT_GUTTER_BOUNDS (f));
2976
2977 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left =
2978 FRAME_LEFT_BORDER_END (f) + FRAME_LEFT_GUTTER_BOUNDS (f);
2979 set_window_pixwidth (FRAME_ROOT_WINDOW (f), new_pixwidth, 0); 2897 set_window_pixwidth (FRAME_ROOT_WINDOW (f), new_pixwidth, 0);
2980 2898
2981 if (FRAME_HAS_MINIBUF_P (f)) 2899 if (FRAME_HAS_MINIBUF_P (f))
2982 { 2900 {
2983 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_left = 2901 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_left =
2984 FRAME_LEFT_BORDER_END (f) + FRAME_LEFT_GUTTER_BOUNDS (f); 2902 FRAME_LEFT_BORDER_END (f);
2985 set_window_pixwidth (FRAME_MINIBUF_WINDOW (f), new_pixwidth, 0); 2903 set_window_pixwidth (FRAME_MINIBUF_WINDOW (f), new_pixwidth, 0);
2986 } 2904 }
2987 2905
2988 FRAME_WIDTH (f) = newwidth; 2906 FRAME_WIDTH (f) = newwidth;
2989 if (FRAME_TTY_P (f)) 2907 if (FRAME_TTY_P (f))
2998 FRAME_CHARWIDTH (f) = FRAME_WIDTH (f); 2916 FRAME_CHARWIDTH (f) = FRAME_WIDTH (f);
2999 FRAME_CHARHEIGHT (f) = FRAME_HEIGHT (f); 2917 FRAME_CHARHEIGHT (f) = FRAME_HEIGHT (f);
3000 } 2918 }
3001 2919
3002 MARK_FRAME_TOOLBARS_CHANGED (f); 2920 MARK_FRAME_TOOLBARS_CHANGED (f);
3003 MARK_FRAME_GUTTERS_CHANGED (f);
3004 MARK_FRAME_CHANGED (f); 2921 MARK_FRAME_CHANGED (f);
3005 f->echo_area_garbaged = 1; 2922 f->echo_area_garbaged = 1;
3006 } 2923 }
3007 2924
3008 void 2925 void
3034 else 2951 else
3035 change_frame_size_1 (f, newheight, newwidth); 2952 change_frame_size_1 (f, newheight, newwidth);
3036 } 2953 }
3037 2954
3038 2955
3039 /* The caller is responsible for freeing the returned string. */
3040 static Bufbyte *
3041 generate_title_string (struct window *w, Lisp_Object format_str,
3042 face_index findex, int type)
3043 {
3044 struct display_line *dl;
3045 struct display_block *db;
3046 int elt = 0;
3047
3048 dl = &title_string_display_line;
3049 db = get_display_block_from_line (dl, TEXT);
3050 Dynarr_reset (db->runes);
3051
3052 generate_formatted_string_db (format_str, Qnil, w, dl, db, findex, 0,
3053 -1, type);
3054
3055 Dynarr_reset (title_string_emchar_dynarr);
3056 while (elt < Dynarr_length (db->runes))
3057 {
3058 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR)
3059 Dynarr_add (title_string_emchar_dynarr,
3060 Dynarr_atp (db->runes, elt)->object.chr.ch);
3061 elt++;
3062 }
3063
3064 return
3065 convert_emchar_string_into_malloced_string
3066 (Dynarr_atp (title_string_emchar_dynarr, 0),
3067 Dynarr_length (title_string_emchar_dynarr), 0);
3068 }
3069
3070 void 2956 void
3071 update_frame_title (struct frame *f) 2957 update_frame_title (struct frame *f)
3072 { 2958 {
3073 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); 2959 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
3074 Lisp_Object title_format; 2960 Lisp_Object title_format;
3088 title_format = symbol_value_in_buffer (Qframe_title_format, w->buffer); 2974 title_format = symbol_value_in_buffer (Qframe_title_format, w->buffer);
3089 icon_format = symbol_value_in_buffer (Qframe_icon_title_format, w->buffer); 2975 icon_format = symbol_value_in_buffer (Qframe_icon_title_format, w->buffer);
3090 2976
3091 if (HAS_FRAMEMETH_P (f, set_title_from_bufbyte)) 2977 if (HAS_FRAMEMETH_P (f, set_title_from_bufbyte))
3092 { 2978 {
3093 title = generate_title_string (w, title_format, 2979 title = generate_formatted_string (w, title_format, Qnil,
3094 DEFAULT_INDEX, CURRENT_DISP); 2980 DEFAULT_INDEX, CURRENT_DISP);
3095 FRAMEMETH (f, set_title_from_bufbyte, (f, title)); 2981 FRAMEMETH (f, set_title_from_bufbyte, (f, title));
3096 } 2982 }
3097 2983
3098 if (HAS_FRAMEMETH_P (f, set_icon_name_from_bufbyte)) 2984 if (HAS_FRAMEMETH_P (f, set_icon_name_from_bufbyte))
3099 { 2985 {
3100 if (!EQ (icon_format, title_format) || !title) 2986 if (!EQ (icon_format, title_format) || !title)
3101 { 2987 {
3102 if (title) 2988 if (title)
3103 xfree (title); 2989 xfree (title);
3104 2990
3105 title = generate_title_string (w, icon_format, 2991 title = generate_formatted_string (w, icon_format, Qnil,
3106 DEFAULT_INDEX, CURRENT_DISP); 2992 DEFAULT_INDEX, CURRENT_DISP);
3107 } 2993 }
3108 FRAMEMETH (f, set_icon_name_from_bufbyte, (f, title)); 2994 FRAMEMETH (f, set_icon_name_from_bufbyte, (f, title));
3109 } 2995 }
3110 2996
3111 if (title) 2997 if (title)
3160 { 3046 {
3161 MARK_ICON_CHANGED; 3047 MARK_ICON_CHANGED;
3162 } 3048 }
3163 3049
3164 3050
3165 /***************************************************************************/
3166 /* */
3167 /* initialization */
3168 /* */
3169 /***************************************************************************/
3170
3171 void
3172 init_frame (void)
3173 {
3174 #ifndef PDUMP
3175 if (!initialized)
3176 #endif
3177 {
3178 title_string_emchar_dynarr = Dynarr_new (Emchar);
3179 xzero (title_string_display_line);
3180 }
3181 }
3182
3183 void 3051 void
3184 syms_of_frame (void) 3052 syms_of_frame (void)
3185 { 3053 {
3186 INIT_LRECORD_IMPLEMENTATION (frame);
3187
3188 defsymbol (&Qdelete_frame_hook, "delete-frame-hook"); 3054 defsymbol (&Qdelete_frame_hook, "delete-frame-hook");
3189 defsymbol (&Qselect_frame_hook, "select-frame-hook"); 3055 defsymbol (&Qselect_frame_hook, "select-frame-hook");
3190 defsymbol (&Qdeselect_frame_hook, "deselect-frame-hook"); 3056 defsymbol (&Qdeselect_frame_hook, "deselect-frame-hook");
3191 defsymbol (&Qcreate_frame_hook, "create-frame-hook"); 3057 defsymbol (&Qcreate_frame_hook, "create-frame-hook");
3192 defsymbol (&Qcustom_initialize_frame, "custom-initialize-frame"); 3058 defsymbol (&Qcustom_initialize_frame, "custom-initialize-frame");
3195 defsymbol (&Qmap_frame_hook, "map-frame-hook"); 3061 defsymbol (&Qmap_frame_hook, "map-frame-hook");
3196 defsymbol (&Qunmap_frame_hook, "unmap-frame-hook"); 3062 defsymbol (&Qunmap_frame_hook, "unmap-frame-hook");
3197 3063
3198 defsymbol (&Qframep, "framep"); 3064 defsymbol (&Qframep, "framep");
3199 defsymbol (&Qframe_live_p, "frame-live-p"); 3065 defsymbol (&Qframe_live_p, "frame-live-p");
3066 defsymbol (&Qframe_x_p, "frame-x-p");
3067 defsymbol (&Qframe_tty_p, "frame-tty-p");
3200 defsymbol (&Qdelete_frame, "delete-frame"); 3068 defsymbol (&Qdelete_frame, "delete-frame");
3201 defsymbol (&Qsynchronize_minibuffers, "synchronize-minibuffers"); 3069 defsymbol (&Qsynchronize_minibuffers, "synchronize-minibuffers");
3202 defsymbol (&Qbuffer_predicate, "buffer-predicate"); 3070 defsymbol (&Qbuffer_predicate, "buffer-predicate");
3203 defsymbol (&Qframe_being_created, "frame-being-created"); 3071 defsymbol (&Qframe_being_created, "frame-being-created");
3204 defsymbol (&Qmake_initial_minibuffer_frame, "make-initial-minibuffer-frame"); 3072 defsymbol (&Qmake_initial_minibuffer_frame, "make-initial-minibuffer-frame");
3293 DEFSUBR (Fset_frame_height); 3161 DEFSUBR (Fset_frame_height);
3294 DEFSUBR (Fset_frame_width); 3162 DEFSUBR (Fset_frame_width);
3295 DEFSUBR (Fset_frame_size); 3163 DEFSUBR (Fset_frame_size);
3296 DEFSUBR (Fset_frame_position); 3164 DEFSUBR (Fset_frame_position);
3297 DEFSUBR (Fset_frame_pointer); 3165 DEFSUBR (Fset_frame_pointer);
3298 DEFSUBR (Fprint_job_page_number);
3299 DEFSUBR (Fprint_job_eject_page);
3300 } 3166 }
3301 3167
3302 void 3168 void
3303 vars_of_frame (void) 3169 vars_of_frame (void)
3304 { 3170 {
3408 visible frames. 3274 visible frames.
3409 */ ); 3275 */ );
3410 Vsynchronize_minibuffers = Qnil; 3276 Vsynchronize_minibuffers = Qnil;
3411 3277
3412 DEFVAR_LISP ("frame-title-format", &Vframe_title_format /* 3278 DEFVAR_LISP ("frame-title-format", &Vframe_title_format /*
3413 Controls the title of the window-system window of the selected frame. 3279 Controls the title of the X window corresponding to the selected frame.
3414 This is the same format as `modeline-format' with the exception that 3280 This is the same format as `modeline-format' with the exception that
3415 %- is ignored. 3281 %- is ignored.
3416 */ ); 3282 */ );
3417 /* #### I would change this unilaterally but for the wrath of the Kyles 3283 Vframe_title_format = Fpurecopy (build_string ("%S: %b"));
3418 of the world. */
3419 #ifdef WIN32_NATIVE
3420 Vframe_title_format = build_string ("%b - XEmacs");
3421 #else
3422 Vframe_title_format = build_string ("%S: %b");
3423 #endif
3424 3284
3425 DEFVAR_LISP ("frame-icon-title-format", &Vframe_icon_title_format /* 3285 DEFVAR_LISP ("frame-icon-title-format", &Vframe_icon_title_format /*
3426 Controls the title of the icon corresponding to the selected frame. 3286 Controls the title of the icon corresponding to the selected frame.
3427 See also the variable `frame-title-format'. 3287 See also the variable `frame-title-format'.
3428 */ ); 3288 */ );
3429 Vframe_icon_title_format = build_string ("%b"); 3289 Vframe_icon_title_format = Fpurecopy (build_string ("%b"));
3430 3290
3431 DEFVAR_LISP ("default-frame-name", &Vdefault_frame_name /* 3291 DEFVAR_LISP ("default-frame-name", &Vdefault_frame_name /*
3432 The default name to assign to newly-created frames. 3292 The default name to assign to newly-created frames.
3433 This can be overridden by arguments to `make-frame'. This must be a string. 3293 This can be overridden by arguments to `make-frame'.
3434 This is used primarily for picking up X resources, and is *not* the title 3294 This must be a string.
3435 of the frame. (See `frame-title-format'.)
3436 */ ); 3295 */ );
3437 #ifndef INFODOCK 3296 #ifndef INFODOCK
3438 Vdefault_frame_name = build_string ("emacs"); 3297 Vdefault_frame_name = Fpurecopy (build_string ("emacs"));
3439 #else 3298 #else
3440 Vdefault_frame_name = build_string ("InfoDock"); 3299 Vdefault_frame_name = Fpurecopy (build_string ("InfoDock"));
3441 #endif 3300 #endif
3442 3301
3443 DEFVAR_LISP ("default-frame-plist", &Vdefault_frame_plist /* 3302 DEFVAR_LISP ("default-frame-plist", &Vdefault_frame_plist /*
3444 Plist of default values for frame creation, other than the first one. 3303 Plist of default values for frame creation, other than the first one.
3445 These may be set in your init file, like this: 3304 These may be set in your init file, like this: