1 /* TTY frame functions.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996 Ben Wing.
4 Copyright (C) 1997 Free Software Foundation, Inc.
6 This file is part of XEmacs.
8 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with XEmacs; see the file COPYING. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* Synched up with: Not in FSF. */
25 /* Written by Ben Wing.
26 Multi-frame support added by Hrvoje Niksic. */
31 #include "console-tty.h"
41 /* Default properties to use when creating frames. */
42 Lisp_Object Vdefault_tty_frame_plist;
44 static void tty_raise_frame (struct frame *);
48 tty_init_frame_1 (struct frame *f, Lisp_Object props)
50 struct device *d = XDEVICE (FRAME_DEVICE (f));
51 struct console *c = XCONSOLE (DEVICE_CONSOLE (d));
53 ++CONSOLE_TTY_DATA (c)->frame_count;
54 f->order_count = CONSOLE_TTY_DATA (c)->frame_count;
55 f->height = CONSOLE_TTY_DATA (c)->height;
56 f->width = CONSOLE_TTY_DATA (c)->width;
60 tty_init_frame_3 (struct frame *f)
66 tty_select_frame_if_unhidden (Lisp_Object frame)
68 if (FRAME_REPAINT_P (XFRAME (frame)))
69 select_frame_1 (frame);
73 tty_schedule_frame_select (struct frame *f)
78 enqueue_magic_eval_event (tty_select_frame_if_unhidden, frame);
82 tty_after_init_frame (struct frame *f, int first_on_device,
86 call1 (Qinit_post_tty_win, FRAME_CONSOLE (f));
91 tty_get_mouse_position (struct device *d, Lisp_Object *frame, int *x, int *y)
96 num_buttons = Gpm_GetSnapshot(&ev);
99 *frame = DEVICE_SELECTED_FRAME (d);
104 tty_set_mouse_position (struct window *w, int x, int y)
107 I couldn't find any GPM functions that set the mouse position.
108 Mr. Perry had left this function empty; that must be why.
116 /* Change from withdrawn state to mapped state. */
118 tty_make_frame_visible (struct frame *f)
120 if (!FRAME_VISIBLE_P(f))
126 /* Change from mapped state to withdrawn state. */
128 tty_make_frame_invisible (struct frame *f)
134 tty_make_frame_hidden (struct frame *f)
140 tty_make_frame_unhidden (struct frame *f)
142 if (!FRAME_REPAINT_P(f))
150 tty_frame_visible_p (struct frame *f)
152 return FRAME_VISIBLE_P (f);
156 tty_raise_frame_no_select (struct frame *f)
159 LIST_LOOP_2 (frame, DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f))))
161 struct frame *o = XFRAME (frame);
162 if (o != f && FRAME_REPAINT_P (o))
164 tty_make_frame_hidden (o);
168 tty_make_frame_unhidden (f);
172 tty_raise_frame (struct frame *f)
174 tty_raise_frame_no_select (f);
175 tty_schedule_frame_select (f);
179 tty_lower_frame (struct frame *f)
181 Lisp_Object frame_list = DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f)));
182 Lisp_Object tail, new;
184 if (!FRAME_REPAINT_P (f))
187 LIST_LOOP (tail, frame_list)
189 if (f == XFRAME (XCAR (tail)))
193 /* To lower this frame, another frame has to be raised. Return if
194 there is no other frame. */
195 if (NILP (tail) && EQ(frame_list, tail))
198 tty_make_frame_hidden (f);
199 if (CONSP (XCDR (tail)))
200 new = XCAR (XCDR (tail));
202 new = XCAR (frame_list);
203 tty_make_frame_unhidden (XFRAME (new));
204 tty_schedule_frame_select (XFRAME (new));
208 tty_delete_frame (struct frame *f)
210 struct device *d = XDEVICE (FRAME_DEVICE (f));
212 if (!NILP (DEVICE_SELECTED_FRAME (d)))
213 tty_raise_frame (XFRAME (DEVICE_SELECTED_FRAME (d)));
216 /************************************************************************/
218 /************************************************************************/
221 console_type_create_frame_tty (void)
223 CONSOLE_HAS_METHOD (tty, init_frame_1);
224 CONSOLE_HAS_METHOD (tty, init_frame_3);
225 CONSOLE_HAS_METHOD (tty, after_init_frame);
227 CONSOLE_HAS_METHOD (tty, get_mouse_position);
228 CONSOLE_HAS_METHOD (tty, set_mouse_position);
230 CONSOLE_HAS_METHOD (tty, make_frame_visible);
231 CONSOLE_HAS_METHOD (tty, make_frame_invisible);
232 CONSOLE_HAS_METHOD (tty, frame_visible_p);
233 CONSOLE_HAS_METHOD (tty, raise_frame);
234 CONSOLE_HAS_METHOD (tty, lower_frame);
235 CONSOLE_HAS_METHOD (tty, delete_frame);
239 vars_of_frame_tty (void)
241 DEFVAR_LISP ("default-tty-frame-plist", &Vdefault_tty_frame_plist /*
242 Plist of default frame-creation properties for tty frames.
243 These are in addition to and override what is specified in
244 `default-frame-plist', but are overridden by the arguments to the
245 particular call to `make-frame'.
247 Vdefault_tty_frame_plist = Qnil;
249 tty_console_methods->device_specific_frame_props =
250 &Vdefault_tty_frame_plist;
252 /* Tty frames are now supported. Advertise a feature to indicate this. */
253 Fprovide (intern ("tty-frames"));