This source file includes following definitions.
- fset_buffer_predicate
- fset_minibuffer_window
- decode_live_frame
- decode_any_frame
- display_available
- decode_window_system_frame
- check_window_system
- get_frame_param
- frame_inhibit_resize
- set_menu_bar_lines
- set_tab_bar_lines
- DEFUN
- DEFUN
- DEFUN
- frame_windows_min_size
- keep_ratio
- frame_size_history_adjust
- frame_size_history_plain
- frame_size_history_extra
- adjust_frame_size
- allocate_frame
- make_frame
- make_frame_without_minibuffer
- make_minibuffer_frame
- make_initial_frame
- make_terminal_frame
- get_future_frame_param
- DEFUN
- do_switch_frame
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- frame_ancestor_p
- candidate_frame
- next_frame
- prev_frame
- DEFUN
- other_frames
- delete_frame
- frame_internal_border_part
- DEFUN
- mouse_position
- DEFUN
- frame_char_to_pixel_position
- frame_set_mouse_position
- DEFUN
- make_frame_visible_1
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- frames_discard_buffer
- store_in_alist
- frame_name_fnn_p
- set_term_frame_name
- store_frame_param
- frame_unspecified_color
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- check_frame_pixels
- DEFUN
- DEFUN
- DEFUN
- frame_float
- gui_set_frame_parameters_1
- gui_set_frame_parameters
- gui_report_frame_params
- gui_set_fullscreen
- gui_set_line_spacing
- gui_set_screen_gamma
- gui_set_font
- gui_set_font_backend
- gui_set_left_fringe
- gui_set_right_fringe
- gui_set_border_width
- gui_set_right_divider_width
- gui_set_bottom_divider_width
- gui_set_visibility
- gui_set_autoraise
- gui_set_autolower
- gui_set_unsplittable
- gui_set_vertical_scroll_bars
- gui_set_horizontal_scroll_bars
- gui_set_scroll_bar_width
- gui_set_scroll_bar_height
- gui_set_alpha
- gui_set_alpha_background
- gui_set_no_special_glyphs
- gui_mouse_grabbed
- gui_redo_mouse_highlight
- validate_x_resource_name
- gui_display_get_resource
- x_get_resource_string
- gui_display_get_arg
- gui_frame_get_arg
- gui_frame_get_and_record_arg
- gui_default_parameter
- XParseGeometry
- DEFUN
- gui_figure_window_size
- frame_make_pointer_invisible
- frame_make_pointer_visible
- DEFUN
- DEFUN
- free_monitors
- make_monitor_attribute_list
- init_frame_once
- init_frame_once_for_pdumper
- syms_of_frame
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <config.h>
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <errno.h>
25 #include <limits.h>
26
27 #include <c-ctype.h>
28
29 #include "lisp.h"
30
31 #ifdef HAVE_WINDOW_SYSTEM
32 #include TERM_HEADER
33 #endif
34
35 #include "buffer.h"
36
37 #include "keyboard.h"
38 #include "frame.h"
39 #include "blockinput.h"
40 #include "termchar.h"
41 #include "termhooks.h"
42 #include "dispextern.h"
43 #include "window.h"
44 #ifdef HAVE_WINDOW_SYSTEM
45 #include "fontset.h"
46 #endif
47 #include "cm.h"
48 #ifdef MSDOS
49 #include "msdos.h"
50 #include "dosfns.h"
51 #endif
52 #ifdef USE_X_TOOLKIT
53 #include "widget.h"
54 #endif
55 #include "pdumper.h"
56
57
58 Lisp_Object selected_frame;
59
60
61 Lisp_Object old_selected_frame;
62
63
64
65
66 static struct frame *last_nonminibuf_frame;
67
68
69 bool frame_garbaged;
70
71
72 int frame_default_tab_bar_height;
73
74
75 #ifdef HAVE_EXT_TOOL_BAR
76 enum { frame_default_tool_bar_height = 0 };
77 #else
78 int frame_default_tool_bar_height;
79 #endif
80
81 #ifdef HAVE_WINDOW_SYSTEM
82 static void gui_report_frame_params (struct frame *, Lisp_Object *);
83 #endif
84
85
86 static void
87 fset_buffer_predicate (struct frame *f, Lisp_Object val)
88 {
89 f->buffer_predicate = val;
90 }
91 static void
92 fset_minibuffer_window (struct frame *f, Lisp_Object val)
93 {
94 f->minibuffer_window = val;
95 }
96
97 struct frame *
98 decode_live_frame (register Lisp_Object frame)
99 {
100 if (NILP (frame))
101 frame = selected_frame;
102 CHECK_LIVE_FRAME (frame);
103 return XFRAME (frame);
104 }
105
106 struct frame *
107 decode_any_frame (register Lisp_Object frame)
108 {
109 if (NILP (frame))
110 frame = selected_frame;
111 CHECK_FRAME (frame);
112 return XFRAME (frame);
113 }
114
115 #ifdef HAVE_WINDOW_SYSTEM
116 bool
117 display_available (void)
118 {
119 return x_display_list != NULL;
120 }
121 #endif
122
123 struct frame *
124 decode_window_system_frame (Lisp_Object frame)
125 {
126 struct frame *f = decode_live_frame (frame);
127 check_window_system (f);
128 #ifdef HAVE_WINDOW_SYSTEM
129 return f;
130 #endif
131 }
132
133 void
134 check_window_system (struct frame *f)
135 {
136 #ifdef HAVE_WINDOW_SYSTEM
137 if (window_system_available (f))
138 return;
139 #endif
140 error (f ? "Window system frame should be used"
141 : "Window system is not in use or not initialized");
142 }
143
144
145
146 Lisp_Object
147 get_frame_param (struct frame *frame, Lisp_Object prop)
148 {
149 return Fcdr (Fassq (prop, frame->param_alist));
150 }
151
152
153
154
155
156
157 bool
158 frame_inhibit_resize (struct frame *f, bool horizontal, Lisp_Object parameter)
159 {
160 Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
161 bool inhibit
162 = (f->after_make_frame
163 ? (EQ (frame_inhibit_implied_resize, Qt)
164 || (CONSP (frame_inhibit_implied_resize)
165 && !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))
166 || (horizontal
167 && !NILP (fullscreen) && !EQ (fullscreen, Qfullheight))
168 || (!horizontal
169 && !NILP (fullscreen) && !EQ (fullscreen, Qfullwidth))
170 || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
171 : ((horizontal && f->inhibit_horizontal_resize)
172 || (!horizontal && f->inhibit_vertical_resize)));
173
174 return inhibit;
175 }
176
177
178
179 static void
180 set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
181 {
182 int olines = FRAME_MENU_BAR_LINES (f);
183 int nlines = TYPE_RANGED_FIXNUMP (int, value) ? XFIXNUM (value) : 0;
184
185
186
187
188
189 if (!FRAME_MINIBUF_ONLY_P (f) && nlines != olines)
190 {
191 windows_or_buffers_changed = 14;
192 FRAME_MENU_BAR_LINES (f) = FRAME_MENU_BAR_HEIGHT (f) = nlines;
193 change_frame_size (f, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f),
194 false, true, false);
195 }
196 }
197
198
199
200 static void
201 set_tab_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
202 {
203 int olines = FRAME_TAB_BAR_LINES (f);
204 int nlines = TYPE_RANGED_FIXNUMP (int, value) ? XFIXNUM (value) : 0;
205
206
207
208
209
210 if (!FRAME_MINIBUF_ONLY_P (f) && nlines != olines)
211 {
212 windows_or_buffers_changed = 14;
213 FRAME_TAB_BAR_LINES (f) = FRAME_TAB_BAR_HEIGHT (f) = nlines;
214 change_frame_size (f, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f),
215 false, true, false);
216 }
217 }
218
219 Lisp_Object Vframe_list;
220
221 DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
222 doc:
223
224
225
226
227
228
229
230
231 )
232 (Lisp_Object object)
233 {
234 if (!FRAMEP (object))
235 return Qnil;
236 switch (XFRAME (object)->output_method)
237 {
238 case output_initial:
239 case output_termcap:
240 return Qt;
241 case output_x_window:
242 return Qx;
243 case output_w32:
244 return Qw32;
245 case output_msdos_raw:
246 return Qpc;
247 case output_ns:
248 return Qns;
249 case output_pgtk:
250 return Qpgtk;
251 case output_haiku:
252 return Qhaiku;
253 default:
254 emacs_abort ();
255 }
256 }
257
258 DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0,
259 doc:
260
261
262
263 )
264 (Lisp_Object object)
265 {
266 return ((FRAMEP (object)
267 && FRAME_LIVE_P (XFRAME (object)))
268 ? Fframep (object)
269 : Qnil);
270 }
271
272 DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0,
273 doc:
274
275
276
277
278
279
280
281
282
283
284
285
286
287 )
288 (Lisp_Object frame)
289 {
290 Lisp_Object type;
291 if (NILP (frame))
292 frame = selected_frame;
293
294 type = Fframep (frame);
295
296 if (NILP (type))
297 wrong_type_argument (Qframep, frame);
298
299 if (EQ (type, Qt))
300 return Qnil;
301 else
302 return type;
303 }
304
305
306 DEFUN ("frame-windows-min-size", Fframe_windows_min_size,
307 Sframe_windows_min_size, 4, 4, 0,
308 doc:
309 attributes: const)
310 (Lisp_Object frame, Lisp_Object horizontal,
311 Lisp_Object ignore, Lisp_Object pixelwise)
312 {
313 return make_fixnum (0);
314 }
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338 static int
339 frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal,
340 Lisp_Object ignore, Lisp_Object pixelwise)
341 {
342 struct frame *f = XFRAME (frame);
343 Lisp_Object par_size;
344 int retval;
345
346 if ((!NILP (horizontal)
347 && RANGED_FIXNUMP (INT_MIN,
348 par_size = get_frame_param (f, Qmin_width),
349 INT_MAX))
350 || (NILP (horizontal)
351 && RANGED_FIXNUMP (INT_MIN,
352 par_size = get_frame_param (f, Qmin_height),
353 INT_MAX)))
354 {
355 int min_size = XFIXNUM (par_size);
356
357
358 if (min_size < 1)
359 min_size = 1;
360
361 retval = (NILP (pixelwise)
362 ? min_size
363 : min_size * (NILP (horizontal)
364 ? FRAME_LINE_HEIGHT (f)
365 : FRAME_COLUMN_WIDTH (f)));
366 }
367 else
368 retval = XFIXNUM (call4 (Qframe_windows_min_size, frame, horizontal,
369 ignore, pixelwise));
370
371
372
373 if ((FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) && NILP (horizontal))
374 {
375 int min_height = (FRAME_MENU_BAR_LINES (f)
376 + FRAME_TAB_BAR_LINES (f)
377 + FRAME_WANTS_MODELINE_P (f)
378 + 2);
379
380 if (retval < min_height)
381 retval = min_height;
382 }
383
384 return retval;
385 }
386
387
388 #ifdef HAVE_WINDOW_SYSTEM
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417 static void
418 keep_ratio (struct frame *f, struct frame *p, int old_width, int old_height,
419 int new_width, int new_height)
420 {
421 Lisp_Object keep_ratio = get_frame_param (f, Qkeep_ratio);
422
423
424 if (!NILP (keep_ratio))
425 {
426 double width_factor = (double)new_width / (double)old_width;
427 double height_factor = (double)new_height / (double)old_height;
428 int pixel_width, pixel_height, pos_x, pos_y;
429
430 if (!CONSP (keep_ratio) || !NILP (Fcdr (keep_ratio)))
431 {
432 if (CONSP (keep_ratio) && EQ (Fcdr (keep_ratio), Qtop_only))
433 pos_x = f->left_pos;
434 else
435 {
436 pos_x = (int)(f->left_pos * width_factor + 0.5);
437
438 if (CONSP (keep_ratio)
439 && (NILP (Fcar (keep_ratio))
440 || EQ (Fcar (keep_ratio), Qheight_only))
441 && FRAME_PIXEL_WIDTH (p) - FRAME_PIXEL_WIDTH (f) < pos_x)
442 {
443 int p_f_width
444 = FRAME_PIXEL_WIDTH (p) - FRAME_PIXEL_WIDTH (f);
445
446 if (p_f_width <= 0)
447 pos_x = 0;
448 else
449 pos_x = (int)(p_f_width * width_factor * 0.5 + 0.5);
450 }
451
452 f->left_pos = pos_x;
453 }
454
455 if (CONSP (keep_ratio) && EQ (Fcdr (keep_ratio), Qleft_only))
456 pos_y = f->top_pos;
457 else
458 {
459 pos_y = (int)(f->top_pos * height_factor + 0.5);
460
461 if (CONSP (keep_ratio)
462 && (NILP (Fcar (keep_ratio))
463 || EQ (Fcar (keep_ratio), Qwidth_only))
464 && FRAME_PIXEL_HEIGHT (p) - FRAME_PIXEL_HEIGHT (f) < pos_y)
465
466
467
468
469
470 {
471 int p_f_height
472 = FRAME_PIXEL_HEIGHT (p) - FRAME_PIXEL_HEIGHT (f);
473
474 if (p_f_height <= 0)
475 pos_y = 0;
476 else
477 pos_y = (int)(p_f_height * height_factor * 0.5 + 0.5);
478 }
479
480 f->top_pos = pos_y;
481 }
482
483 if (FRAME_TERMINAL (f)->set_frame_offset_hook)
484 FRAME_TERMINAL (f)->set_frame_offset_hook (f, pos_x, pos_y, -1);
485 }
486
487 if (!CONSP (keep_ratio) || !NILP (Fcar (keep_ratio)))
488 {
489 if (CONSP (keep_ratio) && EQ (Fcar (keep_ratio), Qheight_only))
490 pixel_width = -1;
491 else
492 pixel_width
493 = (int)(FRAME_PIXEL_WIDTH (f) * width_factor + 0.5);
494
495 if (CONSP (keep_ratio) && EQ (Fcar (keep_ratio), Qwidth_only))
496 pixel_height = -1;
497 else
498 pixel_height
499 = (int)(FRAME_PIXEL_HEIGHT (f) * height_factor + 0.5);
500
501 adjust_frame_size (f, FRAME_PIXEL_TO_TEXT_WIDTH (f, pixel_width),
502 FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixel_height), 1,
503 false, Qkeep_ratio);
504 }
505 }
506 }
507 #endif
508
509
510 static void
511 frame_size_history_adjust (struct frame *f, int inhibit, Lisp_Object parameter,
512 int old_text_width, int old_text_height,
513 int new_text_width, int new_text_height,
514 int old_text_cols, int old_text_lines,
515 int new_text_cols, int new_text_lines,
516 int old_native_width, int old_native_height,
517 int new_native_width, int new_native_height,
518 int old_inner_width, int old_inner_height,
519 int new_inner_width, int new_inner_height,
520 int min_inner_width, int min_inner_height,
521 bool inhibit_horizontal, bool inhibit_vertical)
522 {
523 Lisp_Object frame;
524
525 XSETFRAME (frame, f);
526 if (CONSP (frame_size_history)
527 && FIXNUMP (XCAR (frame_size_history))
528 && 0 < XFIXNUM (XCAR (frame_size_history)))
529 frame_size_history =
530 Fcons (make_fixnum (XFIXNUM (XCAR (frame_size_history)) - 1),
531 Fcons (Fcons (list4 (frame, make_fixnum (5),
532 make_fixnum (inhibit), parameter),
533 list5 (list4i (old_text_width, old_text_height,
534 new_text_width, new_text_height),
535 list4i (old_text_cols, old_text_lines,
536 new_text_cols, new_text_lines),
537 list4i (old_native_width, old_native_height,
538 new_native_width, new_native_height),
539 list4i (old_inner_width, old_inner_height,
540 new_inner_width, new_inner_height),
541 list4 (make_fixnum (min_inner_width),
542 make_fixnum (min_inner_height),
543 inhibit_horizontal ? Qt : Qnil,
544 inhibit_vertical ? Qt : Qnil))),
545 XCDR (frame_size_history)));
546 }
547
548
549 void
550 frame_size_history_plain (struct frame *f, Lisp_Object parameter)
551 {
552 Lisp_Object frame;
553
554 XSETFRAME (frame, f);
555 if (CONSP (frame_size_history)
556 && FIXNUMP (XCAR (frame_size_history))
557 && 0 < XFIXNUM (XCAR (frame_size_history)))
558 frame_size_history =
559 Fcons (make_fixnum (XFIXNUM (XCAR (frame_size_history)) - 1),
560 Fcons (Fcons (list3 (frame, make_fixnum (1), parameter), Qt),
561 XCDR (frame_size_history)));
562 }
563
564
565 void
566 frame_size_history_extra (struct frame *f, Lisp_Object parameter,
567 int pixel_width, int pixel_height,
568 int extra_width, int extra_height,
569 int delayed_width, int delayed_height)
570 {
571 Lisp_Object frame;
572
573 XSETFRAME (frame, f);
574 if (CONSP (frame_size_history)
575 && FIXNUMP (XCAR (frame_size_history))
576 && 0 < XFIXNUM (XCAR (frame_size_history)))
577 frame_size_history =
578 Fcons (make_fixnum (XFIXNUM (XCAR (frame_size_history)) - 1),
579 Fcons (Fcons (list3 (frame, make_fixnum (2), parameter),
580 list2 (list4i (pixel_width, pixel_height,
581 extra_width, extra_height),
582 list2i (delayed_width, delayed_height))),
583 XCDR (frame_size_history)));
584 }
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638 void
639 adjust_frame_size (struct frame *f, int new_text_width, int new_text_height,
640 int inhibit, bool pretend, Lisp_Object parameter)
641 {
642 int unit_width = FRAME_COLUMN_WIDTH (f);
643 int unit_height = FRAME_LINE_HEIGHT (f);
644 int old_native_width = FRAME_PIXEL_WIDTH (f);
645 int old_native_height = FRAME_PIXEL_HEIGHT (f);
646 int new_native_width, new_native_height;
647
648
649 int min_inner_width, min_inner_height;
650
651
652
653
654 struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
655 int old_inner_width = WINDOW_PIXEL_WIDTH (r);
656 int old_inner_height
657 = (WINDOW_PIXEL_HEIGHT (r)
658 + ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f))
659 ? WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_MINIBUF_WINDOW (f)))
660 : 0));
661 int new_inner_width, new_inner_height;
662 int old_text_cols = FRAME_COLS (f);
663 int old_text_lines = FRAME_LINES (f);
664 int new_text_cols, new_text_lines;
665 int old_text_width = FRAME_TEXT_WIDTH (f);
666 int old_text_height = FRAME_TEXT_HEIGHT (f);
667 bool inhibit_horizontal, inhibit_vertical;
668 Lisp_Object frame;
669
670 XSETFRAME (frame, f);
671
672 min_inner_width
673 = frame_windows_min_size (frame, Qt, (inhibit == 5) ? Qsafe : Qnil, Qt);
674 min_inner_height
675 = frame_windows_min_size (frame, Qnil, (inhibit == 5) ? Qsafe : Qnil, Qt);
676
677 if (inhibit >= 2 && inhibit <= 4)
678
679
680
681 {
682 if (new_text_width == -1)
683 new_text_width = FRAME_TEXT_WIDTH (f);
684 if (new_text_height == -1)
685 new_text_height = FRAME_TEXT_HEIGHT (f);
686
687 inhibit_horizontal = (FRAME_INNER_WIDTH (f) >= min_inner_width
688 && (inhibit == 4
689 || frame_inhibit_resize (f, true, parameter)));
690 inhibit_vertical = (FRAME_INNER_HEIGHT (f) >= min_inner_height
691 && (inhibit == 4
692 || frame_inhibit_resize (f, false, parameter)));
693 }
694 else
695
696
697
698 inhibit_horizontal = inhibit_vertical = inhibit == 5;
699
700 new_native_width = ((inhibit_horizontal && inhibit < 5)
701 ? old_native_width
702 : max (FRAME_TEXT_TO_PIXEL_WIDTH (f, new_text_width),
703 min_inner_width
704 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)));
705 new_inner_width = new_native_width - 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
706 new_text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, new_native_width);
707 new_text_cols = new_text_width / unit_width;
708
709 new_native_height = ((inhibit_vertical && inhibit < 5)
710 ? old_native_height
711 : max (FRAME_TEXT_TO_PIXEL_HEIGHT (f, new_text_height),
712 min_inner_height
713 + FRAME_TOP_MARGIN_HEIGHT (f)
714 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)));
715 new_inner_height = (new_native_height
716 - FRAME_TOP_MARGIN_HEIGHT (f)
717 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
718 new_text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, new_native_height);
719 new_text_lines = new_text_height / unit_height;
720
721 if (FRAME_WINDOW_P (f)
722 && f->can_set_window_size
723
724
725
726 && ((!inhibit_horizontal
727 && (new_native_width != old_native_width
728 || inhibit == 0 || inhibit == 2))
729 || (!inhibit_vertical
730 && (new_native_height != old_native_height
731 || inhibit == 0 || inhibit == 2))))
732 {
733 if (inhibit == 2
734 #ifdef USE_MOTIF
735 && !EQ (parameter, Qmenu_bar_lines)
736 #endif
737 && (f->new_width >= 0 || f->new_height >= 0))
738
739
740
741
742
743
744
745
746
747 {
748 if (f->new_width >= 0)
749 new_native_width = f->new_width;
750 if (f->new_height >= 0)
751 new_native_height = f->new_height;
752 }
753
754 if (CONSP (frame_size_history))
755 frame_size_history_adjust (f, inhibit, parameter,
756 old_text_width, old_text_height,
757 new_text_width, new_text_height,
758 old_text_cols, old_text_lines,
759 new_text_cols, new_text_lines,
760 old_native_width, old_native_height,
761 new_native_width, new_native_height,
762 old_inner_width, old_inner_height,
763 new_inner_width, new_inner_height,
764 min_inner_width, min_inner_height,
765 inhibit_horizontal, inhibit_vertical);
766
767 if (inhibit == 0 || inhibit == 1)
768 {
769 f->new_width = new_native_width;
770 f->new_height = new_native_height;
771
772
773
774
775 f->new_size_p = false;
776 }
777
778 if (FRAME_TERMINAL (f)->set_window_size_hook)
779 FRAME_TERMINAL (f)->set_window_size_hook
780 (f, 0, new_native_width, new_native_height);
781 f->resized_p = true;
782
783 return;
784 }
785
786 if (CONSP (frame_size_history))
787 frame_size_history_adjust (f, inhibit, parameter,
788 old_text_width, old_text_height,
789 new_text_width, new_text_height,
790 old_text_cols, old_text_lines,
791 new_text_cols, new_text_lines,
792 old_native_width, old_native_height,
793 new_native_width, new_native_height,
794 old_inner_width, old_inner_height,
795 new_inner_width, new_inner_height,
796 min_inner_width, min_inner_height,
797 inhibit_horizontal, inhibit_vertical);
798
799 if ((XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top
800 == FRAME_TOP_MARGIN_HEIGHT (f))
801 && new_text_width == old_text_width
802 && new_text_height == old_text_height
803 && new_inner_width == old_inner_width
804 && new_inner_height == old_inner_height
805
806 && new_native_width == old_native_width
807 && new_native_height == old_native_height
808 && new_text_cols == old_text_cols
809 && new_text_lines == old_text_lines)
810
811 return;
812
813 block_input ();
814
815 #ifdef MSDOS
816
817
818
819
820 int dos_new_text_lines = new_text_lines + FRAME_TOP_MARGIN (f);
821
822 dos_set_window_size (&dos_new_text_lines, &new_text_cols);
823 new_text_lines = dos_new_text_lines - FRAME_TOP_MARGIN (f);
824 #endif
825
826 if (new_inner_width != old_inner_width)
827 {
828 resize_frame_windows (f, new_inner_width, true);
829
830
831
832 if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f))
833 FrameCols (FRAME_TTY (f)) = new_text_cols;
834
835 #if defined (HAVE_WINDOW_SYSTEM)
836 if (WINDOWP (f->tab_bar_window))
837 {
838 XWINDOW (f->tab_bar_window)->pixel_width = new_inner_width;
839 XWINDOW (f->tab_bar_window)->total_cols
840 = new_inner_width / unit_width;
841 }
842 #endif
843
844 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
845 if (WINDOWP (f->tool_bar_window))
846 {
847 XWINDOW (f->tool_bar_window)->pixel_width = new_inner_width;
848 XWINDOW (f->tool_bar_window)->total_cols
849 = new_inner_width / unit_width;
850 }
851 #endif
852 }
853 else if (new_text_cols != old_text_cols)
854 call2 (Qwindow__pixel_to_total, frame, Qt);
855
856 if (new_inner_height != old_inner_height
857
858
859
860 || WINDOW_TOP_PIXEL_EDGE (r) != FRAME_TOP_MARGIN_HEIGHT (f))
861 {
862 resize_frame_windows (f, new_inner_height, false);
863
864
865
866 if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f))
867 FrameRows (FRAME_TTY (f)) = new_text_lines + FRAME_TOP_MARGIN (f);
868 }
869 else if (new_text_lines != old_text_lines)
870 call2 (Qwindow__pixel_to_total, frame, Qnil);
871
872
873 FRAME_COLS (f) = new_text_cols;
874 FRAME_LINES (f) = new_text_lines;
875 FRAME_TEXT_WIDTH (f) = new_text_width;
876 FRAME_TEXT_HEIGHT (f) = new_text_height;
877 FRAME_PIXEL_WIDTH (f) = new_native_width;
878 FRAME_PIXEL_HEIGHT (f) = new_native_height;
879 FRAME_TOTAL_COLS (f) = FRAME_PIXEL_WIDTH (f) / FRAME_COLUMN_WIDTH (f);
880 FRAME_TOTAL_LINES (f) = FRAME_PIXEL_HEIGHT (f) / FRAME_LINE_HEIGHT (f);
881
882 {
883 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
884 int text_area_x, text_area_y, text_area_width, text_area_height;
885
886 window_box (w, TEXT_AREA, &text_area_x, &text_area_y, &text_area_width,
887 &text_area_height);
888 if (w->cursor.x >= text_area_x + text_area_width)
889 w->cursor.hpos = w->cursor.x = 0;
890 if (w->cursor.y >= text_area_y + text_area_height)
891 w->cursor.vpos = w->cursor.y = 0;
892 }
893
894 adjust_frame_glyphs (f);
895 calculate_costs (f);
896 SET_FRAME_GARBAGED (f);
897
898
899
900 f->resized_p = true;
901
902
903
904
905
906
907 unblock_input ();
908
909 #ifdef HAVE_WINDOW_SYSTEM
910 {
911
912 Lisp_Object frames, frame1;
913
914 FOR_EACH_FRAME (frames, frame1)
915 if (FRAME_PARENT_FRAME (XFRAME (frame1)) == f)
916 keep_ratio (XFRAME (frame1), f, old_native_width, old_native_height,
917 new_native_width, new_native_height);
918 }
919 #endif
920 }
921
922
923
924 static struct frame *
925 allocate_frame (void)
926 {
927 return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame, tool_bar_items,
928 PVEC_FRAME);
929 }
930
931 struct frame *
932 make_frame (bool mini_p)
933 {
934 Lisp_Object frame;
935 struct frame *f;
936 struct window *rw, *mw UNINIT;
937 Lisp_Object root_window;
938 Lisp_Object mini_window;
939
940 f = allocate_frame ();
941 XSETFRAME (frame, f);
942
943 #ifdef USE_GTK
944
945
946 fset_tool_bar_position (f, Qtop);
947 #endif
948
949
950
951
952
953 f->wants_modeline = true;
954 f->redisplay = true;
955 f->garbaged = true;
956 f->can_set_window_size = false;
957 f->after_make_frame = false;
958 f->inhibit_horizontal_resize = false;
959 f->inhibit_vertical_resize = false;
960 f->tab_bar_redisplayed = false;
961 f->tab_bar_resized = false;
962 f->tool_bar_redisplayed = false;
963 f->tool_bar_resized = false;
964 f->column_width = 1;
965 f->line_height = 1;
966 f->new_width = -1;
967 f->new_height = -1;
968 #ifdef HAVE_WINDOW_SYSTEM
969 f->vertical_scroll_bar_type = vertical_scroll_bar_none;
970 f->horizontal_scroll_bars = false;
971 f->want_fullscreen = FULLSCREEN_NONE;
972 f->undecorated = false;
973 f->no_special_glyphs = false;
974 #ifndef HAVE_NTGUI
975 f->override_redirect = false;
976 #endif
977 f->skip_taskbar = false;
978 f->no_focus_on_map = false;
979 f->no_accept_focus = false;
980 f->z_group = z_group_none;
981 f->tooltip = false;
982 f->was_invisible = false;
983 f->child_frame_border_width = -1;
984 f->last_tab_bar_item = -1;
985 #ifndef HAVE_EXT_TOOL_BAR
986 f->last_tool_bar_item = -1;
987 #endif
988 #ifdef NS_IMPL_COCOA
989 f->ns_appearance = ns_appearance_system_default;
990 f->ns_transparent_titlebar = false;
991 #endif
992 #endif
993 f->select_mini_window_flag = false;
994
995 f->change_stamp = 1;
996 root_window = make_window ();
997 rw = XWINDOW (root_window);
998 if (mini_p)
999 {
1000 mini_window = make_window ();
1001 mw = XWINDOW (mini_window);
1002 wset_next (rw, mini_window);
1003 wset_prev (mw, root_window);
1004 mw->mini = 1;
1005 wset_frame (mw, frame);
1006 fset_minibuffer_window (f, mini_window);
1007 store_frame_param (f, Qminibuffer, Qt);
1008 }
1009 else
1010 {
1011 mini_window = Qnil;
1012 wset_next (rw, Qnil);
1013 fset_minibuffer_window (f, Qnil);
1014 }
1015
1016 wset_frame (rw, frame);
1017
1018
1019
1020 FRAME_COLS (f) = FRAME_TOTAL_COLS (f) = rw->total_cols = 80;
1021 FRAME_TEXT_WIDTH (f) = FRAME_PIXEL_WIDTH (f) = rw->pixel_width
1022 = 80 * FRAME_COLUMN_WIDTH (f);
1023 FRAME_LINES (f) = FRAME_TOTAL_LINES (f) = 25;
1024 FRAME_TEXT_HEIGHT (f) = FRAME_PIXEL_HEIGHT (f) = 25 * FRAME_LINE_HEIGHT (f);
1025
1026 rw->total_lines = FRAME_LINES (f) - (mini_p ? 1 : 0);
1027 rw->pixel_height = rw->total_lines * FRAME_LINE_HEIGHT (f);
1028
1029 fset_face_hash_table
1030 (f, make_hash_table (hashtest_eq, DEFAULT_HASH_SIZE, DEFAULT_REHASH_SIZE,
1031 DEFAULT_REHASH_THRESHOLD, Qnil, false));
1032
1033 if (mini_p)
1034 {
1035 mw->top_line = rw->total_lines;
1036 mw->pixel_top = rw->pixel_height;
1037 mw->total_cols = rw->total_cols;
1038 mw->pixel_width = rw->pixel_width;
1039 mw->total_lines = 1;
1040 mw->pixel_height = FRAME_LINE_HEIGHT (f);
1041 }
1042
1043
1044 {
1045 Lisp_Object buf = Fcurrent_buffer ();
1046
1047
1048 if (BUFFER_HIDDEN_P (XBUFFER (buf)))
1049 buf = other_buffer_safely (buf);
1050
1051
1052
1053
1054
1055
1056
1057 set_window_buffer (root_window, buf, 0, 0);
1058 fset_buffer_list (f, list1 (buf));
1059 }
1060
1061 if (mini_p)
1062 set_window_buffer (mini_window,
1063 (NILP (Vminibuffer_list)
1064 ? get_minibuffer (0)
1065 : Fcar (Vminibuffer_list)),
1066 0, 0);
1067
1068 fset_root_window (f, root_window);
1069 fset_selected_window (f, root_window);
1070
1071
1072 XWINDOW (f->selected_window)->use_time = ++window_select_count;
1073
1074 return f;
1075 }
1076
1077 #ifdef HAVE_WINDOW_SYSTEM
1078
1079
1080
1081
1082 struct frame *
1083 make_frame_without_minibuffer (Lisp_Object mini_window, KBOARD *kb,
1084 Lisp_Object display)
1085 {
1086 struct frame *f;
1087
1088 if (!NILP (mini_window))
1089 CHECK_LIVE_WINDOW (mini_window);
1090
1091 if (!NILP (mini_window)
1092 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window)->frame)) != kb)
1093 error ("Frame and minibuffer must be on the same terminal");
1094
1095
1096 f = make_frame (0);
1097
1098 if (NILP (mini_window))
1099 {
1100
1101 if (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame))
1102 || ! FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame))))
1103 {
1104 Lisp_Object frame_dummy;
1105
1106 XSETFRAME (frame_dummy, f);
1107
1108 kset_default_minibuffer_frame
1109 (kb, call1 (intern ("make-initial-minibuffer-frame"), display));
1110 }
1111
1112 mini_window
1113 = XFRAME (KVAR (kb, Vdefault_minibuffer_frame))->minibuffer_window;
1114 }
1115
1116 fset_minibuffer_window (f, mini_window);
1117 store_frame_param (f, Qminibuffer, mini_window);
1118
1119
1120
1121 if (NILP (Fmemq (XWINDOW (mini_window)->contents, Vminibuffer_list)))
1122
1123
1124 set_window_buffer (mini_window,
1125 (NILP (Vminibuffer_list)
1126 ? get_minibuffer (0)
1127 : Fcar (Vminibuffer_list)), 0, 0);
1128 return f;
1129 }
1130
1131
1132
1133 struct frame *
1134 make_minibuffer_frame (void)
1135 {
1136
1137
1138 register struct frame *f = make_frame (0);
1139 register Lisp_Object mini_window;
1140 register Lisp_Object frame;
1141
1142 XSETFRAME (frame, f);
1143
1144 f->auto_raise = 0;
1145 f->auto_lower = 0;
1146 f->no_split = 1;
1147 f->wants_modeline = 0;
1148
1149
1150
1151
1152
1153 mini_window = f->root_window;
1154 fset_minibuffer_window (f, mini_window);
1155 store_frame_param (f, Qminibuffer, Qonly);
1156 XWINDOW (mini_window)->mini = 1;
1157 wset_next (XWINDOW (mini_window), Qnil);
1158 wset_prev (XWINDOW (mini_window), Qnil);
1159 wset_frame (XWINDOW (mini_window), frame);
1160
1161
1162
1163
1164
1165 set_window_buffer (mini_window,
1166 (NILP (Vminibuffer_list)
1167 ? get_minibuffer (0)
1168 : Fcar (Vminibuffer_list)), 0, 0);
1169 return f;
1170 }
1171 #endif
1172
1173
1174
1175 static intmax_t tty_frame_count;
1176
1177 struct frame *
1178 make_initial_frame (void)
1179 {
1180 struct frame *f;
1181 struct terminal *terminal;
1182 Lisp_Object frame;
1183
1184 eassert (initial_kboard);
1185 eassert (NILP (Vframe_list) || CONSP (Vframe_list));
1186
1187 terminal = init_initial_terminal ();
1188
1189 f = make_frame (true);
1190 XSETFRAME (frame, f);
1191
1192 Vframe_list = Fcons (frame, Vframe_list);
1193
1194 tty_frame_count = 1;
1195 fset_name (f, build_pure_c_string ("F1"));
1196
1197 SET_FRAME_VISIBLE (f, 1);
1198
1199 f->output_method = terminal->type;
1200 f->terminal = terminal;
1201 f->terminal->reference_count++;
1202
1203 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
1204 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
1205
1206 #ifdef HAVE_WINDOW_SYSTEM
1207 f->vertical_scroll_bar_type = vertical_scroll_bar_none;
1208 f->horizontal_scroll_bars = false;
1209 #endif
1210
1211
1212 set_menu_bar_lines (f, make_fixnum (1), Qnil);
1213
1214
1215 set_tab_bar_lines (f, make_fixnum (0), Qnil);
1216
1217
1218 adjust_frame_glyphs (f);
1219
1220 if (!noninteractive)
1221 init_frame_faces (f);
1222
1223 last_nonminibuf_frame = f;
1224
1225 f->can_set_window_size = true;
1226 f->after_make_frame = true;
1227
1228 return f;
1229 }
1230
1231
1232 static struct frame *
1233 make_terminal_frame (struct terminal *terminal)
1234 {
1235 register struct frame *f;
1236 Lisp_Object frame;
1237 char name[sizeof "F" + INT_STRLEN_BOUND (tty_frame_count)];
1238
1239 if (!terminal->name)
1240 error ("Terminal is not live, can't create new frames on it");
1241
1242 f = make_frame (1);
1243
1244 XSETFRAME (frame, f);
1245 Vframe_list = Fcons (frame, Vframe_list);
1246
1247 fset_name (f, make_formatted_string (name, "F%"PRIdMAX, ++tty_frame_count));
1248
1249 SET_FRAME_VISIBLE (f, 1);
1250
1251 f->terminal = terminal;
1252 f->terminal->reference_count++;
1253 #ifdef MSDOS
1254 f->output_data.tty = &the_only_tty_output;
1255 f->output_data.tty->display_info = &the_only_display_info;
1256 if (!inhibit_window_system
1257 && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))
1258 || XFRAME (selected_frame)->output_method == output_msdos_raw))
1259 f->output_method = output_msdos_raw;
1260 else
1261 f->output_method = output_termcap;
1262 #else
1263 f->output_method = output_termcap;
1264 create_tty_output (f);
1265 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
1266 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
1267 #endif
1268
1269 #ifdef HAVE_WINDOW_SYSTEM
1270 f->vertical_scroll_bar_type = vertical_scroll_bar_none;
1271 f->horizontal_scroll_bars = false;
1272 #endif
1273
1274 FRAME_MENU_BAR_LINES (f) = NILP (Vmenu_bar_mode) ? 0 : 1;
1275 FRAME_TAB_BAR_LINES (f) = NILP (Vtab_bar_mode) ? 0 : 1;
1276 FRAME_LINES (f) = FRAME_LINES (f) - FRAME_MENU_BAR_LINES (f)
1277 - FRAME_TAB_BAR_LINES (f);
1278 FRAME_MENU_BAR_HEIGHT (f) = FRAME_MENU_BAR_LINES (f) * FRAME_LINE_HEIGHT (f);
1279 FRAME_TAB_BAR_HEIGHT (f) = FRAME_TAB_BAR_LINES (f) * FRAME_LINE_HEIGHT (f);
1280 FRAME_TEXT_HEIGHT (f) = FRAME_TEXT_HEIGHT (f) - FRAME_MENU_BAR_HEIGHT (f)
1281 - FRAME_TAB_BAR_HEIGHT (f);
1282
1283
1284 if (FRAMEP (FRAME_TTY (f)->top_frame)
1285 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame)))
1286 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f)->top_frame), 2);
1287
1288 FRAME_TTY (f)->top_frame = frame;
1289
1290 if (!noninteractive)
1291 init_frame_faces (f);
1292
1293 return f;
1294 }
1295
1296
1297
1298
1299
1300 static Lisp_Object
1301 get_future_frame_param (Lisp_Object parameter,
1302 Lisp_Object supplied_parms,
1303 char *current_value)
1304 {
1305 Lisp_Object result;
1306
1307 result = Fassq (parameter, supplied_parms);
1308 if (NILP (result))
1309 result = Fassq (parameter, XFRAME (selected_frame)->param_alist);
1310 if (NILP (result) && current_value != NULL)
1311 result = build_string (current_value);
1312 if (!NILP (result) && !STRINGP (result))
1313 result = XCDR (result);
1314 if (NILP (result) || !STRINGP (result))
1315 result = Qnil;
1316
1317 return result;
1318 }
1319
1320 DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame,
1321 1, 1, 0,
1322 doc:
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336 )
1337 (Lisp_Object parms)
1338 {
1339 struct frame *f;
1340 struct terminal *t = NULL;
1341 Lisp_Object frame;
1342 struct frame *sf = SELECTED_FRAME ();
1343
1344 #ifdef MSDOS
1345 if (sf->output_method != output_msdos_raw
1346 && sf->output_method != output_termcap)
1347 emacs_abort ();
1348 #else
1349
1350 #ifdef WINDOWSNT
1351 if (sf->output_method != output_termcap)
1352 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
1353 #endif
1354 #endif
1355
1356 {
1357 Lisp_Object terminal;
1358
1359 terminal = Fassq (Qterminal, parms);
1360 if (CONSP (terminal))
1361 {
1362 terminal = XCDR (terminal);
1363 t = decode_live_terminal (terminal);
1364 }
1365 #ifdef MSDOS
1366 if (t && t != the_only_display_info.terminal)
1367
1368 error ("Multiple terminals are not supported on this platform");
1369 if (!t)
1370 t = the_only_display_info.terminal;
1371 #endif
1372 }
1373
1374 if (!t)
1375 {
1376 char *name = 0, *type = 0;
1377 Lisp_Object tty, tty_type;
1378 USE_SAFE_ALLOCA;
1379
1380 tty = get_future_frame_param
1381 (Qtty, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
1382 ? FRAME_TTY (XFRAME (selected_frame))->name
1383 : NULL));
1384 if (!NILP (tty))
1385 SAFE_ALLOCA_STRING (name, tty);
1386
1387 tty_type = get_future_frame_param
1388 (Qtty_type, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
1389 ? FRAME_TTY (XFRAME (selected_frame))->type
1390 : NULL));
1391 if (!NILP (tty_type))
1392 SAFE_ALLOCA_STRING (type, tty_type);
1393
1394 t = init_tty (name, type, 0);
1395 SAFE_FREE ();
1396 }
1397
1398 f = make_terminal_frame (t);
1399
1400 {
1401 int width, height;
1402 get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height);
1403
1404 adjust_frame_size (f, width, height - FRAME_TOP_MARGIN (f),
1405 5, 0, Qterminal_frame);
1406 }
1407
1408 adjust_frame_glyphs (f);
1409 calculate_costs (f);
1410 XSETFRAME (frame, f);
1411
1412 store_in_alist (&parms, Qtty_type, build_string (t->display_info.tty->type));
1413 store_in_alist (&parms, Qtty,
1414 (t->display_info.tty->name
1415 ? build_string (t->display_info.tty->name)
1416 : Qnil));
1417
1418
1419
1420 fset_face_hash_table (f, Fcopy_hash_table (sf->face_hash_table));
1421
1422
1423
1424 ptrdiff_t idx = 0;
1425 struct Lisp_Hash_Table *table = XHASH_TABLE (f->face_hash_table);
1426 for (idx = 0; idx < table->count; ++idx)
1427 set_hash_value_slot (table, idx, Fcopy_sequence (HASH_VALUE (table, idx)));
1428
1429
1430
1431
1432 store_in_alist (&parms, Qminibuffer, Qt);
1433 Fmodify_frame_parameters (frame, parms);
1434
1435 f->can_set_window_size = true;
1436 f->after_make_frame = true;
1437
1438 return frame;
1439 }
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457 Lisp_Object
1458 do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object norecord)
1459 {
1460 struct frame *sf = SELECTED_FRAME (), *f;
1461
1462
1463
1464 if (CONSP (frame)
1465 && EQ (XCAR (frame), Qswitch_frame)
1466 && CONSP (XCDR (frame)))
1467 frame = XCAR (XCDR (frame));
1468
1469
1470
1471
1472 CHECK_FRAME (frame);
1473 f = XFRAME (frame);
1474
1475 if (!FRAME_LIVE_P (f) || FRAME_TOOLTIP_P (f))
1476 return Qnil;
1477 else if (f == sf)
1478 return frame;
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489 #ifdef HAVE_WINDOW_SYSTEM
1490 if (track && FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->get_focus_frame)
1491 {
1492 Lisp_Object gfocus;
1493
1494
1495 Lisp_Object focus;
1496
1497
1498
1499
1500 gfocus = FRAME_TERMINAL (f)->get_focus_frame (f);
1501 if (FRAMEP (gfocus))
1502 {
1503 focus = FRAME_FOCUS_FRAME (XFRAME (gfocus));
1504 if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ())
1505
1506
1507
1508
1509
1510
1511
1512
1513 Fredirect_frame_focus (gfocus, frame);
1514 }
1515 }
1516 #endif
1517
1518 if (!for_deletion && FRAME_HAS_MINIBUF_P (sf))
1519 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1);
1520
1521 if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
1522 {
1523 struct tty_display_info *tty = FRAME_TTY (f);
1524 Lisp_Object top_frame = tty->top_frame;
1525
1526
1527
1528
1529 if (!EQ (frame, top_frame))
1530 {
1531 if (FRAMEP (top_frame))
1532
1533 SET_FRAME_VISIBLE (XFRAME (top_frame), 2);
1534 SET_FRAME_VISIBLE (f, 1);
1535
1536
1537
1538 if (FRAME_COLS (f) != FrameCols (tty))
1539 FrameCols (tty) = FRAME_COLS (f);
1540 if (FRAME_TOTAL_LINES (f) != FrameRows (tty))
1541 FrameRows (tty) = FRAME_TOTAL_LINES (f);
1542 }
1543 tty->top_frame = frame;
1544 }
1545
1546 sf->select_mini_window_flag = MINI_WINDOW_P (XWINDOW (sf->selected_window));
1547
1548 move_minibuffers_onto_frame (sf, frame, for_deletion);
1549
1550
1551
1552
1553 if (EQ (f->selected_window, f->minibuffer_window)
1554
1555
1556 && NILP (Fminibufferp (XWINDOW (f->minibuffer_window)->contents, Qt)))
1557 {
1558 Lisp_Object w = call1 (Qget_mru_window, frame);
1559 if (WINDOW_LIVE_P (w))
1560 Fset_frame_selected_window (frame, w, Qnil);
1561 }
1562
1563
1564
1565
1566
1567 selected_frame = frame;
1568
1569 if (f->select_mini_window_flag
1570 && !NILP (Fminibufferp (XWINDOW (f->minibuffer_window)->contents, Qt)))
1571 f->selected_window = f->minibuffer_window;
1572 f->select_mini_window_flag = false;
1573
1574 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame)))
1575 last_nonminibuf_frame = XFRAME (selected_frame);
1576
1577 Fselect_window (f->selected_window, norecord);
1578
1579
1580
1581
1582
1583
1584
1585 #ifdef HAVE_WINDOW_SYSTEM
1586 if (!frame_ancestor_p (f, sf))
1587 #endif
1588 internal_last_event_frame = Qnil;
1589
1590 return frame;
1591 }
1592
1593 DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
1594 doc:
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607 )
1608 (Lisp_Object frame, Lisp_Object norecord)
1609 {
1610 struct frame *f;
1611
1612 CHECK_LIVE_FRAME (frame);
1613 f = XFRAME (frame);
1614
1615 if (FRAME_TOOLTIP_P (f))
1616
1617 error ("Cannot select a tooltip frame");
1618 else
1619 return do_switch_frame (frame, 1, 0, norecord);
1620 }
1621
1622 DEFUN ("handle-switch-frame", Fhandle_switch_frame,
1623 Shandle_switch_frame, 1, 1, "^e",
1624 doc:
1625
1626
1627
1628 )
1629 (Lisp_Object event)
1630 {
1631
1632 kset_prefix_arg (current_kboard, Vcurrent_prefix_arg);
1633 run_hook (Qmouse_leave_buffer_hook);
1634
1635 return do_switch_frame (event, 0, 0, Qnil);
1636 }
1637
1638 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
1639 doc: )
1640 (void)
1641 {
1642 return selected_frame;
1643 }
1644
1645 DEFUN ("old-selected-frame", Fold_selected_frame,
1646 Sold_selected_frame, 0, 0, 0,
1647 doc:
1648
1649
1650
1651 )
1652 (void)
1653 {
1654 return old_selected_frame;
1655 }
1656
1657 DEFUN ("frame-list", Fframe_list, Sframe_list,
1658 0, 0, 0,
1659 doc:
1660 )
1661 (void)
1662 {
1663 #ifdef HAVE_WINDOW_SYSTEM
1664 Lisp_Object list = Qnil, tail, frame;
1665
1666 FOR_EACH_FRAME (tail, frame)
1667 if (!FRAME_TOOLTIP_P (XFRAME (frame)))
1668 list = Fcons (frame, list);
1669
1670 return Fnreverse (list);
1671 #else
1672 return Fcopy_sequence (Vframe_list);
1673 #endif
1674 }
1675
1676 DEFUN ("frame-parent", Fframe_parent, Sframe_parent,
1677 0, 1, 0,
1678 doc:
1679
1680
1681
1682
1683
1684
1685
1686 )
1687 (Lisp_Object frame)
1688 {
1689 struct frame *f = decode_live_frame (frame);
1690 struct frame *p = FRAME_PARENT_FRAME (f);
1691 Lisp_Object parent;
1692
1693
1694
1695 if (p)
1696 {
1697 XSETFRAME (parent, p);
1698
1699 return parent;
1700 }
1701 else
1702 return Qnil;
1703 }
1704
1705 #ifdef HAVE_WINDOW_SYSTEM
1706 bool
1707 frame_ancestor_p (struct frame *af, struct frame *df)
1708 {
1709 struct frame *pf = FRAME_PARENT_FRAME (df);
1710
1711 while (pf)
1712 {
1713 if (pf == af)
1714 return true;
1715 else
1716 pf = FRAME_PARENT_FRAME (pf);
1717 }
1718
1719 return false;
1720 }
1721 #endif
1722
1723 DEFUN ("frame-ancestor-p", Fframe_ancestor_p, Sframe_ancestor_p,
1724 2, 2, 0,
1725 doc:
1726
1727
1728
1729 )
1730 (Lisp_Object ancestor, Lisp_Object descendant)
1731 {
1732 #ifdef HAVE_WINDOW_SYSTEM
1733 struct frame *af = decode_live_frame (ancestor);
1734 struct frame *df = decode_live_frame (descendant);
1735
1736 return frame_ancestor_p (af, df) ? Qt : Qnil;
1737 #else
1738 return Qnil;
1739 #endif
1740 }
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752 static Lisp_Object
1753 candidate_frame (Lisp_Object candidate, Lisp_Object frame, Lisp_Object minibuf)
1754 {
1755 struct frame *c = XFRAME (candidate), *f = XFRAME (frame);
1756
1757 if ((!FRAME_TERMCAP_P (c) && !FRAME_TERMCAP_P (f)
1758 && FRAME_KBOARD (c) == FRAME_KBOARD (f))
1759 || (FRAME_TERMCAP_P (c) && FRAME_TERMCAP_P (f)
1760 && FRAME_TTY (c) == FRAME_TTY (f)))
1761 {
1762 if (!NILP (get_frame_param (c, Qno_other_frame)))
1763 return Qnil;
1764 else if (NILP (minibuf))
1765 {
1766 if (!FRAME_MINIBUF_ONLY_P (c))
1767 return candidate;
1768 }
1769 else if (EQ (minibuf, Qvisible))
1770 {
1771 if (FRAME_VISIBLE_P (c))
1772 return candidate;
1773 }
1774 else if (WINDOWP (minibuf))
1775 {
1776 if (EQ (FRAME_MINIBUF_WINDOW (c), minibuf)
1777 || EQ (WINDOW_FRAME (XWINDOW (minibuf)), candidate)
1778 || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
1779 FRAME_FOCUS_FRAME (c)))
1780 return candidate;
1781 }
1782 else if (FIXNUMP (minibuf) && XFIXNUM (minibuf) == 0)
1783 {
1784 if (FRAME_VISIBLE_P (c) || FRAME_ICONIFIED_P (c))
1785 return candidate;
1786 }
1787 else
1788 return candidate;
1789 }
1790 return Qnil;
1791 }
1792
1793
1794
1795 static Lisp_Object
1796 next_frame (Lisp_Object frame, Lisp_Object minibuf)
1797 {
1798 Lisp_Object f, tail;
1799 int passed = 0;
1800
1801 eassume (CONSP (Vframe_list));
1802
1803 while (passed < 2)
1804 FOR_EACH_FRAME (tail, f)
1805 {
1806 if (passed)
1807 {
1808 f = candidate_frame (f, frame, minibuf);
1809 if (!NILP (f))
1810 return f;
1811 }
1812 if (EQ (frame, f))
1813 passed++;
1814 }
1815 return frame;
1816 }
1817
1818
1819
1820 static Lisp_Object
1821 prev_frame (Lisp_Object frame, Lisp_Object minibuf)
1822 {
1823 Lisp_Object f, tail, prev = Qnil;
1824
1825 eassume (CONSP (Vframe_list));
1826
1827 FOR_EACH_FRAME (tail, f)
1828 {
1829 if (EQ (frame, f) && !NILP (prev))
1830 return prev;
1831 f = candidate_frame (f, frame, minibuf);
1832 if (!NILP (f))
1833 prev = f;
1834 }
1835
1836
1837 if (NILP (prev))
1838
1839
1840 return frame;
1841 else
1842
1843
1844
1845 return prev;
1846 }
1847
1848
1849 DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0,
1850 doc:
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864 )
1865 (Lisp_Object frame, Lisp_Object miniframe)
1866 {
1867 if (NILP (frame))
1868 frame = selected_frame;
1869 CHECK_LIVE_FRAME (frame);
1870 return next_frame (frame, miniframe);
1871 }
1872
1873 DEFUN ("previous-frame", Fprevious_frame, Sprevious_frame, 0, 2, 0,
1874 doc:
1875
1876
1877
1878
1879
1880
1881
1882
1883 )
1884 (Lisp_Object frame, Lisp_Object miniframe)
1885 {
1886 if (NILP (frame))
1887 frame = selected_frame;
1888 CHECK_LIVE_FRAME (frame);
1889 return prev_frame (frame, miniframe);
1890 }
1891
1892 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame,
1893 Slast_nonminibuf_frame, 0, 0, 0,
1894 doc: )
1895 (void)
1896 {
1897 Lisp_Object frame = Qnil;
1898
1899 if (last_nonminibuf_frame)
1900 XSETFRAME (frame, last_nonminibuf_frame);
1901
1902 return frame;
1903 }
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920 static bool
1921 other_frames (struct frame *f, bool invisible, bool force)
1922 {
1923 Lisp_Object frames, frame, frame1;
1924 Lisp_Object minibuffer_window = FRAME_MINIBUF_WINDOW (f);
1925
1926 XSETFRAME (frame, f);
1927 if (WINDOWP (minibuffer_window)
1928 && !EQ (frame, WINDOW_FRAME (XWINDOW (minibuffer_window))))
1929 minibuffer_window = Qnil;
1930
1931 FOR_EACH_FRAME (frames, frame1)
1932 {
1933 struct frame *f1 = XFRAME (frame1);
1934
1935 if (f != f1)
1936 {
1937
1938
1939 #ifdef HAVE_X_WINDOWS
1940 if (FRAME_WINDOW_P (f1))
1941 x_sync (f1);
1942 #endif
1943 if (!FRAME_TOOLTIP_P (f1)
1944
1945
1946 && !FRAME_PARENT_FRAME (f1)
1947
1948
1949 && (invisible || NILP (get_frame_param (f1, Qdelete_before)))
1950
1951
1952 && (FRAME_VISIBLE_P (f1) || FRAME_ICONIFIED_P (f1)
1953 || (!invisible
1954 && (force
1955
1956
1957 || (FRAME_WINDOW_P (f1) && !FRAME_WINDOW_P (f))))))
1958 return true;
1959 }
1960 }
1961
1962 return false;
1963 }
1964
1965
1966
1967
1968
1969
1970
1971
1972 Lisp_Object
1973 delete_frame (Lisp_Object frame, Lisp_Object force)
1974 {
1975 struct frame *f = decode_any_frame (frame);
1976 struct frame *sf;
1977 struct kboard *kb;
1978 Lisp_Object frames, frame1;
1979 int is_tooltip_frame;
1980 bool nochild = !FRAME_PARENT_FRAME (f);
1981 Lisp_Object minibuffer_child_frame = Qnil;
1982 #ifdef HAVE_X_WINDOWS
1983 specpdl_ref ref;
1984 #endif
1985
1986 if (!FRAME_LIVE_P (f))
1987 return Qnil;
1988 else if (!EQ (force, Qnoelisp) && !other_frames (f, false, !NILP (force)))
1989 {
1990 if (NILP (force))
1991 error ("Attempt to delete the sole visible or iconified frame");
1992 else
1993 error ("Attempt to delete the only frame");
1994 }
1995 #ifdef HAVE_X_WINDOWS
1996 else if ((x_dnd_in_progress && f == x_dnd_frame)
1997 || (x_dnd_waiting_for_finish && f == x_dnd_finish_frame))
1998 error ("Attempt to delete the drop source frame");
1999 #endif
2000 #ifdef HAVE_HAIKU
2001 else if (f == haiku_dnd_frame)
2002 error ("Attempt to delete the drop source frame");
2003 #endif
2004
2005 XSETFRAME (frame, f);
2006
2007
2008
2009 FOR_EACH_FRAME (frames, frame1)
2010 {
2011 struct frame *f1 = XFRAME (frame1);
2012
2013 if (EQ (frame1, frame) || FRAME_TOOLTIP_P (f1))
2014 continue;
2015 else if (FRAME_PARENT_FRAME (f1) == f)
2016 {
2017 if (FRAME_HAS_MINIBUF_P (f1) && !FRAME_HAS_MINIBUF_P (f)
2018 && EQ (FRAME_MINIBUF_WINDOW (f), FRAME_MINIBUF_WINDOW (f1)))
2019
2020
2021
2022 {
2023 Fmodify_frame_parameters
2024 (frame1, Fcons (Fcons (Qparent_frame, Qnil), Qnil));
2025 minibuffer_child_frame = frame1;
2026 }
2027 else
2028 delete_frame (frame1, Qnil);
2029 }
2030 else if (nochild
2031 && EQ (get_frame_param (XFRAME (frame1), Qdelete_before), frame))
2032
2033
2034
2035 delete_frame (frame1, Qnil);
2036 }
2037
2038
2039
2040 if (FRAME_HAS_MINIBUF_P (f))
2041 {
2042 FOR_EACH_FRAME (frames, frame1)
2043 {
2044 Lisp_Object fminiw;
2045
2046 if (EQ (frame1, frame))
2047 continue;
2048
2049 fminiw = FRAME_MINIBUF_WINDOW (XFRAME (frame1));
2050
2051 if (WINDOWP (fminiw) && EQ (frame, WINDOW_FRAME (XWINDOW (fminiw))))
2052 {
2053
2054
2055 if (EQ (force, Qnoelisp))
2056 delete_frame (frame1, Qnoelisp);
2057 else
2058 error ("Attempt to delete a surrogate minibuffer frame");
2059 }
2060 }
2061 }
2062
2063 is_tooltip_frame = FRAME_TOOLTIP_P (f);
2064
2065
2066
2067
2068
2069 if (NILP (Vrun_hooks) || is_tooltip_frame)
2070 ;
2071 else if (EQ (force, Qnoelisp))
2072 pending_funcalls
2073 = Fcons (list3 (Qrun_hook_with_args, Qdelete_frame_functions, frame),
2074 pending_funcalls);
2075 else
2076 {
2077 #ifdef HAVE_X_WINDOWS
2078
2079 x_clipboard_manager_save_frame (frame);
2080 #endif
2081
2082 safe_call2 (Qrun_hook_with_args, Qdelete_frame_functions, frame);
2083 }
2084
2085
2086
2087 if (!FRAME_LIVE_P (f))
2088 return Qnil;
2089 else if (!EQ (force, Qnoelisp) && !other_frames (f, false, !NILP (force)))
2090 {
2091 if (NILP (force))
2092 error ("Attempt to delete the sole visible or iconified frame");
2093 else
2094 error ("Attempt to delete the only frame");
2095 }
2096
2097
2098
2099 sf = SELECTED_FRAME ();
2100
2101 if (f == sf)
2102 {
2103 Lisp_Object tail;
2104 Lisp_Object frame1 UNINIT;
2105 eassume (CONSP (Vframe_list));
2106
2107
2108
2109
2110 FOR_EACH_FRAME (tail, frame1)
2111 {
2112 struct frame *f1 = XFRAME (frame1);
2113
2114 if (!EQ (frame, frame1)
2115 && !FRAME_TOOLTIP_P (f1)
2116 && FRAME_TERMINAL (f) == FRAME_TERMINAL (f1)
2117 && FRAME_VISIBLE_P (f1))
2118 break;
2119 }
2120
2121
2122 if (NILP (frame1) || EQ (frame1, frame))
2123 {
2124 FOR_EACH_FRAME (tail, frame1)
2125 {
2126 struct frame *f1 = XFRAME (frame1);
2127
2128 if (!EQ (frame, frame1)
2129 && FRAME_LIVE_P (f1)
2130 && !FRAME_TOOLTIP_P (f1))
2131 {
2132 if (FRAME_TERMCAP_P (f1) || FRAME_MSDOS_P (f1))
2133 {
2134 Lisp_Object top_frame = FRAME_TTY (f1)->top_frame;
2135
2136 if (!EQ (top_frame, frame))
2137 frame1 = top_frame;
2138 }
2139 break;
2140 }
2141 }
2142 }
2143 #ifdef NS_IMPL_COCOA
2144 else
2145
2146
2147
2148
2149
2150 Fraise_frame (frame1);
2151 #endif
2152
2153 do_switch_frame (frame1, 0, 1, Qnil);
2154 sf = SELECTED_FRAME ();
2155 }
2156 else
2157
2158
2159 move_minibuffers_onto_frame (f, selected_frame, true);
2160
2161
2162 if (EQ (f->minibuffer_window, echo_area_window))
2163 echo_area_window = sf->minibuffer_window;
2164
2165
2166 #ifdef HAVE_X_WINDOWS
2167 if (FRAME_X_P (f))
2168 {
2169
2170
2171
2172 ref = SPECPDL_INDEX ();
2173
2174 if (EQ (force, Qnoelisp))
2175 specbind (Qx_auto_preserve_selections, Qnil);
2176
2177 x_clear_frame_selections (f);
2178 unbind_to (ref, Qnil);
2179 }
2180 #endif
2181
2182 #ifdef HAVE_PGTK
2183 if (FRAME_PGTK_P (f))
2184 {
2185
2186
2187 swallow_events (false);
2188
2189 pgtk_clear_frame_selections (f);
2190 }
2191 #endif
2192
2193
2194
2195
2196
2197 free_glyphs (f);
2198
2199 #ifdef HAVE_WINDOW_SYSTEM
2200
2201 font_update_drivers (f, Qnil);
2202 #endif
2203
2204
2205
2206 delete_all_child_windows (f->root_window);
2207 fset_root_window (f, Qnil);
2208
2209 Vframe_list = Fdelq (frame, Vframe_list);
2210 SET_FRAME_VISIBLE (f, 0);
2211
2212
2213
2214
2215
2216 fset_menu_bar_vector (f, Qnil);
2217
2218
2219
2220 fset_buffer_list (f, Qnil);
2221 fset_buried_buffer_list (f, Qnil);
2222
2223 free_font_driver_list (f);
2224 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2225 xfree (f->namebuf);
2226 #endif
2227 xfree (f->decode_mode_spec_buffer);
2228 xfree (FRAME_INSERT_COST (f));
2229 xfree (FRAME_DELETEN_COST (f));
2230 xfree (FRAME_INSERTN_COST (f));
2231 xfree (FRAME_DELETE_COST (f));
2232
2233
2234
2235
2236
2237
2238
2239 {
2240 struct terminal *terminal;
2241 block_input ();
2242 if (FRAME_TERMINAL (f)->delete_frame_hook)
2243 (*FRAME_TERMINAL (f)->delete_frame_hook) (f);
2244 terminal = FRAME_TERMINAL (f);
2245 f->terminal = 0;
2246 unblock_input ();
2247
2248
2249
2250 terminal->reference_count--;
2251 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
2252
2253
2254
2255
2256
2257
2258
2259 if (terminal->reference_count == 0
2260 && (terminal->type == output_x_window
2261 || terminal->type == output_pgtk))
2262 terminal->reference_count = 1;
2263 #endif
2264
2265 if (terminal->reference_count == 0)
2266 {
2267 Lisp_Object tmp;
2268 XSETTERMINAL (tmp, terminal);
2269
2270 kb = NULL;
2271
2272
2273
2274
2275 if (!EQ (force, Qnoelisp))
2276 Fdelete_terminal (tmp, NILP (force) ? Qt : force);
2277 }
2278 else
2279 kb = terminal->kboard;
2280 }
2281
2282
2283
2284 if (f == last_nonminibuf_frame)
2285 {
2286 last_nonminibuf_frame = 0;
2287
2288 FOR_EACH_FRAME (frames, frame1)
2289 {
2290 struct frame *f1 = XFRAME (frame1);
2291
2292 if (!FRAME_MINIBUF_ONLY_P (f1))
2293 {
2294 last_nonminibuf_frame = f1;
2295 break;
2296 }
2297 }
2298 }
2299
2300
2301
2302 if (kb != NULL)
2303 {
2304
2305 Lisp_Object frame_on_same_kboard = Qnil;
2306
2307 FOR_EACH_FRAME (frames, frame1)
2308 if (kb == FRAME_KBOARD (XFRAME (frame1)))
2309 frame_on_same_kboard = frame1;
2310
2311 if (NILP (frame_on_same_kboard))
2312 not_single_kboard_state (kb);
2313 }
2314
2315
2316
2317
2318
2319 if (kb != NULL && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame)))
2320 {
2321
2322 Lisp_Object frame_with_minibuf = Qnil;
2323
2324 Lisp_Object frame_on_same_kboard = Qnil;
2325
2326 FOR_EACH_FRAME (frames, frame1)
2327 {
2328 struct frame *f1 = XFRAME (frame1);
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341 if (kb == FRAME_KBOARD (f1))
2342 {
2343 frame_on_same_kboard = frame1;
2344 if (FRAME_HAS_MINIBUF_P (f1))
2345 {
2346 frame_with_minibuf = frame1;
2347 if (FRAME_MINIBUF_ONLY_P (f1))
2348 break;
2349 }
2350 }
2351 }
2352
2353 if (!NILP (frame_on_same_kboard))
2354 {
2355
2356
2357
2358
2359
2360
2361 if (NILP (frame_with_minibuf))
2362 emacs_abort ();
2363
2364 kset_default_minibuffer_frame (kb, frame_with_minibuf);
2365 }
2366 else
2367
2368 kset_default_minibuffer_frame (kb, Qnil);
2369 }
2370
2371
2372
2373 if (!is_tooltip_frame)
2374 update_mode_lines = 15;
2375
2376
2377 if (NILP (Vrun_hooks) || is_tooltip_frame)
2378 ;
2379 else if (EQ (force, Qnoelisp))
2380 pending_funcalls
2381 = Fcons (list3 (Qrun_hook_with_args, Qafter_delete_frame_functions, frame),
2382 pending_funcalls);
2383 else
2384 safe_call2 (Qrun_hook_with_args, Qafter_delete_frame_functions, frame);
2385
2386 if (!NILP (minibuffer_child_frame))
2387
2388
2389
2390 {
2391 struct frame *f1 = XFRAME (minibuffer_child_frame);
2392
2393 if (FRAME_LIVE_P (f1))
2394 {
2395 Lisp_Object window1 = FRAME_ROOT_WINDOW (f1);
2396 Lisp_Object frame2;
2397
2398 FOR_EACH_FRAME (frames, frame2)
2399 {
2400 struct frame *f2 = XFRAME (frame2);
2401
2402 if (EQ (frame2, minibuffer_child_frame) || FRAME_TOOLTIP_P (f2))
2403 continue;
2404 else if (EQ (FRAME_MINIBUF_WINDOW (f2), window1))
2405 {
2406
2407
2408
2409 if (!FRAME_VISIBLE_P (f1) && !FRAME_ICONIFIED_P (f1))
2410 Fmake_frame_visible (minibuffer_child_frame);
2411
2412 return Qnil;
2413 }
2414 }
2415
2416
2417
2418
2419
2420 if (EQ (force, Qnoelisp) || other_frames (f1, false, !NILP (force)))
2421 delete_frame (minibuffer_child_frame, Qnoelisp);
2422 }
2423 }
2424
2425 return Qnil;
2426 }
2427
2428 DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
2429 doc:
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442 )
2443 (Lisp_Object frame, Lisp_Object force)
2444 {
2445 return delete_frame (frame, !NILP (force) ? Qt : Qnil);
2446 }
2447
2448 #ifdef HAVE_WINDOW_SYSTEM
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468 enum internal_border_part
2469 frame_internal_border_part (struct frame *f, int x, int y)
2470 {
2471 int border = FRAME_INTERNAL_BORDER_WIDTH (f);
2472 int offset = FRAME_LINE_HEIGHT (f);
2473 int width = FRAME_PIXEL_WIDTH (f);
2474 int height = FRAME_PIXEL_HEIGHT (f);
2475 enum internal_border_part part = INTERNAL_BORDER_NONE;
2476
2477 if (offset < border)
2478
2479
2480 offset = border;
2481
2482 if (offset < x && x < width - offset)
2483
2484 {
2485 if (0 <= y && y <= border)
2486 part = INTERNAL_BORDER_TOP_EDGE;
2487 else if (height - border <= y && y <= height)
2488 part = INTERNAL_BORDER_BOTTOM_EDGE;
2489 }
2490 else if (offset < y && y < height - offset)
2491
2492 {
2493 if (0 <= x && x <= border)
2494 part = INTERNAL_BORDER_LEFT_EDGE;
2495 else if (width - border <= x && x <= width)
2496 part = INTERNAL_BORDER_RIGHT_EDGE;
2497 }
2498 else
2499 {
2500
2501 int half_width = width / 2;
2502 int half_height = height / 2;
2503
2504 if (0 <= x && x <= border)
2505 {
2506
2507 if (0 <= y && y <= half_height)
2508 part = INTERNAL_BORDER_TOP_LEFT_CORNER;
2509 else if (half_height < y && y <= height)
2510 part = INTERNAL_BORDER_BOTTOM_LEFT_CORNER;
2511 }
2512 else if (width - border <= x && x <= width)
2513 {
2514
2515 if (0 <= y && y <= half_height)
2516 part = INTERNAL_BORDER_TOP_RIGHT_CORNER;
2517 else if (half_height < y && y <= height)
2518 part = INTERNAL_BORDER_BOTTOM_RIGHT_CORNER;
2519 }
2520 else if (0 <= y && y <= border)
2521 {
2522
2523 if (0 <= x && x <= half_width)
2524 part = INTERNAL_BORDER_TOP_LEFT_CORNER;
2525 else if (half_width < x && x <= width)
2526 part = INTERNAL_BORDER_TOP_RIGHT_CORNER;
2527 }
2528 else if (height - border <= y && y <= height)
2529 {
2530
2531 if (0 <= x && x <= half_width)
2532 part = INTERNAL_BORDER_BOTTOM_LEFT_CORNER;
2533 else if (half_width < x && x <= width)
2534 part = INTERNAL_BORDER_BOTTOM_RIGHT_CORNER;
2535 }
2536 }
2537
2538 return part;
2539 }
2540 #endif
2541
2542
2543
2544 DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
2545 doc:
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557 )
2558 (void)
2559 {
2560 return mouse_position (true);
2561 }
2562
2563 Lisp_Object
2564 mouse_position (bool call_mouse_position_function)
2565 {
2566 struct frame *f;
2567 Lisp_Object lispy_dummy;
2568 Lisp_Object x, y, retval;
2569
2570 f = SELECTED_FRAME ();
2571 x = y = Qnil;
2572
2573
2574 if (FRAME_TERMINAL (f)->mouse_position_hook)
2575 {
2576 enum scroll_bar_part party_dummy;
2577 Time time_dummy;
2578 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
2579 &lispy_dummy, &party_dummy,
2580 &x, &y,
2581 &time_dummy);
2582 }
2583
2584 if (! NILP (x) && f)
2585 {
2586 int col = XFIXNUM (x);
2587 int row = XFIXNUM (y);
2588 pixel_to_glyph_coords (f, col, row, &col, &row, NULL, 1);
2589 XSETINT (x, col);
2590 XSETINT (y, row);
2591 }
2592 if (f)
2593 XSETFRAME (lispy_dummy, f);
2594 else
2595 lispy_dummy = Qnil;
2596 retval = Fcons (lispy_dummy, Fcons (x, y));
2597 if (call_mouse_position_function && !NILP (Vmouse_position_function))
2598 retval = call1 (Vmouse_position_function, retval);
2599 return retval;
2600 }
2601
2602 DEFUN ("mouse-pixel-position", Fmouse_pixel_position,
2603 Smouse_pixel_position, 0, 0, 0,
2604 doc:
2605
2606
2607
2608
2609
2610
2611
2612 )
2613 (void)
2614 {
2615 struct frame *f;
2616 Lisp_Object lispy_dummy;
2617 Lisp_Object x, y, retval;
2618
2619 f = SELECTED_FRAME ();
2620 x = y = Qnil;
2621
2622
2623 if (FRAME_TERMINAL (f)->mouse_position_hook)
2624 {
2625 enum scroll_bar_part party_dummy;
2626 Time time_dummy;
2627 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
2628 &lispy_dummy, &party_dummy,
2629 &x, &y,
2630 &time_dummy);
2631 }
2632
2633 if (f)
2634 XSETFRAME (lispy_dummy, f);
2635 else
2636 lispy_dummy = Qnil;
2637
2638 retval = Fcons (lispy_dummy, Fcons (x, y));
2639 if (!NILP (Vmouse_position_function))
2640 retval = call1 (Vmouse_position_function, retval);
2641 return retval;
2642 }
2643
2644 #ifdef HAVE_WINDOW_SYSTEM
2645
2646
2647
2648
2649 static void
2650 frame_char_to_pixel_position (struct frame *f, int x, int y,
2651 int *pix_x, int *pix_y)
2652 {
2653 *pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2;
2654 *pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2;
2655
2656 if (*pix_x < 0)
2657 *pix_x = 0;
2658 if (*pix_x > FRAME_PIXEL_WIDTH (f))
2659 *pix_x = FRAME_PIXEL_WIDTH (f);
2660
2661 if (*pix_y < 0)
2662 *pix_y = 0;
2663 if (*pix_y > FRAME_PIXEL_HEIGHT (f))
2664 *pix_y = FRAME_PIXEL_HEIGHT (f);
2665 }
2666
2667
2668
2669 static void
2670 frame_set_mouse_position (struct frame *f, int x, int y)
2671 {
2672 int pix_x, pix_y;
2673
2674 frame_char_to_pixel_position (f, x, y, &pix_x, &pix_y);
2675 frame_set_mouse_pixel_position (f, pix_x, pix_y);
2676 }
2677
2678 #endif
2679
2680 DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0,
2681 doc:
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694 )
2695 (Lisp_Object frame, Lisp_Object x, Lisp_Object y)
2696 {
2697 CHECK_LIVE_FRAME (frame);
2698 int xval = check_integer_range (x, INT_MIN, INT_MAX);
2699 int yval = check_integer_range (y, INT_MIN, INT_MAX);
2700
2701
2702 if (FRAME_WINDOW_P (XFRAME (frame)))
2703 {
2704 #ifdef HAVE_WINDOW_SYSTEM
2705
2706 frame_set_mouse_position (XFRAME (frame), xval, yval);
2707 #endif
2708 }
2709 #ifdef MSDOS
2710 else if (FRAME_MSDOS_P (XFRAME (frame)))
2711 {
2712 Fselect_frame (frame, Qnil);
2713 mouse_moveto (xval, yval);
2714 }
2715 #endif
2716 else
2717 {
2718 Fselect_frame (frame, Qnil);
2719 #ifdef HAVE_GPM
2720 term_mouse_moveto (xval, yval);
2721 #else
2722 (void) xval;
2723 (void) yval;
2724 #endif
2725 }
2726
2727 return Qnil;
2728 }
2729
2730 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position,
2731 Sset_mouse_pixel_position, 3, 3, 0,
2732 doc:
2733
2734
2735
2736
2737
2738
2739 )
2740 (Lisp_Object frame, Lisp_Object x, Lisp_Object y)
2741 {
2742 CHECK_LIVE_FRAME (frame);
2743 int xval = check_integer_range (x, INT_MIN, INT_MAX);
2744 int yval = check_integer_range (y, INT_MIN, INT_MAX);
2745
2746
2747 if (FRAME_WINDOW_P (XFRAME (frame)))
2748 {
2749
2750 #ifdef HAVE_WINDOW_SYSTEM
2751 frame_set_mouse_pixel_position (XFRAME (frame), xval, yval);
2752 #endif
2753 }
2754 #ifdef MSDOS
2755 else if (FRAME_MSDOS_P (XFRAME (frame)))
2756 {
2757 Fselect_frame (frame, Qnil);
2758 mouse_moveto (xval, yval);
2759 }
2760 #endif
2761 else
2762 {
2763 Fselect_frame (frame, Qnil);
2764 #ifdef HAVE_GPM
2765 term_mouse_moveto (xval, yval);
2766 #else
2767 (void) xval;
2768 (void) yval;
2769 #endif
2770
2771 }
2772
2773 return Qnil;
2774 }
2775
2776 static void make_frame_visible_1 (Lisp_Object);
2777
2778 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
2779 0, 1, "",
2780 doc:
2781 )
2782 (Lisp_Object frame)
2783 {
2784 struct frame *f = decode_live_frame (frame);
2785
2786 if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->frame_visible_invisible_hook)
2787 FRAME_TERMINAL (f)->frame_visible_invisible_hook (f, true);
2788
2789 make_frame_visible_1 (f->root_window);
2790
2791
2792
2793
2794 XSETFRAME (frame, f);
2795 return frame;
2796 }
2797
2798
2799
2800
2801 static void
2802 make_frame_visible_1 (Lisp_Object window)
2803 {
2804 struct window *w;
2805
2806 for (; !NILP (window); window = w->next)
2807 {
2808 w = XWINDOW (window);
2809 if (WINDOWP (w->contents))
2810 make_frame_visible_1 (w->contents);
2811 else
2812 bset_display_time (XBUFFER (w->contents), Fcurrent_time ());
2813 }
2814 }
2815
2816 DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible,
2817 0, 2, "",
2818 doc:
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828 )
2829 (Lisp_Object frame, Lisp_Object force)
2830 {
2831 struct frame *f = decode_live_frame (frame);
2832
2833 if (NILP (force) && !other_frames (f, true, false))
2834 error ("Attempt to make invisible the sole visible or iconified frame");
2835
2836 if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->frame_visible_invisible_hook)
2837 FRAME_TERMINAL (f)->frame_visible_invisible_hook (f, false);
2838
2839
2840 windows_or_buffers_changed = 16;
2841
2842 return Qnil;
2843 }
2844
2845 DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
2846 0, 1, "",
2847 doc:
2848
2849
2850
2851 )
2852 (Lisp_Object frame)
2853 {
2854 struct frame *f = decode_live_frame (frame);
2855 #ifdef HAVE_WINDOW_SYSTEM
2856 Lisp_Object parent = f->parent_frame;
2857
2858 if (!NILP (parent))
2859 {
2860 if (NILP (iconify_child_frame))
2861
2862 return Qnil;
2863 else if (EQ (iconify_child_frame, Qiconify_top_level))
2864 {
2865
2866 Ficonify_frame (parent);
2867 return Qnil;
2868 }
2869 else if (EQ (iconify_child_frame, Qmake_invisible))
2870 {
2871
2872 Fmake_frame_invisible (frame, Qnil);
2873 return Qnil;
2874 }
2875 }
2876 #endif
2877
2878 if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->iconify_frame_hook)
2879 FRAME_TERMINAL (f)->iconify_frame_hook (f);
2880
2881 return Qnil;
2882 }
2883
2884 DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
2885 1, 1, 0,
2886 doc:
2887
2888
2889
2890
2891
2892
2893
2894 )
2895 (Lisp_Object frame)
2896 {
2897 CHECK_LIVE_FRAME (frame);
2898
2899 if (FRAME_VISIBLE_P (XFRAME (frame)))
2900 return Qt;
2901 if (FRAME_ICONIFIED_P (XFRAME (frame)))
2902 return Qicon;
2903 return Qnil;
2904 }
2905
2906 DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
2907 0, 0, 0,
2908 doc: )
2909 (void)
2910 {
2911 Lisp_Object tail, frame, value = Qnil;
2912
2913 FOR_EACH_FRAME (tail, frame)
2914 if (FRAME_VISIBLE_P (XFRAME (frame)))
2915 value = Fcons (frame, value);
2916
2917 return value;
2918 }
2919
2920
2921 DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "",
2922 doc:
2923
2924
2925
2926 )
2927 (Lisp_Object frame)
2928 {
2929 struct frame *f = decode_live_frame (frame);
2930
2931 XSETFRAME (frame, f);
2932
2933 if (FRAME_TERMCAP_P (f))
2934
2935 Fselect_frame (frame, Qnil);
2936 else
2937
2938 Fmake_frame_visible (frame);
2939
2940 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
2941 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, true);
2942
2943 return Qnil;
2944 }
2945
2946
2947 DEFUN ("lower-frame", Flower_frame, Slower_frame, 0, 1, "",
2948 doc:
2949
2950
2951 )
2952 (Lisp_Object frame)
2953 {
2954 struct frame *f = decode_live_frame (frame);
2955
2956 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
2957 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, false);
2958
2959 return Qnil;
2960 }
2961
2962
2963 DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
2964 1, 2, 0,
2965 doc:
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987 )
2988 (Lisp_Object frame, Lisp_Object focus_frame)
2989 {
2990
2991
2992
2993 struct frame *f = decode_any_frame (frame);
2994
2995 if (! NILP (focus_frame))
2996 CHECK_LIVE_FRAME (focus_frame);
2997
2998 fset_focus_frame (f, focus_frame);
2999
3000 if (FRAME_TERMINAL (f)->frame_rehighlight_hook)
3001 (*FRAME_TERMINAL (f)->frame_rehighlight_hook) (f);
3002
3003 return Qnil;
3004 }
3005
3006
3007 DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 0, 1, 0,
3008 doc:
3009
3010
3011 )
3012 (Lisp_Object frame)
3013 {
3014 return FRAME_FOCUS_FRAME (decode_live_frame (frame));
3015 }
3016
3017 DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 2, 0,
3018 doc:
3019
3020
3021
3022 )
3023 (Lisp_Object frame, Lisp_Object noactivate)
3024 {
3025 #ifdef HAVE_WINDOW_SYSTEM
3026 struct frame *f = decode_window_system_frame (frame);
3027 if (f && FRAME_TERMINAL (f)->focus_frame_hook)
3028 FRAME_TERMINAL (f)->focus_frame_hook (f, !NILP (noactivate));
3029 #endif
3030 return Qnil;
3031 }
3032
3033 DEFUN ("frame-after-make-frame",
3034 Fframe_after_make_frame,
3035 Sframe_after_make_frame, 2, 2, 0,
3036 doc:
3037
3038
3039
3040
3041
3042
3043
3044 )
3045 (Lisp_Object frame, Lisp_Object made)
3046 {
3047 struct frame *f = decode_live_frame (frame);
3048 f->after_make_frame = !NILP (made);
3049 f->inhibit_horizontal_resize = false;
3050 f->inhibit_vertical_resize = false;
3051 return made;
3052 }
3053
3054
3055
3056
3057 void
3058 frames_discard_buffer (Lisp_Object buffer)
3059 {
3060 Lisp_Object frame, tail;
3061
3062 FOR_EACH_FRAME (tail, frame)
3063 {
3064 fset_buffer_list
3065 (XFRAME (frame), Fdelq (buffer, XFRAME (frame)->buffer_list));
3066 fset_buried_buffer_list
3067 (XFRAME (frame), Fdelq (buffer, XFRAME (frame)->buried_buffer_list));
3068 }
3069 }
3070
3071
3072
3073
3074 void
3075 store_in_alist (Lisp_Object *alistptr, Lisp_Object prop, Lisp_Object val)
3076 {
3077 Lisp_Object tem = Fassq (prop, *alistptr);
3078 if (NILP (tem))
3079 *alistptr = Fcons (Fcons (prop, val), *alistptr);
3080 else
3081 Fsetcdr (tem, val);
3082 }
3083
3084 static int
3085 frame_name_fnn_p (char *str, ptrdiff_t len)
3086 {
3087 if (len > 1 && str[0] == 'F' && '0' <= str[1] && str[1] <= '9')
3088 {
3089 char *p = str + 2;
3090 while ('0' <= *p && *p <= '9')
3091 p++;
3092 if (p == str + len)
3093 return 1;
3094 }
3095 return 0;
3096 }
3097
3098
3099
3100
3101 static void
3102 set_term_frame_name (struct frame *f, Lisp_Object name)
3103 {
3104 f->explicit_name = ! NILP (name);
3105
3106
3107 if (NILP (name))
3108 {
3109 char namebuf[sizeof "F" + INT_STRLEN_BOUND (tty_frame_count)];
3110
3111
3112
3113 if (frame_name_fnn_p (SSDATA (f->name), SBYTES (f->name)))
3114 return;
3115
3116 name = make_formatted_string (namebuf, "F%"PRIdMAX, ++tty_frame_count);
3117 }
3118 else
3119 {
3120 CHECK_STRING (name);
3121
3122
3123 if (! NILP (Fstring_equal (name, f->name)))
3124 return;
3125
3126
3127
3128 if (frame_name_fnn_p (SSDATA (name), SBYTES (name)))
3129 error ("Frame names of the form F<num> are usurped by Emacs");
3130 }
3131
3132 fset_name (f, name);
3133 update_mode_lines = 16;
3134 }
3135
3136 void
3137 store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
3138 {
3139 register Lisp_Object old_alist_elt;
3140
3141 if (EQ (prop, Qminibuffer))
3142 {
3143 if (WINDOWP (val))
3144 {
3145 if (!MINI_WINDOW_P (XWINDOW (val)))
3146 error ("The `minibuffer' parameter does not specify a valid minibuffer window");
3147 else if (FRAME_MINIBUF_ONLY_P (f))
3148 {
3149 if (EQ (val, FRAME_MINIBUF_WINDOW (f)))
3150 val = Qonly;
3151 else
3152 error ("Can't change the minibuffer window of a minibuffer-only frame");
3153 }
3154 else if (FRAME_HAS_MINIBUF_P (f))
3155 {
3156 if (EQ (val, FRAME_MINIBUF_WINDOW (f)))
3157 val = Qt;
3158 else
3159 error ("Can't change the minibuffer window of a frame with its own minibuffer");
3160 }
3161 else
3162
3163 fset_minibuffer_window (f, val);
3164 }
3165 else
3166 {
3167 Lisp_Object old_val = Fcdr (Fassq (Qminibuffer, f->param_alist));
3168
3169 if (!NILP (old_val))
3170 {
3171 if (WINDOWP (old_val) && NILP (val))
3172
3173
3174 val = old_val;
3175 else if (!EQ (old_val, val))
3176 error ("Can't change the `minibuffer' parameter of this frame");
3177 }
3178 }
3179 }
3180
3181
3182
3183
3184
3185
3186
3187 else if (EQ (prop, Qparent_frame) || EQ (prop, Qdelete_before))
3188 {
3189 Lisp_Object oldval = Fcdr (Fassq (prop, f->param_alist));
3190
3191 if (!EQ (oldval, val) && !NILP (val))
3192 {
3193 Lisp_Object frame;
3194 Lisp_Object frame1 = val;
3195
3196 if (!FRAMEP (frame1) || !FRAME_LIVE_P (XFRAME (frame1)))
3197 error ("Invalid `%s' frame parameter",
3198 SSDATA (SYMBOL_NAME (prop)));
3199
3200 XSETFRAME (frame, f);
3201
3202 while (FRAMEP (frame1) && FRAME_LIVE_P (XFRAME (frame1)))
3203 if (EQ (frame1, frame))
3204 error ("Circular specification of `%s' frame parameter",
3205 SSDATA (SYMBOL_NAME (prop)));
3206 else
3207 frame1 = get_frame_param (XFRAME (frame1), prop);
3208 }
3209 }
3210
3211
3212
3213 else if (EQ (prop, Qbuffer_list))
3214 {
3215 Lisp_Object list = Qnil;
3216 for (; CONSP (val); val = XCDR (val))
3217 if (!NILP (Fbuffer_live_p (XCAR (val))))
3218 list = Fcons (XCAR (val), list);
3219 fset_buffer_list (f, Fnreverse (list));
3220 return;
3221 }
3222 else if (EQ (prop, Qburied_buffer_list))
3223 {
3224 Lisp_Object list = Qnil;
3225 for (; CONSP (val); val = XCDR (val))
3226 if (!NILP (Fbuffer_live_p (XCAR (val))))
3227 list = Fcons (XCAR (val), list);
3228 fset_buried_buffer_list (f, Fnreverse (list));
3229 return;
3230 }
3231 else if ((EQ (prop, Qscroll_bar_width) || EQ (prop, Qscroll_bar_height))
3232 && !NILP (val) && !RANGED_FIXNUMP (1, val, INT_MAX))
3233 {
3234 Lisp_Object old_val = Fcdr (Fassq (prop, f->param_alist));
3235
3236 val = old_val;
3237 }
3238
3239
3240
3241
3242 if (FRAME_TERMCAP_P (f) && EQ (prop, Qtty_color_mode)
3243 && f == FRAME_TTY (f)->previous_frame)
3244
3245 FRAME_TTY (f)->previous_frame = NULL;
3246
3247
3248 old_alist_elt = Fassq (prop, f->param_alist);
3249 if (NILP (old_alist_elt))
3250 fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist));
3251 else
3252 Fsetcdr (old_alist_elt, val);
3253
3254
3255
3256
3257 if (EQ (prop, Qbuffer_predicate))
3258 fset_buffer_predicate (f, val);
3259
3260 if (! FRAME_WINDOW_P (f))
3261 {
3262 if (EQ (prop, Qmenu_bar_lines))
3263 set_menu_bar_lines (f, val, make_fixnum (FRAME_MENU_BAR_LINES (f)));
3264 else if (EQ (prop, Qtab_bar_lines))
3265 set_tab_bar_lines (f, val, make_fixnum (FRAME_TAB_BAR_LINES (f)));
3266 else if (EQ (prop, Qname))
3267 set_term_frame_name (f, val);
3268 }
3269 }
3270
3271
3272
3273
3274 static Lisp_Object
3275 frame_unspecified_color (struct frame *f, Lisp_Object unspec)
3276 {
3277 return (!strncmp (SSDATA (unspec), unspecified_bg, SBYTES (unspec))
3278 ? tty_color_name (f, FRAME_BACKGROUND_PIXEL (f))
3279 : (!strncmp (SSDATA (unspec), unspecified_fg, SBYTES (unspec))
3280 ? tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)) : Qnil));
3281 }
3282
3283 DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
3284 doc:
3285
3286
3287 )
3288 (Lisp_Object frame)
3289 {
3290 Lisp_Object alist;
3291 struct frame *f = decode_any_frame (frame);
3292 int height, width;
3293
3294 if (!FRAME_LIVE_P (f))
3295 return Qnil;
3296
3297 alist = Fcopy_alist (f->param_alist);
3298
3299 if (!FRAME_WINDOW_P (f))
3300 {
3301 Lisp_Object elt;
3302
3303
3304
3305
3306 elt = Fassq (Qforeground_color, alist);
3307 if (CONSP (elt) && STRINGP (XCDR (elt)))
3308 {
3309 elt = frame_unspecified_color (f, XCDR (elt));
3310 if (!NILP (elt))
3311 store_in_alist (&alist, Qforeground_color, elt);
3312 }
3313 else
3314 store_in_alist (&alist, Qforeground_color,
3315 tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)));
3316 elt = Fassq (Qbackground_color, alist);
3317 if (CONSP (elt) && STRINGP (XCDR (elt)))
3318 {
3319 elt = frame_unspecified_color (f, XCDR (elt));
3320 if (!NILP (elt))
3321 store_in_alist (&alist, Qbackground_color, elt);
3322 }
3323 else
3324 store_in_alist (&alist, Qbackground_color,
3325 tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)));
3326 store_in_alist (&alist, Qfont,
3327 build_string (FRAME_MSDOS_P (f)
3328 ? "ms-dos"
3329 : FRAME_W32_P (f) ? "w32term"
3330 :"tty"));
3331 }
3332
3333 store_in_alist (&alist, Qname, f->name);
3334
3335
3336
3337
3338
3339
3340
3341 height = ((f->new_size_p && f->new_height >= 0)
3342 ? f->new_height / FRAME_LINE_HEIGHT (f)
3343 : FRAME_LINES (f));
3344 store_in_alist (&alist, Qheight, make_fixnum (height));
3345 width = ((f->new_size_p && f->new_width >= 0)
3346 ? f->new_width / FRAME_COLUMN_WIDTH (f)
3347 : FRAME_COLS(f));
3348 store_in_alist (&alist, Qwidth, make_fixnum (width));
3349
3350 store_in_alist (&alist, Qmodeline, FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil);
3351 store_in_alist (&alist, Qunsplittable, FRAME_NO_SPLIT_P (f) ? Qt : Qnil);
3352 store_in_alist (&alist, Qbuffer_list, f->buffer_list);
3353 store_in_alist (&alist, Qburied_buffer_list, f->buried_buffer_list);
3354
3355
3356 #ifdef HAVE_WINDOW_SYSTEM
3357 if (FRAME_WINDOW_P (f))
3358 gui_report_frame_params (f, &alist);
3359 else
3360 #endif
3361 {
3362
3363 Lisp_Object lines;
3364
3365 XSETFASTINT (lines, FRAME_MENU_BAR_LINES (f));
3366 store_in_alist (&alist, Qmenu_bar_lines, lines);
3367 XSETFASTINT (lines, FRAME_TAB_BAR_LINES (f));
3368 store_in_alist (&alist, Qtab_bar_lines, lines);
3369 }
3370
3371 return alist;
3372 }
3373
3374
3375 DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0,
3376 doc:
3377 )
3378 (Lisp_Object frame, Lisp_Object parameter)
3379 {
3380 struct frame *f = decode_any_frame (frame);
3381 Lisp_Object value = Qnil;
3382
3383 CHECK_SYMBOL (parameter);
3384
3385 XSETFRAME (frame, f);
3386
3387 if (FRAME_LIVE_P (f))
3388 {
3389
3390 if (EQ (parameter, Qname))
3391 value = f->name;
3392 #ifdef HAVE_WINDOW_SYSTEM
3393
3394 else if (EQ (parameter, Qvertical_scroll_bars))
3395 value = (f->vertical_scroll_bar_type == vertical_scroll_bar_none
3396 ? Qnil
3397 : (f->vertical_scroll_bar_type == vertical_scroll_bar_left
3398 ? Qleft : Qright));
3399 else if (EQ (parameter, Qhorizontal_scroll_bars))
3400 value = f->horizontal_scroll_bars ? Qt : Qnil;
3401 else if (EQ (parameter, Qline_spacing) && f->extra_line_spacing == 0)
3402
3403
3404 value = make_fixnum (0);
3405 else if (EQ (parameter, Qfont) && FRAME_X_P (f))
3406 value = FRAME_FONT (f)->props[FONT_NAME_INDEX];
3407 #endif
3408 #ifdef HAVE_X_WINDOWS
3409 else if (EQ (parameter, Qdisplay) && FRAME_X_P (f))
3410 value = XCAR (FRAME_DISPLAY_INFO (f)->name_list_element);
3411 #endif
3412 else if (EQ (parameter, Qbackground_color)
3413 || EQ (parameter, Qforeground_color))
3414 {
3415 value = Fassq (parameter, f->param_alist);
3416 if (CONSP (value))
3417 {
3418 value = XCDR (value);
3419
3420
3421
3422
3423 if (STRINGP (value) && !FRAME_WINDOW_P (f))
3424 {
3425 Lisp_Object tem = frame_unspecified_color (f, value);
3426
3427 if (!NILP (tem))
3428 value = tem;
3429 }
3430 }
3431 else
3432 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
3433 }
3434 else if (EQ (parameter, Qdisplay_type)
3435 || EQ (parameter, Qbackground_mode))
3436 value = Fcdr (Fassq (parameter, f->param_alist));
3437 else
3438
3439
3440 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
3441 }
3442
3443 return value;
3444 }
3445
3446
3447 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters,
3448 Smodify_frame_parameters, 2, 2, 0,
3449 doc:
3450
3451
3452
3453
3454
3455
3456
3457
3458 )
3459 (Lisp_Object frame, Lisp_Object alist)
3460 {
3461 struct frame *f = decode_live_frame (frame);
3462 Lisp_Object prop, val;
3463
3464
3465 #ifdef HAVE_WINDOW_SYSTEM
3466 if (FRAME_WINDOW_P (f))
3467 gui_set_frame_parameters (f, alist);
3468 else
3469 #endif
3470 #ifdef MSDOS
3471 if (FRAME_MSDOS_P (f))
3472 IT_set_frame_parameters (f, alist);
3473 else
3474 #endif
3475
3476 {
3477 EMACS_INT length = list_length (alist);
3478 ptrdiff_t i;
3479 Lisp_Object *parms;
3480 Lisp_Object *values;
3481 USE_SAFE_ALLOCA;
3482 SAFE_ALLOCA_LISP (parms, 2 * length);
3483 values = parms + length;
3484
3485
3486
3487 for (i = 0; CONSP (alist); alist = XCDR (alist))
3488 {
3489 Lisp_Object elt;
3490
3491 elt = XCAR (alist);
3492 parms[i] = Fcar (elt);
3493 values[i] = Fcdr (elt);
3494 i++;
3495 }
3496
3497
3498 while (--i >= 0)
3499 {
3500 prop = parms[i];
3501 val = values[i];
3502 store_frame_param (f, prop, val);
3503
3504 if (EQ (prop, Qforeground_color)
3505 || EQ (prop, Qbackground_color))
3506 update_face_from_frame_parameter (f, prop, val);
3507 }
3508
3509 SAFE_FREE ();
3510 }
3511 return Qnil;
3512 }
3513
3514 DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
3515 0, 1, 0,
3516 doc:
3517
3518 )
3519 (Lisp_Object frame)
3520 {
3521 #ifdef HAVE_WINDOW_SYSTEM
3522 struct frame *f = decode_any_frame (frame);
3523
3524 if (FRAME_WINDOW_P (f))
3525 return make_fixnum (FRAME_LINE_HEIGHT (f));
3526 else
3527 #endif
3528 return make_fixnum (1);
3529 }
3530
3531
3532 DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
3533 0, 1, 0,
3534 doc:
3535
3536
3537 )
3538 (Lisp_Object frame)
3539 {
3540 #ifdef HAVE_WINDOW_SYSTEM
3541 struct frame *f = decode_any_frame (frame);
3542
3543 if (FRAME_WINDOW_P (f))
3544 return make_fixnum (FRAME_COLUMN_WIDTH (f));
3545 else
3546 #endif
3547 return make_fixnum (1);
3548 }
3549
3550 DEFUN ("frame-native-width", Fframe_native_width,
3551 Sframe_native_width, 0, 1, 0,
3552 doc:
3553
3554
3555
3556
3557 )
3558 (Lisp_Object frame)
3559 {
3560 struct frame *f = decode_any_frame (frame);
3561
3562 #ifdef HAVE_WINDOW_SYSTEM
3563 if (FRAME_WINDOW_P (f))
3564 return make_fixnum (FRAME_PIXEL_WIDTH (f));
3565 else
3566 #endif
3567 return make_fixnum (FRAME_TOTAL_COLS (f));
3568 }
3569
3570 DEFUN ("frame-native-height", Fframe_native_height,
3571 Sframe_native_height, 0, 1, 0,
3572 doc:
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586 )
3587 (Lisp_Object frame)
3588 {
3589 struct frame *f = decode_any_frame (frame);
3590
3591 #ifdef HAVE_WINDOW_SYSTEM
3592 if (FRAME_WINDOW_P (f))
3593 return make_fixnum (FRAME_PIXEL_HEIGHT (f));
3594 else
3595 #endif
3596 return make_fixnum (FRAME_TOTAL_LINES (f));
3597 }
3598
3599 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width,
3600 Stool_bar_pixel_width, 0, 1, 0,
3601 doc:
3602
3603
3604 )
3605 (Lisp_Object frame)
3606 {
3607 #ifdef FRAME_TOOLBAR_WIDTH
3608 struct frame *f = decode_any_frame (frame);
3609
3610 if (FRAME_WINDOW_P (f))
3611 return make_fixnum (FRAME_TOOLBAR_WIDTH (f));
3612 #endif
3613 return make_fixnum (0);
3614 }
3615
3616 DEFUN ("frame-text-cols", Fframe_text_cols, Sframe_text_cols, 0, 1, 0,
3617 doc: )
3618 (Lisp_Object frame)
3619 {
3620 return make_fixnum (FRAME_COLS (decode_any_frame (frame)));
3621 }
3622
3623 DEFUN ("frame-text-lines", Fframe_text_lines, Sframe_text_lines, 0, 1, 0,
3624 doc: )
3625 (Lisp_Object frame)
3626 {
3627 return make_fixnum (FRAME_LINES (decode_any_frame (frame)));
3628 }
3629
3630 DEFUN ("frame-total-cols", Fframe_total_cols, Sframe_total_cols, 0, 1, 0,
3631 doc: )
3632 (Lisp_Object frame)
3633 {
3634 return make_fixnum (FRAME_TOTAL_COLS (decode_any_frame (frame)));
3635 }
3636
3637 DEFUN ("frame-total-lines", Fframe_total_lines, Sframe_total_lines, 0, 1, 0,
3638 doc: )
3639 (Lisp_Object frame)
3640 {
3641 return make_fixnum (FRAME_TOTAL_LINES (decode_any_frame (frame)));
3642 }
3643
3644 DEFUN ("frame-text-width", Fframe_text_width, Sframe_text_width, 0, 1, 0,
3645 doc: )
3646 (Lisp_Object frame)
3647 {
3648 return make_fixnum (FRAME_TEXT_WIDTH (decode_any_frame (frame)));
3649 }
3650
3651 DEFUN ("frame-text-height", Fframe_text_height, Sframe_text_height, 0, 1, 0,
3652 doc: )
3653 (Lisp_Object frame)
3654 {
3655 return make_fixnum (FRAME_TEXT_HEIGHT (decode_any_frame (frame)));
3656 }
3657
3658 DEFUN ("frame-scroll-bar-width", Fscroll_bar_width, Sscroll_bar_width, 0, 1, 0,
3659 doc: )
3660 (Lisp_Object frame)
3661 {
3662 return make_fixnum (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame)));
3663 }
3664
3665 DEFUN ("frame-scroll-bar-height", Fscroll_bar_height, Sscroll_bar_height, 0, 1, 0,
3666 doc: )
3667 (Lisp_Object frame)
3668 {
3669 return make_fixnum (FRAME_SCROLL_BAR_AREA_HEIGHT (decode_any_frame (frame)));
3670 }
3671
3672 DEFUN ("frame-fringe-width", Ffringe_width, Sfringe_width, 0, 1, 0,
3673 doc: )
3674 (Lisp_Object frame)
3675 {
3676 return make_fixnum (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame)));
3677 }
3678
3679 DEFUN ("frame-child-frame-border-width", Fframe_child_frame_border_width, Sframe_child_frame_border_width, 0, 1, 0,
3680 doc:
3681
3682 )
3683 (Lisp_Object frame)
3684 {
3685 int width = FRAME_CHILD_FRAME_BORDER_WIDTH (decode_any_frame (frame));
3686
3687 if (width < 0)
3688 return make_fixnum (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame)));
3689 else
3690 return make_fixnum (FRAME_CHILD_FRAME_BORDER_WIDTH (decode_any_frame (frame)));
3691 }
3692
3693 DEFUN ("frame-internal-border-width", Fframe_internal_border_width, Sframe_internal_border_width, 0, 1, 0,
3694 doc: )
3695 (Lisp_Object frame)
3696 {
3697 return make_fixnum (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame)));
3698 }
3699
3700 DEFUN ("frame-right-divider-width", Fright_divider_width, Sright_divider_width, 0, 1, 0,
3701 doc: )
3702 (Lisp_Object frame)
3703 {
3704 return make_fixnum (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame)));
3705 }
3706
3707 DEFUN ("frame-bottom-divider-width", Fbottom_divider_width, Sbottom_divider_width, 0, 1, 0,
3708 doc: )
3709 (Lisp_Object frame)
3710 {
3711 return make_fixnum (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame)));
3712 }
3713
3714 static int
3715 check_frame_pixels (Lisp_Object size, Lisp_Object pixelwise, int item_size)
3716 {
3717 intmax_t sz;
3718 int pixel_size;
3719
3720 CHECK_INTEGER (size);
3721 if (!NILP (pixelwise))
3722 item_size = 1;
3723
3724 if (!integer_to_intmax (size, &sz)
3725 || INT_MULTIPLY_WRAPV (sz, item_size, &pixel_size))
3726 args_out_of_range_3 (size, make_int (INT_MIN / item_size),
3727 make_int (INT_MAX / item_size));
3728
3729 return pixel_size;
3730 }
3731
3732 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 4,
3733 "(set-frame-property--interactive \"Frame height: \" (frame-height))",
3734 doc:
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747 )
3748 (Lisp_Object frame, Lisp_Object height, Lisp_Object pretend, Lisp_Object pixelwise)
3749 {
3750 struct frame *f = decode_live_frame (frame);
3751 int text_height
3752 = check_frame_pixels (height, pixelwise, FRAME_LINE_HEIGHT (f));
3753
3754
3755 adjust_frame_size
3756 (f, FRAME_TEXT_WIDTH (f), text_height, 1, !NILP (pretend), Qheight);
3757
3758 return Qnil;
3759 }
3760
3761 DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 4,
3762 "(set-frame-property--interactive \"Frame width: \" (frame-width))",
3763 doc:
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776 )
3777 (Lisp_Object frame, Lisp_Object width, Lisp_Object pretend, Lisp_Object pixelwise)
3778 {
3779 struct frame *f = decode_live_frame (frame);
3780 int text_width
3781 = check_frame_pixels (width, pixelwise, FRAME_COLUMN_WIDTH (f));
3782
3783
3784 adjust_frame_size
3785 (f, text_width, FRAME_TEXT_HEIGHT (f), 1, !NILP (pretend), Qwidth);
3786
3787 return Qnil;
3788 }
3789
3790 DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 4, 0,
3791 doc:
3792
3793
3794
3795
3796
3797
3798 )
3799 (Lisp_Object frame, Lisp_Object width, Lisp_Object height, Lisp_Object pixelwise)
3800 {
3801 struct frame *f = decode_live_frame (frame);
3802 int text_width
3803 = check_frame_pixels (width, pixelwise, FRAME_COLUMN_WIDTH (f));
3804 int text_height
3805 = check_frame_pixels (height, pixelwise, FRAME_LINE_HEIGHT (f));
3806
3807
3808 adjust_frame_size (f, text_width, text_height, 1, false, Qsize);
3809
3810 return Qnil;
3811 }
3812
3813 DEFUN ("frame-position", Fframe_position,
3814 Sframe_position, 0, 1, 0,
3815 doc:
3816
3817
3818
3819
3820
3821
3822
3823 )
3824 (Lisp_Object frame)
3825 {
3826 register struct frame *f = decode_live_frame (frame);
3827
3828 return Fcons (make_fixnum (f->left_pos), make_fixnum (f->top_pos));
3829 }
3830
3831 DEFUN ("set-frame-position", Fset_frame_position,
3832 Sset_frame_position, 3, 3, 0,
3833 doc:
3834
3835
3836
3837
3838
3839 )
3840 (Lisp_Object frame, Lisp_Object x, Lisp_Object y)
3841 {
3842 struct frame *f = decode_live_frame (frame);
3843 int xval = check_integer_range (x, INT_MIN, INT_MAX);
3844 int yval = check_integer_range (y, INT_MIN, INT_MAX);
3845
3846 if (FRAME_WINDOW_P (f))
3847 {
3848 #ifdef HAVE_WINDOW_SYSTEM
3849 if (FRAME_TERMINAL (f)->set_frame_offset_hook)
3850 FRAME_TERMINAL (f)->set_frame_offset_hook (f, xval, yval, 1);
3851 #else
3852 (void) xval;
3853 (void) yval;
3854 #endif
3855 }
3856
3857 return Qt;
3858 }
3859
3860 DEFUN ("frame-window-state-change", Fframe_window_state_change,
3861 Sframe_window_state_change, 0, 1, 0,
3862 doc:
3863
3864
3865
3866
3867
3868
3869 )
3870 (Lisp_Object frame)
3871 {
3872 return FRAME_WINDOW_STATE_CHANGE (decode_live_frame (frame)) ? Qt : Qnil;
3873 }
3874
3875 DEFUN ("set-frame-window-state-change", Fset_frame_window_state_change,
3876 Sset_frame_window_state_change, 0, 2, 0,
3877 doc:
3878
3879
3880
3881
3882
3883
3884
3885 )
3886 (Lisp_Object frame, Lisp_Object arg)
3887 {
3888 struct frame *f = decode_live_frame (frame);
3889
3890 return (FRAME_WINDOW_STATE_CHANGE (f) = !NILP (arg)) ? Qt : Qnil;
3891 }
3892
3893 DEFUN ("frame-scale-factor", Fframe_scale_factor, Sframe_scale_factor,
3894 0, 1, 0,
3895 doc:
3896
3897
3898 )
3899 (Lisp_Object frame)
3900 {
3901 struct frame *f = decode_live_frame (frame);
3902
3903 return (make_float (f ? FRAME_SCALE_FACTOR (f) : 1));
3904 }
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917 struct frame_parm_table {
3918 const char *name;
3919 int sym;
3920 };
3921
3922 static const struct frame_parm_table frame_parms[] =
3923 {
3924 {"auto-raise", SYMBOL_INDEX (Qauto_raise)},
3925 {"auto-lower", SYMBOL_INDEX (Qauto_lower)},
3926 {"background-color", -1},
3927 {"border-color", SYMBOL_INDEX (Qborder_color)},
3928 {"border-width", SYMBOL_INDEX (Qborder_width)},
3929 {"cursor-color", SYMBOL_INDEX (Qcursor_color)},
3930 {"cursor-type", SYMBOL_INDEX (Qcursor_type)},
3931 {"font", -1},
3932 {"foreground-color", -1},
3933 {"icon-name", SYMBOL_INDEX (Qicon_name)},
3934 {"icon-type", SYMBOL_INDEX (Qicon_type)},
3935 {"child-frame-border-width", SYMBOL_INDEX (Qchild_frame_border_width)},
3936 {"internal-border-width", SYMBOL_INDEX (Qinternal_border_width)},
3937 {"right-divider-width", SYMBOL_INDEX (Qright_divider_width)},
3938 {"bottom-divider-width", SYMBOL_INDEX (Qbottom_divider_width)},
3939 {"menu-bar-lines", SYMBOL_INDEX (Qmenu_bar_lines)},
3940 {"mouse-color", SYMBOL_INDEX (Qmouse_color)},
3941 {"name", SYMBOL_INDEX (Qname)},
3942 {"scroll-bar-width", SYMBOL_INDEX (Qscroll_bar_width)},
3943 {"scroll-bar-height", SYMBOL_INDEX (Qscroll_bar_height)},
3944 {"title", SYMBOL_INDEX (Qtitle)},
3945 {"unsplittable", SYMBOL_INDEX (Qunsplittable)},
3946 {"vertical-scroll-bars", SYMBOL_INDEX (Qvertical_scroll_bars)},
3947 {"horizontal-scroll-bars", SYMBOL_INDEX (Qhorizontal_scroll_bars)},
3948 {"visibility", SYMBOL_INDEX (Qvisibility)},
3949 {"tab-bar-lines", SYMBOL_INDEX (Qtab_bar_lines)},
3950 {"tool-bar-lines", SYMBOL_INDEX (Qtool_bar_lines)},
3951 {"scroll-bar-foreground", SYMBOL_INDEX (Qscroll_bar_foreground)},
3952 {"scroll-bar-background", SYMBOL_INDEX (Qscroll_bar_background)},
3953 {"screen-gamma", SYMBOL_INDEX (Qscreen_gamma)},
3954 {"line-spacing", SYMBOL_INDEX (Qline_spacing)},
3955 {"left-fringe", SYMBOL_INDEX (Qleft_fringe)},
3956 {"right-fringe", SYMBOL_INDEX (Qright_fringe)},
3957 {"wait-for-wm", SYMBOL_INDEX (Qwait_for_wm)},
3958 {"fullscreen", SYMBOL_INDEX (Qfullscreen)},
3959 {"font-backend", SYMBOL_INDEX (Qfont_backend)},
3960 {"alpha", SYMBOL_INDEX (Qalpha)},
3961 {"sticky", SYMBOL_INDEX (Qsticky)},
3962 {"tool-bar-position", SYMBOL_INDEX (Qtool_bar_position)},
3963 {"inhibit-double-buffering", SYMBOL_INDEX (Qinhibit_double_buffering)},
3964 {"undecorated", SYMBOL_INDEX (Qundecorated)},
3965 {"parent-frame", SYMBOL_INDEX (Qparent_frame)},
3966 {"skip-taskbar", SYMBOL_INDEX (Qskip_taskbar)},
3967 {"no-focus-on-map", SYMBOL_INDEX (Qno_focus_on_map)},
3968 {"no-accept-focus", SYMBOL_INDEX (Qno_accept_focus)},
3969 {"z-group", SYMBOL_INDEX (Qz_group)},
3970 {"override-redirect", SYMBOL_INDEX (Qoverride_redirect)},
3971 {"no-special-glyphs", SYMBOL_INDEX (Qno_special_glyphs)},
3972 {"alpha-background", SYMBOL_INDEX (Qalpha_background)},
3973 {"use-frame-synchronization", SYMBOL_INDEX (Quse_frame_synchronization)},
3974 #ifdef HAVE_X_WINDOWS
3975 {"shaded", SYMBOL_INDEX (Qshaded)},
3976 #endif
3977 #ifdef NS_IMPL_COCOA
3978 {"ns-appearance", SYMBOL_INDEX (Qns_appearance)},
3979 {"ns-transparent-titlebar", SYMBOL_INDEX (Qns_transparent_titlebar)},
3980 #endif
3981 };
3982
3983 #ifdef HAVE_WINDOW_SYSTEM
3984
3985
3986 enum frame_float_type
3987 {
3988 FRAME_FLOAT_WIDTH,
3989 FRAME_FLOAT_HEIGHT,
3990 FRAME_FLOAT_LEFT,
3991 FRAME_FLOAT_TOP
3992 };
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020 static int
4021 frame_float (struct frame *f, Lisp_Object val, enum frame_float_type what,
4022 int *parent_done, int *outer_done, int default_value)
4023 {
4024 double d_val = XFLOAT_DATA (val);
4025
4026 if (d_val < 0.0 || d_val > 1.0)
4027
4028 return default_value;
4029 else
4030 {
4031 static unsigned parent_width, parent_height;
4032 static int parent_left, parent_top;
4033 static unsigned outer_minus_text_width, outer_minus_text_height;
4034 struct frame *p = FRAME_PARENT_FRAME (f);
4035
4036 if (*parent_done == 1)
4037 ;
4038 else if (p)
4039 {
4040 parent_width = FRAME_PIXEL_WIDTH (p);
4041 parent_height = FRAME_PIXEL_HEIGHT (p);
4042 *parent_done = 1;
4043 }
4044 else
4045 {
4046 if (*parent_done == 0)
4047
4048 return default_value;
4049 else if (*parent_done == -1)
4050 {
4051 Lisp_Object monitor_attributes;
4052 Lisp_Object workarea;
4053 Lisp_Object frame;
4054
4055 XSETFRAME (frame, f);
4056 monitor_attributes = call1 (Qframe_monitor_attributes, frame);
4057 if (NILP (monitor_attributes))
4058 {
4059
4060 *parent_done = 0;
4061
4062 return default_value;
4063 }
4064
4065 workarea = Fcdr (Fassq (Qworkarea, monitor_attributes));
4066 if (NILP (workarea))
4067 {
4068
4069 *parent_done = 0;
4070
4071 return default_value;
4072 }
4073
4074
4075 parent_left = XFIXNUM (Fnth (make_fixnum (0), workarea));
4076 parent_top = XFIXNUM (Fnth (make_fixnum (1), workarea));
4077 parent_width = XFIXNUM (Fnth (make_fixnum (2), workarea));
4078 parent_height = XFIXNUM (Fnth (make_fixnum (3), workarea));
4079 *parent_done = 1;
4080 }
4081 }
4082
4083 if (*outer_done == 1)
4084 ;
4085 else if (FRAME_UNDECORATED (f))
4086 {
4087 outer_minus_text_width
4088 = FRAME_PIXEL_WIDTH (f) - FRAME_TEXT_WIDTH (f);
4089 outer_minus_text_height
4090 = FRAME_PIXEL_HEIGHT (f) - FRAME_TEXT_HEIGHT (f);
4091 *outer_done = 1;
4092 }
4093 else if (*outer_done == 0)
4094
4095 return default_value;
4096 else if (*outer_done == -1)
4097 {
4098 Lisp_Object frame, outer_edges;
4099
4100 XSETFRAME (frame, f);
4101 outer_edges = call2 (Qframe_edges, frame, Qouter_edges);
4102
4103 if (!NILP (outer_edges))
4104 {
4105 outer_minus_text_width
4106 = (XFIXNUM (Fnth (make_fixnum (2), outer_edges))
4107 - XFIXNUM (Fnth (make_fixnum (0), outer_edges))
4108 - FRAME_TEXT_WIDTH (f));
4109 outer_minus_text_height
4110 = (XFIXNUM (Fnth (make_fixnum (3), outer_edges))
4111 - XFIXNUM (Fnth (make_fixnum (1), outer_edges))
4112 - FRAME_TEXT_HEIGHT (f));
4113 }
4114 else
4115 {
4116
4117
4118 outer_minus_text_width
4119 = FRAME_PIXEL_WIDTH (f) - FRAME_TEXT_WIDTH (f);
4120 outer_minus_text_height
4121 = FRAME_PIXEL_HEIGHT (f) - FRAME_TEXT_HEIGHT (f);
4122 }
4123
4124 *outer_done = 1;
4125 }
4126
4127 switch (what)
4128 {
4129 case FRAME_FLOAT_WIDTH:
4130 return parent_width * d_val - outer_minus_text_width;
4131
4132 case FRAME_FLOAT_HEIGHT:
4133 return parent_height * d_val - outer_minus_text_height;
4134
4135 case FRAME_FLOAT_LEFT:
4136 {
4137 int rest_width = (parent_width
4138 - FRAME_TEXT_WIDTH (f)
4139 - outer_minus_text_width);
4140
4141 if (p)
4142 return (rest_width <= 0 ? 0 : d_val * rest_width);
4143 else
4144 return (rest_width <= 0
4145 ? parent_left
4146 : parent_left + d_val * rest_width);
4147 }
4148 case FRAME_FLOAT_TOP:
4149 {
4150 int rest_height = (parent_height
4151 - FRAME_TEXT_HEIGHT (f)
4152 - outer_minus_text_height);
4153
4154 if (p)
4155 return (rest_height <= 0 ? 0 : d_val * rest_height);
4156 else
4157 return (rest_height <= 0
4158 ? parent_top
4159 : parent_top + d_val * rest_height);
4160 }
4161 default:
4162 emacs_abort ();
4163 }
4164 }
4165 }
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179 void
4180 gui_set_frame_parameters_1 (struct frame *f, Lisp_Object alist,
4181 bool default_parameter)
4182 {
4183 Lisp_Object tail, frame;
4184
4185
4186 int width = -1, height = -1;
4187 bool width_change = false, height_change = false;
4188
4189
4190 Lisp_Object left, top;
4191
4192
4193 Lisp_Object icon_left, icon_top;
4194
4195
4196 Lisp_Object fullscreen UNINIT;
4197 bool fullscreen_change = false;
4198
4199
4200 Lisp_Object *parms;
4201 Lisp_Object *values;
4202 ptrdiff_t i, j, size;
4203 bool left_no_change = 0, top_no_change = 0;
4204 #ifdef HAVE_X_WINDOWS
4205 bool icon_left_no_change = 0, icon_top_no_change = 0;
4206 #endif
4207 int parent_done = -1, outer_done = -1;
4208
4209 XSETFRAME (frame, f);
4210 for (size = 0, tail = alist; CONSP (tail); tail = XCDR (tail))
4211 size++;
4212 CHECK_LIST_END (tail, alist);
4213
4214 USE_SAFE_ALLOCA;
4215 SAFE_ALLOCA_LISP (parms, 2 * size);
4216 values = parms + size;
4217
4218
4219
4220 i = 0, j = size - 1;
4221 for (tail = alist; CONSP (tail); tail = XCDR (tail))
4222 {
4223 Lisp_Object elt = XCAR (tail), prop = Fcar (elt), val = Fcdr (elt);
4224
4225
4226
4227
4228
4229
4230
4231
4232 if (EQ (prop, Qforeground_color)
4233 || EQ (prop, Qbackground_color)
4234 || EQ (prop, Qfont))
4235 {
4236 parms[j] = prop;
4237 values[j] = val;
4238 j--;
4239 }
4240 else
4241 {
4242 parms[i] = prop;
4243 values[i] = val;
4244 i++;
4245 }
4246 }
4247
4248
4249 alist = tail = Qnil;
4250
4251 top = left = Qunbound;
4252 icon_left = icon_top = Qunbound;
4253
4254
4255
4256 for (i = size - 1; i >= 0; i--)
4257 {
4258 Lisp_Object prop, val;
4259
4260 prop = parms[i];
4261 val = values[i];
4262
4263 if (EQ (prop, Qwidth))
4264 {
4265 width_change = true;
4266
4267 if (RANGED_FIXNUMP (0, val, INT_MAX))
4268 width = XFIXNAT (val) * FRAME_COLUMN_WIDTH (f) ;
4269 else if (CONSP (val) && EQ (XCAR (val), Qtext_pixels)
4270 && RANGED_FIXNUMP (0, XCDR (val), INT_MAX))
4271 width = XFIXNAT (XCDR (val));
4272 else if (FLOATP (val))
4273 width = frame_float (f, val, FRAME_FLOAT_WIDTH, &parent_done,
4274 &outer_done, -1);
4275 else
4276 width_change = false;
4277 }
4278 else if (EQ (prop, Qheight))
4279 {
4280 height_change = true;
4281
4282 if (RANGED_FIXNUMP (0, val, INT_MAX))
4283 height = XFIXNAT (val) * FRAME_LINE_HEIGHT (f);
4284 else if (CONSP (val) && EQ (XCAR (val), Qtext_pixels)
4285 && RANGED_FIXNUMP (0, XCDR (val), INT_MAX))
4286 height = XFIXNAT (XCDR (val));
4287 else if (FLOATP (val))
4288 height = frame_float (f, val, FRAME_FLOAT_HEIGHT, &parent_done,
4289 &outer_done, -1);
4290 else
4291 height_change = false;
4292 }
4293 else if (EQ (prop, Qtop))
4294 top = val;
4295 else if (EQ (prop, Qleft))
4296 left = val;
4297 else if (EQ (prop, Qicon_top))
4298 icon_top = val;
4299 else if (EQ (prop, Qicon_left))
4300 icon_left = val;
4301 else if (EQ (prop, Qfullscreen))
4302 {
4303 fullscreen = val;
4304 fullscreen_change = true;
4305 }
4306 else
4307 {
4308 Lisp_Object param_index, old_value;
4309
4310 old_value = get_frame_param (f, prop);
4311
4312 store_frame_param (f, prop, val);
4313
4314 param_index = Fget (prop, Qx_frame_parameter);
4315 if (FIXNATP (param_index)
4316 && XFIXNAT (param_index) < ARRAYELTS (frame_parms)
4317 && FRAME_RIF (f)->frame_parm_handlers[XFIXNUM (param_index)])
4318 (*(FRAME_RIF (f)->frame_parm_handlers[XFIXNUM (param_index)])) (f, val, old_value);
4319
4320 if (!default_parameter && EQ (prop, Qfont))
4321
4322
4323
4324 store_frame_param (f, Qfont_parameter, val);
4325 }
4326 }
4327
4328
4329 if (BASE_EQ (left, Qunbound))
4330 {
4331 left_no_change = 1;
4332 if (f->left_pos < 0)
4333 left = list2 (Qplus, make_fixnum (f->left_pos));
4334 else
4335 XSETINT (left, f->left_pos);
4336 }
4337 if (BASE_EQ (top, Qunbound))
4338 {
4339 top_no_change = 1;
4340 if (f->top_pos < 0)
4341 top = list2 (Qplus, make_fixnum (f->top_pos));
4342 else
4343 XSETINT (top, f->top_pos);
4344 }
4345
4346
4347 if (! TYPE_RANGED_FIXNUMP (int, icon_left))
4348 {
4349 #ifdef HAVE_X_WINDOWS
4350 icon_left_no_change = 1;
4351 #endif
4352 icon_left = Fcdr (Fassq (Qicon_left, f->param_alist));
4353 if (NILP (icon_left))
4354 XSETINT (icon_left, 0);
4355 }
4356 if (! TYPE_RANGED_FIXNUMP (int, icon_top))
4357 {
4358 #ifdef HAVE_X_WINDOWS
4359 icon_top_no_change = 1;
4360 #endif
4361 icon_top = Fcdr (Fassq (Qicon_top, f->param_alist));
4362 if (NILP (icon_top))
4363 XSETINT (icon_top, 0);
4364 }
4365
4366 if (width_change || height_change)
4367 {
4368 Lisp_Object parameter;
4369
4370 if (width_change)
4371 {
4372 if (height_change)
4373 parameter = Qsize;
4374 else
4375 {
4376 height = FRAME_TEXT_HEIGHT (f);
4377 parameter = Qwidth;
4378 }
4379 }
4380 else
4381 {
4382 width = FRAME_TEXT_WIDTH (f);
4383 parameter = Qheight;
4384 }
4385
4386 adjust_frame_size (f, width, height, 1, 0, parameter);
4387 }
4388
4389 if ((!NILP (left) || !NILP (top))
4390 && ! (left_no_change && top_no_change)
4391 && ! (FIXNUMP (left) && XFIXNUM (left) == f->left_pos
4392 && FIXNUMP (top) && XFIXNUM (top) == f->top_pos))
4393 {
4394 int leftpos = 0;
4395 int toppos = 0;
4396
4397
4398 f->size_hint_flags &= ~ (XNegative | YNegative);
4399 if (EQ (left, Qminus))
4400 f->size_hint_flags |= XNegative;
4401 else if (TYPE_RANGED_FIXNUMP (int, left))
4402 {
4403 leftpos = XFIXNUM (left);
4404 if (leftpos < 0)
4405 f->size_hint_flags |= XNegative;
4406 }
4407 else if (CONSP (left) && EQ (XCAR (left), Qminus)
4408 && CONSP (XCDR (left))
4409 && RANGED_FIXNUMP (-INT_MAX, XCAR (XCDR (left)), INT_MAX))
4410 {
4411 leftpos = - XFIXNUM (XCAR (XCDR (left)));
4412 f->size_hint_flags |= XNegative;
4413 }
4414 else if (CONSP (left) && EQ (XCAR (left), Qplus)
4415 && CONSP (XCDR (left))
4416 && TYPE_RANGED_FIXNUMP (int, XCAR (XCDR (left))))
4417 leftpos = XFIXNUM (XCAR (XCDR (left)));
4418 else if (FLOATP (left))
4419 leftpos = frame_float (f, left, FRAME_FLOAT_LEFT, &parent_done,
4420 &outer_done, 0);
4421
4422 if (EQ (top, Qminus))
4423 f->size_hint_flags |= YNegative;
4424 else if (TYPE_RANGED_FIXNUMP (int, top))
4425 {
4426 toppos = XFIXNUM (top);
4427 if (toppos < 0)
4428 f->size_hint_flags |= YNegative;
4429 }
4430 else if (CONSP (top) && EQ (XCAR (top), Qminus)
4431 && CONSP (XCDR (top))
4432 && RANGED_FIXNUMP (-INT_MAX, XCAR (XCDR (top)), INT_MAX))
4433 {
4434 toppos = - XFIXNUM (XCAR (XCDR (top)));
4435 f->size_hint_flags |= YNegative;
4436 }
4437 else if (CONSP (top) && EQ (XCAR (top), Qplus)
4438 && CONSP (XCDR (top))
4439 && TYPE_RANGED_FIXNUMP (int, XCAR (XCDR (top))))
4440 toppos = XFIXNUM (XCAR (XCDR (top)));
4441 else if (FLOATP (top))
4442 toppos = frame_float (f, top, FRAME_FLOAT_TOP, &parent_done,
4443 &outer_done, 0);
4444
4445
4446 f->top_pos = toppos;
4447 f->left_pos = leftpos;
4448
4449 f->win_gravity = NorthWestGravity;
4450
4451
4452 if (FRAME_TERMINAL (f)->set_frame_offset_hook)
4453 FRAME_TERMINAL (f)->set_frame_offset_hook (f, leftpos, toppos, -1);
4454 }
4455
4456 if (fullscreen_change)
4457 {
4458 Lisp_Object old_value = get_frame_param (f, Qfullscreen);
4459
4460 store_frame_param (f, Qfullscreen, fullscreen);
4461 if (!EQ (fullscreen, old_value))
4462 gui_set_fullscreen (f, fullscreen, old_value);
4463 }
4464
4465
4466 #ifdef HAVE_X_WINDOWS
4467 if ((!NILP (icon_left) || !NILP (icon_top))
4468 && ! (icon_left_no_change && icon_top_no_change))
4469 x_wm_set_icon_position (f, XFIXNUM (icon_left), XFIXNUM (icon_top));
4470 #endif
4471
4472 SAFE_FREE ();
4473 }
4474
4475 void
4476 gui_set_frame_parameters (struct frame *f, Lisp_Object alist)
4477 {
4478 gui_set_frame_parameters_1 (f, alist, false);
4479 }
4480
4481
4482
4483
4484
4485
4486
4487 void
4488 gui_report_frame_params (struct frame *f, Lisp_Object *alistptr)
4489 {
4490 Lisp_Object tem;
4491 uintmax_t w;
4492 char buf[INT_BUFSIZE_BOUND (w)];
4493
4494
4495
4496 XSETINT (tem, f->left_pos);
4497 if (f->left_pos >= 0)
4498 store_in_alist (alistptr, Qleft, tem);
4499 else
4500 store_in_alist (alistptr, Qleft, list2 (Qplus, tem));
4501
4502 XSETINT (tem, f->top_pos);
4503 if (f->top_pos >= 0)
4504 store_in_alist (alistptr, Qtop, tem);
4505 else
4506 store_in_alist (alistptr, Qtop, list2 (Qplus, tem));
4507
4508 store_in_alist (alistptr, Qborder_width,
4509 make_fixnum (f->border_width));
4510 store_in_alist (alistptr, Qchild_frame_border_width,
4511 FRAME_CHILD_FRAME_BORDER_WIDTH (f) >= 0
4512 ? make_fixnum (FRAME_CHILD_FRAME_BORDER_WIDTH (f))
4513 : Qnil);
4514 store_in_alist (alistptr, Qinternal_border_width,
4515 make_fixnum (FRAME_INTERNAL_BORDER_WIDTH (f)));
4516 store_in_alist (alistptr, Qright_divider_width,
4517 make_fixnum (FRAME_RIGHT_DIVIDER_WIDTH (f)));
4518 store_in_alist (alistptr, Qbottom_divider_width,
4519 make_fixnum (FRAME_BOTTOM_DIVIDER_WIDTH (f)));
4520 store_in_alist (alistptr, Qleft_fringe,
4521 make_fixnum (FRAME_LEFT_FRINGE_WIDTH (f)));
4522 store_in_alist (alistptr, Qright_fringe,
4523 make_fixnum (FRAME_RIGHT_FRINGE_WIDTH (f)));
4524 store_in_alist (alistptr, Qscroll_bar_width,
4525 (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
4526 ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
4527
4528
4529
4530 : Qnil));
4531 store_in_alist (alistptr, Qscroll_bar_height,
4532 (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0
4533 ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
4534
4535
4536 : Qnil));
4537
4538
4539
4540
4541 w = (uintptr_t) FRAME_NATIVE_WINDOW (f);
4542 store_in_alist (alistptr, Qwindow_id,
4543 make_formatted_string (buf, "%"PRIuMAX, w));
4544 #ifdef HAVE_X_WINDOWS
4545 #ifdef USE_X_TOOLKIT
4546
4547 if (FRAME_X_OUTPUT (f)->widget)
4548 #endif
4549 w = (uintptr_t) FRAME_OUTER_WINDOW (f);
4550 store_in_alist (alistptr, Qouter_window_id,
4551 make_formatted_string (buf, "%"PRIuMAX, w));
4552 #endif
4553 store_in_alist (alistptr, Qicon_name, f->icon_name);
4554 store_in_alist (alistptr, Qvisibility,
4555 (FRAME_VISIBLE_P (f) ? Qt
4556 : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
4557 store_in_alist (alistptr, Qdisplay,
4558 XCAR (FRAME_DISPLAY_INFO (f)->name_list_element));
4559
4560 if (FRAME_OUTPUT_DATA (f)->parent_desc == FRAME_DISPLAY_INFO (f)->root_window)
4561 tem = Qnil;
4562 else
4563 tem = make_fixed_natnum ((uintptr_t) FRAME_OUTPUT_DATA (f)->parent_desc);
4564 store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil));
4565 store_in_alist (alistptr, Qparent_id, tem);
4566 store_in_alist (alistptr, Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f));
4567 }
4568
4569
4570
4571
4572
4573 void
4574 gui_set_fullscreen (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
4575 {
4576 if (NILP (new_value))
4577 f->want_fullscreen = FULLSCREEN_NONE;
4578 else if (EQ (new_value, Qfullboth) || EQ (new_value, Qfullscreen))
4579 f->want_fullscreen = FULLSCREEN_BOTH;
4580 else if (EQ (new_value, Qfullwidth))
4581 f->want_fullscreen = FULLSCREEN_WIDTH;
4582 else if (EQ (new_value, Qfullheight))
4583 f->want_fullscreen = FULLSCREEN_HEIGHT;
4584 else if (EQ (new_value, Qmaximized))
4585 f->want_fullscreen = FULLSCREEN_MAXIMIZED;
4586
4587 if (FRAME_TERMINAL (f)->fullscreen_hook != NULL)
4588 FRAME_TERMINAL (f)->fullscreen_hook (f);
4589 }
4590
4591
4592
4593
4594
4595 void
4596 gui_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
4597 {
4598 if (NILP (new_value))
4599 f->extra_line_spacing = 0;
4600 else if (RANGED_FIXNUMP (0, new_value, INT_MAX))
4601 f->extra_line_spacing = XFIXNAT (new_value);
4602 else if (FLOATP (new_value))
4603 {
4604 int new_spacing = XFLOAT_DATA (new_value) * FRAME_LINE_HEIGHT (f) + 0.5;
4605
4606 if (new_spacing >= 0)
4607 f->extra_line_spacing = new_spacing;
4608 else
4609 signal_error ("Invalid line-spacing", new_value);
4610 }
4611 else
4612 signal_error ("Invalid line-spacing", new_value);
4613 if (FRAME_VISIBLE_P (f))
4614 redraw_frame (f);
4615 }
4616
4617
4618
4619
4620
4621 void
4622 gui_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
4623 {
4624 Lisp_Object bgcolor;
4625
4626 if (NILP (new_value))
4627 f->gamma = 0;
4628 else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0)
4629
4630 f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value));
4631 else
4632 signal_error ("Invalid screen-gamma", new_value);
4633
4634
4635 bgcolor = Fassq (Qbackground_color, f->param_alist);
4636 if (CONSP (bgcolor) && (bgcolor = XCDR (bgcolor), STRINGP (bgcolor)))
4637 {
4638 Lisp_Object parm_index = Fget (Qbackground_color, Qx_frame_parameter);
4639 if (FIXNATP (parm_index)
4640 && XFIXNAT (parm_index) < ARRAYELTS (frame_parms)
4641 && FRAME_RIF (f)->frame_parm_handlers[XFIXNAT (parm_index)])
4642 (*FRAME_RIF (f)->frame_parm_handlers[XFIXNAT (parm_index)])
4643 (f, bgcolor, Qnil);
4644 }
4645
4646 clear_face_cache (true);
4647 fset_redisplay (f);
4648 }
4649
4650
4651 void
4652 gui_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4653 {
4654 Lisp_Object font_object;
4655 int fontset = -1;
4656
4657
4658
4659 store_frame_param (f, Qfont, oldval);
4660
4661
4662
4663
4664 if (STRINGP (arg))
4665 {
4666 fontset = fs_query_fontset (arg, 0);
4667 if (fontset < 0)
4668 {
4669 font_object = font_open_by_name (f, arg);
4670 if (NILP (font_object))
4671 error ("Font `%s' is not defined", SSDATA (arg));
4672 arg = AREF (font_object, FONT_NAME_INDEX);
4673 }
4674 else if (fontset > 0)
4675 {
4676 font_object = font_open_by_name (f, fontset_ascii (fontset));
4677 if (NILP (font_object))
4678 error ("Font `%s' is not defined", SDATA (arg));
4679 arg = AREF (font_object, FONT_NAME_INDEX);
4680 }
4681 else
4682 error ("The default fontset can't be used for a frame font");
4683 }
4684 else if (CONSP (arg) && STRINGP (XCAR (arg)) && FONT_OBJECT_P (XCDR (arg)))
4685 {
4686
4687
4688
4689 fontset = fs_query_fontset (XCAR (arg), 0);
4690 if (fontset < 0)
4691 error ("Unknown fontset: %s", SDATA (XCAR (arg)));
4692 font_object = XCDR (arg);
4693 arg = AREF (font_object, FONT_NAME_INDEX);
4694 }
4695 else if (FONT_OBJECT_P (arg))
4696 {
4697 font_object = arg;
4698
4699
4700
4701 arg = AREF (font_object, FONT_NAME_INDEX);
4702 fontset = FRAME_FONTSET (f);
4703
4704
4705 if (fontset >= 0)
4706 {
4707 Lisp_Object ascii_font = fontset_ascii (fontset);
4708 Lisp_Object spec = font_spec_from_name (ascii_font);
4709
4710
4711
4712
4713
4714
4715 if (NILP (spec) || ! font_match_p (spec, font_object))
4716 fontset = -1;
4717 }
4718 }
4719 else
4720 signal_error ("Invalid font", arg);
4721
4722 if (! NILP (Fequal (font_object, oldval)))
4723 return;
4724
4725 if (FRAME_TERMINAL (f)->set_new_font_hook)
4726 FRAME_TERMINAL (f)->set_new_font_hook (f, font_object, fontset);
4727 store_frame_param (f, Qfont, arg);
4728
4729
4730 f->n_tab_bar_rows = 0;
4731
4732 f->n_tool_bar_rows = 0;
4733
4734
4735 clear_current_matrices (f);
4736
4737
4738 SET_FRAME_GARBAGED (f);
4739
4740
4741
4742 f->fonts_changed = true;
4743
4744 recompute_basic_faces (f);
4745
4746 do_pending_window_change (0);
4747
4748
4749
4750
4751
4752
4753
4754 }
4755
4756
4757 void
4758 gui_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
4759 {
4760 if (! NILP (new_value)
4761 && !CONSP (new_value))
4762 {
4763 char *p0, *p1;
4764
4765 CHECK_STRING (new_value);
4766 p0 = p1 = SSDATA (new_value);
4767 new_value = Qnil;
4768 while (*p0)
4769 {
4770 while (*p1 && ! c_isspace (*p1) && *p1 != ',') p1++;
4771 if (p0 < p1)
4772 new_value = Fcons (Fintern (make_string (p0, p1 - p0), Qnil),
4773 new_value);
4774 if (*p1)
4775 {
4776 int c;
4777
4778 while ((c = *++p1) && c_isspace (c));
4779 }
4780 p0 = p1;
4781 }
4782 new_value = Fnreverse (new_value);
4783 }
4784
4785 if (! NILP (old_value) && ! NILP (Fequal (old_value, new_value)))
4786 return;
4787
4788 if (FRAME_FONT (f))
4789 {
4790 Lisp_Object frame;
4791 XSETFRAME (frame, f);
4792 free_all_realized_faces (frame);
4793 }
4794
4795 new_value = font_update_drivers (f, NILP (new_value) ? Qt : new_value);
4796 if (NILP (new_value))
4797 {
4798 if (NILP (old_value))
4799 error ("No font backend available");
4800 font_update_drivers (f, old_value);
4801 error ("None of specified font backends are available");
4802 }
4803 store_frame_param (f, Qfont_backend, new_value);
4804
4805 if (FRAME_FONT (f))
4806 {
4807
4808 FRAME_RIF (f)->default_font_parameter (f, Qnil);
4809 face_change = true;
4810 windows_or_buffers_changed = 18;
4811 }
4812 }
4813
4814 void
4815 gui_set_left_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
4816 {
4817 int unit = FRAME_COLUMN_WIDTH (f);
4818 int old_width = FRAME_LEFT_FRINGE_WIDTH (f);
4819 int new_width;
4820
4821 new_width = (RANGED_FIXNUMP (-INT_MAX, new_value, INT_MAX)
4822 ? eabs (XFIXNUM (new_value)) : 8);
4823
4824 if (new_width != old_width)
4825 {
4826 f->left_fringe_width = new_width;
4827 f->fringe_cols
4828 = (new_width + FRAME_RIGHT_FRINGE_WIDTH (f) + unit - 1) / unit;
4829
4830 if (FRAME_NATIVE_WINDOW (f) != 0)
4831 adjust_frame_size (f, -1, -1, 3, 0, Qleft_fringe);
4832
4833 SET_FRAME_GARBAGED (f);
4834 }
4835 }
4836
4837
4838 void
4839 gui_set_right_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
4840 {
4841 int unit = FRAME_COLUMN_WIDTH (f);
4842 int old_width = FRAME_RIGHT_FRINGE_WIDTH (f);
4843 int new_width;
4844
4845 new_width = (RANGED_FIXNUMP (-INT_MAX, new_value, INT_MAX)
4846 ? eabs (XFIXNUM (new_value)) : 8);
4847
4848 if (new_width != old_width)
4849 {
4850 f->right_fringe_width = new_width;
4851 f->fringe_cols
4852 = (new_width + FRAME_LEFT_FRINGE_WIDTH (f) + unit - 1) / unit;
4853
4854 if (FRAME_NATIVE_WINDOW (f) != 0)
4855 adjust_frame_size (f, -1, -1, 3, 0, Qright_fringe);
4856
4857 SET_FRAME_GARBAGED (f);
4858 }
4859 }
4860
4861
4862 void
4863 gui_set_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4864 {
4865 int border_width = check_integer_range (arg, INT_MIN, INT_MAX);
4866
4867 if (border_width == f->border_width)
4868 return;
4869
4870 if (FRAME_NATIVE_WINDOW (f) != 0)
4871 error ("Cannot change the border width of a frame");
4872
4873 f->border_width = border_width;
4874 }
4875
4876 void
4877 gui_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4878 {
4879 int old = FRAME_RIGHT_DIVIDER_WIDTH (f);
4880 int new = check_int_nonnegative (arg);
4881 if (new != old)
4882 {
4883 f->right_divider_width = new;
4884 adjust_frame_size (f, -1, -1, 4, 0, Qright_divider_width);
4885 adjust_frame_glyphs (f);
4886 SET_FRAME_GARBAGED (f);
4887 }
4888 }
4889
4890 void
4891 gui_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4892 {
4893 int old = FRAME_BOTTOM_DIVIDER_WIDTH (f);
4894 int new = check_int_nonnegative (arg);
4895 if (new != old)
4896 {
4897 f->bottom_divider_width = new;
4898 adjust_frame_size (f, -1, -1, 4, 0, Qbottom_divider_width);
4899 adjust_frame_glyphs (f);
4900 SET_FRAME_GARBAGED (f);
4901 }
4902 }
4903
4904 void
4905 gui_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval)
4906 {
4907 Lisp_Object frame;
4908 XSETFRAME (frame, f);
4909
4910 if (NILP (value))
4911 Fmake_frame_invisible (frame, Qt);
4912 else if (EQ (value, Qicon))
4913 Ficonify_frame (frame);
4914 else
4915 Fmake_frame_visible (frame);
4916 }
4917
4918 void
4919 gui_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4920 {
4921 f->auto_raise = !NILP (arg);
4922 }
4923
4924 void
4925 gui_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4926 {
4927 f->auto_lower = !NILP (arg);
4928 }
4929
4930 void
4931 gui_set_unsplittable (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4932 {
4933 f->no_split = !NILP (arg);
4934 }
4935
4936 void
4937 gui_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4938 {
4939 if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
4940 || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
4941 || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f))
4942 || (!NILP (arg) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f)))
4943 {
4944 FRAME_VERTICAL_SCROLL_BAR_TYPE (f)
4945 = (NILP (arg)
4946 ? vertical_scroll_bar_none
4947 : EQ (Qleft, arg)
4948 ? vertical_scroll_bar_left
4949 : EQ (Qright, arg)
4950 ? vertical_scroll_bar_right
4951 : EQ (Qleft, Vdefault_frame_scroll_bars)
4952 ? vertical_scroll_bar_left
4953 : EQ (Qright, Vdefault_frame_scroll_bars)
4954 ? vertical_scroll_bar_right
4955 : vertical_scroll_bar_none);
4956
4957
4958
4959
4960
4961 if (FRAME_NATIVE_WINDOW (f))
4962 adjust_frame_size (f, -1, -1, 3, 0, Qvertical_scroll_bars);
4963
4964 SET_FRAME_GARBAGED (f);
4965 }
4966 }
4967
4968 void
4969 gui_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4970 {
4971 #if USE_HORIZONTAL_SCROLL_BARS
4972 if ((NILP (arg) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f))
4973 || (!NILP (arg) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f)))
4974 {
4975 f->horizontal_scroll_bars = NILP (arg) ? false : true;
4976
4977
4978
4979
4980
4981 if (FRAME_NATIVE_WINDOW (f))
4982 adjust_frame_size (f, -1, -1, 3, 0, Qhorizontal_scroll_bars);
4983
4984 SET_FRAME_GARBAGED (f);
4985 }
4986 #endif
4987 }
4988
4989 void
4990 gui_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4991 {
4992 int unit = FRAME_COLUMN_WIDTH (f);
4993
4994 if (RANGED_FIXNUMP (1, arg, INT_MAX)
4995 && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
4996 {
4997 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg);
4998 FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit;
4999 if (FRAME_NATIVE_WINDOW (f))
5000 adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
5001
5002 SET_FRAME_GARBAGED (f);
5003 }
5004 else
5005 {
5006 if (FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook)
5007 FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook (f);
5008
5009 if (FRAME_NATIVE_WINDOW (f))
5010 adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
5011
5012 SET_FRAME_GARBAGED (f);
5013 }
5014
5015 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
5016 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
5017 }
5018
5019 void
5020 gui_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
5021 {
5022 #if USE_HORIZONTAL_SCROLL_BARS
5023 int unit = FRAME_LINE_HEIGHT (f);
5024
5025 if (RANGED_FIXNUMP (1, arg, INT_MAX)
5026 && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
5027 {
5028 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg);
5029 FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit;
5030 if (FRAME_NATIVE_WINDOW (f))
5031 adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
5032
5033 SET_FRAME_GARBAGED (f);
5034 }
5035 else
5036 {
5037 if (FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook)
5038 FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook (f);
5039
5040 if (FRAME_NATIVE_WINDOW (f))
5041 adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
5042
5043 SET_FRAME_GARBAGED (f);
5044 }
5045
5046 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.vpos = 0;
5047 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.y = 0;
5048 #endif
5049 }
5050
5051 void
5052 gui_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
5053 {
5054 double alpha = 1.0;
5055 double newval[2];
5056 int i;
5057 Lisp_Object item;
5058
5059 for (i = 0; i < 2; i++)
5060 {
5061 newval[i] = 1.0;
5062 if (CONSP (arg))
5063 {
5064 item = CAR (arg);
5065 arg = CDR (arg);
5066 }
5067 else
5068 item = arg;
5069
5070 if (NILP (item))
5071 alpha = - 1.0;
5072 else if (FLOATP (item))
5073 {
5074 alpha = XFLOAT_DATA (item);
5075 if (! (0 <= alpha && alpha <= 1.0))
5076 args_out_of_range (make_float (0.0), make_float (1.0));
5077 }
5078 else if (FIXNUMP (item))
5079 {
5080 EMACS_INT ialpha = XFIXNUM (item);
5081 if (! (0 <= ialpha && ialpha <= 100))
5082 args_out_of_range (make_fixnum (0), make_fixnum (100));
5083 alpha = ialpha / 100.0;
5084 }
5085 else
5086 wrong_type_argument (Qnumberp, item);
5087 newval[i] = alpha;
5088 }
5089
5090 for (i = 0; i < 2; i++)
5091 f->alpha[i] = newval[i];
5092
5093 if (FRAME_TERMINAL (f)->set_frame_alpha_hook)
5094 {
5095 block_input ();
5096 FRAME_TERMINAL (f)->set_frame_alpha_hook (f);
5097 unblock_input ();
5098 }
5099 }
5100
5101 void
5102 gui_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
5103 {
5104 double alpha = 1.0;
5105
5106 if (NILP (arg))
5107 alpha = 1.0;
5108 else if (FLOATP (arg))
5109 {
5110 alpha = XFLOAT_DATA (arg);
5111 if (! (0 <= alpha && alpha <= 1.0))
5112 args_out_of_range (make_float (0.0), make_float (1.0));
5113 }
5114 else if (FIXNUMP (arg))
5115 {
5116 EMACS_INT ialpha = XFIXNUM (arg);
5117 if (! (0 <= ialpha && ialpha <= 100))
5118 args_out_of_range (make_fixnum (0), make_fixnum (100));
5119 alpha = ialpha / 100.0;
5120 }
5121 else
5122 wrong_type_argument (Qnumberp, arg);
5123
5124 f->alpha_background = alpha;
5125
5126 recompute_basic_faces (f);
5127 SET_FRAME_GARBAGED (f);
5128 }
5129
5130
5131
5132
5133
5134
5135
5136
5137 void
5138 gui_set_no_special_glyphs (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
5139 {
5140 if (!EQ (new_value, old_value))
5141 FRAME_NO_SPECIAL_GLYPHS (f) = !NILP (new_value);
5142 }
5143
5144
5145
5146
5147
5148 bool
5149 gui_mouse_grabbed (Display_Info *dpyinfo)
5150 {
5151 return ((dpyinfo->grabbed
5152 || (dpyinfo->terminal->any_grab_hook
5153 && dpyinfo->terminal->any_grab_hook (dpyinfo)))
5154 && dpyinfo->last_mouse_frame
5155 && FRAME_LIVE_P (dpyinfo->last_mouse_frame));
5156 }
5157
5158
5159
5160
5161 void
5162 gui_redo_mouse_highlight (Display_Info *dpyinfo)
5163 {
5164 if (dpyinfo->last_mouse_motion_frame
5165 && FRAME_LIVE_P (dpyinfo->last_mouse_motion_frame))
5166 note_mouse_highlight (dpyinfo->last_mouse_motion_frame,
5167 dpyinfo->last_mouse_motion_x,
5168 dpyinfo->last_mouse_motion_y);
5169 }
5170
5171
5172
5173
5174
5175
5176 void
5177 validate_x_resource_name (void)
5178 {
5179 ptrdiff_t len = 0;
5180
5181 ptrdiff_t good_count = 0;
5182
5183 ptrdiff_t bad_count = 0;
5184 Lisp_Object new;
5185 ptrdiff_t i;
5186
5187 if (!STRINGP (Vx_resource_class))
5188 Vx_resource_class = build_string (EMACS_CLASS);
5189
5190 if (STRINGP (Vx_resource_name))
5191 {
5192 unsigned char *p = SDATA (Vx_resource_name);
5193
5194 len = SBYTES (Vx_resource_name);
5195
5196
5197
5198 for (i = 0; i < len; i++)
5199 {
5200 int c = p[i];
5201 if (! ((c >= 'a' && c <= 'z')
5202 || (c >= 'A' && c <= 'Z')
5203 || (c >= '0' && c <= '9')
5204 || c == '-' || c == '_'))
5205 bad_count++;
5206 else
5207 good_count++;
5208 }
5209 }
5210 else
5211
5212 bad_count = 5, good_count = 0;
5213
5214
5215 if (bad_count == 0)
5216 return;
5217
5218
5219
5220 if (good_count < 2 || MAX_ALLOCA - sizeof ".customization" < len)
5221 {
5222 Vx_resource_name = build_string ("emacs");
5223 return;
5224 }
5225
5226
5227
5228
5229 Vx_resource_name = new = Fcopy_sequence (Vx_resource_name);
5230
5231 for (i = 0; i < len; i++)
5232 {
5233 int c = SREF (new, i);
5234 if (! ((c >= 'a' && c <= 'z')
5235 || (c >= 'A' && c <= 'Z')
5236 || (c >= '0' && c <= '9')
5237 || c == '-' || c == '_'))
5238 SSET (new, i, '_');
5239 }
5240 }
5241
5242
5243
5244
5245 Lisp_Object
5246 gui_display_get_resource (Display_Info *dpyinfo, Lisp_Object attribute,
5247 Lisp_Object class, Lisp_Object component,
5248 Lisp_Object subclass)
5249 {
5250 CHECK_STRING (attribute);
5251 CHECK_STRING (class);
5252
5253 if (!NILP (component))
5254 CHECK_STRING (component);
5255 if (!NILP (subclass))
5256 CHECK_STRING (subclass);
5257 if (NILP (component) != NILP (subclass))
5258 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
5259
5260 validate_x_resource_name ();
5261
5262
5263
5264 ptrdiff_t name_keysize = (SBYTES (Vx_resource_name)
5265 + (STRINGP (component)
5266 ? SBYTES (component) : 0)
5267 + SBYTES (attribute)
5268 + 3);
5269
5270 ptrdiff_t class_keysize = (SBYTES (Vx_resource_class)
5271 + SBYTES (class)
5272 + (STRINGP (subclass)
5273 ? SBYTES (subclass) : 0)
5274 + 3);
5275 USE_SAFE_ALLOCA;
5276 char *name_key = SAFE_ALLOCA (name_keysize + class_keysize);
5277 char *class_key = name_key + name_keysize;
5278
5279
5280
5281 char *nz = lispstpcpy (name_key, Vx_resource_name);
5282 char *cz = lispstpcpy (class_key, Vx_resource_class);
5283
5284 *cz++ = '.';
5285 cz = lispstpcpy (cz, class);
5286
5287 if (!NILP (component))
5288 {
5289 *cz++ = '.';
5290 lispstpcpy (cz, subclass);
5291
5292 *nz++ = '.';
5293 nz = lispstpcpy (nz, component);
5294 }
5295
5296 *nz++ = '.';
5297 lispstpcpy (nz, attribute);
5298
5299 const char *value =
5300 dpyinfo->terminal->get_string_resource_hook (&dpyinfo->rdb,
5301 name_key,
5302 class_key);
5303 SAFE_FREE();
5304
5305 if (value && *value)
5306 return build_string (value);
5307 else
5308 return Qnil;
5309 }
5310
5311
5312 DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0,
5313 doc:
5314
5315
5316
5317
5318
5319
5320
5321 )
5322 (Lisp_Object attribute, Lisp_Object class, Lisp_Object component,
5323 Lisp_Object subclass)
5324 {
5325 check_window_system (NULL);
5326
5327 return gui_display_get_resource (check_x_display_info (Qnil),
5328 attribute, class, component, subclass);
5329 }
5330
5331 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT && !defined USE_GTK
5332
5333
5334 const char *
5335 x_get_resource_string (const char *attribute, const char *class)
5336 {
5337 const char *result;
5338 struct frame *sf = SELECTED_FRAME ();
5339 ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name);
5340 USE_SAFE_ALLOCA;
5341
5342
5343
5344 ptrdiff_t name_keysize = invocation_namelen + strlen (attribute) + 2;
5345 ptrdiff_t class_keysize = sizeof (EMACS_CLASS) - 1 + strlen (class) + 2;
5346 char *name_key = SAFE_ALLOCA (name_keysize + class_keysize);
5347 char *class_key = name_key + name_keysize;
5348 esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
5349 sprintf (class_key, "%s.%s", EMACS_CLASS, class);
5350
5351 result = x_get_string_resource (&FRAME_DISPLAY_INFO (sf)->rdb,
5352 name_key, class_key);
5353 SAFE_FREE ();
5354 return result;
5355 }
5356 #endif
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371 Lisp_Object
5372 gui_display_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
5373 const char *attribute, const char *class,
5374 enum resource_types type)
5375 {
5376 Lisp_Object tem;
5377
5378 tem = Fassq (param, alist);
5379
5380 if (!NILP (tem))
5381 {
5382
5383
5384 Lisp_Object tail;
5385 XSETCAR (tem, Qnil);
5386
5387
5388 for (tail = alist; CONSP (tail); tail = XCDR (tail))
5389 if (CONSP (XCAR (tail))
5390 && EQ (XCAR (XCAR (tail)), param))
5391 XSETCAR (XCAR (tail), Qnil);
5392 }
5393 else
5394 tem = Fassq (param, Vdefault_frame_alist);
5395
5396
5397
5398 if (NILP (tem))
5399 {
5400 if (attribute && dpyinfo)
5401 {
5402 AUTO_STRING (at, attribute);
5403 AUTO_STRING (cl, class);
5404 tem = gui_display_get_resource (dpyinfo, at, cl, Qnil, Qnil);
5405
5406 if (NILP (tem))
5407 return Qunbound;
5408
5409 switch (type)
5410 {
5411 case RES_TYPE_NUMBER:
5412 return make_fixnum (atoi (SSDATA (tem)));
5413
5414 case RES_TYPE_BOOLEAN_NUMBER:
5415 if (!strcmp (SSDATA (tem), "on")
5416 || !strcmp (SSDATA (tem), "true"))
5417 return make_fixnum (1);
5418 return make_fixnum (atoi (SSDATA (tem)));
5419 break;
5420
5421 case RES_TYPE_FLOAT:
5422 return make_float (atof (SSDATA (tem)));
5423
5424 case RES_TYPE_BOOLEAN:
5425 tem = Fdowncase (tem);
5426 if (!strcmp (SSDATA (tem), "on")
5427 #ifdef HAVE_NS
5428 || !strcmp (SSDATA (tem), "yes")
5429 #endif
5430 || !strcmp (SSDATA (tem), "true"))
5431 return Qt;
5432 else
5433 return Qnil;
5434
5435 case RES_TYPE_STRING:
5436 return tem;
5437
5438 case RES_TYPE_SYMBOL:
5439
5440
5441 {
5442 Lisp_Object lower;
5443 lower = Fdowncase (tem);
5444 if (!strcmp (SSDATA (lower), "on")
5445 #ifdef HAVE_NS
5446 || !strcmp (SSDATA (lower), "yes")
5447 #endif
5448 || !strcmp (SSDATA (lower), "true"))
5449 return Qt;
5450 else if (!strcmp (SSDATA (lower), "off")
5451 #ifdef HAVE_NS
5452 || !strcmp (SSDATA (lower), "no")
5453 #endif
5454 || !strcmp (SSDATA (lower), "false"))
5455 return Qnil;
5456 else
5457 return Fintern (tem, Qnil);
5458 }
5459
5460 default:
5461 emacs_abort ();
5462 }
5463 }
5464 else
5465 return Qunbound;
5466 }
5467 return Fcdr (tem);
5468 }
5469
5470 static Lisp_Object
5471 gui_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param,
5472 const char *attribute, const char *class,
5473 enum resource_types type)
5474 {
5475 return gui_display_get_arg (FRAME_DISPLAY_INFO (f),
5476 alist, param, attribute, class, type);
5477 }
5478
5479
5480
5481 Lisp_Object
5482 gui_frame_get_and_record_arg (struct frame *f, Lisp_Object alist,
5483 Lisp_Object param,
5484 const char *attribute, const char *class,
5485 enum resource_types type)
5486 {
5487 Lisp_Object value;
5488
5489 value = gui_display_get_arg (FRAME_DISPLAY_INFO (f), alist, param,
5490 attribute, class, type);
5491 if (! NILP (value) && ! BASE_EQ (value, Qunbound))
5492 store_frame_param (f, param, value);
5493
5494 return value;
5495 }
5496
5497
5498
5499
5500
5501
5502
5503
5504 Lisp_Object
5505 gui_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop,
5506 Lisp_Object deflt, const char *xprop, const char *xclass,
5507 enum resource_types type)
5508 {
5509 Lisp_Object tem;
5510 bool was_unbound;
5511
5512 tem = gui_frame_get_arg (f, alist, prop, xprop, xclass, type);
5513
5514 if (BASE_EQ (tem, Qunbound))
5515 {
5516 tem = deflt;
5517 was_unbound = true;
5518 }
5519 else
5520 was_unbound = false;
5521
5522 AUTO_FRAME_ARG (arg, prop, tem);
5523 gui_set_frame_parameters_1 (f, arg, was_unbound);
5524 return tem;
5525 }
5526
5527
5528 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542 static int
5543 XParseGeometry (char *string,
5544 int *x, int *y,
5545 unsigned int *width, unsigned int *height)
5546 {
5547 int mask = NoValue;
5548 char *strind;
5549 unsigned long tempWidth UNINIT, tempHeight UNINIT;
5550 long int tempX UNINIT, tempY UNINIT;
5551 char *nextCharacter;
5552
5553 if (string == NULL || *string == '\0')
5554 return mask;
5555 if (*string == '=')
5556 string++;
5557
5558 strind = string;
5559 if (*strind != '+' && *strind != '-' && *strind != 'x')
5560 {
5561 tempWidth = strtoul (strind, &nextCharacter, 10);
5562 if (strind == nextCharacter)
5563 return 0;
5564 strind = nextCharacter;
5565 mask |= WidthValue;
5566 }
5567
5568 if (*strind == 'x' || *strind == 'X')
5569 {
5570 strind++;
5571 tempHeight = strtoul (strind, &nextCharacter, 10);
5572 if (strind == nextCharacter)
5573 return 0;
5574 strind = nextCharacter;
5575 mask |= HeightValue;
5576 }
5577
5578 if (*strind == '+' || *strind == '-')
5579 {
5580 if (*strind == '-')
5581 mask |= XNegative;
5582 tempX = strtol (strind, &nextCharacter, 10);
5583 if (strind == nextCharacter)
5584 return 0;
5585 strind = nextCharacter;
5586 mask |= XValue;
5587 if (*strind == '+' || *strind == '-')
5588 {
5589 if (*strind == '-')
5590 mask |= YNegative;
5591 tempY = strtol (strind, &nextCharacter, 10);
5592 if (strind == nextCharacter)
5593 return 0;
5594 strind = nextCharacter;
5595 mask |= YValue;
5596 }
5597 }
5598
5599
5600
5601
5602 if (*strind != '\0')
5603 return 0;
5604
5605 if (mask & XValue)
5606 *x = clip_to_bounds (INT_MIN, tempX, INT_MAX);
5607 if (mask & YValue)
5608 *y = clip_to_bounds (INT_MIN, tempY, INT_MAX);
5609 if (mask & WidthValue)
5610 *width = min (tempWidth, UINT_MAX);
5611 if (mask & HeightValue)
5612 *height = min (tempHeight, UINT_MAX);
5613 return mask;
5614 }
5615
5616 #endif
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627 DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
5628 doc:
5629
5630
5631
5632
5633
5634 )
5635 (Lisp_Object string)
5636 {
5637
5638
5639
5640 int x UNINIT, y UNINIT;
5641 unsigned int width, height;
5642
5643 CHECK_STRING (string);
5644
5645 #ifdef HAVE_NS
5646 if (strchr (SSDATA (string), ' ') != NULL)
5647 return call1 (Qns_parse_geometry, string);
5648 #endif
5649 int geometry = XParseGeometry (SSDATA (string),
5650 &x, &y, &width, &height);
5651 Lisp_Object result = Qnil;
5652 if (geometry & XValue)
5653 {
5654 Lisp_Object element;
5655
5656 if (x >= 0 && (geometry & XNegative))
5657 element = list3 (Qleft, Qminus, make_fixnum (-x));
5658 else if (x < 0 && ! (geometry & XNegative))
5659 element = list3 (Qleft, Qplus, make_fixnum (x));
5660 else
5661 element = Fcons (Qleft, make_fixnum (x));
5662 result = Fcons (element, result);
5663 }
5664
5665 if (geometry & YValue)
5666 {
5667 Lisp_Object element;
5668
5669 if (y >= 0 && (geometry & YNegative))
5670 element = list3 (Qtop, Qminus, make_fixnum (-y));
5671 else if (y < 0 && ! (geometry & YNegative))
5672 element = list3 (Qtop, Qplus, make_fixnum (y));
5673 else
5674 element = Fcons (Qtop, make_fixnum (y));
5675 result = Fcons (element, result);
5676 }
5677
5678 if (geometry & WidthValue)
5679 result = Fcons (Fcons (Qwidth, make_fixnum (width)), result);
5680 if (geometry & HeightValue)
5681 result = Fcons (Fcons (Qheight, make_fixnum (height)), result);
5682
5683 return result;
5684 }
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696 long
5697 gui_figure_window_size (struct frame *f, Lisp_Object parms, bool tabbar_p,
5698 bool toolbar_p)
5699 {
5700 Lisp_Object height, width, user_size, top, left, user_position;
5701 long window_prompting = 0;
5702 Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
5703 int parent_done = -1, outer_done = -1;
5704 int text_width = 80 * FRAME_COLUMN_WIDTH (f);
5705 int text_height = 36 * FRAME_LINE_HEIGHT (f);
5706
5707
5708
5709 f->top_pos = 0;
5710 f->left_pos = 0;
5711
5712
5713
5714
5715
5716
5717 if (tabbar_p && FRAME_TAB_BAR_LINES (f))
5718 {
5719 if (frame_default_tab_bar_height)
5720
5721
5722 FRAME_TAB_BAR_HEIGHT (f) = frame_default_tab_bar_height;
5723 else
5724
5725
5726 {
5727 int margin, relief;
5728
5729 relief = (tab_bar_button_relief < 0
5730 ? DEFAULT_TAB_BAR_BUTTON_RELIEF
5731 : min (tab_bar_button_relief, 1000000));
5732
5733 if (RANGED_FIXNUMP (1, Vtab_bar_button_margin, INT_MAX))
5734 margin = XFIXNAT (Vtab_bar_button_margin);
5735 else if (CONSP (Vtab_bar_button_margin)
5736 && RANGED_FIXNUMP (1, XCDR (Vtab_bar_button_margin), INT_MAX))
5737 margin = XFIXNAT (XCDR (Vtab_bar_button_margin));
5738 else
5739 margin = 0;
5740
5741 FRAME_TAB_BAR_HEIGHT (f)
5742 = DEFAULT_TAB_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
5743 }
5744 }
5745
5746
5747
5748
5749
5750
5751 if (toolbar_p && FRAME_TOOL_BAR_LINES (f))
5752 {
5753 if (frame_default_tool_bar_height)
5754 FRAME_TOOL_BAR_HEIGHT (f) = frame_default_tool_bar_height;
5755 else
5756 {
5757 int margin, relief;
5758
5759 relief = (tool_bar_button_relief < 0
5760 ? DEFAULT_TOOL_BAR_BUTTON_RELIEF
5761 : min (tool_bar_button_relief, 1000000));
5762
5763 if (RANGED_FIXNUMP (1, Vtool_bar_button_margin, INT_MAX))
5764 margin = XFIXNAT (Vtool_bar_button_margin);
5765 else if (CONSP (Vtool_bar_button_margin)
5766 && RANGED_FIXNUMP (1, XCDR (Vtool_bar_button_margin), INT_MAX))
5767 margin = XFIXNAT (XCDR (Vtool_bar_button_margin));
5768 else
5769 margin = 0;
5770
5771 FRAME_TOOL_BAR_HEIGHT (f)
5772 = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
5773 }
5774 }
5775
5776
5777
5778 f->new_width = f->new_height = -1;
5779
5780 height = gui_display_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
5781 width = gui_display_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
5782 if (!BASE_EQ (width, Qunbound) || !BASE_EQ (height, Qunbound))
5783 {
5784 if (!BASE_EQ (width, Qunbound))
5785 {
5786 if (CONSP (width) && EQ (XCAR (width), Qtext_pixels))
5787 {
5788 CHECK_FIXNUM (XCDR (width));
5789 if ((XFIXNUM (XCDR (width)) < 0 || XFIXNUM (XCDR (width)) > INT_MAX))
5790 xsignal1 (Qargs_out_of_range, XCDR (width));
5791
5792 text_width = XFIXNUM (XCDR (width));
5793 f->inhibit_horizontal_resize = true;
5794 }
5795 else if (FLOATP (width))
5796 {
5797 double d_width = XFLOAT_DATA (width);
5798
5799 if (d_width < 0.0 || d_width > 1.0)
5800 xsignal1 (Qargs_out_of_range, width);
5801 else
5802 {
5803 int new_width = frame_float (f, width, FRAME_FLOAT_WIDTH,
5804 &parent_done, &outer_done, -1);
5805
5806 if (new_width > -1)
5807 text_width = new_width;
5808 }
5809 }
5810 else
5811 {
5812 CHECK_FIXNUM (width);
5813 if ((XFIXNUM (width) < 0 || XFIXNUM (width) > INT_MAX))
5814 xsignal1 (Qargs_out_of_range, width);
5815
5816 text_width = XFIXNUM (width) * FRAME_COLUMN_WIDTH (f);
5817 }
5818 }
5819
5820 if (!BASE_EQ (height, Qunbound))
5821 {
5822 if (CONSP (height) && EQ (XCAR (height), Qtext_pixels))
5823 {
5824 CHECK_FIXNUM (XCDR (height));
5825 if ((XFIXNUM (XCDR (height)) < 0 || XFIXNUM (XCDR (height)) > INT_MAX))
5826 xsignal1 (Qargs_out_of_range, XCDR (height));
5827
5828 text_height = XFIXNUM (XCDR (height));
5829 f->inhibit_vertical_resize = true;
5830 }
5831 else if (FLOATP (height))
5832 {
5833 double d_height = XFLOAT_DATA (height);
5834
5835 if (d_height < 0.0 || d_height > 1.0)
5836 xsignal1 (Qargs_out_of_range, height);
5837 else
5838 {
5839 int new_height = frame_float (f, height, FRAME_FLOAT_HEIGHT,
5840 &parent_done, &outer_done, -1);
5841
5842 if (new_height > -1)
5843 text_height = new_height;
5844 }
5845 }
5846 else
5847 {
5848 CHECK_FIXNUM (height);
5849 if ((XFIXNUM (height) < 0) || (XFIXNUM (height) > INT_MAX))
5850 xsignal1 (Qargs_out_of_range, height);
5851
5852 text_height = XFIXNUM (height) * FRAME_LINE_HEIGHT (f);
5853 }
5854 }
5855
5856 user_size = gui_display_get_arg (dpyinfo, parms, Quser_size, 0, 0,
5857 RES_TYPE_NUMBER);
5858 if (!NILP (user_size) && !BASE_EQ (user_size, Qunbound))
5859 window_prompting |= USSize;
5860 else
5861 window_prompting |= PSize;
5862 }
5863
5864 adjust_frame_size (f, text_width, text_height, 5, false,
5865 Qgui_figure_window_size);
5866
5867 top = gui_display_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
5868 left = gui_display_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
5869 user_position = gui_display_get_arg (dpyinfo, parms, Quser_position, 0, 0,
5870 RES_TYPE_NUMBER);
5871 if (! BASE_EQ (top, Qunbound) || ! BASE_EQ (left, Qunbound))
5872 {
5873 if (EQ (top, Qminus))
5874 {
5875 f->top_pos = 0;
5876 window_prompting |= YNegative;
5877 }
5878 else if (CONSP (top) && EQ (XCAR (top), Qminus)
5879 && CONSP (XCDR (top))
5880 && RANGED_FIXNUMP (-INT_MAX, XCAR (XCDR (top)), INT_MAX))
5881 {
5882 f->top_pos = - XFIXNUM (XCAR (XCDR (top)));
5883 window_prompting |= YNegative;
5884 }
5885 else if (CONSP (top) && EQ (XCAR (top), Qplus)
5886 && CONSP (XCDR (top))
5887 && TYPE_RANGED_FIXNUMP (int, XCAR (XCDR (top))))
5888 {
5889 f->top_pos = XFIXNUM (XCAR (XCDR (top)));
5890 }
5891 else if (FLOATP (top))
5892 f->top_pos = frame_float (f, top, FRAME_FLOAT_TOP, &parent_done,
5893 &outer_done, 0);
5894 else if (BASE_EQ (top, Qunbound))
5895 f->top_pos = 0;
5896 else
5897 {
5898 f->top_pos = check_integer_range (top, INT_MIN, INT_MAX);
5899 if (f->top_pos < 0)
5900 window_prompting |= YNegative;
5901 }
5902
5903 if (EQ (left, Qminus))
5904 {
5905 f->left_pos = 0;
5906 window_prompting |= XNegative;
5907 }
5908 else if (CONSP (left) && EQ (XCAR (left), Qminus)
5909 && CONSP (XCDR (left))
5910 && RANGED_FIXNUMP (-INT_MAX, XCAR (XCDR (left)), INT_MAX))
5911 {
5912 f->left_pos = - XFIXNUM (XCAR (XCDR (left)));
5913 window_prompting |= XNegative;
5914 }
5915 else if (CONSP (left) && EQ (XCAR (left), Qplus)
5916 && CONSP (XCDR (left))
5917 && TYPE_RANGED_FIXNUMP (int, XCAR (XCDR (left))))
5918 {
5919 f->left_pos = XFIXNUM (XCAR (XCDR (left)));
5920 }
5921 else if (FLOATP (left))
5922 f->left_pos = frame_float (f, left, FRAME_FLOAT_LEFT, &parent_done,
5923 &outer_done, 0);
5924 else if (BASE_EQ (left, Qunbound))
5925 f->left_pos = 0;
5926 else
5927 {
5928 f->left_pos = check_integer_range (left, INT_MIN, INT_MAX);
5929 if (f->left_pos < 0)
5930 window_prompting |= XNegative;
5931 }
5932
5933 if (!NILP (user_position) && ! BASE_EQ (user_position, Qunbound))
5934 window_prompting |= USPosition;
5935 else
5936 window_prompting |= PPosition;
5937 }
5938
5939 if (window_prompting & XNegative)
5940 {
5941 if (window_prompting & YNegative)
5942 f->win_gravity = SouthEastGravity;
5943 else
5944 f->win_gravity = NorthEastGravity;
5945 }
5946 else
5947 {
5948 if (window_prompting & YNegative)
5949 f->win_gravity = SouthWestGravity;
5950 else
5951 f->win_gravity = NorthWestGravity;
5952 }
5953
5954 f->size_hint_flags = window_prompting;
5955
5956 return window_prompting;
5957 }
5958
5959
5960
5961 #endif
5962
5963 void
5964 frame_make_pointer_invisible (struct frame *f)
5965 {
5966 if (! NILP (Vmake_pointer_invisible))
5967 {
5968 if (f && FRAME_LIVE_P (f) && !f->pointer_invisible
5969 && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook)
5970 {
5971 f->mouse_moved = 0;
5972 FRAME_TERMINAL (f)->toggle_invisible_pointer_hook (f, 1);
5973 f->pointer_invisible = 1;
5974 }
5975 }
5976 }
5977
5978 void
5979 frame_make_pointer_visible (struct frame *f)
5980 {
5981
5982
5983 if (f && FRAME_LIVE_P (f) && f->pointer_invisible && f->mouse_moved
5984 && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook)
5985 {
5986 FRAME_TERMINAL (f)->toggle_invisible_pointer_hook (f, 0);
5987 f->pointer_invisible = 0;
5988 }
5989 }
5990
5991 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p,
5992 Sframe_pointer_visible_p, 0, 1, 0,
5993 doc:
5994
5995 )
5996 (Lisp_Object frame)
5997 {
5998 return decode_any_frame (frame)->pointer_invisible ? Qnil : Qt;
5999 }
6000
6001 DEFUN ("frame--set-was-invisible", Fframe__set_was_invisible,
6002 Sframe__set_was_invisible, 2, 2, 0,
6003 doc:
6004 )
6005 (Lisp_Object frame, Lisp_Object was_invisible)
6006 {
6007 struct frame *f = decode_live_frame (frame);
6008
6009 f->was_invisible = !NILP (was_invisible);
6010
6011 return f->was_invisible ? Qt : Qnil;
6012 }
6013
6014 #ifdef HAVE_WINDOW_SYSTEM
6015
6016 DEFUN ("reconsider-frame-fonts", Freconsider_frame_fonts,
6017 Sreconsider_frame_fonts, 1, 1, 0,
6018 doc:
6019
6020
6021
6022 )
6023 (Lisp_Object frame)
6024 {
6025 struct frame *f;
6026 Lisp_Object params, font_parameter;
6027
6028 f = decode_window_system_frame (frame);
6029
6030
6031
6032
6033
6034 params = Qnil;
6035
6036
6037
6038
6039
6040
6041
6042 font_parameter = get_frame_param (f, Qfont_parameter);
6043
6044 if (!NILP (font_parameter))
6045 params = list1 (Fcons (Qfont, font_parameter));
6046
6047
6048
6049
6050 if (FRAME_RIF (f)->default_font_parameter)
6051 FRAME_RIF (f)->default_font_parameter (f, params);
6052
6053
6054
6055
6056 if (!NILP (font_parameter))
6057 params = list1 (Fcons (Qfont, font_parameter));
6058
6059
6060
6061 call2 (Qface_set_after_frame_default, frame, params);
6062
6063
6064
6065
6066 if (!NILP (font_parameter))
6067 store_frame_param (f, Qfont_parameter, font_parameter);
6068
6069 return Qnil;
6070 }
6071
6072 #endif
6073
6074
6075
6076
6077
6078
6079 #ifdef HAVE_WINDOW_SYSTEM
6080
6081 # if (defined USE_GTK || defined HAVE_PGTK || defined HAVE_NS || defined HAVE_XINERAMA \
6082 || defined HAVE_XRANDR)
6083 void
6084 free_monitors (struct MonitorInfo *monitors, int n_monitors)
6085 {
6086 int i;
6087 for (i = 0; i < n_monitors; ++i)
6088 xfree (monitors[i].name);
6089 xfree (monitors);
6090 }
6091 # endif
6092
6093 Lisp_Object
6094 make_monitor_attribute_list (struct MonitorInfo *monitors,
6095 int n_monitors,
6096 int primary_monitor,
6097 Lisp_Object monitor_frames,
6098 const char *source)
6099 {
6100 Lisp_Object attributes_list = Qnil;
6101 Lisp_Object primary_monitor_attributes = Qnil;
6102 int i;
6103
6104 for (i = 0; i < n_monitors; ++i)
6105 {
6106 Lisp_Object geometry, workarea, attributes = Qnil;
6107 struct MonitorInfo *mi = &monitors[i];
6108
6109 if (mi->geom.width == 0) continue;
6110
6111 workarea = list4i (mi->work.x, mi->work.y,
6112 mi->work.width, mi->work.height);
6113 geometry = list4i (mi->geom.x, mi->geom.y,
6114 mi->geom.width, mi->geom.height);
6115 attributes = Fcons (Fcons (Qsource, build_string (source)),
6116 attributes);
6117 attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
6118 attributes);
6119 #ifdef HAVE_PGTK
6120 attributes = Fcons (Fcons (Qscale_factor, make_float (mi->scale_factor)),
6121 attributes);
6122 #endif
6123 attributes = Fcons (Fcons (Qmm_size,
6124 list2i (mi->mm_width, mi->mm_height)),
6125 attributes);
6126 attributes = Fcons (Fcons (Qworkarea, workarea), attributes);
6127 attributes = Fcons (Fcons (Qgeometry, geometry), attributes);
6128 if (mi->name)
6129 attributes = Fcons (Fcons (Qname, make_string (mi->name,
6130 strlen (mi->name))),
6131 attributes);
6132
6133 if (i == primary_monitor)
6134 primary_monitor_attributes = attributes;
6135 else
6136 attributes_list = Fcons (attributes, attributes_list);
6137 }
6138
6139 if (!NILP (primary_monitor_attributes))
6140 attributes_list = Fcons (primary_monitor_attributes, attributes_list);
6141 return attributes_list;
6142 }
6143
6144 #endif
6145
6146
6147
6148
6149
6150
6151 static void init_frame_once_for_pdumper (void);
6152
6153 void
6154 init_frame_once (void)
6155 {
6156 staticpro (&Vframe_list);
6157 staticpro (&selected_frame);
6158 PDUMPER_IGNORE (last_nonminibuf_frame);
6159 Vframe_list = Qnil;
6160 selected_frame = Qnil;
6161 pdumper_do_now_and_after_load (init_frame_once_for_pdumper);
6162 }
6163
6164 static void
6165 init_frame_once_for_pdumper (void)
6166 {
6167 PDUMPER_RESET_LV (Vframe_list, Qnil);
6168 PDUMPER_RESET_LV (selected_frame, Qnil);
6169 }
6170
6171 void
6172 syms_of_frame (void)
6173 {
6174 DEFSYM (Qframep, "framep");
6175 DEFSYM (Qframe_live_p, "frame-live-p");
6176 DEFSYM (Qframe_windows_min_size, "frame-windows-min-size");
6177 DEFSYM (Qframe_monitor_attributes, "frame-monitor-attributes");
6178 DEFSYM (Qwindow__pixel_to_total, "window--pixel-to-total");
6179 DEFSYM (Qexplicit_name, "explicit-name");
6180 DEFSYM (Qheight, "height");
6181 DEFSYM (Qicon, "icon");
6182 DEFSYM (Qminibuffer, "minibuffer");
6183 DEFSYM (Qundecorated, "undecorated");
6184 DEFSYM (Qno_special_glyphs, "no-special-glyphs");
6185 DEFSYM (Qparent_frame, "parent-frame");
6186 DEFSYM (Qskip_taskbar, "skip-taskbar");
6187 DEFSYM (Qno_focus_on_map, "no-focus-on-map");
6188 DEFSYM (Qno_accept_focus, "no-accept-focus");
6189 DEFSYM (Qz_group, "z-group");
6190 DEFSYM (Qoverride_redirect, "override-redirect");
6191 DEFSYM (Qdelete_before, "delete-before");
6192 DEFSYM (Qmodeline, "modeline");
6193 DEFSYM (Qonly, "only");
6194 DEFSYM (Qnone, "none");
6195 DEFSYM (Qwidth, "width");
6196 DEFSYM (Qtext_pixels, "text-pixels");
6197 DEFSYM (Qgeometry, "geometry");
6198 DEFSYM (Qicon_left, "icon-left");
6199 DEFSYM (Qicon_top, "icon-top");
6200 DEFSYM (Qtooltip, "tooltip");
6201 DEFSYM (Quser_position, "user-position");
6202 DEFSYM (Quser_size, "user-size");
6203 DEFSYM (Qwindow_id, "window-id");
6204 #ifdef HAVE_X_WINDOWS
6205 DEFSYM (Qouter_window_id, "outer-window-id");
6206 #endif
6207 DEFSYM (Qparent_id, "parent-id");
6208 DEFSYM (Qx, "x");
6209 DEFSYM (Qw32, "w32");
6210 DEFSYM (Qpc, "pc");
6211 DEFSYM (Qns, "ns");
6212 DEFSYM (Qpgtk, "pgtk");
6213 DEFSYM (Qhaiku, "haiku");
6214 DEFSYM (Qvisible, "visible");
6215 DEFSYM (Qbuffer_predicate, "buffer-predicate");
6216 DEFSYM (Qbuffer_list, "buffer-list");
6217 DEFSYM (Qburied_buffer_list, "buried-buffer-list");
6218 DEFSYM (Qdisplay_type, "display-type");
6219 DEFSYM (Qbackground_mode, "background-mode");
6220 DEFSYM (Qnoelisp, "noelisp");
6221 DEFSYM (Qtty_color_mode, "tty-color-mode");
6222 DEFSYM (Qtty, "tty");
6223 DEFSYM (Qtty_type, "tty-type");
6224
6225 DEFSYM (Qface_set_after_frame_default, "face-set-after-frame-default");
6226
6227 DEFSYM (Qfullwidth, "fullwidth");
6228 DEFSYM (Qfullheight, "fullheight");
6229 DEFSYM (Qfullboth, "fullboth");
6230 DEFSYM (Qmaximized, "maximized");
6231 DEFSYM (Qshaded, "shaded");
6232 DEFSYM (Qx_resource_name, "x-resource-name");
6233 DEFSYM (Qx_frame_parameter, "x-frame-parameter");
6234
6235 DEFSYM (Qworkarea, "workarea");
6236 DEFSYM (Qmm_size, "mm-size");
6237 #ifdef HAVE_PGTK
6238 DEFSYM (Qscale_factor, "scale-factor");
6239 #endif
6240 DEFSYM (Qframes, "frames");
6241 DEFSYM (Qsource, "source");
6242
6243 DEFSYM (Qframe_edges, "frame-edges");
6244 DEFSYM (Qouter_edges, "outer-edges");
6245 DEFSYM (Qouter_position, "outer-position");
6246 DEFSYM (Qouter_size, "outer-size");
6247 DEFSYM (Qnative_edges, "native-edges");
6248 DEFSYM (Qinner_edges, "inner-edges");
6249 DEFSYM (Qexternal_border_size, "external-border-size");
6250 DEFSYM (Qtitle_bar_size, "title-bar-size");
6251 DEFSYM (Qmenu_bar_external, "menu-bar-external");
6252 DEFSYM (Qmenu_bar_size, "menu-bar-size");
6253 DEFSYM (Qtab_bar_size, "tab-bar-size");
6254 DEFSYM (Qtool_bar_external, "tool-bar-external");
6255 DEFSYM (Qtool_bar_size, "tool-bar-size");
6256
6257 DEFSYM (Qx_set_menu_bar_lines, "x_set_menu_bar_lines");
6258 DEFSYM (Qchange_frame_size, "change_frame_size");
6259 DEFSYM (Qxg_frame_set_char_size, "xg_frame_set_char_size");
6260 DEFSYM (Qx_set_window_size_1, "x_set_window_size_1");
6261 DEFSYM (Qset_window_configuration, "set_window_configuration");
6262 DEFSYM (Qx_create_frame_1, "x_create_frame_1");
6263 DEFSYM (Qx_create_frame_2, "x_create_frame_2");
6264 DEFSYM (Qgui_figure_window_size, "gui_figure_window_size");
6265 DEFSYM (Qtip_frame, "tip_frame");
6266 DEFSYM (Qterminal_frame, "terminal_frame");
6267
6268 #ifdef HAVE_NS
6269 DEFSYM (Qns_parse_geometry, "ns-parse-geometry");
6270 #endif
6271 #ifdef NS_IMPL_COCOA
6272 DEFSYM (Qns_appearance, "ns-appearance");
6273 DEFSYM (Qns_transparent_titlebar, "ns-transparent-titlebar");
6274 #endif
6275
6276 DEFSYM (Qalpha, "alpha");
6277 DEFSYM (Qalpha_background, "alpha-background");
6278 DEFSYM (Qauto_lower, "auto-lower");
6279 DEFSYM (Qauto_raise, "auto-raise");
6280 DEFSYM (Qborder_color, "border-color");
6281 DEFSYM (Qborder_width, "border-width");
6282 DEFSYM (Qouter_border_width, "outer-border-width");
6283 DEFSYM (Qbottom_divider_width, "bottom-divider-width");
6284 DEFSYM (Qcursor_color, "cursor-color");
6285 DEFSYM (Qcursor_type, "cursor-type");
6286 DEFSYM (Qfont_backend, "font-backend");
6287 DEFSYM (Qfullscreen, "fullscreen");
6288 DEFSYM (Qhorizontal_scroll_bars, "horizontal-scroll-bars");
6289 DEFSYM (Qicon_name, "icon-name");
6290 DEFSYM (Qicon_type, "icon-type");
6291 DEFSYM (Qchild_frame_border_width, "child-frame-border-width");
6292 DEFSYM (Qinternal_border_width, "internal-border-width");
6293 DEFSYM (Qleft_fringe, "left-fringe");
6294 DEFSYM (Qline_spacing, "line-spacing");
6295 DEFSYM (Qmenu_bar_lines, "menu-bar-lines");
6296 DEFSYM (Qtab_bar_lines, "tab-bar-lines");
6297 DEFSYM (Qmouse_color, "mouse-color");
6298 DEFSYM (Qname, "name");
6299 DEFSYM (Qright_divider_width, "right-divider-width");
6300 DEFSYM (Qright_fringe, "right-fringe");
6301 DEFSYM (Qscreen_gamma, "screen-gamma");
6302 DEFSYM (Qscroll_bar_background, "scroll-bar-background");
6303 DEFSYM (Qscroll_bar_foreground, "scroll-bar-foreground");
6304 DEFSYM (Qscroll_bar_height, "scroll-bar-height");
6305 DEFSYM (Qscroll_bar_width, "scroll-bar-width");
6306 DEFSYM (Qsticky, "sticky");
6307 DEFSYM (Qtitle, "title");
6308 DEFSYM (Qtool_bar_lines, "tool-bar-lines");
6309 DEFSYM (Qtool_bar_position, "tool-bar-position");
6310 DEFSYM (Qunsplittable, "unsplittable");
6311 DEFSYM (Qvertical_scroll_bars, "vertical-scroll-bars");
6312 DEFSYM (Qvisibility, "visibility");
6313 DEFSYM (Qwait_for_wm, "wait-for-wm");
6314 DEFSYM (Qinhibit_double_buffering, "inhibit-double-buffering");
6315 DEFSYM (Qno_other_frame, "no-other-frame");
6316 DEFSYM (Qbelow, "below");
6317 DEFSYM (Qabove_suspended, "above-suspended");
6318 DEFSYM (Qmin_width, "min-width");
6319 DEFSYM (Qmin_height, "min-height");
6320 DEFSYM (Qmouse_wheel_frame, "mouse-wheel-frame");
6321 DEFSYM (Qkeep_ratio, "keep-ratio");
6322 DEFSYM (Qwidth_only, "width-only");
6323 DEFSYM (Qheight_only, "height-only");
6324 DEFSYM (Qleft_only, "left-only");
6325 DEFSYM (Qtop_only, "top-only");
6326 DEFSYM (Qiconify_top_level, "iconify-top-level");
6327 DEFSYM (Qmake_invisible, "make-invisible");
6328 DEFSYM (Quse_frame_synchronization, "use-frame-synchronization");
6329 DEFSYM (Qfont_parameter, "font-parameter");
6330
6331 {
6332 int i;
6333
6334 for (i = 0; i < ARRAYELTS (frame_parms); i++)
6335 {
6336 Lisp_Object v = (frame_parms[i].sym < 0
6337 ? intern_c_string (frame_parms[i].name)
6338 : builtin_lisp_symbol (frame_parms[i].sym));
6339 Fput (v, Qx_frame_parameter, make_fixnum (i));
6340 }
6341 }
6342
6343 #ifdef HAVE_WINDOW_SYSTEM
6344 DEFVAR_LISP ("x-resource-name", Vx_resource_name,
6345 doc:
6346
6347
6348
6349
6350
6351
6352
6353 );
6354 Vx_resource_name = Qnil;
6355
6356 DEFVAR_LISP ("x-resource-class", Vx_resource_class,
6357 doc:
6358
6359
6360
6361
6362
6363
6364
6365 );
6366 Vx_resource_class = build_string (EMACS_CLASS);
6367
6368 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit,
6369 doc:
6370
6371 );
6372 Vframe_alpha_lower_limit = make_fixnum (20);
6373 #endif
6374
6375 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist,
6376 doc:
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397 );
6398 Vdefault_frame_alist = Qnil;
6399
6400 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars,
6401 doc: );
6402 #ifdef HAVE_WINDOW_SYSTEM
6403 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
6404
6405
6406 Vdefault_frame_scroll_bars = Qright;
6407 #else
6408 Vdefault_frame_scroll_bars = Qleft;
6409 #endif
6410 #else
6411 Vdefault_frame_scroll_bars = Qnil;
6412 #endif
6413
6414 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
6415 scroll_bar_adjust_thumb_portion_p,
6416 doc:
6417
6418
6419
6420
6421 );
6422 scroll_bar_adjust_thumb_portion_p = 1;
6423
6424 DEFVAR_LISP ("terminal-frame", Vterminal_frame,
6425 doc: );
6426
6427 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function,
6428 doc:
6429
6430
6431
6432 );
6433 Vmouse_position_function = Qnil;
6434
6435 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight,
6436 doc:
6437
6438
6439
6440 );
6441 Vmouse_highlight = Qt;
6442
6443 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible,
6444 doc:
6445
6446
6447
6448 );
6449 Vmake_pointer_invisible = Qt;
6450
6451 DEFVAR_LISP ("move-frame-functions", Vmove_frame_functions,
6452 doc:
6453 );
6454 Vmove_frame_functions = Qnil;
6455
6456 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions,
6457 doc:
6458
6459
6460
6461
6462
6463
6464 );
6465 Vdelete_frame_functions = Qnil;
6466 DEFSYM (Qdelete_frame_functions, "delete-frame-functions");
6467
6468 DEFVAR_LISP ("after-delete-frame-functions",
6469 Vafter_delete_frame_functions,
6470 doc:
6471
6472 );
6473 Vafter_delete_frame_functions = Qnil;
6474 DEFSYM (Qafter_delete_frame_functions, "after-delete-frame-functions");
6475
6476 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode,
6477 doc:
6478
6479
6480
6481 );
6482 Vmenu_bar_mode = Qt;
6483
6484 DEFVAR_LISP ("tab-bar-mode", Vtab_bar_mode,
6485 doc:
6486
6487
6488
6489 );
6490 Vtab_bar_mode = Qnil;
6491
6492 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode,
6493 doc:
6494
6495
6496
6497 );
6498 #ifdef HAVE_WINDOW_SYSTEM
6499 Vtool_bar_mode = Qt;
6500 #else
6501 Vtool_bar_mode = Qnil;
6502 #endif
6503
6504 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame,
6505 doc:
6506
6507
6508
6509
6510
6511 );
6512
6513 DEFVAR_LISP ("resize-mini-frames", resize_mini_frames,
6514 doc:
6515
6516
6517
6518
6519
6520
6521
6522
6523 );
6524 resize_mini_frames = Qnil;
6525
6526 DEFVAR_LISP ("focus-follows-mouse", focus_follows_mouse,
6527 doc:
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569 );
6570 focus_follows_mouse = Qnil;
6571
6572 DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise,
6573 doc:
6574
6575
6576
6577
6578
6579
6580
6581
6582 );
6583 frame_resize_pixelwise = 0;
6584
6585 DEFVAR_LISP ("frame-inhibit-implied-resize", frame_inhibit_implied_resize,
6586 doc:
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619 );
6620 #if defined (HAVE_WINDOW_SYSTEM)
6621 #if defined (USE_GTK) || defined (HAVE_NS)
6622 frame_inhibit_implied_resize = list1 (Qtab_bar_lines);
6623 #else
6624 frame_inhibit_implied_resize = list2 (Qtab_bar_lines, Qtool_bar_lines);
6625 #endif
6626 #else
6627 frame_inhibit_implied_resize = Qt;
6628 #endif
6629
6630 DEFVAR_LISP ("frame-size-history", frame_size_history,
6631 doc:
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644 );
6645 frame_size_history = Qnil;
6646
6647 DEFVAR_BOOL ("tooltip-reuse-hidden-frame", tooltip_reuse_hidden_frame,
6648 doc:
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659 );
6660 tooltip_reuse_hidden_frame = false;
6661
6662 DEFVAR_BOOL ("use-system-tooltips", use_system_tooltips,
6663 doc:
6664
6665
6666
6667 );
6668 use_system_tooltips = true;
6669
6670 DEFVAR_LISP ("iconify-child-frame", iconify_child_frame,
6671 doc:
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682 );
6683 iconify_child_frame = Qiconify_top_level;
6684
6685 DEFVAR_LISP ("frame-internal-parameters", frame_internal_parameters,
6686 doc: );
6687 #ifdef HAVE_X_WINDOWS
6688 frame_internal_parameters = list4 (Qname, Qparent_id, Qwindow_id, Qouter_window_id);
6689 #else
6690 frame_internal_parameters = list3 (Qname, Qparent_id, Qwindow_id);
6691 #endif
6692
6693 defsubr (&Sframep);
6694 defsubr (&Sframe_live_p);
6695 defsubr (&Swindow_system);
6696 defsubr (&Sframe_windows_min_size);
6697 defsubr (&Smake_terminal_frame);
6698 defsubr (&Sselect_frame);
6699 defsubr (&Shandle_switch_frame);
6700 defsubr (&Sselected_frame);
6701 defsubr (&Sold_selected_frame);
6702 defsubr (&Sframe_list);
6703 defsubr (&Sframe_parent);
6704 defsubr (&Sframe_ancestor_p);
6705 defsubr (&Snext_frame);
6706 defsubr (&Sprevious_frame);
6707 defsubr (&Slast_nonminibuf_frame);
6708 defsubr (&Sdelete_frame);
6709 defsubr (&Smouse_position);
6710 defsubr (&Smouse_pixel_position);
6711 defsubr (&Sset_mouse_position);
6712 defsubr (&Sset_mouse_pixel_position);
6713 #if 0
6714 defsubr (&Sframe_configuration);
6715 defsubr (&Srestore_frame_configuration);
6716 #endif
6717 defsubr (&Smake_frame_visible);
6718 defsubr (&Smake_frame_invisible);
6719 defsubr (&Siconify_frame);
6720 defsubr (&Sframe_visible_p);
6721 defsubr (&Svisible_frame_list);
6722 defsubr (&Sraise_frame);
6723 defsubr (&Slower_frame);
6724 defsubr (&Sx_focus_frame);
6725 defsubr (&Sframe_after_make_frame);
6726 defsubr (&Sredirect_frame_focus);
6727 defsubr (&Sframe_focus);
6728 defsubr (&Sframe_parameters);
6729 defsubr (&Sframe_parameter);
6730 defsubr (&Smodify_frame_parameters);
6731 defsubr (&Sframe_char_height);
6732 defsubr (&Sframe_char_width);
6733 defsubr (&Sframe_native_height);
6734 defsubr (&Sframe_native_width);
6735 defsubr (&Sframe_text_cols);
6736 defsubr (&Sframe_text_lines);
6737 defsubr (&Sframe_total_cols);
6738 defsubr (&Sframe_total_lines);
6739 defsubr (&Sframe_text_width);
6740 defsubr (&Sframe_text_height);
6741 defsubr (&Sscroll_bar_width);
6742 defsubr (&Sscroll_bar_height);
6743 defsubr (&Sfringe_width);
6744 defsubr (&Sframe_child_frame_border_width);
6745 defsubr (&Sframe_internal_border_width);
6746 defsubr (&Sright_divider_width);
6747 defsubr (&Sbottom_divider_width);
6748 defsubr (&Stool_bar_pixel_width);
6749 defsubr (&Sset_frame_height);
6750 defsubr (&Sset_frame_width);
6751 defsubr (&Sset_frame_size);
6752 defsubr (&Sframe_position);
6753 defsubr (&Sset_frame_position);
6754 defsubr (&Sframe_pointer_visible_p);
6755 defsubr (&Sframe__set_was_invisible);
6756 defsubr (&Sframe_window_state_change);
6757 defsubr (&Sset_frame_window_state_change);
6758 defsubr (&Sframe_scale_factor);
6759
6760 #ifdef HAVE_WINDOW_SYSTEM
6761 defsubr (&Sx_get_resource);
6762 defsubr (&Sx_parse_geometry);
6763 defsubr (&Sreconsider_frame_fonts);
6764 #endif
6765 }