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