0
|
1 /* TTY frame functions.
|
149
|
2 Copyright (C) 1995 Free Software Foundation, Inc.
|
0
|
3 Copyright (C) 1995, 1996 Ben Wing.
|
149
|
4 Copyright (C) 1997 Free Software Foundation, Inc.
|
0
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
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
|
|
11 later version.
|
|
12
|
|
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
|
|
16 for more details.
|
|
17
|
|
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. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
149
|
25 /* Written by Ben Wing.
|
|
26 Multi-frame support added by Hrvoje Niksic. */
|
0
|
27
|
|
28 #include <config.h>
|
|
29 #include "lisp.h"
|
|
30
|
|
31 #include "console-tty.h"
|
|
32 #include "frame.h"
|
|
33
|
155
|
34 #include "events.h"
|
|
35
|
153
|
36 #ifdef HAVE_GPM
|
|
37 #include <gpm.h>
|
|
38 #endif
|
|
39
|
149
|
40
|
|
41 /* Default properties to use when creating frames. */
|
0
|
42 Lisp_Object Vdefault_tty_frame_plist;
|
|
43
|
155
|
44 static void tty_raise_frame (struct frame *);
|
149
|
45
|
|
46
|
0
|
47 static void
|
|
48 tty_init_frame_1 (struct frame *f, Lisp_Object props)
|
|
49 {
|
|
50 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
51 struct console *c = XCONSOLE (DEVICE_CONSOLE (d));
|
|
52
|
149
|
53 ++CONSOLE_TTY_DATA (c)->frame_count;
|
|
54 f->order_count = CONSOLE_TTY_DATA (c)->frame_count;
|
0
|
55 f->height = CONSOLE_TTY_DATA (c)->height;
|
|
56 f->width = CONSOLE_TTY_DATA (c)->width;
|
149
|
57 }
|
|
58
|
|
59 static void
|
|
60 tty_init_frame_3 (struct frame *f)
|
|
61 {
|
155
|
62 tty_raise_frame (f);
|
|
63 }
|
149
|
64
|
155
|
65 static void
|
|
66 tty_select_frame_if_unhidden (Lisp_Object frame)
|
|
67 {
|
223
|
68 if (FRAME_REPAINT_P (XFRAME (frame)))
|
|
69 select_frame_1 (frame);
|
155
|
70 }
|
|
71
|
|
72 static void
|
|
73 tty_schedule_frame_select (struct frame *f)
|
|
74 {
|
|
75 Lisp_Object frame;
|
|
76
|
|
77 XSETFRAME (frame, f);
|
|
78 enqueue_magic_eval_event (tty_select_frame_if_unhidden, frame);
|
0
|
79 }
|
|
80
|
|
81 static void
|
|
82 tty_after_init_frame (struct frame *f, int first_on_device,
|
|
83 int first_on_console)
|
|
84 {
|
|
85 if (first_on_console)
|
149
|
86 call1 (Qinit_post_tty_win, FRAME_CONSOLE (f));
|
0
|
87 }
|
|
88
|
153
|
89 #ifdef HAVE_GPM
|
|
90 static int
|
|
91 tty_get_mouse_position (struct device *d, Lisp_Object *frame, int *x, int *y)
|
|
92 {
|
|
93 Gpm_Event ev;
|
|
94 int num_buttons;
|
|
95
|
|
96 num_buttons = Gpm_GetSnapshot(&ev);
|
|
97 *x = ev.x;
|
|
98 *y = ev.y;
|
|
99 *frame = DEVICE_SELECTED_FRAME (d);
|
|
100 return (1);
|
|
101 }
|
|
102
|
|
103 static void
|
|
104 tty_set_mouse_position (struct window *w, int x, int y)
|
|
105 {
|
|
106 /* XXX
|
|
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.
|
|
109 karlheg
|
|
110 */
|
|
111 }
|
|
112
|
|
113 #endif
|
|
114
|
|
115
|
108
|
116 /* Change from withdrawn state to mapped state. */
|
|
117 static void
|
|
118 tty_make_frame_visible (struct frame *f)
|
|
119 {
|
|
120 if (!FRAME_VISIBLE_P(f))
|
|
121 {
|
155
|
122 f->visible = -1;
|
108
|
123 }
|
|
124 }
|
|
125
|
|
126 /* Change from mapped state to withdrawn state. */
|
|
127 static void
|
|
128 tty_make_frame_invisible (struct frame *f)
|
|
129 {
|
149
|
130 f->visible = 0;
|
108
|
131 }
|
|
132
|
155
|
133 static void
|
|
134 tty_make_frame_hidden (struct frame *f)
|
|
135 {
|
|
136 f->visible = -1;
|
|
137 }
|
|
138
|
|
139 static void
|
|
140 tty_make_frame_unhidden (struct frame *f)
|
|
141 {
|
|
142 if (!FRAME_REPAINT_P(f))
|
|
143 {
|
|
144 SET_FRAME_CLEAR(f);
|
|
145 f->visible = 1;
|
|
146 }
|
|
147 }
|
|
148
|
108
|
149 static int
|
|
150 tty_frame_visible_p (struct frame *f)
|
|
151 {
|
149
|
152 return FRAME_VISIBLE_P (f);
|
|
153 }
|
|
154
|
|
155 static void
|
155
|
156 tty_raise_frame_no_select (struct frame *f)
|
149
|
157 {
|
155
|
158 struct frame *o;
|
223
|
159 Lisp_Object tail;
|
149
|
160
|
223
|
161 LIST_LOOP (tail, DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f))))
|
149
|
162 {
|
155
|
163 o = XFRAME (XCAR (tail));
|
|
164 if (o != f && FRAME_REPAINT_P(o))
|
|
165 {
|
|
166 tty_make_frame_hidden (o);
|
|
167 break;
|
|
168 }
|
149
|
169 }
|
155
|
170 tty_make_frame_unhidden (f);
|
149
|
171 }
|
|
172
|
155
|
173 static void
|
|
174 tty_raise_frame (struct frame *f)
|
|
175 {
|
|
176 tty_raise_frame_no_select (f);
|
|
177 tty_schedule_frame_select (f);
|
|
178 }
|
|
179
|
149
|
180 static void
|
|
181 tty_lower_frame (struct frame *f)
|
|
182 {
|
223
|
183 Lisp_Object frame_list = DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f)));
|
|
184 Lisp_Object tail, new;
|
149
|
185
|
155
|
186 if (!FRAME_REPAINT_P (f))
|
149
|
187 return;
|
|
188
|
223
|
189 LIST_LOOP (tail, frame_list)
|
149
|
190 {
|
223
|
191 if (f == XFRAME (XCAR (tail)))
|
149
|
192 break;
|
|
193 }
|
|
194
|
223
|
195 /* To lower this frame, another frame has to be raised. Return if
|
|
196 there is no other frame. */
|
|
197 if (NILP (tail) && EQ(frame_list, tail))
|
155
|
198 return;
|
|
199
|
|
200 tty_make_frame_hidden (f);
|
149
|
201 if (CONSP (XCDR (tail)))
|
|
202 new = XCAR (XCDR (tail));
|
|
203 else
|
|
204 new = XCAR (frame_list);
|
155
|
205 tty_make_frame_unhidden (XFRAME (new));
|
|
206 tty_schedule_frame_select (XFRAME (new));
|
108
|
207 }
|
|
208
|
155
|
209 static void
|
|
210 tty_delete_frame (struct frame *f)
|
|
211 {
|
223
|
212 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
155
|
213
|
223
|
214 if (!NILP (DEVICE_SELECTED_FRAME (d)))
|
|
215 tty_raise_frame (XFRAME (DEVICE_SELECTED_FRAME (d)));
|
155
|
216 }
|
0
|
217
|
|
218 /************************************************************************/
|
|
219 /* initialization */
|
|
220 /************************************************************************/
|
|
221
|
|
222 void
|
|
223 console_type_create_frame_tty (void)
|
|
224 {
|
|
225 CONSOLE_HAS_METHOD (tty, init_frame_1);
|
149
|
226 CONSOLE_HAS_METHOD (tty, init_frame_3);
|
0
|
227 CONSOLE_HAS_METHOD (tty, after_init_frame);
|
153
|
228 #ifdef HAVE_GPM
|
|
229 CONSOLE_HAS_METHOD (tty, get_mouse_position);
|
|
230 CONSOLE_HAS_METHOD (tty, set_mouse_position);
|
|
231 #endif
|
108
|
232 CONSOLE_HAS_METHOD (tty, make_frame_visible);
|
|
233 CONSOLE_HAS_METHOD (tty, make_frame_invisible);
|
|
234 CONSOLE_HAS_METHOD (tty, frame_visible_p);
|
149
|
235 CONSOLE_HAS_METHOD (tty, raise_frame);
|
|
236 CONSOLE_HAS_METHOD (tty, lower_frame);
|
155
|
237 CONSOLE_HAS_METHOD (tty, delete_frame);
|
0
|
238 }
|
|
239
|
|
240 void
|
|
241 vars_of_frame_tty (void)
|
|
242 {
|
|
243 DEFVAR_LISP ("default-tty-frame-plist", &Vdefault_tty_frame_plist /*
|
|
244 Plist of default frame-creation properties for tty frames.
|
|
245 These are in addition to and override what is specified in
|
|
246 `default-frame-plist', but are overridden by the arguments to the
|
|
247 particular call to `make-frame'.
|
|
248 */ );
|
|
249 Vdefault_tty_frame_plist = Qnil;
|
|
250
|
|
251 tty_console_methods->device_specific_frame_props =
|
|
252 &Vdefault_tty_frame_plist;
|
153
|
253
|
|
254 /* Tty frames are now supported. Advertise a feature to indicate this. */
|
|
255 Fprovide (intern ("tty-frames"));
|
0
|
256 }
|