Mercurial > hg > xemacs-beta
annotate src/frame-tty.c @ 617:af57a77cbc92
[xemacs-hg @ 2001-06-18 07:09:50 by ben]
---------------------------------------------------------------
DOCUMENTATION FIXES:
---------------------------------------------------------------
eval.c: Correct documentation.
elhash.c: Doc correction.
---------------------------------------------------------------
LISP OBJECT CLEANUP:
---------------------------------------------------------------
bytecode.h, buffer.h, casetab.h, chartab.h, console-msw.h, console.h, database.c, device.h, eldap.h, elhash.h, events.h, extents.h, faces.h, file-coding.h, frame.h, glyphs.h, gui-x.h, gui.h, keymap.h, lisp-disunion.h, lisp-union.h, lisp.h, lrecord.h, lstream.h, mule-charset.h, objects.h, opaque.h, postgresql.h, process.h, rangetab.h, specifier.h, toolbar.h, tooltalk.h, ui-gtk.h: Add wrap_* to all objects (it was already there for a few of them)
-- an expression to encapsulate a pointer into a Lisp object,
rather than the inconvenient XSET*. "wrap" was chosen because
"make" as in make_int(), make_char() is not appropriate. (It
implies allocation. The issue does not exist for ints and chars
because they are not allocated.)
Full error checking has been added to these expressions. When
used without error checking, non-union build, use of these
expressions will incur no loss of efficiency. (In fact, XSET* is
now defined in terms of wrap_* in a non-union build.) In a union
build, you will also get no loss of efficiency provided that you
have a decent optimizing compiler, and a compiler that either
understands inlines or automatically inlines those particular
functions. (And since people don't normally do their production
builds on union, it doesn't matter.)
Update the sample Lisp object definition in lrecord.h accordingly.
dumper.c: Fix places in dumper that referenced wrap_object to reference
its new name, wrap_pointer_1.
buffer.c, bufslots.h, conslots.h, console.c, console.h, devslots.h, device.c, device.h, frame.c, frame.h, frameslots.h, window.c, window.h, winslots.h: -- Extract out the Lisp objects of `struct device' into devslots.h,
just like for the other structures.
-- Extract out the remaining (not copied into the window config)
Lisp objects in `struct window' into winslots.h; use different
macros (WINDOW_SLOT vs. WINDOW_SAVED_SLOT) to differentiate them.
-- Eliminate the `dead' flag of `struct frame', since it
duplicates information already available in `framemeths', and fix
FRAME_LIVE_P accordingly. (Devices and consoles already work this
way.)
-- In *slots.h, switch to system where MARKED_SLOT is automatically
undef'd at the end of the file. (Follows what winslots.h already
does.)
-- Update the comments at the beginning of *slots.h to be accurate.
-- When making any of the above objects dead, zero it out entirely
and reset all Lisp object slots to Qnil. (We were already doing
this somewhat, but not consistently.) This (1) Eliminates the
possibility of extra objects hanging around that ought to be
GC'd, (2) Causes an immediate crash if anyone tries to access a
structure in one of these objects, (3) Ensures consistent behavior
wrt dead objects.
dialog-msw.c: Use internal_object_printer, since this object should not escape.
---------------------------------------------------------------
FIXING A CRASH THAT I HIT ONCE (AND A RELATED BAD BEHAVIOR):
---------------------------------------------------------------
eval.c: Fix up some comments about the FSF implementation.
Fix two nasty bugs:
(1) condition_case_unwind frees the conses sitting in the
catch->tag slot too quickly, resulting in a crash that I hit.
(2) catches need to be unwound one at a time when calling
unwind-protect code, rather than all at once at the end; otherwise,
incorrect behavior can result. (A comment shows exactly how.)
backtrace.h: Improve comment about FSF differences in the handler stack.
---------------------------------------------------------------
FIXING A CRASH THAT I REPEATEDLY HIT WHEN USING THE MOUSE WHEEL
UNDER MSWINDOWS:
---------------------------------------------------------------
Basic idea: My crash is due either to a dead, non-marked,
GC-collected frame inside of a window mirror, or a prematurely
freed window mirror. We need to mark the Lisp objects inside of
window mirrors. Tracking the lifespan of window mirrors and
scrollbar instances is extremely hard, and there may well be
lurking bugs where such objects are freed too soon. The only safe
way to fix these problems (and it fixes both problems at once) is
to make both of these structures Lisp objects.
lrecord.h, emacs.c, inline.c, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, scrollbar.h, symsinit.h: Make scrollbar instances actual Lisp objects. Mark the window
mirrors in them. inline.c needs to know about scrollbar.h now.
Record the new type in lrecord.h. Fix up scrollbar-*.c
appropriately. Create a hash table in scrollbar-msw.c so that the
scrollbar instances stored in scrollbar HWND's are properly
GC-protected. Create complex_vars_of_scrollbar_mswindows() to
create the hash table at startup, and call it from emacs.c. Don't
store the scrollbar instance as a property of the GTK scrollbar,
as it's not used and if we did this, we'd have to separately
GC-protect it in a hash table, like in MS Windows.
lrecord.h, frame.h, frame.c, frameslots.h, redisplay.c, window.c, window.h: Move mark_window_mirror from redisplay.c to window.c. Make window
mirrors actual Lisp objects. Tell lrecord.h about them. Change
the window mirror member of struct frame from a pointer to a Lisp
object, and add XWINDOW_MIRROR in appropriate places. Mark the
scrollbar instances in the window mirror.
redisplay.c, redisplay.h, alloc.c: Delete mark_redisplay. Don't call mark_redisplay. We now mark
frame-specific structures in mark_frame.
NOTE: I also deleted an extremely questionable call to
update_frame_window_mirrors(). It was extremely questionable
before, and now totally impossible, since it will create
Lisp objects during redisplay.
frame.c: Mark the scrollbar instances, which are now Lisp objects.
Call mark_gutter() here, not in mark_redisplay().
gutter.c: Update comments about correct marking.
---------------------------------------------------------------
ISSUES BROUGHT UP BY MARTIN:
---------------------------------------------------------------
buffer.h: Put back these macros the way Steve T and I think they ought to be.
I already explained in a previous changelog entry why I think these
macros should be the way I'd defined them. Once again:
We fix these macros so they don't care about the type of their
lvalues. The non-C-string equivalents of these already function
in the same way, and it's correct because it should be OK to pass
in a CBufbyte *, a BufByte *, a Char_Binary *, an UChar_Binary *,
etc. The whole reason for these different types is to work around
errors caused by signed-vs-unsigned non-matching types. Any
possible error that might be caught in a DFC macro would also be
caught wherever the argument is used elsewhere. So creating
multiple macro versions would add no useful error-checking and
just further complicate an already complicated area.
As for Martin's "ANSI aliasing" bug, XEmacs is not ANSI-aliasing
clean and probably never will be. Unless the board agrees to
change XEmacs in this way (and we really don't want to go down
that road), this is not a bug.
sound.h: Undo Martin's type change.
signal.c: Fix problem identified by Martin with Linux and g++ due to
non-standard declaration of setitimer().
systime.h: Update the docs for "qxe_" to point out why making the
encapsulation explicit is always the right way to go. (setitimer()
itself serves as an example.)
For 21.4:
update-elc-2.el: Correct misplaced parentheses, making lisp/mule not get
recompiled.
author | ben |
---|---|
date | Mon, 18 Jun 2001 07:10:32 +0000 |
parents | abe6d1db359e |
children | 943eaba38521 |
rev | line source |
---|---|
428 | 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. | |
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 | |
25 /* Written by Ben Wing. | |
26 Multi-frame support added by Hrvoje Niksic. */ | |
27 | |
28 #include <config.h> | |
29 #include "lisp.h" | |
30 | |
31 #include "console-tty.h" | |
32 #include "frame.h" | |
33 | |
34 #include "events.h" | |
35 | |
36 | |
37 /* Default properties to use when creating frames. */ | |
38 Lisp_Object Vdefault_tty_frame_plist; | |
39 | |
40 static void tty_raise_frame (struct frame *); | |
41 | |
42 | |
43 static void | |
44 tty_init_frame_1 (struct frame *f, Lisp_Object props) | |
45 { | |
46 struct device *d = XDEVICE (FRAME_DEVICE (f)); | |
47 struct console *c = XCONSOLE (DEVICE_CONSOLE (d)); | |
48 | |
49 ++CONSOLE_TTY_DATA (c)->frame_count; | |
50 f->order_count = CONSOLE_TTY_DATA (c)->frame_count; | |
51 f->height = CONSOLE_TTY_DATA (c)->height; | |
52 f->width = CONSOLE_TTY_DATA (c)->width; | |
53 } | |
54 | |
55 static void | |
56 tty_init_frame_3 (struct frame *f) | |
57 { | |
58 tty_raise_frame (f); | |
59 } | |
60 | |
61 static void | |
62 tty_select_frame_if_unhidden (Lisp_Object frame) | |
63 { | |
64 if (FRAME_REPAINT_P (XFRAME (frame))) | |
65 select_frame_1 (frame); | |
66 } | |
67 | |
68 static void | |
69 tty_schedule_frame_select (struct frame *f) | |
70 { | |
71 Lisp_Object frame; | |
72 | |
73 XSETFRAME (frame, f); | |
74 enqueue_magic_eval_event (tty_select_frame_if_unhidden, frame); | |
75 } | |
76 | |
77 static void | |
78 tty_after_init_frame (struct frame *f, int first_on_device, | |
79 int first_on_console) | |
80 { | |
81 if (first_on_console) | |
82 call1 (Qinit_post_tty_win, FRAME_CONSOLE (f)); | |
83 } | |
84 | |
85 /* Change from withdrawn state to mapped state. */ | |
86 static void | |
87 tty_make_frame_visible (struct frame *f) | |
88 { | |
89 if (!FRAME_VISIBLE_P(f)) | |
90 { | |
91 f->visible = -1; | |
92 } | |
93 } | |
94 | |
95 /* Change from mapped state to withdrawn state. */ | |
96 static void | |
97 tty_make_frame_invisible (struct frame *f) | |
98 { | |
99 f->visible = 0; | |
100 } | |
101 | |
102 static void | |
103 tty_make_frame_hidden (struct frame *f) | |
104 { | |
105 f->visible = -1; | |
106 } | |
107 | |
108 static void | |
109 tty_make_frame_unhidden (struct frame *f) | |
110 { | |
111 if (!FRAME_REPAINT_P(f)) | |
112 { | |
113 SET_FRAME_CLEAR(f); | |
114 f->visible = 1; | |
115 } | |
116 } | |
117 | |
118 static int | |
119 tty_frame_visible_p (struct frame *f) | |
120 { | |
121 return FRAME_VISIBLE_P (f); | |
122 } | |
123 | |
124 static void | |
125 tty_raise_frame_no_select (struct frame *f) | |
126 { | |
127 LIST_LOOP_2 (frame, DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f)))) | |
128 { | |
129 struct frame *o = XFRAME (frame); | |
130 if (o != f && FRAME_REPAINT_P (o)) | |
131 { | |
132 tty_make_frame_hidden (o); | |
133 break; | |
134 } | |
135 } | |
136 tty_make_frame_unhidden (f); | |
137 } | |
138 | |
139 static void | |
140 tty_raise_frame (struct frame *f) | |
141 { | |
142 tty_raise_frame_no_select (f); | |
143 tty_schedule_frame_select (f); | |
144 } | |
145 | |
146 static void | |
147 tty_lower_frame (struct frame *f) | |
148 { | |
149 Lisp_Object frame_list = DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f))); | |
150 Lisp_Object tail, new; | |
151 | |
152 if (!FRAME_REPAINT_P (f)) | |
153 return; | |
154 | |
155 LIST_LOOP (tail, frame_list) | |
156 { | |
157 if (f == XFRAME (XCAR (tail))) | |
158 break; | |
159 } | |
160 | |
161 /* To lower this frame, another frame has to be raised. Return if | |
162 there is no other frame. */ | |
163 if (NILP (tail) && EQ(frame_list, tail)) | |
164 return; | |
165 | |
166 tty_make_frame_hidden (f); | |
167 if (CONSP (XCDR (tail))) | |
168 new = XCAR (XCDR (tail)); | |
169 else | |
170 new = XCAR (frame_list); | |
171 tty_make_frame_unhidden (XFRAME (new)); | |
172 tty_schedule_frame_select (XFRAME (new)); | |
173 } | |
174 | |
175 static void | |
176 tty_delete_frame (struct frame *f) | |
177 { | |
178 struct device *d = XDEVICE (FRAME_DEVICE (f)); | |
179 | |
180 if (!NILP (DEVICE_SELECTED_FRAME (d))) | |
181 tty_raise_frame (XFRAME (DEVICE_SELECTED_FRAME (d))); | |
182 } | |
183 | |
184 /************************************************************************/ | |
185 /* initialization */ | |
186 /************************************************************************/ | |
187 | |
188 void | |
189 console_type_create_frame_tty (void) | |
190 { | |
191 CONSOLE_HAS_METHOD (tty, init_frame_1); | |
192 CONSOLE_HAS_METHOD (tty, init_frame_3); | |
193 CONSOLE_HAS_METHOD (tty, after_init_frame); | |
194 CONSOLE_HAS_METHOD (tty, make_frame_visible); | |
195 CONSOLE_HAS_METHOD (tty, make_frame_invisible); | |
196 CONSOLE_HAS_METHOD (tty, frame_visible_p); | |
197 CONSOLE_HAS_METHOD (tty, raise_frame); | |
198 CONSOLE_HAS_METHOD (tty, lower_frame); | |
199 CONSOLE_HAS_METHOD (tty, delete_frame); | |
200 } | |
201 | |
202 void | |
203 vars_of_frame_tty (void) | |
204 { | |
205 DEFVAR_LISP ("default-tty-frame-plist", &Vdefault_tty_frame_plist /* | |
206 Plist of default frame-creation properties for tty frames. | |
207 These are in addition to and override what is specified in | |
208 `default-frame-plist', but are overridden by the arguments to the | |
209 particular call to `make-frame'. | |
210 */ ); | |
211 Vdefault_tty_frame_plist = Qnil; | |
212 | |
213 tty_console_methods->device_specific_frame_props = | |
214 &Vdefault_tty_frame_plist; | |
215 | |
216 /* Tty frames are now supported. Advertise a feature to indicate this. */ | |
217 Fprovide (intern ("tty-frames")); | |
218 } |