1 /* Generic screen functions.
2 Copyright (C) 1989 Free Software Foundation.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "termhooks.h"
28 Lisp_Object Vemacs_iconified
;
30 Lisp_Object Vscreen_list
;
31 Lisp_Object Vterminal_screen
;
32 Lisp_Object Vglobal_minibuffer_screen
;
33 Lisp_Object Vdefault_screen_alist
;
35 /* A screen which is not just a minibuffer, or 0 if there are no
36 such screens. This is usually the most recent such screen that
38 struct screen
*last_nonminibuf_screen
;
40 extern Lisp_Object Vminibuffer_list
;
41 extern Lisp_Object
get_minibuffer ();
43 DEFUN ("screenp", Fscreenp
, Sscreenp
, 1, 1, 0,
44 "Return non-nil if OBJECT is a screen.\n\
45 Value is t for a termcap screen (a character-only terminal),\n\
46 `x' for an Emacs screen that is really an X window.")
50 if (XTYPE (screen
) != Lisp_Screen
)
52 switch (XSCREEN (screen
)->output_method
)
68 register struct screen
*s
;
69 register Lisp_Object root_window
;
70 register Lisp_Object mini_window
;
72 screen
= Fmake_vector (((sizeof (struct screen
) - (sizeof (Lisp_Vector
)
73 - sizeof (Lisp_Object
)))
74 / sizeof (Lisp_Object
)),
76 XSETTYPE (screen
, Lisp_Screen
);
81 s
->current_glyphs
= 0;
82 s
->desired_glyphs
= 0;
84 s
->display
.nothing
= 0;
86 s
->wants_modeline
= 1;
91 s
->has_minibuffer
= mini_p
;
92 s
->focus_screen
= screen
;
94 s
->param_alist
= Qnil
;
96 root_window
= make_window (0);
99 mini_window
= make_window (0);
100 XWINDOW (root_window
)->next
= mini_window
;
101 XWINDOW (mini_window
)->prev
= root_window
;
102 XWINDOW (mini_window
)->mini_p
= Qt
;
103 XWINDOW (mini_window
)->screen
= screen
;
104 s
->minibuffer_window
= mini_window
;
109 XWINDOW (root_window
)->next
= Qnil
;
110 s
->minibuffer_window
= Qnil
;
113 XWINDOW (root_window
)->screen
= screen
;
116 just so that there is "something there."
117 Correct size will be set up later with change_screen_size. */
122 XFASTINT (XWINDOW (root_window
)->width
) = 10;
123 XFASTINT (XWINDOW (root_window
)->height
) = (mini_p
? 9 : 10);
127 XFASTINT (XWINDOW (mini_window
)->width
) = 10;
128 XFASTINT (XWINDOW (mini_window
)->top
) = 9;
129 XFASTINT (XWINDOW (mini_window
)->height
) = 1;
132 /* Choose a buffer for the screen's root window. */
136 XWINDOW (root_window
)->buffer
= Qt
;
137 buf
= Fcurrent_buffer ();
138 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
139 a space), try to find another one. */
140 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
141 buf
= Fother_buffer (buf
);
142 Fset_window_buffer (root_window
, buf
);
147 XWINDOW (mini_window
)->buffer
= Qt
;
148 Fset_window_buffer (mini_window
,
149 (NULL (Vminibuffer_list
)
151 : Fcar (Vminibuffer_list
)));
154 s
->root_window
= root_window
;
155 s
->selected_window
= root_window
;
156 /* Make sure this window seems more recently used than
157 a newly-created, never-selected window. */
158 XFASTINT (XWINDOW (s
->selected_window
)->use_time
) = ++window_select_count
;
160 Vscreen_list
= Fcons (screen
, Vscreen_list
);
165 /* Make a screen using a separate minibuffer window on another screen.
166 MINI_WINDOW is the minibuffer window to use. nil means use the
167 default (the global minibuffer). */
170 make_screen_without_minibuffer (mini_window
)
171 register Lisp_Object mini_window
;
173 register struct screen
*s
;
175 /* Choose the minibuffer window to use. */
176 if (NULL (mini_window
))
178 if (XTYPE (Vglobal_minibuffer_screen
) != Lisp_Screen
)
179 error ("global-minibuffer-screen must be set to create minibufferless screens.");
180 mini_window
= XSCREEN (Vglobal_minibuffer_screen
)->minibuffer_window
;
184 CHECK_WINDOW (mini_window
, 0);
187 /* Make a screen containing just a root window. */
190 /* Install the chosen minibuffer window, with proper buffer. */
191 s
->minibuffer_window
= mini_window
;
192 Fset_window_buffer (mini_window
,
193 (NULL (Vminibuffer_list
)
195 : Fcar (Vminibuffer_list
)));
199 /* Make a screen containing only a minibuffer window. */
202 make_minibuffer_screen ()
204 /* First make a screen containing just a root window, no minibuffer. */
206 register struct screen
*s
= make_screen (0);
207 register Lisp_Object mini_window
;
208 register Lisp_Object screen
;
210 XSET (screen
, Lisp_Screen
, s
);
212 /* ??? Perhaps leave it to the user program to set auto_raise. */
216 s
->wants_modeline
= 0;
217 /* Note we leave has_minibuffer as 0. This is a little strange. */
219 /* Now label the root window as also being the minibuffer.
220 Avoid infinite looping on the window chain by marking next pointer
223 mini_window
= s
->minibuffer_window
= s
->root_window
;
224 XWINDOW (mini_window
)->mini_p
= Qt
;
225 XWINDOW (mini_window
)->next
= Qnil
;
226 XWINDOW (mini_window
)->prev
= mini_window
;
227 XWINDOW (mini_window
)->screen
= screen
;
229 /* Put the proper buffer in that window. */
231 Fset_window_buffer (mini_window
,
232 (NULL (Vminibuffer_list
)
234 : Fcar (Vminibuffer_list
)));
238 /* Construct a screen that refers to the terminal (stdin and stdout). */
241 make_terminal_screen ()
243 register struct screen
*s
;
247 s
->name
= build_string ("terminal");
249 s
->display
.nothing
= 1; /* Nonzero means screen isn't deleted. */
250 XSET (Vterminal_screen
, Lisp_Screen
, s
);
254 DEFUN ("select-screen", Fselect_screen
, Sselect_screen
, 1, 2, 0,
255 "Select the screen S. S's selected window becomes \"the\"\n\
256 selected window. If the optional parameter NO-ENTER is non-nil, don't\n\
257 focus on that screen.")
259 Lisp_Object screen
, no_enter
;
261 CHECK_SCREEN (screen
, 0);
263 if (selected_screen
== XSCREEN (screen
))
266 selected_screen
= XSCREEN (screen
);
267 if (!EQ (SCREEN_ROOT_WINDOW (selected_screen
),
268 SCREEN_MINIBUF_WINDOW (selected_screen
)))
269 last_nonminibuf_screen
= selected_screen
;
271 Fselect_window (XSCREEN (screen
)->selected_window
);
273 #ifdef HAVE_X_WINDOWS
275 if (XSCREEN (screen
)->output_method
== output_x_window
278 Ffocus_screen (screen
);
282 choose_minibuf_screen ();
287 DEFUN ("selected-screen", Fselected_screen
, Sselected_screen
, 0, 0, 0,
288 "Return the screen that is now selected.")
292 XSET (tem
, Lisp_Screen
, selected_screen
);
296 DEFUN ("window-screen", Fwindow_screen
, Swindow_screen
, 1, 1, 0,
297 "Return the screen object that window WINDOW is on.")
301 CHECK_WINDOW (window
, 0);
302 return XWINDOW (window
)->screen
;
305 DEFUN ("screen-root-window", Fscreen_root_window
, Sscreen_root_window
, 0, 1, 0,
306 "Returns the root-window of SCREEN.")
311 XSET (screen
, Lisp_Screen
, selected_screen
);
312 CHECK_SCREEN (screen
, 0);
314 return XSCREEN (screen
)->root_window
;
317 DEFUN ("screen-selected-window", Fscreen_selected_window
,
318 Sscreen_selected_window
, 0, 1, 0,
319 "Return the selected window of screen object SCREEN.")
324 XSET (screen
, Lisp_Screen
, selected_screen
);
325 CHECK_SCREEN (screen
, 0);
327 return XSCREEN (screen
)->selected_window
;
330 DEFUN ("screen-list", Fscreen_list
, Sscreen_list
,
332 "Return a list of all screens.")
335 return Fcopy_sequence (Vscreen_list
);
340 next_screen (screen
, mini_screen
)
348 for (tail
= Vscreen_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
352 SCREEN_PTR s
= XSCREEN (XCONS (tail
)->car
);
356 /* Is this screen only a minibuffer? */
357 && EQ (SCREEN_ROOT_WINDOW (s
),
358 SCREEN_MINIBUF_WINDOW (s
))
360 /* If we have wrapped all the way around the list (i.e.
361 the only screen is an all-minibuffer screen), return
363 && s
!= XSCREEN (screen
))
366 return XCONS (tail
)->car
;
369 if (EQ (screen
, XCONS (tail
)->car
))
375 prev_screen (screen
, mini_screen
)
384 for (tail
= Vscreen_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
386 if (EQ (screen
, XCONS (tail
)->car
))
388 if (!NULL (prev
) && (mini_screen
389 || !EQ (XCONS (tail
)->car
,
390 Vglobal_minibuffer_screen
)))
393 prev
= XCONS (tail
)->car
;
397 DEFUN ("next-screen", Fnext_screen
, Snext_screen
,
399 "Return the next screen in the screen list after SCREEN.\n\
400 If MINISCREEN is non-nil, include screens whose only window is a minibuffer.\n\
401 If MINISCREEN is nil or omitted, these screens are skipped.")
403 Lisp_Object screen
, miniscreen
;
408 XSET (screen
, Lisp_Screen
, selected_screen
);
409 CHECK_SCREEN (screen
, 0);
411 return next_screen (screen
, (NULL (miniscreen
) ? 0 : 1));
413 #endif /* MULTI_SCREEN */
415 DEFUN ("delete-screen", Fdelete_screen
, Sdelete_screen
,
417 "Delete SCREEN, permanently eliminating it from use.\n\
418 Default is current screen.")
425 if (EQ (screen
, Qnil
))
428 XSET (screen
, Lisp_Screen
, s
);
432 CHECK_SCREEN (screen
, 0);
433 s
= XSCREEN (screen
);
436 /* Are there any other screens besides this one? */
437 if (s
== selected_screen
&& EQ (next_screen (screen
, 1), screen
))
438 error ("Attempt to delete the only screen");
440 /* Does this screen have a minibuffer, and is it the surrogate
441 minibuffer for any other screen? */
443 WINDOW_SCREEN (XWINDOW (SCREEN_MINIBUF_WINDOW (XSCREEN (screen
))))))
447 for (screen2
= Vscreen_list
; CONSP (2); screen2
= XCONS (screen2
)->cdr
)
448 if (! EQ (screen2
, screen
)
450 WINDOW_SCREEN (XWINDOW (SCREEN_MINIBUF_WINDOW (XSCREEN (screen2
))))))
451 error ("Attempt to delete a surrogate minibuffer screen");
454 /* Don't let the screen remain selected. */
455 if (s
== selected_screen
)
456 Fselect_screen (next_screen (screen
, 1));
458 /* Don't allow minibuf_window to remain on a deleted screen. */
459 if (EQ (s
->minibuffer_window
, minibuf_window
))
461 Fset_window_buffer (selected_screen
->minibuffer_window
,
462 XWINDOW (minibuf_window
)->buffer
);
463 minibuf_window
= selected_screen
->minibuffer_window
;
466 Vscreen_list
= Fdelq (screen
, Vscreen_list
);
469 s
->display
.nothing
= 0;
471 #ifdef HAVE_X_WINDOWS
472 if (s
->output_method
== output_x_window
)
473 x_destroy_window (s
, displ
);
476 /* If we've deleted the last_nonminibuf_screen, then try to find
478 if (s
== last_nonminibuf_screen
)
480 last_nonminibuf_screen
= 0;
482 for (screen
= Vscreen_list
; CONSP (screen
); screen
= XCONS (screen
)->cdr
)
484 s
= XSCREEN (XCONS (screen
)->cdr
);
485 if (!EQ (SCREEN_ROOT_WINDOW (s
), SCREEN_MINIBUF_WINDOW (s
)))
487 last_nonminibuf_screen
= s
;
496 /* Return mouse position in character cell units. */
499 read_mouse_position (screen
, x
, y
)
503 CHECK_SCREEN (screen
, 0);
508 #ifdef HAVE_X_WINDOWS
509 if (XSCREEN (screen
)->output_method
== output_x_window
)
510 x_read_mouse_position (XSCREEN (screen
), x
, y
);
514 DEFUN ("read-mouse-position", Fread_mouse_position
, Sread_mouse_position
, 1, 1, 0,
515 "Return a cons (x . y) which represents the position of the mouse.")
522 CHECK_SCREEN (screen
, 0);
524 read_mouse_position (screen
, &x
, &y
);
525 return Fcons (make_number (x
), make_number (y
));
528 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
529 "Move the mouse pointer to the center of cell (X,Y) in SCREEN.\n\
530 WARNING: If you use this under X, you should do unfocus-screen afterwards.")
532 Lisp_Object screen
, x
, y
;
534 CHECK_SCREEN (screen
, 0);
538 #ifdef HAVE_X_WINDOWS
539 if (XSCREEN (screen
)->output_method
== output_x_window
)
540 /* Warping the mouse will cause enternotify and focus events. */
541 x_set_mouse_position (XSCREEN (screen
), x
, y
);
548 /* ??? Can this be replaced with a Lisp function?
549 It is used in minibuf.c. Can we get rid of that? */
551 DEFUN ("screen-configuration", Fscreen_configuration
, Sscreen_configuration
,
553 "Return object describing current screen configuration.\n\
554 The screen configuration is the current mouse position and selected screen.\n\
555 This object can be given to `restore-screen-configuration'\n\
556 to restore this screen configuration.")
560 Lisp_Object c
, screen
;
563 c
= Fmake_vector (make_number(3), Qnil
);
564 XVECTOR (c
)->contents
[0] = screen
= Fselected_screen();
565 read_mouse_position (screen
, &x
, &y
);
566 XVECTOR (c
)->contents
[1] = make_number (x
);
567 XVECTOR (c
)->contents
[2] = make_number (y
);
572 DEFUN ("restore-screen-configuration", Frestore_screen_configuration
,
573 Srestore_screen_configuration
,
575 "Restores screen configuration CONFIGURATION.")
579 Lisp_Object x_pos
, y_pos
, screen
;
581 CHECK_VECTOR (config
, 0);
582 if (XVECTOR (config
)->size
!= 3)
584 error ("Wrong size vector passed to restore-screen-configuration");
586 screen
= XVECTOR (config
)->contents
[0];
587 CHECK_SCREEN (screen
, 0);
589 Fselect_screen (screen
, Qnil
);
592 /* This seems to interfere with the screen selection mechanism. jla */
593 x_pos
= XVECTOR (config
)->contents
[1];
594 y_pos
= XVECTOR (config
)->contents
[2];
595 set_mouse_position (screen
, XINT (x_pos
), XINT (y_pos
));
602 DEFUN ("make-screen-visible", Fmake_screen_visible
, Smake_screen_visible
,
604 "Make the screen SCREEN visible (assuming it is an X-window).\n\
605 Also raises the screen so that nothing obscures it.")
609 CHECK_SCREEN (screen
, 0);
611 if (XSCREEN (screen
)->display
.nothing
== 0)
612 error ("Cannot make a dead screen object visible");
614 if (XSCREEN (screen
)->output_method
== output_x_window
)
615 x_make_screen_visible (XSCREEN (screen
));
620 DEFUN ("make-screen-invisible", Fmake_screen_invisible
, Smake_screen_invisible
,
622 "Make the screen SCREEN invisible (assuming it is an X-window).")
626 CHECK_SCREEN (screen
, 0);
628 if (XSCREEN (screen
)->output_method
== output_x_window
)
629 x_make_screen_invisible (XSCREEN (screen
));
634 DEFUN ("iconify-screen", Ficonify_screen
, Siconify_screen
,
636 "Make the screen SCREEN into an icon.")
640 CHECK_SCREEN (screen
, 0);
642 if (XSCREEN (screen
)->display
.nothing
== 0)
643 error ("Cannot make a dead screen object iconified.");
645 if (XSCREEN (screen
)->output_method
== output_x_window
)
646 x_iconify_screen (XSCREEN (screen
));
651 DEFUN ("deiconify-screen", Fdeiconify_screen
, Sdeiconify_screen
,
653 "Open (de-iconify) the iconified screen SCREEN.")
657 CHECK_SCREEN (screen
, 0);
659 if (XSCREEN (screen
)->display
.nothing
== 0)
660 error ("Cannot deiconify a dead screen object.");
662 if (XSCREEN (screen
)->output_method
== output_x_window
)
663 x_make_screen_visible (XSCREEN (screen
));
668 DEFUN ("screen-visible-p", Fscreen_visible_p
, Sscreen_visible_p
,
670 "Return t if SCREEN is now \"visible\" (actually in use for display).\n\
671 A screen that is not \"visible\" is not updated and, if it works through\n\
672 a window system, it may not show at all.\n\
673 Return the symbol `icon' if window is visible only as an icon.")
677 CHECK_SCREEN (screen
, 0);
679 if (XSCREEN (screen
)->visible
)
681 if (XSCREEN (screen
)->iconified
)
682 return intern ("icon");
686 DEFUN ("visible-screen-list", Fvisible_screen_list
, Svisible_screen_list
,
688 "Return a list of all screens now \"visible\" (being updated).")
691 Lisp_Object tail
, screen
;
696 for (tail
= Vscreen_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
698 screen
= XCONS (tail
)->car
;
699 if (XTYPE (screen
) != Lisp_Screen
)
701 s
= XSCREEN (screen
);
703 value
= Fcons (screen
, value
);
710 DEFUN ("redirect-screen-focus", Fredirect_screen_focus
, Sredirect_screen_focus
,
712 "Arrange for keystrokes typed at SCREEN to be sent to FOCUS-SCREEN.\n\
713 This means that, after reading a keystroke typed at SCREEN,\n\
714 last-event-screen will be FOCUS-SCREEN.\n\
716 If FOCUS-SCREEN is omitted or eq to SCREEN, any existing redirection is\n\
717 cancelled, and the screen again receives its own keystrokes.\n\
719 The redirection lasts until the next call to redirect-screen-focus\n\
722 This is useful for temporarily redirecting keystrokes to the minibuffer\n\
723 window when a screen doesn't have its own minibuffer.")
724 (screen
, focus_screen
)
725 Lisp_Object screen
, focus_screen
;
727 CHECK_SCREEN (screen
, 0);
728 if (NULL (focus_screen
))
729 focus_screen
= screen
;
731 CHECK_SCREEN (focus_screen
, 1);
733 XSCREEN (screen
)->focus_screen
= focus_screen
;
735 if (screen_rehighlight_hook
)
736 (*screen_rehighlight_hook
) ();
742 DEFUN ("screen-focus", Fscreen_focus
, Sscreen_focus
, 1, 1, 0,
743 "Return the screen to which SCREEN's keystrokes are currently being sent.\n\
744 See redirect-screen-focus.")
748 CHECK_SCREEN (screen
, 0);
749 return SCREEN_FOCUS_SCREEN (XSCREEN (screen
));
755 get_screen_param (screen
, prop
)
756 register struct screen
*screen
;
759 register Lisp_Object tem
;
761 tem
= Fassq (prop
, screen
->param_alist
);
768 store_in_alist (alistptr
, propname
, val
)
769 Lisp_Object
*alistptr
, val
;
772 register Lisp_Object tem
;
773 register Lisp_Object prop
;
775 prop
= intern (propname
);
776 tem
= Fassq (prop
, *alistptr
);
778 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
784 store_screen_param (s
, prop
, val
)
786 Lisp_Object prop
, val
;
788 register Lisp_Object tem
;
790 tem
= Fassq (prop
, s
->param_alist
);
792 s
->param_alist
= Fcons (Fcons (prop
, val
), s
->param_alist
);
797 DEFUN ("screen-parameters", Fscreen_parameters
, Sscreen_parameters
, 0, 1, 0,
798 "Return the parameters-alist of screen SCREEN.\n\
799 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
800 The meaningful PARMs depend on the kind of screen.")
807 if (EQ (screen
, Qnil
))
811 CHECK_SCREEN (screen
, 0);
812 s
= XSCREEN (screen
);
815 if (s
->display
.nothing
== 0)
818 alist
= Fcopy_alist (s
->param_alist
);
819 store_in_alist (&alist
, "name", s
->name
);
820 store_in_alist (&alist
, "height", make_number (s
->height
));
821 store_in_alist (&alist
, "width", make_number (s
->width
));
822 store_in_alist (&alist
, "modeline", (s
->wants_modeline
? Qt
: Qnil
));
823 store_in_alist (&alist
, "minibuffer", (s
->has_minibuffer
? Qt
: Qnil
));
824 store_in_alist (&alist
, "unsplittable", (s
->no_split
? Qt
: Qnil
));
826 if (s
->output_method
== output_x_window
)
827 x_report_screen_params (s
, &alist
);
831 DEFUN ("modify-screen-parameters", Fmodify_screen_parameters
,
832 Smodify_screen_parameters
, 2, 2, 0,
833 "Modify the parameters of screen SCREEN according to ALIST.\n\
834 ALIST is an alist of parameters to change and their new values.\n\
835 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
836 The meaningful PARMs depend on the kind of screen; undefined PARMs are ignored.")
838 Lisp_Object screen
, alist
;
840 register struct screen
*s
;
841 register Lisp_Object tail
, elt
, prop
, val
;
843 if (EQ (screen
, Qnil
))
847 CHECK_SCREEN (screen
, 0);
848 s
= XSCREEN (screen
);
851 if (s
->display
.nothing
== 0)
852 error ("Cannot modify parameters of a deleted screen");
854 if (s
->output_method
== output_x_window
)
855 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
860 x_set_screen_param (s
, prop
, val
,
861 get_screen_param (s
, prop
));
862 store_screen_param (s
, prop
, val
);
869 DEFUN ("screen-pixel-size", Fscreen_pixel_size
,
870 Sscreen_pixel_size
, 1, 1, 0,
871 "Return a cons (width . height) of screen SCREEN's dimensions.")
875 register struct screen
*s
;
878 CHECK_SCREEN (screen
, 0);
879 s
= XSCREEN (screen
);
881 return Fcons (make_number (x_pixel_width (s
)),
882 make_number (x_pixel_height (s
)));
885 DEFUN ("screen-height", Fscreen_height
, Sscreen_height
, 0, 0, 0,
886 "Return number of lines available for display on selected screen.")
889 return make_number (SCREEN_HEIGHT (selected_screen
));
892 DEFUN ("screen-width", Fscreen_width
, Sscreen_width
, 0, 0, 0,
893 "Return number of columns available for display on selected screen.")
896 return make_number (SCREEN_WIDTH (selected_screen
));
899 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 2, 3, 0,
900 "Specify that the screen SCREEN has LINES lines.\n\
901 Optional third arg non-nil means that redisplay should use LINES lines\n\
902 but that the idea of the actual height of the screen should not be changed.")
903 (screen
, rows
, pretend
)
904 Lisp_Object rows
, pretend
;
906 register struct screen
*s
;
908 CHECK_NUMBER (rows
, 0);
913 CHECK_SCREEN (screen
, 0);
914 s
= XSCREEN (screen
);
917 if (s
->output_method
== output_x_window
)
919 if (XINT (rows
) != s
->width
)
920 x_set_window_size (s
, s
->width
, XINT (rows
));
923 change_screen_size (s
, XINT (rows
), 0, !NULL (pretend
));
927 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 2, 3, 0,
928 "Specify that the screen SCREEN has COLS columns.\n\
929 Optional third arg non-nil means that redisplay should use COLS columns\n\
930 but that the idea of the actual width of the screen should not be changed.")
931 (screen
, cols
, pretend
)
932 Lisp_Object cols
, pretend
;
934 register struct screen
*s
;
935 CHECK_NUMBER (cols
, 0);
940 CHECK_SCREEN (screen
, 0);
941 s
= XSCREEN (screen
);
944 if (s
->output_method
== output_x_window
)
946 if (XINT (cols
) != s
->width
)
947 x_set_window_size (s
, XINT (cols
), s
->height
);
950 change_screen_size (selected_screen
, 0, XINT (cols
), !NULL (pretend
));
954 DEFUN ("set-screen-size", Fset_screen_size
,
955 Sset_screen_size
, 3, 3, 0,
956 "Sets size of SCREEN to COLS by ROWS, measured in characters.")
958 Lisp_Object screen
, cols
, rows
;
960 register struct screen
*s
;
963 CHECK_SCREEN (screen
, 0);
964 CHECK_NUMBER (cols
, 2);
965 CHECK_NUMBER (rows
, 1);
966 s
= XSCREEN (screen
);
968 if (s
->output_method
== output_x_window
)
970 if (XINT (rows
) != s
->height
|| XINT (cols
) != s
->width
)
971 x_set_window_size (s
, XINT (cols
), XINT (rows
));
974 change_screen_size (s
, XINT (rows
), XINT (cols
), 0);
979 DEFUN ("set-screen-position", Fset_screen_position
,
980 Sset_screen_position
, 3, 3, 0,
981 "Sets size of SCREEN in pixels to XOFFSET by YOFFSET.")
982 (screen
, xoffset
, yoffset
)
983 Lisp_Object screen
, xoffset
, yoffset
;
985 register struct screen
*s
;
988 CHECK_SCREEN (screen
, 0);
989 CHECK_NUMBER (xoffset
, 1);
990 CHECK_NUMBER (yoffset
, 2);
991 s
= XSCREEN (screen
);
993 if (s
->output_method
== output_x_window
)
994 x_set_offset (s
, XINT (xoffset
), XINT (yoffset
));
999 /* Test if column *x, row *y is within window *w. If they are not,
1000 return 0; if they are on the window's modeline, return -1; if
1001 they are in the window's text area (the only other alternative)
1002 set *x and *y to their locations relative to the upper left
1003 corner of the window, and return 1. */
1005 coordinates_in_window (w
, x
, y
)
1006 register struct window
*w
;
1007 register int *x
, *y
;
1009 register int left
= XINT (w
->left
);
1010 register int width
= XINT (w
->width
);
1011 register int window_height
= XINT (w
->height
);
1012 register int top
= XFASTINT (w
->top
);
1014 if (*x
< left
|| *x
>= left
+ width
1015 || *y
< top
|| *y
> top
+ window_height
- 1)
1018 if (*y
== top
+ window_height
- 1
1019 && window_height
> 1) /* 1 line => minibuffer */
1028 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p
,
1029 Scoordinates_in_window_p
, 2, 2, 0,
1030 "Return non-nil if COORDINATES are in WINDOW.\n\
1031 COORDINATES is a cons of the form (X Y), X and Y being screen-relative.\n\
1032 If COORDINATES are in the text portion of WINDOW, the coordinates relative\n\
1033 to the window are returned. If they are in the modeline of WINDOW, t is\n\
1035 (coordinates
, window
)
1036 register Lisp_Object coordinates
, window
;
1040 CHECK_WINDOW (window
, 0);
1041 CHECK_CONS (coordinates
, 1);
1042 x
= XINT (Fcar (coordinates
));
1043 y
= XINT (Fcar (Fcdr (coordinates
)));
1045 switch (coordinates_in_window (XWINDOW (window
), &x
, &y
))
1047 case -1: /* In modeline of window. */
1050 case 0: /* NOT in window at all. */
1053 case 1: /* In text part of window. */
1054 return Fcons (x
, Fcons (y
, Qnil
));
1062 DEFUN ("rubber-band-rectangle", Frubber_band_rectangle
, Srubber_band_rectangle
,
1064 "Ask user to specify a window position and size on SCREEN with the mouse.\n\
1065 Arguments are SCREEN, NAME and GEO. NAME is a name to be displayed as\n\
1066 the purpose of this rectangle. GEO is an X-windows size spec that can\n\
1067 specify defaults for some sizes/positions. If GEO specifies everything,\n\
1068 the mouse is not used.\n\
1069 Returns a list of five values: (SCREEN LEFT TOP WIDTH HEIGHT).")
1076 Lisp_Object nums
[4];
1079 CHECK_SCREEN (screen
, 0);
1080 CHECK_STRING (name
, 1);
1081 CHECK_STRING (geo
, 2);
1083 switch (XSCREEN (screen
)->output_method
)
1085 case output_x_window
:
1086 x_rubber_band (XSCREEN (screen
), &vals
[0], &vals
[1], &vals
[2], &vals
[3],
1087 XSTRING (geo
)->data
, XSTRING (name
)->data
);
1094 for (i
= 0; i
< 4; i
++)
1095 XFASTINT (nums
[i
]) = vals
[i
];
1096 return Fcons (screen
, Flist (4, nums
));
1099 #endif /* not HAVE_X11 */
1101 choose_minibuf_screen ()
1103 /* For lowest-level minibuf, put it on currently selected screen
1104 if screen has a minibuffer. */
1105 if (minibuf_level
== 0
1106 && selected_screen
!= 0
1107 && !EQ (minibuf_window
, selected_screen
->minibuffer_window
)
1108 && !EQ (Qnil
, selected_screen
->minibuffer_window
))
1110 Fset_window_buffer (selected_screen
->minibuffer_window
,
1111 XWINDOW (minibuf_window
)->buffer
);
1112 minibuf_window
= selected_screen
->minibuffer_window
;
1118 Qscreenp
= intern ("screenp");
1120 staticpro (&Vscreen_list
);
1122 DEFVAR_LISP ("terminal-screen", &Vterminal_screen
,
1123 "The initial screen-object, which represents Emacs's stdout.");
1125 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1126 "Non-nil if all of emacs is iconified and not screen updates are needed.");
1127 Vemacs_iconified
= Qnil
;
1129 DEFVAR_LISP ("global-minibuffer-screen", &Vglobal_minibuffer_screen
,
1130 "A screen whose minibuffer is used by minibufferless screens.\n\
1131 When you create a minibufferless screen, by default it will use the\n\
1132 minibuffer of this screen. It is up to you to create a suitable screen\n\
1133 and store it in this variable.");
1134 Vglobal_minibuffer_screen
= Qnil
;
1136 DEFVAR_LISP ("default-screen-alist", &Vdefault_screen_alist
,
1137 "Alist of default values for screen creation.\n\
1138 These may be set in your init file, like this:\n\
1139 (setq default-screen-alist '((width . 80) (height . 55)))\n\
1140 These override values given in window system configuration data, like\n\
1141 X Windows' defaults database.\n\
1142 For values specific to the first emacs screen, see initial-screen-alist.\n\
1143 For values specific to the separate minibuffer screen, see\n\
1144 minibuffer-screen-alist.");
1145 Vdefault_screen_alist
= Qnil
;
1147 defsubr (&Sscreenp
);
1148 defsubr (&Sselect_screen
);
1149 defsubr (&Sselected_screen
);
1150 defsubr (&Swindow_screen
);
1151 defsubr (&Sscreen_root_window
);
1152 defsubr (&Sscreen_selected_window
);
1153 defsubr (&Sscreen_list
);
1154 defsubr (&Snext_screen
);
1155 defsubr (&Sdelete_screen
);
1156 defsubr (&Sread_mouse_position
);
1157 defsubr (&Sset_mouse_position
);
1159 defsubr (&Sscreen_configuration
);
1160 defsubr (&Srestore_screen_configuration
);
1162 defsubr (&Smake_screen_visible
);
1163 defsubr (&Smake_screen_invisible
);
1164 defsubr (&Siconify_screen
);
1165 defsubr (&Sdeiconify_screen
);
1166 defsubr (&Sscreen_visible_p
);
1167 defsubr (&Svisible_screen_list
);
1168 defsubr (&Sredirect_screen_focus
);
1169 defsubr (&Sscreen_focus
);
1170 defsubr (&Sscreen_parameters
);
1171 defsubr (&Smodify_screen_parameters
);
1172 defsubr (&Sscreen_pixel_size
);
1173 defsubr (&Sscreen_height
);
1174 defsubr (&Sscreen_width
);
1175 defsubr (&Sset_screen_height
);
1176 defsubr (&Sset_screen_width
);
1177 defsubr (&Sset_screen_size
);
1178 defsubr (&Sset_screen_position
);
1179 defsubr (&Scoordinates_in_window_p
);
1181 defsubr (&Srubber_band_rectangle
);
1182 #endif /* HAVE_X11 */