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
|
149
|
44 /* The count of frame number. */
|
|
45 static int tty_frame_count;
|
|
46
|
155
|
47 static void tty_raise_frame (struct frame *);
|
149
|
48
|
|
49
|
0
|
50 static void
|
|
51 tty_init_frame_1 (struct frame *f, Lisp_Object props)
|
|
52 {
|
|
53 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
54 struct console *c = XCONSOLE (DEVICE_CONSOLE (d));
|
|
55
|
149
|
56 ++CONSOLE_TTY_DATA (c)->frame_count;
|
|
57 f->order_count = CONSOLE_TTY_DATA (c)->frame_count;
|
0
|
58 f->height = CONSOLE_TTY_DATA (c)->height;
|
|
59 f->width = CONSOLE_TTY_DATA (c)->width;
|
|
60 #ifdef HAVE_SCROLLBARS
|
|
61 f->scrollbar_on_left = 1;
|
|
62 f->scrollbar_on_top = 0;
|
|
63 #endif
|
149
|
64 }
|
|
65
|
|
66 static void
|
|
67 tty_init_frame_3 (struct frame *f)
|
|
68 {
|
155
|
69 tty_raise_frame (f);
|
|
70 }
|
149
|
71
|
155
|
72 static void
|
|
73 tty_select_frame_if_unhidden (Lisp_Object frame)
|
|
74 {
|
|
75 if (FRAME_REPAINT_P (XFRAME (frame)))
|
|
76 select_frame_1 (frame);
|
|
77 }
|
|
78
|
|
79 static void
|
|
80 tty_schedule_frame_select (struct frame *f)
|
|
81 {
|
|
82 Lisp_Object frame;
|
|
83
|
|
84 XSETFRAME (frame, f);
|
|
85 enqueue_magic_eval_event (tty_select_frame_if_unhidden, frame);
|
0
|
86 }
|
|
87
|
|
88 static void
|
|
89 tty_after_init_frame (struct frame *f, int first_on_device,
|
|
90 int first_on_console)
|
|
91 {
|
|
92 if (first_on_console)
|
149
|
93 call1 (Qinit_post_tty_win, FRAME_CONSOLE (f));
|
0
|
94 }
|
|
95
|
153
|
96 #ifdef HAVE_GPM
|
|
97 static int
|
|
98 tty_get_mouse_position (struct device *d, Lisp_Object *frame, int *x, int *y)
|
|
99 {
|
|
100 Gpm_Event ev;
|
|
101 int num_buttons;
|
|
102
|
|
103 num_buttons = Gpm_GetSnapshot(&ev);
|
|
104 *x = ev.x;
|
|
105 *y = ev.y;
|
|
106 *frame = DEVICE_SELECTED_FRAME (d);
|
|
107 return (1);
|
|
108 }
|
|
109
|
|
110 static void
|
|
111 tty_set_mouse_position (struct window *w, int x, int y)
|
|
112 {
|
|
113 /* XXX
|
|
114 I couldn't find any GPM functions that set the mouse position.
|
|
115 Mr. Perry had left this function empty; that must be why.
|
|
116 karlheg
|
|
117 */
|
|
118 }
|
|
119
|
|
120 #endif
|
|
121
|
|
122
|
108
|
123 /* Change from withdrawn state to mapped state. */
|
|
124 static void
|
|
125 tty_make_frame_visible (struct frame *f)
|
|
126 {
|
|
127 if (!FRAME_VISIBLE_P(f))
|
|
128 {
|
155
|
129 f->visible = -1;
|
108
|
130 }
|
|
131 }
|
|
132
|
|
133 /* Change from mapped state to withdrawn state. */
|
|
134 static void
|
|
135 tty_make_frame_invisible (struct frame *f)
|
|
136 {
|
149
|
137 f->visible = 0;
|
108
|
138 }
|
|
139
|
155
|
140 static void
|
|
141 tty_make_frame_hidden (struct frame *f)
|
|
142 {
|
|
143 f->visible = -1;
|
|
144 }
|
|
145
|
|
146 static void
|
|
147 tty_make_frame_unhidden (struct frame *f)
|
|
148 {
|
|
149 if (!FRAME_REPAINT_P(f))
|
|
150 {
|
|
151 SET_FRAME_CLEAR(f);
|
|
152 f->visible = 1;
|
|
153 }
|
|
154 }
|
|
155
|
108
|
156 static int
|
|
157 tty_frame_visible_p (struct frame *f)
|
|
158 {
|
149
|
159 return FRAME_VISIBLE_P (f);
|
|
160 }
|
|
161
|
|
162 static void
|
155
|
163 tty_raise_frame_no_select (struct frame *f)
|
149
|
164 {
|
155
|
165 struct frame *o;
|
149
|
166 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
167 Lisp_Object frame_list = DEVICE_FRAME_LIST (d);
|
|
168 Lisp_Object tail = frame_list;
|
|
169
|
|
170 while (CONSP (tail))
|
|
171 {
|
155
|
172 o = XFRAME (XCAR (tail));
|
|
173 if (o != f && FRAME_REPAINT_P(o))
|
|
174 {
|
|
175 tty_make_frame_hidden (o);
|
|
176 break;
|
|
177 }
|
149
|
178 tail = XCDR (tail);
|
|
179 }
|
155
|
180 tty_make_frame_unhidden (f);
|
149
|
181 }
|
|
182
|
155
|
183 static void
|
|
184 tty_raise_frame (struct frame *f)
|
|
185 {
|
|
186 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
187
|
|
188 tty_raise_frame_no_select (f);
|
|
189 tty_schedule_frame_select (f);
|
|
190 }
|
|
191
|
149
|
192 static void
|
|
193 tty_lower_frame (struct frame *f)
|
|
194 {
|
155
|
195 struct frame *o;
|
149
|
196 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
197 Lisp_Object frame_list = DEVICE_FRAME_LIST (d);
|
|
198 Lisp_Object tail;
|
|
199 Lisp_Object new;
|
|
200
|
155
|
201 if (!FRAME_REPAINT_P (f))
|
149
|
202 return;
|
|
203
|
|
204 tail = frame_list;
|
|
205 while (CONSP (tail))
|
|
206 {
|
155
|
207 o = XFRAME (XCAR (tail));
|
|
208 if (o == f)
|
149
|
209 break;
|
|
210 tail = XCDR (tail);
|
|
211 }
|
|
212
|
155
|
213 /* to lower this frame another frame has to be raised.
|
|
214 return if there is no other frame. */
|
|
215 if (!CONSP (tail) && EQ(frame_list, tail))
|
|
216 return;
|
|
217
|
|
218 tty_make_frame_hidden (f);
|
149
|
219 if (CONSP (XCDR (tail)))
|
|
220 new = XCAR (XCDR (tail));
|
|
221 else
|
|
222 new = XCAR (frame_list);
|
155
|
223 tty_make_frame_unhidden (XFRAME (new));
|
|
224 tty_schedule_frame_select (XFRAME (new));
|
108
|
225 }
|
|
226
|
155
|
227 static void
|
|
228 tty_delete_frame (struct frame *f)
|
|
229 {
|
|
230 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
231
|
|
232 if (!NILP (DEVICE_SELECTED_FRAME (d)))
|
|
233 tty_raise_frame (XFRAME (DEVICE_SELECTED_FRAME (d)));
|
|
234 }
|
0
|
235
|
|
236 /************************************************************************/
|
|
237 /* initialization */
|
|
238 /************************************************************************/
|
|
239
|
|
240 void
|
|
241 console_type_create_frame_tty (void)
|
|
242 {
|
|
243 CONSOLE_HAS_METHOD (tty, init_frame_1);
|
149
|
244 CONSOLE_HAS_METHOD (tty, init_frame_3);
|
0
|
245 CONSOLE_HAS_METHOD (tty, after_init_frame);
|
153
|
246 #ifdef HAVE_GPM
|
|
247 CONSOLE_HAS_METHOD (tty, get_mouse_position);
|
|
248 CONSOLE_HAS_METHOD (tty, set_mouse_position);
|
|
249 #endif
|
108
|
250 CONSOLE_HAS_METHOD (tty, make_frame_visible);
|
|
251 CONSOLE_HAS_METHOD (tty, make_frame_invisible);
|
|
252 CONSOLE_HAS_METHOD (tty, frame_visible_p);
|
149
|
253 CONSOLE_HAS_METHOD (tty, raise_frame);
|
|
254 CONSOLE_HAS_METHOD (tty, lower_frame);
|
155
|
255 CONSOLE_HAS_METHOD (tty, delete_frame);
|
0
|
256 }
|
|
257
|
|
258 void
|
|
259 vars_of_frame_tty (void)
|
|
260 {
|
|
261 DEFVAR_LISP ("default-tty-frame-plist", &Vdefault_tty_frame_plist /*
|
|
262 Plist of default frame-creation properties for tty frames.
|
|
263 These are in addition to and override what is specified in
|
|
264 `default-frame-plist', but are overridden by the arguments to the
|
|
265 particular call to `make-frame'.
|
|
266 */ );
|
|
267 Vdefault_tty_frame_plist = Qnil;
|
|
268
|
|
269 tty_console_methods->device_specific_frame_props =
|
|
270 &Vdefault_tty_frame_plist;
|
153
|
271
|
|
272 /* Tty frames are now supported. Advertise a feature to indicate this. */
|
|
273 Fprovide (intern ("tty-frames"));
|
0
|
274 }
|