Mercurial > emacs
annotate src/xterm.c @ 989:dc3fda1e21d0
* alloc.c (Fgarbage_collect): Doc fix.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Fri, 14 Aug 1992 02:34:06 +0000 |
parents | cbdfc337ec8f |
children | 7c2565dd644c |
rev | line source |
---|---|
286 | 1 /* X Communication module for terminals which understand the X protocol. |
621 | 2 Copyright (C) 1989, 1992 Free Software Foundation, Inc. |
286 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
621 | 8 the Free Software Foundation; either version 2, or (at your option) |
286 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 /* Serious problems: | |
21 | |
22 Kludge: dup2 is used to put the X-connection socket into desc # 0 | |
23 so that wait_reading_process_input will wait for it in place of | |
24 actual terminal input. | |
25 | |
26 */ | |
27 | |
28 #include "config.h" | |
29 | |
30 #ifdef HAVE_X_WINDOWS | |
31 | |
32 #include "lisp.h" | |
33 | |
34 /* On 4.3 this loses if it comes after xterm.h. */ | |
35 #include <signal.h> | |
36 | |
37 /* This may include sys/types.h, and that somehow loses | |
38 if this is not done before the other system files. */ | |
39 #include "xterm.h" | |
40 | |
41 /* Load sys/types.h if not already loaded. | |
42 In some systems loading it twice is suicidal. */ | |
43 #ifndef makedev | |
44 #include <sys/types.h> | |
45 #endif | |
46 | |
47 #ifdef BSD | |
48 #include <sys/ioctl.h> | |
49 #include <strings.h> | |
50 #else | |
51 #include <sys/termio.h> | |
52 #include <string.h> | |
53 #endif | |
54 | |
55 /* Allow m- file to inhibit use of FIONREAD. */ | |
56 #ifdef BROKEN_FIONREAD | |
57 #undef FIONREAD | |
58 #endif | |
59 | |
60 /* We are unable to use interrupts if FIONREAD is not available, | |
61 so flush SIGIO so we won't try. */ | |
62 #ifndef FIONREAD | |
63 #ifdef SIGIO | |
64 #undef SIGIO | |
65 #endif | |
66 #endif | |
67 | |
555 | 68 #include "systime.h" |
286 | 69 |
70 #include <fcntl.h> | |
71 #include <stdio.h> | |
72 #include <ctype.h> | |
73 #include <errno.h> | |
74 #include <setjmp.h> | |
75 #include <sys/stat.h> | |
76 #include <sys/param.h> | |
77 | |
78 #include "dispextern.h" | |
79 #include "termhooks.h" | |
80 #include "termopts.h" | |
81 #include "termchar.h" | |
82 #if 0 | |
83 #include "sink.h" | |
84 #include "sinkmask.h" | |
85 #endif | |
86 #include "gnu.h" | |
771 | 87 #include "frame.h" |
286 | 88 #include "disptab.h" |
89 #include "buffer.h" | |
90 | |
91 #ifdef HAVE_X11 | |
92 #define XMapWindow XMapRaised /* Raise them when mapping. */ | |
93 #else | |
94 #include <X/Xkeyboard.h> | |
95 /*#include <X/Xproto.h> */ | |
96 #endif /* HAVE_X11 */ | |
97 | |
98 /* For sending Meta-characters. Do we need this? */ | |
99 #define METABIT 0200 | |
100 | |
101 #define min(a,b) ((a)<(b) ? (a) : (b)) | |
102 #define max(a,b) ((a)>(b) ? (a) : (b)) | |
103 | |
104 /* Nonzero means we must reprint all windows | |
105 because 1) we received an ExposeWindow event | |
106 or 2) we received too many ExposeRegion events to record. */ | |
107 | |
108 static int expose_all_windows; | |
109 | |
110 /* Nonzero means we must reprint all icon windows. */ | |
111 | |
112 static int expose_all_icons; | |
113 | |
114 #ifndef HAVE_X11 | |
115 /* ExposeRegion events, when received, are copied into this queue | |
116 for later processing. */ | |
117 | |
118 static struct event_queue x_expose_queue; | |
119 | |
120 /* ButtonPressed and ButtonReleased events, when received, | |
121 are copied into this queue for later processing. */ | |
122 | |
123 struct event_queue x_mouse_queue; | |
124 #endif | |
125 | |
126 /* Nonzero after BLOCK_INPUT; prevents input events from being | |
127 processed until later. */ | |
128 | |
129 int x_input_blocked; | |
130 | |
131 #if defined (SIGIO) && defined (FIONREAD) | |
132 int BLOCK_INPUT_mask; | |
133 #endif | |
134 | |
135 /* Nonzero if input events came in while x_input_blocked was nonzero. | |
136 UNBLOCK_INPUT checks for this. */ | |
137 | |
138 int x_pending_input; | |
139 | |
140 /* The id of a bitmap used for icon windows. | |
141 One such map is shared by all Emacs icon windows. | |
142 This is zero if we have not yet had a need to create the bitmap. */ | |
143 | |
144 static Bitmap icon_bitmap; | |
145 | |
146 /* Font used for text icons. */ | |
147 | |
148 static FONT_TYPE *icon_font_info; | |
149 | |
150 /* Stuff for dealing with the main icon title. */ | |
151 | |
152 extern Lisp_Object Vcommand_line_args; | |
398 | 153 char *hostname, *x_id_name; |
395 | 154 Lisp_Object invocation_name; |
286 | 155 |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
156 /* These are the current window manager hints. It seems that |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
157 XSetWMHints, when presented with an unset bit in the `flags' member |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
158 of the hints structure, does not leave the corresponding attribute |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
159 unchanged; rather, it resets that attribute to its default value. |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
160 For example, unless you set the `icon_pixmap' field and the |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
161 `IconPixmapHint' bit, XSetWMHints will forget what your icon pixmap |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
162 was. This is rather troublesome, since some of the members (for |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
163 example, `input' and `icon_pixmap') want to stay the same |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
164 throughout the execution of Emacs. So, we keep this structure |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
165 around, just leaving values in it and adding new bits to the mask |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
166 as we go. */ |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
167 XWMHints x_wm_hints; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
168 |
286 | 169 /* This is the X connection that we are using. */ |
170 | |
171 Display *x_current_display; | |
172 | |
771 | 173 /* Frame being updated by update_frame. */ |
286 | 174 /* This is set by XTupdate_begin and looked at by all the |
175 XT functions. It is zero while not inside an update. | |
771 | 176 In that case, the XT functions assume that `selected_frame' |
177 is the frame to apply to. */ | |
178 | |
179 static struct frame *updating_frame; | |
180 | |
181 /* The frame (if any) which has the X window that has keyboard focus. | |
182 Zero if none. This is examined by Ffocus_frame in frame.c. */ | |
183 struct frame *x_focus_frame; | |
184 | |
185 /* The frame which currently has the visual highlight, and should get | |
186 keyboard input (other sorts of input have the frame encoded in the | |
187 event). It points to the X focus frame's selected window's | |
188 frame. It differs from x_focus_frame when we're using a global | |
369 | 189 minibuffer. */ |
771 | 190 static struct frame *x_highlight_frame; |
369 | 191 |
286 | 192 /* From .Xdefaults, the value of "emacs.WarpMouse". If non-zero, |
771 | 193 mouse is moved to inside of frame when frame is de-iconified. */ |
286 | 194 |
195 static int warp_mouse_on_deiconify; | |
196 | |
197 /* During an update, maximum vpos for ins/del line operations to affect. */ | |
198 | |
199 static int flexlines; | |
200 | |
201 /* During an update, nonzero if chars output now should be highlighted. */ | |
202 | |
203 static int highlight; | |
204 | |
205 /* Nominal cursor position -- where to draw output. | |
206 During an update, these are different from the cursor-box position. */ | |
207 | |
208 static int curs_x; | |
209 static int curs_y; | |
210 | |
211 #ifdef HAVE_X11 | |
212 /* `t' if a mouse button is depressed. */ | |
213 | |
214 extern Lisp_Object Vmouse_depressed; | |
215 | |
216 /* Tells if a window manager is present or not. */ | |
217 | |
218 extern Lisp_Object Vx_no_window_manager; | |
219 | |
220 /* Timestamp that we requested selection data was made. */ | |
221 extern Time requestor_time; | |
222 | |
223 /* ID of the window requesting selection data. */ | |
224 extern Window requestor_window; | |
225 | |
226 /* Nonzero enables some debugging for the X interface code. */ | |
227 extern int _Xdebug; | |
228 | |
229 #else /* X10 stuff */ | |
230 | |
231 /* Bit patterns for the mouse cursor. */ | |
232 | |
233 short MouseCursor[] = { | |
234 0x0000, 0x0008, 0x0018, 0x0038, | |
235 0x0078, 0x00f8, 0x01f8, 0x03f8, | |
236 0x07f8, 0x00f8, 0x00d8, 0x0188, | |
237 0x0180, 0x0300, 0x0300, 0x0000}; | |
238 | |
239 short MouseMask[] = { | |
240 0x000c, 0x001c, 0x003c, 0x007c, | |
241 0x00fc, 0x01fc, 0x03fc, 0x07fc, | |
242 0x0ffc, 0x0ffc, 0x01fc, 0x03dc, | |
243 0x03cc, 0x0780, 0x0780, 0x0300}; | |
244 | |
245 static short grey_bits[] = { | |
246 0x0005, 0x000a, 0x0005, 0x000a}; | |
247 | |
248 static Pixmap GreyPixmap = 0; | |
249 #endif /* X10 stuff */ | |
250 | |
251 /* From time to time we get info on an Emacs window, here. */ | |
252 | |
253 static WINDOWINFO_TYPE windowinfo; | |
254 | |
255 extern int errno; | |
256 | |
257 extern Display *XOpenDisplay (); | |
258 extern Window XCreateWindow (); | |
259 | |
260 extern Cursor XCreateCursor (); | |
261 extern FONT_TYPE *XOpenFont (); | |
262 | |
263 static void flashback (); | |
264 | |
265 #ifndef HAVE_X11 | |
266 static void dumpqueue (); | |
267 #endif | |
268 | |
269 void dumpborder (); | |
621 | 270 static int XTcursor_to (); |
271 static int XTclear_end_of_line (); | |
286 | 272 |
771 | 273 /* These hooks are called by update_frame at the beginning and end |
274 of a frame update. We record in `updating_frame' the identity | |
275 of the frame being updated, so that the XT... functions do not | |
276 need to take a frame as argument. Most of the XT... functions | |
286 | 277 should never be called except during an update, the only exceptions |
278 being XTcursor_to, XTwrite_char and XTreassert_line_highlight. */ | |
279 | |
280 extern int mouse_track_top, mouse_track_left, mouse_track_width; | |
281 | |
282 static | |
771 | 283 XTupdate_begin (f) |
284 struct frame *f; | |
286 | 285 { |
286 int mask; | |
287 | |
771 | 288 if (f == 0) |
286 | 289 abort (); |
290 | |
771 | 291 updating_frame = f; |
292 flexlines = f->height; | |
286 | 293 highlight = 0; |
294 | |
295 BLOCK_INPUT; | |
296 #ifndef HAVE_X11 | |
297 dumpqueue (); | |
298 #endif | |
299 UNBLOCK_INPUT; | |
300 } | |
301 | |
302 static void x_do_pending_expose (); | |
303 | |
304 static | |
771 | 305 XTupdate_end (f) |
306 struct frame *f; | |
286 | 307 { |
308 int mask; | |
309 | |
771 | 310 if (updating_frame == 0 |
311 || updating_frame != f) | |
286 | 312 abort (); |
313 | |
314 BLOCK_INPUT; | |
315 #ifndef HAVE_X11 | |
316 dumpqueue (); | |
317 #endif | |
771 | 318 adjust_scrollbars (f); |
286 | 319 x_do_pending_expose (); |
320 | |
771 | 321 x_display_cursor (f, 1); |
322 | |
323 updating_frame = 0; | |
286 | 324 XFlushQueue (); |
325 UNBLOCK_INPUT; | |
326 } | |
327 | |
328 /* External interface to control of standout mode. | |
329 Call this when about to modify line at position VPOS | |
330 and not change whether it is highlighted. */ | |
331 | |
332 XTreassert_line_highlight (new, vpos) | |
333 int new, vpos; | |
334 { | |
335 highlight = new; | |
336 } | |
337 | |
338 /* Call this when about to modify line at position VPOS | |
339 and change whether it is highlighted. */ | |
340 | |
341 static | |
342 XTchange_line_highlight (new_highlight, vpos, first_unused_hpos) | |
343 int new_highlight, vpos, first_unused_hpos; | |
344 { | |
345 highlight = new_highlight; | |
346 XTcursor_to (vpos, 0); | |
771 | 347 XTclear_end_of_line (updating_frame->width); |
286 | 348 } |
349 | |
350 /* This is used when starting Emacs and when restarting after suspend. | |
351 When starting Emacs, no X window is mapped. And nothing must be done | |
352 to Emacs's own window if it is suspended (though that rarely happens). */ | |
353 | |
354 static | |
355 XTset_terminal_modes () | |
356 { | |
357 } | |
358 | |
359 /* This is called when exiting or suspending Emacs. | |
360 Exiting will make the X-windows go away, and suspending | |
361 requires no action. */ | |
362 | |
363 static | |
364 XTreset_terminal_modes () | |
365 { | |
771 | 366 /* XTclear_frame (); */ |
286 | 367 } |
368 | |
771 | 369 /* Set the nominal cursor position of the frame: |
286 | 370 where display update commands will take effect. |
371 This does not affect the place where the cursor-box is displayed. */ | |
372 | |
621 | 373 static int |
286 | 374 XTcursor_to (row, col) |
375 register int row, col; | |
376 { | |
377 int mask; | |
378 int orow = row; | |
379 | |
380 curs_x = col; | |
381 curs_y = row; | |
382 | |
771 | 383 if (updating_frame == 0) |
286 | 384 { |
385 BLOCK_INPUT; | |
771 | 386 x_display_cursor (selected_frame, 1); |
286 | 387 XFlushQueue (); |
388 UNBLOCK_INPUT; | |
389 } | |
390 } | |
391 | |
392 /* Display a sequence of N glyphs found at GP. | |
393 WINDOW is the x-window to output to. LEFT and TOP are starting coords. | |
394 HL is 1 if this text is highlighted, 2 if the cursor is on it. | |
395 | |
396 FONT is the default font to use (for glyphs whose font-code is 0). */ | |
397 | |
398 static void | |
771 | 399 dumpglyphs (f, left, top, gp, n, hl, font) |
400 struct frame *f; | |
286 | 401 int left, top; |
402 register GLYPH *gp; /* Points to first GLYPH. */ | |
403 register int n; /* Number of glyphs to display. */ | |
404 int hl; | |
405 FONT_TYPE *font; | |
406 { | |
407 register int len; | |
771 | 408 Window window = f->display.x->window_desc; |
409 GC drawing_gc = (hl == 2 ? f->display.x->cursor_gc | |
410 : (hl ? f->display.x->reverse_gc | |
411 : f->display.x->normal_gc)); | |
286 | 412 |
313 | 413 if (sizeof (GLYPH) == sizeof (XChar2b)) |
414 XDrawImageString16 (x_current_display, window, drawing_gc, | |
415 left, top + FONT_BASE (font), (XChar2b *) gp, n); | |
416 else if (sizeof (GLYPH) == sizeof (unsigned char)) | |
417 XDrawImageString (x_current_display, window, drawing_gc, | |
418 left, top + FONT_BASE (font), (char *) gp, n); | |
419 else | |
420 /* What size of glyph ARE you using? And does X have a function to | |
421 draw them? */ | |
422 abort (); | |
286 | 423 } |
424 | |
425 #if 0 | |
426 static void | |
771 | 427 dumpglyphs (f, left, top, gp, n, hl, font) |
428 struct frame *f; | |
286 | 429 int left, top; |
430 register GLYPH *gp; /* Points to first GLYPH. */ | |
431 register int n; /* Number of glyphs to display. */ | |
432 int hl; | |
433 FONT_TYPE *font; | |
434 { | |
771 | 435 char buf[f->width]; /* Holds characters to be displayed. */ |
286 | 436 register char *cp; /* Steps through buf[]. */ |
437 register int tlen = GLYPH_TABLE_LENGTH; | |
438 register Lisp_Object *tbase = GLYPH_TABLE_BASE; | |
771 | 439 Window window = f->display.x->window_desc; |
440 int cursor_pixel = f->display.x->cursor_pixel; | |
441 int fg_pixel = f->display.x->foreground_pixel; | |
442 int bg_pixel = f->display.x->background_pixel; | |
443 int intborder = f->display.x->internal_border_width; | |
286 | 444 |
445 while (n) | |
446 { | |
447 /* Get the face-code of the next GLYPH. */ | |
448 int cf, len; | |
449 int g = *gp; | |
450 | |
451 while (GLYPH_ALIAS_P (tbase, tlen, g)) | |
452 g = GLYPH_ALIAS (tbase, g); | |
453 | |
454 cf = g >> 8; | |
455 | |
456 /* Find the run of consecutive glyphs with the same face-code. | |
457 Extract their character codes into BUF. */ | |
458 cp = buf; | |
459 while (n > 0) | |
460 { | |
461 g = *gp; | |
462 while (GLYPH_ALIAS_P (tbase, tlen, g)) | |
463 g = GLYPH_ALIAS (tbase, g); | |
464 if ((g >> 8) != cf) | |
465 break; | |
466 | |
467 *cp++ = 0377 & g; | |
468 --n; | |
469 ++gp; | |
470 } | |
471 | |
472 /* LEN gets the length of the run. */ | |
473 len = cp - buf; | |
474 | |
475 /* Now output this run of chars, with the font and pixel values | |
476 determined by the face code CF. */ | |
477 if (cf == 0) | |
478 { | |
479 #ifdef HAVE_X11 | |
771 | 480 GC GC_cursor = f->display.x->cursor_gc; |
481 GC GC_reverse = f->display.x->reverse_gc; | |
482 GC GC_normal = f->display.x->normal_gc; | |
286 | 483 |
484 XDrawImageString (x_current_display, window, | |
485 (hl == 2 | |
486 ? GC_cursor | |
487 : (hl ? GC_reverse : GC_normal)), | |
488 left, top + FONT_BASE (font), buf, len); | |
489 #else | |
490 XText (window, left, top, | |
491 buf, | |
492 len, | |
493 font->id, | |
494 (hl == 2 | |
495 ? (cursor_pixel == fg_pixel ? bg_pixel : fg_pixel) | |
496 : hl ? bg_pixel : fg_pixel), | |
497 (hl == 2 ? cursor_pixel | |
498 : hl ? fg_pixel : bg_pixel)); | |
499 #endif /* HAVE_X11 */ | |
500 } | |
501 else | |
502 { | |
503 #ifdef HAVE_X11 | |
504 if (FACE_IS_FONT (cf)) | |
771 | 505 XDrawImageString (x_current_display, f->display.x->window_desc, |
286 | 506 FACE_GC (cf), |
507 left, top + FONT_BASE (FACE_FONT (cf)), | |
508 buf, len); | |
509 else if (FACE_IS_IMAGE (cf)) | |
510 XCopyPlane (x_current_display, FACE_IMAGE (cf), | |
771 | 511 f->display.x->window_desc, |
512 f->display.x->normal_gc, | |
286 | 513 0, 0, |
514 FACE_IMAGE_WIDTH (cf), | |
515 FACE_IMAGE_HEIGHT (cf), left, top); | |
516 else | |
517 abort (); | |
518 #else | |
519 register struct face *fp = x_face_table[cf]; | |
520 | |
521 XText (window, left, top, | |
522 buf, | |
523 len, | |
524 fp->font->id, | |
525 (hl == 2 | |
526 ? (cursor_pixel == fp->fg ? fp->bg : fp->fg) | |
527 : hl ? fp->bg : fp->fg), | |
528 (hl == 2 ? cursor_pixel | |
529 : hl ? fp->fg : fp->bg)); | |
530 #endif /* HAVE_X11 */ | |
531 } | |
532 left += len * FONT_WIDTH (font); | |
533 } | |
534 } | |
535 #endif | |
536 | |
771 | 537 /* Output some text at the nominal frame cursor position, |
286 | 538 advancing the cursor over the text. |
539 Output LEN glyphs at START. | |
540 | |
541 `highlight', set up by XTreassert_line_highlight or XTchange_line_highlight, | |
542 controls the pixel values used for foreground and background. */ | |
543 | |
544 static | |
545 XTwrite_glyphs (start, len) | |
546 register GLYPH *start; | |
547 int len; | |
548 { | |
549 register int temp_length; | |
550 int mask; | |
771 | 551 struct frame *f; |
286 | 552 |
553 BLOCK_INPUT; | |
554 | |
771 | 555 f = updating_frame; |
556 if (f == 0) | |
286 | 557 { |
771 | 558 f = selected_frame; |
286 | 559 /* If not within an update, |
771 | 560 output at the frame's visible cursor. */ |
561 curs_x = f->cursor_x; | |
562 curs_y = f->cursor_y; | |
286 | 563 } |
564 | |
771 | 565 dumpglyphs (f, |
566 (curs_x * FONT_WIDTH (f->display.x->font) | |
567 + f->display.x->internal_border_width), | |
568 (curs_y * FONT_HEIGHT (f->display.x->font) | |
569 + f->display.x->internal_border_width), | |
570 start, len, highlight, f->display.x->font); | |
429 | 571 |
572 /* If we drew on top of the cursor, note that it is turned off. */ | |
771 | 573 if (curs_y == f->phys_cursor_y |
574 && curs_x <= f->phys_cursor_x | |
575 && curs_x + len > f->phys_cursor_x) | |
576 f->phys_cursor_x = -1; | |
286 | 577 |
771 | 578 if (updating_frame == 0) |
286 | 579 { |
771 | 580 f->cursor_x += len; |
581 x_display_cursor (f, 1); | |
582 f->cursor_x -= len; | |
286 | 583 } |
584 else | |
585 curs_x += len; | |
586 | |
587 UNBLOCK_INPUT; | |
588 } | |
589 | |
590 /* Erase the current text line from the nominal cursor position (inclusive) | |
591 to column FIRST_UNUSED (exclusive). The idea is that everything | |
592 from FIRST_UNUSED onward is already erased. */ | |
593 | |
621 | 594 static int |
286 | 595 XTclear_end_of_line (first_unused) |
596 register int first_unused; | |
597 { | |
771 | 598 struct frame *f = updating_frame; |
286 | 599 int mask; |
600 | |
771 | 601 if (f == 0) |
286 | 602 abort (); |
603 | |
771 | 604 if (curs_y < 0 || curs_y >= f->height) |
286 | 605 return; |
606 if (first_unused <= 0) | |
607 return; | |
608 | |
771 | 609 if (first_unused >= f->width) |
610 first_unused = f->width; | |
286 | 611 |
612 BLOCK_INPUT; | |
613 | |
429 | 614 /* Notice if the cursor will be cleared by this operation. */ |
771 | 615 if (curs_y == f->phys_cursor_y |
616 && curs_x <= f->phys_cursor_x | |
617 && f->phys_cursor_x < first_unused) | |
618 f->phys_cursor_x = -1; | |
286 | 619 |
620 #ifdef HAVE_X11 | |
771 | 621 XClearArea (x_current_display, f->display.x->window_desc, |
622 curs_x * FONT_WIDTH (f->display.x->font) | |
623 + f->display.x->internal_border_width, | |
624 curs_y * FONT_HEIGHT (f->display.x->font) | |
625 + f->display.x->internal_border_width, | |
626 FONT_WIDTH (f->display.x->font) * (first_unused - curs_x), | |
627 FONT_HEIGHT (f->display.x->font), False); | |
286 | 628 |
629 #else | |
771 | 630 XPixSet (f->display.x->window_desc, |
631 curs_x * FONT_WIDTH (f->display.x->font) + f->display.x->internal_border_width, | |
632 curs_y * FONT_HEIGHT (f->display.x->font) + f->display.x->internal_border_width, | |
633 FONT_WIDTH (f->display.x->font) * (first_unused - curs_x), | |
634 FONT_HEIGHT (f->display.x->font), | |
635 f->display.x->background_pixel); | |
286 | 636 #endif /* HAVE_X11 */ |
637 | |
638 UNBLOCK_INPUT; | |
639 } | |
640 | |
641 static | |
771 | 642 XTclear_frame () |
286 | 643 { |
644 int mask; | |
771 | 645 struct frame *f = updating_frame; |
646 | |
647 if (f == 0) | |
648 f = selected_frame; | |
649 | |
650 f->phys_cursor_x = -1; /* Cursor not visible. */ | |
286 | 651 curs_x = 0; /* Nominal cursor position is top left. */ |
652 curs_y = 0; | |
653 | |
654 BLOCK_INPUT; | |
771 | 655 XClear (f->display.x->window_desc); |
286 | 656 #ifndef HAVE_X11 |
771 | 657 dumpborder (f, 0); |
286 | 658 #endif |
659 XFlushQueue (); | |
660 UNBLOCK_INPUT; | |
661 } | |
662 | |
771 | 663 /* Paint horzontal bars down the frame for a visible bell. |
286 | 664 Note that this may be way too slow on some machines. */ |
665 | |
771 | 666 XTflash (f) |
667 struct frame *f; | |
286 | 668 { |
771 | 669 register struct frame_glyphs *active_frame = FRAME_CURRENT_GLYPHS (f); |
286 | 670 register int i; |
671 int x, y; | |
672 | |
771 | 673 if (updating_frame != 0) |
286 | 674 abort (); |
675 | |
676 BLOCK_INPUT; | |
677 #ifdef HAVE_X11 | |
678 #if 0 | |
771 | 679 for (i = f->height * FONT_HEIGHT (f->display.x->font) - 10; |
286 | 680 i >= 0; |
681 i -= 100) /* Should be NO LOWER than 75 for speed reasons. */ | |
771 | 682 XFillRectangle (x_current_display, f->display.x->window_desc, |
683 f->display.x->cursor_gc, | |
684 0, i, f->width * FONT_WIDTH (f->display.x->font) | |
685 + 2 * f->display.x->internal_border_width, 25); | |
286 | 686 #endif |
687 | |
771 | 688 x = (f->width * FONT_WIDTH (f->display.x->font)) / 4; |
689 y = (f->height * FONT_HEIGHT (f->display.x->font)) / 4; | |
690 XFillRectangle (x_current_display, f->display.x->window_desc, | |
691 f->display.x->cursor_gc, | |
286 | 692 x, y, 2 * x, 2 * y); |
771 | 693 dumpglyphs (f, (x + f->display.x->internal_border_width), |
694 (y + f->display.x->internal_border_width), | |
695 &active_frame->glyphs[(f->height / 4) + 1][(f->width / 4)], | |
696 1, 0, f->display.x->font); | |
286 | 697 |
698 #else /* X10 */ | |
771 | 699 for (i = f->height * FONT_HEIGHT (f->display.x->font) - 10; |
286 | 700 i >= 0; |
701 i -= 50) | |
771 | 702 XPixFill (f->display.x->window_desc, 0, i, |
703 f->width * FONT_WIDTH (f->display.x->font) | |
704 + 2 * f->display.x->internal_border_width, 10, | |
286 | 705 WHITE_PIX_DEFAULT, ClipModeClipped, GXinvert, AllPlanes); |
706 #endif /* X10 */ | |
707 | |
708 XFlushQueue (); | |
709 UNBLOCK_INPUT; | |
710 } | |
711 | |
771 | 712 /* Flip background and forground colors of the frame. */ |
713 | |
714 x_invert_frame (f) | |
715 struct frame *f; | |
286 | 716 { |
717 #ifdef HAVE_X11 | |
718 GC temp; | |
719 unsigned long pix_temp; | |
720 | |
771 | 721 x_display_cursor (f, 0); |
722 XClearWindow (x_current_display, f->display.x->window_desc); | |
723 temp = f->display.x->normal_gc; | |
724 f->display.x->normal_gc = f->display.x->reverse_gc; | |
725 f->display.x->reverse_gc = temp; | |
726 pix_temp = f->display.x->foreground_pixel; | |
727 f->display.x->foreground_pixel = f->display.x->background_pixel; | |
728 f->display.x->background_pixel = pix_temp; | |
729 | |
730 XSetWindowBackground (x_current_display, f->display.x->window_desc, | |
731 f->display.x->background_pixel); | |
732 if (f->display.x->background_pixel == f->display.x->cursor_pixel) | |
286 | 733 { |
771 | 734 f->display.x->cursor_pixel = f->display.x->foreground_pixel; |
735 XSetBackground (x_current_display, f->display.x->cursor_gc, | |
736 f->display.x->cursor_pixel); | |
737 XSetForeground (x_current_display, f->display.x->cursor_gc, | |
738 f->display.x->background_pixel); | |
286 | 739 } |
771 | 740 redraw_frame (f); |
286 | 741 #endif /* X11 */ |
742 } | |
743 | |
744 /* Make audible bell. */ | |
745 | |
746 #ifdef HAVE_X11 | |
747 #define XRINGBELL XBell(x_current_display, 0) | |
748 #else | |
749 #define XRINGBELL XFeep(0); | |
750 #endif | |
751 | |
752 XTring_bell () | |
753 { | |
754 if (visible_bell) | |
755 #if 0 | |
771 | 756 XTflash (selected_frame); |
286 | 757 #endif |
758 { | |
771 | 759 x_invert_frame (selected_frame); |
760 x_invert_frame (selected_frame); | |
286 | 761 } |
762 else | |
763 { | |
764 BLOCK_INPUT; | |
765 XRINGBELL; | |
766 XFlushQueue (); | |
767 UNBLOCK_INPUT; | |
768 } | |
769 } | |
770 | |
771 /* Insert and delete character are not supposed to be used | |
772 because we are supposed to turn off the feature of using them. */ | |
773 | |
774 static | |
775 XTinsert_glyphs (start, len) | |
776 register char *start; | |
777 register int len; | |
778 { | |
779 abort (); | |
780 } | |
781 | |
782 static | |
783 XTdelete_glyphs (n) | |
784 register int n; | |
785 { | |
786 abort (); | |
787 } | |
788 | |
789 /* Specify how many text lines, from the top of the window, | |
790 should be affected by insert-lines and delete-lines operations. | |
791 This, and those operations, are used only within an update | |
792 that is bounded by calls to XTupdate_begin and XTupdate_end. */ | |
793 | |
794 static | |
795 XTset_terminal_window (n) | |
796 register int n; | |
797 { | |
771 | 798 if (updating_frame == 0) |
286 | 799 abort (); |
800 | |
771 | 801 if ((n <= 0) || (n > updating_frame->height)) |
802 flexlines = updating_frame->height; | |
286 | 803 else |
804 flexlines = n; | |
805 } | |
806 | |
807 /* Perform an insert-lines operation, inserting N lines | |
808 at a vertical position curs_y. */ | |
809 | |
810 static void | |
811 stufflines (n) | |
812 register int n; | |
813 { | |
814 register int topregion, bottomregion; | |
815 register int length, newtop, mask; | |
771 | 816 register struct frame *f = updating_frame; |
817 int intborder = f->display.x->internal_border_width; | |
286 | 818 |
819 if (curs_y >= flexlines) | |
820 return; | |
821 | |
822 topregion = curs_y; | |
823 bottomregion = flexlines - (n + 1); | |
824 newtop = topregion + n; | |
825 length = (bottomregion - topregion) + 1; | |
826 | |
827 #ifndef HAVE_X11 | |
828 dumpqueue (); | |
829 #endif | |
830 | |
831 if ((length > 0) && (newtop <= flexlines)) | |
832 { | |
833 #ifdef HAVE_X11 | |
771 | 834 XCopyArea (x_current_display, f->display.x->window_desc, |
835 f->display.x->window_desc, f->display.x->normal_gc, | |
836 intborder, topregion * FONT_HEIGHT (f->display.x->font) + intborder, | |
837 f->width * FONT_WIDTH (f->display.x->font), | |
838 length * FONT_HEIGHT (f->display.x->font), intborder, | |
839 newtop * FONT_HEIGHT (f->display.x->font) + intborder); | |
286 | 840 #else |
771 | 841 XMoveArea (f->display.x->window_desc, |
842 intborder, topregion * FONT_HEIGHT (f->display.x->font) + intborder, | |
843 intborder, newtop * FONT_HEIGHT (f->display.x->font) + intborder, | |
844 f->width * FONT_WIDTH (f->display.x->font), | |
845 length * FONT_HEIGHT (f->display.x->font)); | |
286 | 846 /* Now we must process any ExposeRegion events that occur |
847 if the area being copied from is obscured. | |
848 We can't let it wait because further i/d operations | |
849 may want to copy this area to another area. */ | |
850 x_read_exposes (); | |
851 #endif /* HAVE_X11 */ | |
852 } | |
853 | |
854 newtop = min (newtop, (flexlines - 1)); | |
855 length = newtop - topregion; | |
856 if (length > 0) | |
857 { | |
858 #ifdef HAVE_X11 | |
771 | 859 XClearArea (x_current_display, f->display.x->window_desc, intborder, |
860 topregion * FONT_HEIGHT (f->display.x->font) + intborder, | |
861 f->width * FONT_WIDTH (f->display.x->font), | |
862 n * FONT_HEIGHT (f->display.x->font), False); | |
286 | 863 #else |
771 | 864 XPixSet (f->display.x->window_desc, |
286 | 865 intborder, |
771 | 866 topregion * FONT_HEIGHT (f->display.x->font) + intborder, |
867 f->width * FONT_WIDTH (f->display.x->font), | |
868 n * FONT_HEIGHT (f->display.x->font), | |
869 f->display.x->background_pixel); | |
286 | 870 #endif /* HAVE_X11 */ |
871 } | |
872 } | |
873 | |
874 /* Perform a delete-lines operation, deleting N lines | |
875 at a vertical position curs_y. */ | |
876 | |
877 static void | |
878 scraplines (n) | |
879 register int n; | |
880 { | |
881 int mask; | |
771 | 882 register struct frame *f = updating_frame; |
883 int intborder = f->display.x->internal_border_width; | |
286 | 884 |
885 if (curs_y >= flexlines) | |
886 return; | |
887 | |
888 #ifndef HAVE_X11 | |
889 dumpqueue (); | |
890 #endif | |
891 | |
892 if ((curs_y + n) >= flexlines) | |
893 { | |
894 if (flexlines >= (curs_y + 1)) | |
895 { | |
896 #ifdef HAVE_X11 | |
771 | 897 XClearArea (x_current_display, f->display.x->window_desc, intborder, |
898 curs_y * FONT_HEIGHT (f->display.x->font) + intborder, | |
899 f->width * FONT_WIDTH (f->display.x->font), | |
900 (flexlines - curs_y) * FONT_HEIGHT (f->display.x->font), False); | |
286 | 901 #else |
771 | 902 XPixSet (f->display.x->window_desc, |
903 intborder, curs_y * FONT_HEIGHT (f->display.x->font) + intborder, | |
904 f->width * FONT_WIDTH (f->display.x->font), | |
905 (flexlines - curs_y) * FONT_HEIGHT (f->display.x->font), | |
906 f->display.x->background_pixel); | |
286 | 907 #endif /* HAVE_X11 */ |
908 } | |
909 } | |
910 else | |
911 { | |
912 #ifdef HAVE_X11 | |
771 | 913 XCopyArea (x_current_display, f->display.x->window_desc, |
914 f->display.x->window_desc, f->display.x->normal_gc, | |
286 | 915 intborder, |
771 | 916 (curs_y + n) * FONT_HEIGHT (f->display.x->font) + intborder, |
917 f->width * FONT_WIDTH (f->display.x->font), | |
918 (flexlines - (curs_y + n)) * FONT_HEIGHT (f->display.x->font), | |
919 intborder, curs_y * FONT_HEIGHT (f->display.x->font) + intborder); | |
920 XClearArea (x_current_display, f->display.x->window_desc, | |
286 | 921 intborder, |
771 | 922 (flexlines - n) * FONT_HEIGHT (f->display.x->font) + intborder, |
923 f->width * FONT_WIDTH (f->display.x->font), | |
924 n * FONT_HEIGHT (f->display.x->font), False); | |
286 | 925 #else |
771 | 926 XMoveArea (f->display.x->window_desc, |
286 | 927 intborder, |
771 | 928 (curs_y + n) * FONT_HEIGHT (f->display.x->font) + intborder, |
929 intborder, curs_y * FONT_HEIGHT (f->display.x->font) + intborder, | |
930 f->width * FONT_WIDTH (f->display.x->font), | |
931 (flexlines - (curs_y + n)) * FONT_HEIGHT (f->display.x->font)); | |
286 | 932 /* Now we must process any ExposeRegion events that occur |
933 if the area being copied from is obscured. | |
934 We can't let it wait because further i/d operations | |
935 may want to copy this area to another area. */ | |
936 x_read_exposes (); | |
771 | 937 XPixSet (f->display.x->window_desc, intborder, |
938 (flexlines - n) * FONT_HEIGHT (f->display.x->font) + intborder, | |
939 f->width * FONT_WIDTH (f->display.x->font), | |
940 n * FONT_HEIGHT (f->display.x->font), f->display.x->background_pixel); | |
286 | 941 #endif /* HAVE_X11 */ |
942 } | |
943 } | |
944 | |
945 /* Perform an insert-lines or delete-lines operation, | |
946 inserting N lines or deleting -N lines at vertical position VPOS. */ | |
947 | |
948 XTins_del_lines (vpos, n) | |
949 int vpos, n; | |
950 { | |
771 | 951 if (updating_frame == 0) |
286 | 952 abort (); |
953 | |
429 | 954 /* Hide the cursor. */ |
771 | 955 x_display_cursor (updating_frame, 0); |
286 | 956 |
957 XTcursor_to (vpos, 0); | |
958 | |
959 BLOCK_INPUT; | |
960 if (n >= 0) | |
961 stufflines (n); | |
962 else | |
963 scraplines (-n); | |
964 XFlushQueue (); | |
965 UNBLOCK_INPUT; | |
966 } | |
967 | |
968 static void clear_cursor (); | |
969 | |
771 | 970 /* Output into a rectangle of an X-window (for frame F) |
971 the characters in f->phys_lines that overlap that rectangle. | |
286 | 972 TOP and LEFT are the position of the upper left corner of the rectangle. |
973 ROWS and COLS are the size of the rectangle. */ | |
974 | |
975 static void | |
771 | 976 dumprectangle (f, left, top, cols, rows) |
977 struct frame *f; | |
286 | 978 register int left, top, cols, rows; |
979 { | |
771 | 980 register struct frame_glyphs *active_frame = FRAME_CURRENT_GLYPHS (f); |
286 | 981 int cursor_cleared = 0; |
982 int bottom, right; | |
983 register int y; | |
984 | |
771 | 985 if (FRAME_GARBAGED_P (f)) |
286 | 986 return; |
987 | |
771 | 988 top -= f->display.x->internal_border_width; |
989 left -= f->display.x->internal_border_width; | |
286 | 990 |
991 /* Express rectangle as four edges, instead of position-and-size. */ | |
992 bottom = top + rows; | |
993 right = left + cols; | |
994 | |
995 #ifndef HAVE_X11 /* Window manger does this for X11. */ | |
996 /* If the rectangle includes any of the internal border area, | |
997 redisplay the border emphasis. */ | |
998 if (top < 0 || left < 0 | |
771 | 999 || bottom > f->height * FONT_HEIGHT (f->display.x->font) |
1000 || right > f->width * FONT_WIDTH (f->display.x->font)) | |
1001 dumpborder (f, 0); | |
286 | 1002 #endif /* HAVE_X11 */ |
1003 | |
1004 /* Convert rectangle edges in pixels to edges in chars. | |
1005 Round down for left and top, up for right and bottom. */ | |
771 | 1006 top /= FONT_HEIGHT (f->display.x->font); |
1007 left /= FONT_WIDTH (f->display.x->font); | |
1008 bottom += (FONT_HEIGHT (f->display.x->font) - 1); | |
1009 right += (FONT_WIDTH (f->display.x->font) - 1); | |
1010 bottom /= FONT_HEIGHT (f->display.x->font); | |
1011 right /= FONT_WIDTH (f->display.x->font); | |
286 | 1012 |
1013 /* Clip the rectangle to what can be visible. */ | |
1014 if (left < 0) | |
1015 left = 0; | |
1016 if (top < 0) | |
1017 top = 0; | |
771 | 1018 if (right > f->width) |
1019 right = f->width; | |
1020 if (bottom > f->height) | |
1021 bottom = f->height; | |
286 | 1022 |
1023 /* Get size in chars of the rectangle. */ | |
1024 cols = right - left; | |
1025 rows = bottom - top; | |
1026 | |
1027 /* If rectangle has zero area, return. */ | |
1028 if (rows <= 0) return; | |
1029 if (cols <= 0) return; | |
1030 | |
1031 /* Turn off the cursor if it is in the rectangle. | |
1032 We will turn it back on afterward. */ | |
771 | 1033 if ((f->phys_cursor_x >= left) && (f->phys_cursor_x < right) |
1034 && (f->phys_cursor_y >= top) && (f->phys_cursor_y < bottom)) | |
286 | 1035 { |
771 | 1036 clear_cursor (f); |
286 | 1037 cursor_cleared = 1; |
1038 } | |
1039 | |
1040 /* Display the text in the rectangle, one text line at a time. */ | |
1041 | |
1042 for (y = top; y < bottom; y++) | |
1043 { | |
771 | 1044 GLYPH *line = &active_frame->glyphs[y][left]; |
1045 | |
1046 if (! active_frame->enable[y] || left > active_frame->used[y]) | |
286 | 1047 continue; |
1048 | |
771 | 1049 dumpglyphs (f, |
1050 (left * FONT_WIDTH (f->display.x->font) | |
1051 + f->display.x->internal_border_width), | |
1052 (y * FONT_HEIGHT (f->display.x->font) | |
1053 + f->display.x->internal_border_width), | |
1054 line, min (cols, active_frame->used[y] - left), | |
1055 active_frame->highlight[y], f->display.x->font); | |
286 | 1056 } |
1057 | |
1058 /* Turn the cursor on if we turned it off. */ | |
1059 | |
1060 if (cursor_cleared) | |
771 | 1061 x_display_cursor (f, 1); |
286 | 1062 } |
1063 | |
1064 #ifndef HAVE_X11 | |
1065 /* Process all queued ExposeRegion events. */ | |
1066 | |
1067 static void | |
1068 dumpqueue () | |
1069 { | |
1070 register int i; | |
1071 XExposeRegionEvent r; | |
1072 | |
1073 while (dequeue_event (&r, &x_expose_queue)) | |
1074 { | |
771 | 1075 struct frame *f = x_window_to_frame (r.window); |
1076 if (f->display.x->icon_desc == r.window) | |
1077 refreshicon (f); | |
286 | 1078 else |
771 | 1079 dumprectangle (f, r.x, r.y, r.width, r.height); |
286 | 1080 } |
1081 XFlushQueue (); | |
1082 } | |
1083 #endif | |
1084 | |
1085 /* Process all expose events that are pending. | |
771 | 1086 Redraws the cursor if necessary on any frame that |
1087 is not in the process of being updated with update_frame. */ | |
286 | 1088 |
1089 static void | |
1090 x_do_pending_expose () | |
1091 { | |
1092 int mask; | |
771 | 1093 struct frame *f; |
1094 Lisp_Object tail, frame; | |
286 | 1095 |
1096 if (expose_all_windows) | |
1097 { | |
1098 expose_all_windows = 0; | |
771 | 1099 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) |
286 | 1100 { |
1101 register int temp_width, temp_height; | |
1102 int intborder; | |
1103 | |
771 | 1104 frame = XCONS (tail)->car; |
1105 if (XTYPE (frame) != Lisp_Frame) | |
286 | 1106 continue; |
771 | 1107 f = XFRAME (frame); |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
1108 if (! FRAME_X_P (f)) |
286 | 1109 continue; |
771 | 1110 if (!f->visible) |
286 | 1111 continue; |
771 | 1112 if (!f->display.x->needs_exposure) |
286 | 1113 continue; |
1114 | |
771 | 1115 intborder = f->display.x->internal_border_width; |
1116 | |
1117 clear_cursor (f); | |
1118 XGetWindowInfo (f->display.x->window_desc, &windowinfo); | |
286 | 1119 temp_width = ((windowinfo.width - 2 * intborder |
771 | 1120 - f->display.x->v_scrollbar_width) |
1121 / FONT_WIDTH (f->display.x->font)); | |
286 | 1122 temp_height = ((windowinfo.height- 2 * intborder |
771 | 1123 - f->display.x->h_scrollbar_height) |
1124 / FONT_HEIGHT (f->display.x->font)); | |
1125 if (temp_width != f->width || temp_height != f->height) | |
286 | 1126 { |
771 | 1127 change_frame_size (f, max (1, temp_height), |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
1128 max (1, temp_width), 0, 1); |
771 | 1129 x_resize_scrollbars (f); |
286 | 1130 } |
771 | 1131 f->display.x->left_pos = windowinfo.x; |
1132 f->display.x->top_pos = windowinfo.y; | |
1133 dumprectangle (f, 0, 0, PIXEL_WIDTH (f), PIXEL_HEIGHT (f)); | |
286 | 1134 #if 0 |
771 | 1135 dumpborder (f, 0); |
286 | 1136 #endif |
771 | 1137 f->display.x->needs_exposure = 0; |
1138 if (updating_frame != f) | |
1139 x_display_cursor (f, 1); | |
286 | 1140 XFlushQueue (); |
1141 } | |
1142 } | |
1143 else | |
1144 /* Handle any individual-rectangle expose events queued | |
1145 for various windows. */ | |
1146 #ifdef HAVE_X11 | |
1147 ; | |
1148 #else | |
1149 dumpqueue (); | |
1150 #endif | |
1151 } | |
1152 | |
1153 #ifdef HAVE_X11 | |
1154 static void | |
771 | 1155 frame_highlight (frame) |
1156 struct frame *frame; | |
286 | 1157 { |
1158 if (! EQ (Vx_no_window_manager, Qnil)) | |
771 | 1159 XSetWindowBorder (x_current_display, frame->display.x->window_desc, |
1160 frame->display.x->border_pixel); | |
1161 x_display_cursor (frame, 1); | |
286 | 1162 } |
1163 | |
1164 static void | |
771 | 1165 frame_unhighlight (frame) |
1166 struct frame *frame; | |
286 | 1167 { |
1168 if (! EQ (Vx_no_window_manager, Qnil)) | |
771 | 1169 XSetWindowBorderPixmap (x_current_display, frame->display.x->window_desc, |
1170 frame->display.x->border_tile); | |
1171 x_display_cursor (frame, 1); | |
286 | 1172 } |
1173 #else /* X10 */ | |
771 | 1174 /* Dump the border-emphasis of frame F. |
1175 If F is selected, this is a lining of the same color as the border, | |
286 | 1176 just within the border, occupying a portion of the internal border. |
771 | 1177 If F is not selected, it is background in the same place. |
286 | 1178 If ALWAYS is 0, don't bother explicitly drawing if it's background. |
1179 | |
771 | 1180 ALWAYS = 1 is used when a frame becomes selected or deselected. |
286 | 1181 In that case, we also turn the cursor off and on again |
1182 so it will appear in the proper shape (solid if selected; else hollow.) */ | |
1183 | |
1184 static void | |
771 | 1185 dumpborder (f, always) |
1186 struct frame *f; | |
286 | 1187 int always; |
1188 { | |
771 | 1189 int thickness = f->display.x->internal_border_width / 2; |
1190 int width = PIXEL_WIDTH (f); | |
1191 int height = PIXEL_HEIGHT (f); | |
286 | 1192 int pixel; |
1193 | |
771 | 1194 if (f != selected_frame) |
286 | 1195 { |
1196 if (!always) | |
1197 return; | |
1198 | |
771 | 1199 pixel = f->display.x->background_pixel; |
286 | 1200 } |
1201 else | |
1202 { | |
771 | 1203 pixel = f->display.x->border_pixel; |
286 | 1204 } |
1205 | |
771 | 1206 XPixSet (f->display.x->window_desc, 0, 0, width, thickness, pixel); |
1207 XPixSet (f->display.x->window_desc, 0, 0, thickness, height, pixel); | |
1208 XPixSet (f->display.x->window_desc, 0, height - thickness, width, | |
286 | 1209 thickness, pixel); |
771 | 1210 XPixSet (f->display.x->window_desc, width - thickness, 0, thickness, |
286 | 1211 height, pixel); |
1212 | |
1213 if (always) | |
771 | 1214 x_display_cursor (f, 1); |
286 | 1215 } |
1216 #endif /* X10 */ | |
1217 | |
771 | 1218 static void XTframe_rehighlight (); |
1219 | |
1220 /* The focus has changed. Update the frames as necessary to reflect | |
1221 the new situation. Note that we can't change the selected frame | |
286 | 1222 here, because the lisp code we are interrupting might become confused. |
771 | 1223 Each event gets marked with the frame in which it occured, so the |
369 | 1224 lisp code can tell when the switch took place by examining the events. */ |
1225 | |
1226 static void | |
771 | 1227 x_new_focus_frame (frame) |
1228 struct frame *frame; | |
286 | 1229 { |
771 | 1230 struct frame *old_focus = x_focus_frame; |
286 | 1231 int events_enqueued = 0; |
1232 | |
771 | 1233 if (frame != x_focus_frame) |
286 | 1234 { |
369 | 1235 /* Set this before calling other routines, so that they see |
771 | 1236 the correct value of x_focus_frame. */ |
1237 x_focus_frame = frame; | |
369 | 1238 |
1239 if (old_focus && old_focus->auto_lower) | |
771 | 1240 x_lower_frame (old_focus); |
286 | 1241 |
1242 #if 0 | |
771 | 1243 selected_frame = frame; |
1244 XSET (XWINDOW (selected_frame->selected_window)->frame, | |
1245 Lisp_Frame, selected_frame); | |
1246 Fselect_window (selected_frame->selected_window); | |
1247 choose_minibuf_frame (); | |
286 | 1248 #endif |
1249 | |
771 | 1250 if (x_focus_frame && x_focus_frame->auto_raise) |
1251 x_raise_frame (x_focus_frame); | |
369 | 1252 } |
1253 | |
771 | 1254 XTframe_rehighlight (); |
369 | 1255 } |
1256 | |
1257 | |
771 | 1258 /* The focus has changed, or we have make a frame's selected window |
1259 point to a window on a different frame (this happens with global | |
1260 minibuffer frames). Shift the highlight as appropriate. */ | |
369 | 1261 static void |
771 | 1262 XTframe_rehighlight () |
369 | 1263 { |
771 | 1264 struct frame *old_highlight = x_highlight_frame; |
1265 | |
1266 if (x_focus_frame) | |
286 | 1267 { |
771 | 1268 x_highlight_frame = XFRAME (FRAME_FOCUS_FRAME (x_focus_frame)); |
1269 if (x_highlight_frame->display.nothing == 0) | |
1270 XSET (FRAME_FOCUS_FRAME (x_focus_frame), Lisp_Frame, | |
1271 (x_highlight_frame = x_focus_frame)); | |
286 | 1272 } |
369 | 1273 else |
771 | 1274 x_highlight_frame = 0; |
1275 | |
1276 if (x_highlight_frame != old_highlight) | |
369 | 1277 { |
1278 if (old_highlight) | |
771 | 1279 frame_unhighlight (old_highlight); |
1280 if (x_highlight_frame) | |
1281 frame_highlight (x_highlight_frame); | |
369 | 1282 } |
286 | 1283 } |
1284 | |
1285 enum window_type | |
1286 { | |
1287 no_window, | |
1288 scrollbar_window, | |
1289 text_window, | |
1290 }; | |
1291 | |
1292 /* Position of the mouse in characters */ | |
1293 unsigned int x_mouse_x, x_mouse_y; | |
1294 | |
1295 /* Offset in buffer of character under the pointer, or 0. */ | |
1296 extern int mouse_buffer_offset; | |
1297 | |
1298 extern int buffer_posn_from_coords (); | |
1299 | |
1300 /* Symbols from xfns.c to denote the different parts of a window. */ | |
1301 extern Lisp_Object Qmodeline_part, Qtext_part; | |
1302 | |
1303 #if 0 | |
1304 /* Set *RESULT to an emacs input_event corresponding to MOTION_EVENT. | |
771 | 1305 F is the frame in which the event occurred. |
286 | 1306 |
1307 WINDOW_TYPE says whether the event happened in a scrollbar window | |
1308 or a text window, affecting the format of the event created. | |
1309 | |
1310 PART specifies which part of the scrollbar the event happened in, | |
1311 if WINDOW_TYPE == scrollbar_window. | |
1312 | |
1313 If the mouse is over the same character as the last time we checked, | |
1314 don't return an event; set result->kind to no_event. */ | |
1315 | |
1316 static void | |
771 | 1317 notice_mouse_movement (result, motion_event, f, window_type, part) |
286 | 1318 struct input_event *result; |
1319 XMotionEvent motion_event; | |
771 | 1320 struct frame *f; |
286 | 1321 int window_type; |
1322 Lisp_Object part; | |
1323 { | |
1324 int x, y, root_x, root_y, pix_x, pix_y; | |
1325 unsigned int keys_and_buttons; | |
1326 Window w, root_window; | |
1327 | |
1328 /* Unless we decide otherwise below, return a non-event. */ | |
1329 result->kind = no_event; | |
1330 | |
1331 if (XQueryPointer (x_current_display, | |
771 | 1332 f->display.x->window_desc, |
286 | 1333 &root_window, &w, |
1334 &root_x, &root_y, &pix_x, &pix_y, | |
1335 &keys_and_buttons) | |
1336 == False) | |
1337 return; | |
1338 | |
1339 #if 0 | |
1340 if (w == None) /* Mouse no longer in window. */ | |
1341 return Qnil; | |
1342 #endif | |
1343 | |
771 | 1344 pixel_to_glyph_translation (f, pix_x, pix_y, &x, &y); |
286 | 1345 if (x == x_mouse_x && y == x_mouse_y) |
1346 return; | |
1347 | |
1348 x_mouse_x = x; | |
1349 x_mouse_y = y; | |
1350 | |
1351 /* What sort of window are we in now? */ | |
1352 if (window_type == text_window) /* Text part */ | |
1353 { | |
1354 int modeline_p; | |
1355 | |
771 | 1356 Vmouse_window = window_from_coordinates (f, x, y, &modeline_p); |
286 | 1357 |
1358 if (XTYPE (Vmouse_window) == Lisp_Window) | |
1359 mouse_buffer_offset | |
1360 = buffer_posn_from_coords (XWINDOW (Vmouse_window), x, y); | |
1361 else | |
1362 mouse_buffer_offset = 0; | |
1363 | |
1364 if (EQ (Vmouse_window, Qnil)) | |
771 | 1365 Vmouse_frame_part = Qnil; |
286 | 1366 else if (modeline_p) |
771 | 1367 Vmouse_frame_part = Qmodeline_part; |
286 | 1368 else |
771 | 1369 Vmouse_frame_part = Qtext_part; |
286 | 1370 |
1371 result->kind = window_sys_event; | |
1372 result->code = Qmouse_moved; | |
1373 | |
1374 return; | |
1375 } | |
1376 else if (window_type == scrollbar_window) /* Scrollbar */ | |
1377 { | |
771 | 1378 Vmouse_window = f->selected_window; |
286 | 1379 mouse_buffer_offset = 0; |
771 | 1380 Vmouse_frame_part = part; |
286 | 1381 |
1382 result->kind = window_sys_event; | |
1383 result->code = Qmouse_moved; | |
1384 | |
1385 return; | |
1386 } | |
1387 | |
1388 return; | |
1389 } | |
1390 #endif | |
1391 | |
429 | 1392 |
1393 /* Mouse clicks and mouse movement. Rah. */ | |
1394 #ifdef HAVE_X11 | |
1395 | |
771 | 1396 /* Given a pixel position (PIX_X, PIX_Y) on the frame F, return |
429 | 1397 glyph co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle |
1398 that the glyph at X, Y occupies, if BOUNDS != 0. */ | |
1399 static void | |
771 | 1400 pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds) |
1401 FRAME_PTR f; | |
286 | 1402 register unsigned int pix_x, pix_y; |
1403 register int *x, *y; | |
429 | 1404 XRectangle *bounds; |
286 | 1405 { |
771 | 1406 int ibw = f->display.x->internal_border_width; |
429 | 1407 int width, height; |
771 | 1408 FONT_TYPE *font = f->display.x->font; |
429 | 1409 |
1410 width = FONT_WIDTH (font); | |
1411 height = FONT_HEIGHT (font); | |
286 | 1412 |
1413 /* What line is it on? */ | |
429 | 1414 if (pix_y < ibw) |
1415 *y = 0; | |
771 | 1416 else if (pix_y > f->display.x->pixel_height - ibw) |
1417 *y = FRAME_HEIGHT (f) - 1; | |
429 | 1418 else |
1419 *y = (pix_y - ibw) / height; | |
1420 | |
1421 /* And what column? */ | |
286 | 1422 if (pix_x < ibw) |
1423 *x = 0; | |
771 | 1424 else if (pix_x > f->display.x->pixel_width - ibw) |
1425 *x = FRAME_WIDTH (f) - 1; | |
286 | 1426 else |
429 | 1427 *x = (pix_x - ibw) / width; |
1428 | |
1429 if (bounds) | |
1430 { | |
1431 bounds->width = width; | |
1432 bounds->height = height; | |
1433 bounds->x = ibw + (*x * width); | |
1434 bounds->y = ibw + (*y * height); | |
1435 } | |
286 | 1436 } |
1437 | |
1438 /* Any buttons grabbed. */ | |
1439 unsigned int x_mouse_grabbed; | |
1440 | |
1441 /* Convert a set of X modifier bits to the proper form for a | |
1442 struct input_event modifiers value. */ | |
1443 | |
1444 static Lisp_Object | |
1445 x_convert_modifiers (state) | |
1446 unsigned int state; | |
1447 { | |
1448 return ( ((state & (ShiftMask | LockMask)) ? shift_modifier : 0) | |
1449 | ((state & ControlMask) ? ctrl_modifier : 0) | |
1450 | ((state & Mod1Mask) ? meta_modifier : 0)); | |
1451 } | |
1452 | |
771 | 1453 extern struct frame *x_window_to_scrollbar (); |
286 | 1454 extern Lisp_Object Vmouse_event; |
1455 | |
1456 /* Prepare a mouse-event in *RESULT for placement in the input queue. | |
1457 | |
1458 If the event is a button press, then note that we have grabbed | |
1459 the mouse. | |
1460 | |
1461 If PART and PREFIX are 0, then the event occurred in the text part; | |
1462 otherwise it happened in a scrollbar. */ | |
1463 | |
1464 static Lisp_Object | |
771 | 1465 construct_mouse_click (result, event, f, part, prefix) |
286 | 1466 struct input_event *result; |
1467 XButtonEvent *event; | |
771 | 1468 struct frame *f; |
286 | 1469 int prefix; |
1470 Lisp_Object part; | |
1471 { | |
1472 /* Initialize those fields text and scrollbar clicks hold in common. | |
1473 Make the event type no_event; we'll change that when we decide | |
1474 otherwise. */ | |
1475 result->kind = no_event; | |
1476 XSET (result->code, Lisp_Int, event->button); | |
708 | 1477 result->timestamp = event->time; |
286 | 1478 result->modifiers = (x_convert_modifiers (event->state) |
1479 | (event->type == ButtonRelease ? up_modifier : 0)); | |
1480 | |
1481 /* Notice if the mouse is still grabbed. */ | |
1482 if (event->type == ButtonPress) | |
1483 { | |
1484 if (! x_mouse_grabbed) | |
1485 Vmouse_depressed = Qt; | |
429 | 1486 x_mouse_grabbed |= (1 << event->button); |
286 | 1487 } |
1488 else if (event->type == ButtonRelease) | |
1489 { | |
429 | 1490 x_mouse_grabbed &= ~(1 << event->button); |
286 | 1491 if (!x_mouse_grabbed) |
1492 Vmouse_depressed = Qnil; | |
1493 } | |
1494 | |
1495 if (part) /* Scrollbar event */ | |
1496 { | |
1497 int pos, len; | |
1498 | |
771 | 1499 pos = event->y - (f->display.x->v_scrollbar_width - 2); |
286 | 1500 XSET (x_mouse_x, Lisp_Int, pos); |
771 | 1501 len = ((FONT_HEIGHT (f->display.x->font) * f->height) |
1502 + f->display.x->internal_border_width | |
1503 - (2 * (f->display.x->v_scrollbar_width - 2))); | |
286 | 1504 XSET (x_mouse_y, Lisp_Int, len); |
1505 | |
1506 result->kind = scrollbar_click; | |
1507 result->part = part; | |
771 | 1508 XSET (result->x, Lisp_Int, (f->display.x->top_pos - event->y)); |
1509 XSET (result->y, Lisp_Int, f->display.x->pixel_height); | |
1510 result->frame = f; | |
286 | 1511 } |
1512 else /* Text Window Event */ | |
1513 { | |
1514 int row, column; | |
1515 | |
771 | 1516 pixel_to_glyph_coords (f, event->x, event->y, &column, &row, NULL); |
286 | 1517 result->kind = mouse_click; |
1518 result->x = column; | |
1519 result->y = row; | |
771 | 1520 result->frame = f; |
286 | 1521 } |
1522 } | |
1523 | |
1524 | |
429 | 1525 /* Mouse movement. Rah. |
1526 | |
1527 In order to avoid asking for motion events and then throwing most | |
1528 of them away or busy-polling the server for mouse positions, we ask | |
1529 the server for pointer motion hints. This means that we get only | |
1530 one event per group of mouse movements. "Groups" are delimited by | |
1531 other kinds of events (focus changes and button clicks, for | |
1532 example), or by XQueryPointer calls; when one of these happens, we | |
1533 get another MotionNotify event the next time the mouse moves. This | |
732 | 1534 is at least as efficient as getting motion events when mouse |
429 | 1535 tracking is on, and I suspect only negligibly worse when tracking |
1536 is off. | |
1537 | |
1538 The silly O'Reilly & Associates Nutshell guides barely document | |
1539 pointer motion hints at all (I think you have to infer how they | |
1540 work from an example), and the description of XQueryPointer doesn't | |
1541 mention that calling it causes you to get another motion hint from | |
1542 the server, which is very important. */ | |
1543 | |
1544 /* Where the mouse was last time we reported a mouse event. */ | |
771 | 1545 static FRAME_PTR last_mouse_frame; |
429 | 1546 static XRectangle last_mouse_glyph; |
1547 | |
732 | 1548 /* This is a hack. We would really prefer that XTmouse_position would |
1549 return the time associated with the position it returns, but there | |
1550 doesn't seem to be any way to wrest the timestamp from the server | |
1551 along with the position query. So, we just keep track of the time | |
1552 of the last movement we received, and return that in hopes that | |
1553 it's somewhat accurate. */ | |
1554 static Time last_mouse_movement_time; | |
1555 | |
429 | 1556 /* Function to report a mouse movement to the mainstream Emacs code. |
1557 The input handler calls this. | |
1558 | |
1559 We have received a mouse movement event, which is given in *event. | |
1560 If the mouse is over a different glyph than it was last time, tell | |
1561 the mainstream emacs code by setting mouse_moved. If not, ask for | |
1562 another motion event, so we can check again the next time it moves. */ | |
1563 static void | |
771 | 1564 note_mouse_position (frame, event) |
1565 FRAME_PTR frame; | |
429 | 1566 XMotionEvent *event; |
1567 | |
1568 { | |
732 | 1569 last_mouse_movement_time = event->time; |
1570 | |
429 | 1571 /* Has the mouse moved off the glyph it was on at the last sighting? */ |
1572 if (event->x < last_mouse_glyph.x | |
1573 || event->x >= last_mouse_glyph.x + last_mouse_glyph.width | |
1574 || event->y < last_mouse_glyph.y | |
1575 || event->y >= last_mouse_glyph.y + last_mouse_glyph.height) | |
1576 mouse_moved = 1; | |
1577 else | |
1578 { | |
1579 /* It's on the same glyph. Call XQueryPointer so we'll get an | |
1580 event the next time the mouse moves and we can see if it's | |
1581 *still* on the same glyph. */ | |
1582 int dummy; | |
1583 | |
1584 XQueryPointer (event->display, event->window, | |
1585 (Window *) &dummy, (Window *) &dummy, | |
1586 &dummy, &dummy, &dummy, &dummy, | |
1587 (unsigned int *) &dummy); | |
1588 } | |
1589 } | |
1590 | |
1591 /* Return the current position of the mouse. | |
1592 | |
1593 This clears the mouse_moved flag, so we can wait for the next mouse | |
1594 position. This also calls XQueryPointer, which will cause the | |
1595 server to give us another MotionNotify when the mouse moves again. | |
1596 */ | |
1597 | |
1598 static void | |
771 | 1599 XTmouse_position (f, x, y, time) |
1600 FRAME_PTR *f; | |
429 | 1601 Lisp_Object *x, *y; |
732 | 1602 unsigned long *time; |
429 | 1603 { |
1604 int ix, iy, dummy; | |
1605 Display *d = x_current_display; | |
1606 Window guess, root, child; | |
1607 | |
1608 BLOCK_INPUT; | |
1609 | |
1610 /* I would like to have an X function that just told me the | |
1611 innermost window containing the mouse. | |
1612 | |
1613 /* There doesn't seem to be any way to just get the innermost window | |
771 | 1614 containing the pointer, no matter what X frame it's on; you have |
429 | 1615 to guess a window, and then X will tell you which one of that |
1616 window's children it's in. If the pointer isn't in any of that | |
1617 window's children, it gives you a root window that contains it. | |
1618 | |
771 | 1619 So we start with the selected frame's window and chase down |
429 | 1620 branches under the guidance of XQueryPointer until we hit a leaf |
1621 (all of the Emacs windows we care about are leaf windows). If at | |
1622 any time XQueryPointer returns false, that means that the current | |
1623 window does not contain the pointer any more (perhaps it moved), | |
1624 so we start with the root window XQueryPointer has given us and | |
1625 start again. */ | |
1626 | |
771 | 1627 guess = selected_frame->display.x->window_desc; |
429 | 1628 for (;;) |
1629 if (XQueryPointer (d, guess, &root, &child, | |
1630 &dummy, &dummy, &ix, &iy, (unsigned int *) &dummy)) | |
1631 { | |
1632 if (child == None) | |
1633 /* Guess is a leaf window, and it contains the pointer. */ | |
1634 break; | |
1635 else | |
1636 guess = child; | |
1637 } | |
1638 else | |
1639 /* When XQueryPointer returns False, the pointer isn't in guess | |
771 | 1640 anymore, but root is the root window of the frame we should |
429 | 1641 try instead. */ |
1642 guess = root; | |
1643 | |
771 | 1644 *f = last_mouse_frame = x_window_to_frame (guess); |
1645 if (! *f) | |
429 | 1646 *x = *y = Qnil; |
1647 else | |
1648 { | |
771 | 1649 pixel_to_glyph_coords (*f, ix, iy, &ix, &iy, &last_mouse_glyph); |
429 | 1650 XSET (*x, Lisp_Int, ix); |
1651 XSET (*y, Lisp_Int, iy); | |
1652 } | |
1653 | |
1654 mouse_moved = 0; | |
1655 | |
1656 /* I don't know how to find the time for the last movement; it seems | |
732 | 1657 like XQueryPointer ought to return it, but it doesn't. So, we'll |
1658 return the time of the last MotionNotify event we received. Note | |
1659 that the use of motion hints means that this isn't guaranteed to | |
1660 be accurate at all. */ | |
1661 *time = last_mouse_movement_time; | |
429 | 1662 |
1663 UNBLOCK_INPUT; | |
1664 } | |
1665 | |
1666 | |
286 | 1667 static char *events[] = |
1668 { | |
1669 "0: ERROR!", | |
1670 "1: REPLY", | |
1671 "KeyPress", | |
395 | 1672 "KeyRelease", |
1673 "ButtonPress", | |
1674 "ButtonRelease", | |
1675 "MotionNotify", | |
1676 "EnterNotify", | |
1677 "LeaveNotify", | |
1678 "FocusIn", | |
1679 "FocusOut", | |
1680 "KeymapNotify", | |
1681 "Expose", | |
1682 "GraphicsExpose", | |
1683 "NoExpose", | |
1684 "VisibilityNotify", | |
1685 "CreateNotify", | |
1686 "DestroyNotify", | |
1687 "UnmapNotify", | |
1688 "MapNotify", | |
1689 "MapRequest", | |
1690 "ReparentNotify", | |
1691 "ConfigureNotify", | |
1692 "ConfigureRequest", | |
1693 "GravityNotify", | |
1694 "ResizeRequest", | |
1695 "CirculateNotify", | |
1696 "CirculateRequest", | |
1697 "PropertyNotify", | |
1698 "SelectionClear", | |
1699 "SelectionRequest", | |
1700 "SelectionNotify", | |
1701 "ColormapNotify", | |
1702 "ClientMessage", | |
1703 "MappingNotify", | |
1704 "LASTEvent" | |
286 | 1705 }; |
1706 #else /* X10 */ | |
1707 #define XEvent XKeyPressedEvent | |
1708 #endif /* HAVE_X11 */ | |
1709 | |
1710 /* Timestamp of enter window event. This is only used by XTread_socket, | |
1711 but we have to put it out here, since static variables within functions | |
1712 sometimes don't work. */ | |
1713 static Time enter_timestamp; | |
1714 | |
642 | 1715 /* Communication with window managers. */ |
1716 Atom Xatom_wm_protocols; | |
1717 | |
1718 /* Kinds of protocol things we may receive. */ | |
1719 Atom Xatom_wm_take_focus; | |
1720 Atom Xatom_wm_save_yourself; | |
1721 Atom Xatom_wm_delete_window; | |
1722 | |
1723 /* Other WM communication */ | |
1724 Atom Xatom_wm_configure_denied; /* When our config request is denied */ | |
1725 Atom Xatom_wm_window_moved; /* When the WM moves us. */ | |
1726 | |
286 | 1727 /* Read events coming from the X server. |
1728 This routine is called by the SIGIO handler. | |
1729 We return as soon as there are no more events to be read. | |
1730 | |
1731 Events representing keys are stored in buffer BUFP, | |
1732 which can hold up to NUMCHARS characters. | |
1733 We return the number of characters stored into the buffer, | |
1734 thus pretending to be `read'. | |
1735 | |
1736 WAITP is nonzero if we should block until input arrives. | |
1737 EXPECTED is nonzero if the caller knows input is available. */ | |
1738 | |
1739 Lisp_Object | |
1740 XTread_socket (sd, bufp, numchars, waitp, expected) | |
1741 register int sd; | |
1742 register struct input_event *bufp; | |
1743 register int numchars; | |
1744 int waitp; | |
1745 int expected; | |
1746 { | |
1747 int count = 0; | |
1748 int nbytes = 0; | |
1749 int mask; | |
1750 int items_pending; /* How many items are in the X queue. */ | |
1751 XEvent event; | |
771 | 1752 struct frame *f; |
286 | 1753 int event_found; |
1754 int prefix; | |
1755 Lisp_Object part; | |
1756 | |
1757 if (x_input_blocked) | |
1758 { | |
1759 x_pending_input = 1; | |
1760 return -1; | |
1761 } | |
1762 | |
1763 x_pending_input = 0; | |
1764 BLOCK_INPUT; | |
1765 | |
1766 if (numchars <= 0) | |
1767 abort (); /* Don't think this happens. */ | |
1768 | |
1769 #ifdef FIOSNBIO | |
1770 /* If available, Xlib uses FIOSNBIO to make the socket | |
1771 non-blocking, and then looks for EWOULDBLOCK. If O_NDELAY is set, | |
1772 FIOSNBIO is ignored, and instead of signalling EWOULDBLOCK, | |
1773 a read returns 0, which Xlib interprets as equivalent to EPIPE. */ | |
1774 fcntl (fileno (stdin), F_SETFL, 0); | |
1775 #endif | |
1776 | |
1777 #ifndef SIGIO | |
1778 #ifndef HAVE_SELECT | |
1779 if (! (fcntl (fileno (stdin), F_GETFL, 0) & O_NDELAY)) | |
1780 { | |
1781 extern int read_alarm_should_throw; | |
1782 read_alarm_should_throw = 1; | |
1783 XPeekEvent (XDISPLAY &event); | |
1784 read_alarm_should_throw = 0; | |
1785 } | |
1786 #endif | |
1787 #endif | |
1788 | |
1789 while (XStuffPending () != 0) | |
1790 { | |
1791 XNextEvent (XDISPLAY &event); | |
1792 event_found = 1; | |
1793 | |
1794 switch (event.type) | |
1795 { | |
1796 #ifdef HAVE_X11 | |
642 | 1797 case ClientMessage: |
1798 { | |
1799 if (event.xclient.message_type == Xatom_wm_protocols | |
1800 && event.xclient.format == 32) | |
1801 { | |
1802 if (event.xclient.data.l[0] == Xatom_wm_take_focus) | |
1803 { | |
771 | 1804 f = x_window_to_frame (event.xclient.window); |
1805 if (f) | |
1806 x_focus_on_frame (f); | |
642 | 1807 /* Not certain about handling scrollbars here */ |
1808 } | |
1809 else if (event.xclient.data.l[0] == Xatom_wm_save_yourself) | |
1810 { | |
1811 /* Save state modify the WM_COMMAND property to | |
1812 something which can reinstate us. This notifies | |
1813 the session manager, who's looking for such a | |
1814 PropertyNotify. Can restart processing when | |
1815 a keyboard or mouse event arrives. */ | |
1816 if (numchars > 0) | |
1817 { | |
1818 } | |
1819 } | |
1820 else if (event.xclient.data.l[0] == Xatom_wm_delete_window) | |
1821 { | |
771 | 1822 struct frame *f = x_window_to_frame (event.xclient.window); |
1823 | |
1824 if (f) | |
642 | 1825 if (numchars > 0) |
1826 { | |
1827 } | |
1828 } | |
1829 } | |
1830 else if (event.xclient.message_type == Xatom_wm_configure_denied) | |
1831 { | |
1832 } | |
1833 else if (event.xclient.message_type == Xatom_wm_window_moved) | |
1834 { | |
1835 int new_x, new_y; | |
1836 | |
786 | 1837 new_x = event.xclient.data.s[0]; |
1838 new_y = event.xclient.data.s[1]; | |
642 | 1839 } |
1840 } | |
1841 break; | |
286 | 1842 |
1843 case SelectionClear: /* Someone has grabbed ownership. */ | |
1844 x_disown_selection (event.xselectionclear.window, | |
1845 event.xselectionclear.selection, | |
1846 event.xselectionclear.time); | |
1847 break; | |
1848 | |
1849 case SelectionRequest: /* Someone wants our selection. */ | |
1850 x_answer_selection_request (event); | |
1851 break; | |
1852 | |
1853 case PropertyNotify: | |
1854 /* If we were to do this synchronously, there'd be no worry | |
1855 about re-selecting. */ | |
1856 x_send_incremental (event); | |
1857 break; | |
1858 | |
1859 case Expose: | |
771 | 1860 f = x_window_to_frame (event.xexpose.window); |
1861 if (f) | |
286 | 1862 { |
771 | 1863 if (f->visible == 0) |
286 | 1864 { |
771 | 1865 f->visible = 1; |
1866 f->iconified = 0; | |
1867 SET_FRAME_GARBAGED (f); | |
286 | 1868 } |
1869 else | |
771 | 1870 dumprectangle (x_window_to_frame (event.xexpose.window), |
286 | 1871 event.xexpose.x, event.xexpose.y, |
1872 event.xexpose.width, event.xexpose.height); | |
1873 } | |
1874 break; | |
1875 | |
1876 case GraphicsExpose: /* This occurs when an XCopyArea's | |
1877 source area was obscured or not | |
1878 available.*/ | |
771 | 1879 dumprectangle (x_window_to_frame (event.xgraphicsexpose.drawable), |
286 | 1880 event.xgraphicsexpose.x, event.xgraphicsexpose.y, |
1881 event.xgraphicsexpose.width, | |
1882 event.xgraphicsexpose.height); | |
1883 break; | |
1884 | |
1885 case NoExpose: /* This occurs when an XCopyArea's | |
1886 source area was completely | |
1887 available */ | |
1888 break; | |
1889 #else /* not HAVE_X11 */ | |
1890 case ExposeWindow: | |
1891 if (event.subwindow != 0) | |
1892 break; /* duplicate event */ | |
771 | 1893 f = x_window_to_frame (event.window); |
1894 if (event.window == f->display.x->icon_desc) | |
286 | 1895 { |
771 | 1896 refreshicon (f); |
1897 f->iconified = 1; | |
286 | 1898 } |
771 | 1899 if (event.window == f->display.x->window_desc) |
286 | 1900 { |
1901 /* Say must check all windows' needs_exposure flags. */ | |
1902 expose_all_windows = 1; | |
771 | 1903 f->display.x->needs_exposure = 1; |
1904 f->visible = 1; | |
286 | 1905 } |
1906 break; | |
1907 | |
1908 case ExposeRegion: | |
1909 if (event.subwindow != 0) | |
1910 break; /* duplicate event */ | |
771 | 1911 f = x_window_to_frame (event.window); |
1912 if (event.window == f->display.x->icon_desc) | |
286 | 1913 { |
771 | 1914 refreshicon (f); |
286 | 1915 break; |
1916 } | |
1917 /* If window already needs full redraw, ignore this rectangle. */ | |
771 | 1918 if (expose_all_windows && f->display.x->needs_exposure) |
286 | 1919 break; |
1920 /* Put the event on the queue of rectangles to redraw. */ | |
1921 if (enqueue_event (&event, &x_expose_queue)) | |
1922 /* If it is full, we can't record the rectangle, | |
1923 so redraw this entire window. */ | |
1924 { | |
1925 /* Say must check all windows' needs_exposure flags. */ | |
1926 expose_all_windows = 1; | |
771 | 1927 f->display.x->needs_exposure = 1; |
286 | 1928 } |
1929 break; | |
1930 | |
1931 case ExposeCopy: | |
1932 /* This should happen only when we are expecting it, | |
1933 in x_read_exposes. */ | |
1934 abort (); | |
1935 #endif /* not HAVE_X11 */ | |
1936 | |
1937 #ifdef HAVE_X11 | |
1938 case UnmapNotify: | |
1939 { | |
1940 XWMHints *hints; | |
1941 | |
771 | 1942 f = x_window_to_frame (event.xunmap.window); |
1943 if (f) /* F may no longer exist if | |
1944 the frame was deleted. */ | |
286 | 1945 { |
771 | 1946 /* While a frame is unmapped, display generation is |
286 | 1947 disabled; you don't want to spend time updating a |
1948 display that won't ever be seen. */ | |
771 | 1949 f->visible = 0; |
286 | 1950 x_mouse_x = x_mouse_y = -1; |
1951 } | |
1952 } | |
1953 break; | |
1954 | |
1955 case MapNotify: | |
771 | 1956 f = x_window_to_frame (event.xmap.window); |
1957 if (f) | |
286 | 1958 { |
771 | 1959 f->visible = 1; |
1960 f->iconified = 0; | |
286 | 1961 |
1962 /* wait_reading_process_input will notice this and update | |
771 | 1963 the frame's display structures. */ |
1964 SET_FRAME_GARBAGED (f); | |
286 | 1965 } |
1966 break; | |
1967 | |
1968 /* Turn off processing if we become fully obscured. */ | |
1969 case VisibilityNotify: | |
1970 break; | |
1971 | |
1972 #else | |
1973 case UnmapWindow: | |
771 | 1974 f = x_window_to_frame (event.window); |
1975 if (event.window == f->display.x->icon_desc) | |
1976 f->iconified = 0; | |
1977 if (event.window == f->display.x->window_desc) | |
1978 f->visible = 0; | |
286 | 1979 break; |
1980 #endif /* HAVE_X11 */ | |
1981 | |
1982 #ifdef HAVE_X11 | |
1983 case KeyPress: | |
771 | 1984 f = x_window_to_frame (event.xkey.window); |
1985 if (f != 0) | |
286 | 1986 { |
1987 KeySym keysym; | |
1988 XComposeStatus status; | |
1989 char copy_buffer[80]; | |
555 | 1990 int modifiers = event.xkey.state; |
1991 | |
1992 /* Some keyboards generate different characters | |
1993 depending on the state of the meta key, in an attempt | |
1994 to support non-English typists. It would be nice to | |
1995 keep this functionality somehow, but for now, we will | |
1996 just clear the meta-key flag to get the 'pure' character. */ | |
1997 event.xkey.state &= ~Mod1Mask; | |
286 | 1998 |
1999 /* This will have to go some day... */ | |
2000 nbytes = XLookupString (&event.xkey, | |
2001 copy_buffer, | |
2002 80, | |
2003 &keysym, | |
2004 &status); | |
2005 | |
395 | 2006 /* Strip off the vendor-specific keysym bit, and take a shot |
2007 at recognizing the codes. HP servers have extra keysyms | |
2008 that fit into the MiscFunctionKey category. */ | |
2009 keysym &= ~(1<<28); | |
2010 | |
286 | 2011 if (numchars > 1) |
2012 { | |
395 | 2013 if (IsCursorKey (keysym) /* 0xff50 <= x < 0xff60 */ |
2014 || IsMiscFunctionKey (keysym) /* 0xff60 <= x < 0xff80 */ | |
2015 || IsKeypadKey (keysym) /* 0xff80 <= x < 0xffbe */ | |
2016 || IsFunctionKey (keysym)) /* 0xffbe <= x < 0xffe1 */ | |
286 | 2017 { |
2018 bufp->kind = non_ascii_keystroke; | |
429 | 2019 XSET (bufp->code, Lisp_Int, (unsigned) keysym - 0xff50); |
771 | 2020 bufp->frame = f; |
555 | 2021 bufp->modifiers = x_convert_modifiers (modifiers); |
708 | 2022 bufp->timestamp = event.xkey.time; |
286 | 2023 bufp++; |
2024 count++; | |
2025 numchars--; | |
2026 } | |
2027 else if (numchars > nbytes) | |
2028 { | |
2029 register int i; | |
2030 | |
2031 if (nbytes == 1) | |
2032 { | |
555 | 2033 if (modifiers & Mod1Mask) |
286 | 2034 *copy_buffer |= METABIT; |
2035 bufp->kind = ascii_keystroke; | |
708 | 2036 XSET (bufp->code, Lisp_Int, *copy_buffer); |
771 | 2037 bufp->frame = f; |
708 | 2038 bufp->timestamp = event.xkey.time; |
286 | 2039 bufp++; |
2040 } | |
2041 else | |
2042 for (i = nbytes - 1; i > 1; i--) | |
2043 { | |
2044 bufp->kind = ascii_keystroke; | |
2045 XSET (bufp->code, Lisp_Int, copy_buffer[i]); | |
771 | 2046 bufp->frame = f; |
708 | 2047 bufp->timestamp = event.xkey.time; |
286 | 2048 bufp++; |
2049 } | |
2050 | |
2051 count += nbytes; | |
2052 numchars -= nbytes; | |
2053 } | |
2054 } | |
2055 } | |
2056 break; | |
2057 #else | |
2058 case KeyPressed: | |
2059 { | |
2060 register char *where_mapping; | |
2061 | |
771 | 2062 f = x_window_to_frame (event.window); |
286 | 2063 /* Ignore keys typed on icon windows. */ |
771 | 2064 if (f != 0 && event.window == f->display.x->icon_desc) |
286 | 2065 break; |
2066 where_mapping = XLookupMapping (&event, &nbytes); | |
2067 /* Nasty fix for arrow keys */ | |
2068 if (!nbytes && IsCursorKey (event.detail & 0xff)) | |
2069 { | |
2070 switch (event.detail & 0xff) | |
2071 { | |
2072 case KC_CURSOR_LEFT: | |
2073 where_mapping = "\002"; | |
2074 break; | |
2075 case KC_CURSOR_RIGHT: | |
2076 where_mapping = "\006"; | |
2077 break; | |
2078 case KC_CURSOR_UP: | |
2079 where_mapping = "\020"; | |
2080 break; | |
2081 case KC_CURSOR_DOWN: | |
2082 where_mapping = "\016"; | |
2083 break; | |
2084 } | |
2085 nbytes = 1; | |
2086 } | |
2087 if (numchars - nbytes > 0) | |
2088 { | |
2089 register int i; | |
2090 | |
2091 for (i = 0; i < nbytes; i++) | |
2092 { | |
2093 bufp->kind = ascii_keystroke; | |
2094 XSET (bufp->code, Lisp_Int, where_mapping[i]); | |
429 | 2095 XSET (bufp->time, Lisp_Int, event.xkey.time); |
771 | 2096 bufp->frame = f; |
286 | 2097 bufp++; |
2098 } | |
2099 count += nbytes; | |
2100 numchars -= nbytes; | |
2101 } | |
2102 } | |
2103 break; | |
2104 #endif /* HAVE_X11 */ | |
2105 | |
2106 #ifdef HAVE_X11 | |
2107 case EnterNotify: | |
771 | 2108 f = x_window_to_frame (event.xcrossing.window); |
369 | 2109 |
286 | 2110 if (event.xcrossing.detail == NotifyInferior) /* Left Scrollbar */ |
2111 ; | |
2112 else if (event.xcrossing.focus) /* Entered Window */ | |
2113 { | |
2114 /* If we decide we want to generate an event to be seen | |
2115 by the rest of Emacs, we put it here. */ | |
2116 struct input_event emacs_event; | |
2117 emacs_event.kind = no_event; | |
2118 | |
2119 /* Avoid nasty pop/raise loops. */ | |
771 | 2120 if (f && (!(f->auto_raise) |
2121 || !(f->auto_lower) | |
286 | 2122 || (event.xcrossing.time - enter_timestamp) > 500)) |
2123 { | |
771 | 2124 x_new_focus_frame (f); |
286 | 2125 enter_timestamp = event.xcrossing.time; |
2126 } | |
2127 #if 0 | |
771 | 2128 else if ((f = x_window_to_scrollbar (event.xcrossing.window, |
286 | 2129 &part, &prefix))) |
2130 /* Fake a motion event */ | |
2131 notice_mouse_movement (&emacs_event, | |
771 | 2132 event.xmotion, f, scrollbar_window, |
286 | 2133 part); |
2134 #endif | |
2135 | |
2136 #if 0 | |
2137 if (! EQ (Vx_send_mouse_movement_events, Qnil) | |
2138 && numchars >= 1 | |
2139 && emacs_event.kind != no_event) | |
2140 { | |
2141 bcopy (&emacs_event, bufp, sizeof (struct input_event)); | |
2142 bufp++; | |
2143 count++; | |
2144 numchars--; | |
2145 } | |
2146 #endif | |
2147 } | |
771 | 2148 else if (f == x_focus_frame) |
2149 x_new_focus_frame (0); | |
286 | 2150 #if 0 |
771 | 2151 else if (f = x_window_to_frame (event.xcrossing.window)) |
2152 x_mouse_frame = f; | |
286 | 2153 #endif |
2154 | |
2155 break; | |
2156 | |
2157 case FocusIn: | |
771 | 2158 f = x_window_to_frame (event.xfocus.window); |
2159 if (f) | |
2160 x_new_focus_frame (f); | |
286 | 2161 break; |
2162 | |
2163 case LeaveNotify: | |
2164 if (event.xcrossing.detail != NotifyInferior | |
2165 && event.xcrossing.subwindow == None | |
2166 && event.xcrossing.mode == NotifyNormal) | |
2167 { | |
771 | 2168 f = x_window_to_frame (event.xcrossing.window); |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
2169 |
313 | 2170 if (event.xcrossing.focus) |
771 | 2171 x_new_focus_frame (f); |
2172 else if (f == x_focus_frame) | |
2173 x_new_focus_frame (0); | |
286 | 2174 } |
2175 break; | |
2176 | |
2177 case FocusOut: | |
771 | 2178 f = x_window_to_frame (event.xfocus.window); |
2179 if (f && f == x_focus_frame) | |
2180 x_new_focus_frame (0); | |
286 | 2181 break; |
2182 | |
2183 #else /* not HAVE_X11 */ | |
2184 | |
2185 case EnterWindow: | |
2186 if ((event.detail & 0xFF) == 1) | |
2187 break; /* Coming from our own subwindow */ | |
2188 if (event.subwindow != 0) | |
2189 break; /* Entering our own subwindow. */ | |
2190 | |
2191 { | |
771 | 2192 f = x_window_to_frame (event.window); |
2193 x_mouse_frame = f; | |
2194 | |
2195 x_new_focus_frame (f); | |
286 | 2196 } |
2197 break; | |
2198 | |
2199 case LeaveWindow: | |
2200 if ((event.detail & 0xFF) == 1) | |
2201 break; /* Entering our own subwindow */ | |
2202 if (event.subwindow != 0) | |
2203 break; /* Leaving our own subwindow. */ | |
2204 | |
771 | 2205 x_mouse_frame = 0; |
2206 if (x_focus_frame == 0 | |
2207 && x_input_frame != 0 | |
2208 && x_input_frame == x_window_to_frame (event.window) | |
2209 && event.window == x_input_frame->display.x->window_desc) | |
286 | 2210 { |
771 | 2211 f = x_input_frame; |
2212 x_input_frame = 0; | |
2213 if (f) | |
2214 frame_unhighlight (f); | |
286 | 2215 } |
2216 break; | |
2217 #endif /* not HAVE_X11 */ | |
2218 | |
2219 #ifdef HAVE_X11 | |
2220 case MotionNotify: | |
2221 { | |
771 | 2222 f = x_window_to_frame (event.xmotion.window); |
2223 if (f) | |
2224 note_mouse_position (f, &event.xmotion); | |
286 | 2225 #if 0 |
771 | 2226 else if ((f = x_window_to_scrollbar (event.xmotion.window, |
286 | 2227 &part, &prefix))) |
2228 { | |
2229 What should go here? | |
2230 } | |
2231 #endif | |
2232 } | |
2233 break; | |
2234 | |
2235 case ConfigureNotify: | |
2236 { | |
2237 int rows, columns; | |
771 | 2238 f = x_window_to_frame (event.xconfigure.window); |
2239 if (!f) | |
286 | 2240 break; |
2241 | |
2242 columns = ((event.xconfigure.width - | |
771 | 2243 (2 * f->display.x->internal_border_width) |
2244 - f->display.x->v_scrollbar_width) | |
2245 / FONT_WIDTH (f->display.x->font)); | |
286 | 2246 rows = ((event.xconfigure.height - |
771 | 2247 (2 * f->display.x->internal_border_width) |
2248 - f->display.x->h_scrollbar_height) | |
2249 / FONT_HEIGHT (f->display.x->font)); | |
286 | 2250 |
429 | 2251 /* Even if the number of character rows and columns has |
2252 not changed, the font size may have changed, so we need | |
2253 to check the pixel dimensions as well. */ | |
771 | 2254 if (columns != f->width |
2255 || rows != f->height | |
2256 || event.xconfigure.width != f->display.x->pixel_width | |
2257 || event.xconfigure.height != f->display.x->pixel_height) | |
286 | 2258 { |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
2259 change_frame_size (f, rows, columns, 0, 1); |
771 | 2260 x_resize_scrollbars (f); |
2261 SET_FRAME_GARBAGED (f); | |
286 | 2262 } |
2263 | |
771 | 2264 f->display.x->pixel_width = event.xconfigure.width; |
2265 f->display.x->pixel_height = event.xconfigure.height; | |
2266 f->display.x->left_pos = event.xconfigure.x; | |
2267 f->display.x->top_pos = event.xconfigure.y; | |
286 | 2268 break; |
2269 } | |
2270 | |
2271 case ButtonPress: | |
2272 case ButtonRelease: | |
2273 { | |
2274 /* If we decide we want to generate an event to be seen | |
2275 by the rest of Emacs, we put it here. */ | |
2276 struct input_event emacs_event; | |
2277 emacs_event.kind = no_event; | |
2278 | |
771 | 2279 f = x_window_to_frame (event.xbutton.window); |
2280 if (f) | |
2281 if (!x_focus_frame || (f == x_focus_frame)) | |
286 | 2282 construct_mouse_click (&emacs_event, |
771 | 2283 &event, f, 0, 0); |
286 | 2284 else |
2285 continue; | |
2286 else | |
771 | 2287 if ((f = x_window_to_scrollbar (event.xbutton.window, |
286 | 2288 &part, &prefix))) |
2289 { | |
771 | 2290 if (!x_focus_frame || (selected_frame == x_focus_frame)) |
286 | 2291 construct_mouse_click (&emacs_event, |
771 | 2292 &event, f, part, prefix); |
286 | 2293 else |
2294 continue; | |
2295 } | |
2296 | |
2297 if (numchars >= 1 && emacs_event.kind != no_event) | |
2298 { | |
2299 bcopy (&emacs_event, bufp, sizeof (struct input_event)); | |
2300 bufp++; | |
2301 count++; | |
2302 numchars--; | |
2303 } | |
2304 } | |
2305 break; | |
2306 | |
2307 #else /* not HAVE_X11 */ | |
2308 case ButtonPressed: | |
2309 case ButtonReleased: | |
771 | 2310 f = x_window_to_frame (event.window); |
2311 if (f) | |
286 | 2312 { |
771 | 2313 if (event.window == f->display.x->icon_desc) |
286 | 2314 { |
771 | 2315 x_make_frame_visible (f); |
286 | 2316 |
2317 if (warp_mouse_on_deiconify) | |
771 | 2318 XWarpMouse (f->display.x->window_desc, 10, 10); |
286 | 2319 break; |
2320 } | |
771 | 2321 if (event.window == f->display.x->window_desc) |
286 | 2322 { |
771 | 2323 if (f->auto_raise) |
2324 x_raise_frame (f); | |
286 | 2325 } |
2326 } | |
2327 enqueue_event (&event, &x_mouse_queue); | |
2328 if (numchars >= 2) | |
2329 { | |
2330 bufp->kind = ascii_keystroke; | |
2331 bufp->code = (char) 'X' & 037; /* C-x */ | |
771 | 2332 bufp->frame = f; |
429 | 2333 XSET (bufp->time, Lisp_Int, event.xkey.time); |
286 | 2334 bufp++; |
2335 | |
2336 bufp->kind = ascii_keystroke; | |
2337 bufp->code = (char) 0; /* C-@ */ | |
771 | 2338 bufp->frame = f; |
429 | 2339 XSET (bufp->time, Lisp_Int, event.xkey.time); |
286 | 2340 bufp++; |
2341 | |
2342 count += 2; | |
2343 numchars -= 2; | |
2344 } | |
2345 break; | |
2346 #endif /* not HAVE_X11 */ | |
2347 | |
2348 #ifdef HAVE_X11 | |
2349 | |
2350 case CirculateNotify: | |
2351 break; | |
2352 case CirculateRequest: | |
2353 break; | |
2354 | |
2355 #endif /* HAVE_X11 */ | |
2356 | |
2357 case MappingNotify: | |
2358 if (event.xmapping.request == MappingKeyboard) | |
2359 /* Someone has changed the keyboard mapping - flush the | |
2360 local cache. */ | |
2361 XRefreshKeyboardMapping (&event.xmapping); | |
2362 break; | |
2363 | |
2364 default: | |
2365 break; | |
2366 } | |
2367 } | |
2368 | |
2369 #if 0 | |
2370 #ifdef HAVE_SELECT | |
2371 if (expected && ! event_found) | |
2372 { | |
2373 /* AOJ 880406: if select returns true but XPending doesn't, it means that | |
2374 there is an EOF condition; in other words, that X has died. | |
2375 Act as if there had been a hangup. */ | |
2376 | |
2377 int fd = ConnectionNumber (x_current_display); | |
2378 int mask = 1 << fd; | |
2379 | |
2380 if (0 != select (fd + 1, &mask, (long *) 0, (long *) 0, | |
555 | 2381 (EMACS_TIME) 0) |
286 | 2382 && !XStuffPending ()) |
2383 kill (getpid (), SIGHUP); | |
2384 } | |
2385 #endif /* HAVE_SELECT */ | |
2386 #endif | |
2387 | |
771 | 2388 if (updating_frame == 0) |
286 | 2389 x_do_pending_expose (); |
2390 | |
2391 UNBLOCK_INPUT; | |
2392 return count; | |
2393 } | |
2394 | |
2395 #ifndef HAVE_X11 | |
2396 /* Read and process only Expose events | |
2397 until we get an ExposeCopy event; then return. | |
2398 This is used in insert/delete line. | |
2399 We assume input is already blocked. */ | |
2400 | |
2401 static void | |
2402 x_read_exposes () | |
2403 { | |
771 | 2404 struct frame *f; |
286 | 2405 XKeyPressedEvent event; |
2406 | |
2407 while (1) | |
2408 { | |
2409 /* while there are more events*/ | |
2410 XMaskEvent (ExposeWindow | ExposeRegion | ExposeCopy, &event); | |
2411 switch (event.type) | |
2412 { | |
2413 case ExposeWindow: | |
2414 if (event.subwindow != 0) | |
2415 break; /* duplicate event */ | |
771 | 2416 f = x_window_to_frame (event.window); |
2417 if (event.window == f->display.x->icon_desc) | |
286 | 2418 { |
771 | 2419 refreshicon (f); |
286 | 2420 break; |
2421 } | |
771 | 2422 if (event.window == f->display.x->window_desc) |
286 | 2423 { |
2424 expose_all_windows = 1; | |
771 | 2425 f->display.x->needs_exposure = 1; |
286 | 2426 break; |
2427 } | |
2428 break; | |
2429 | |
2430 case ExposeRegion: | |
2431 if (event.subwindow != 0) | |
2432 break; /* duplicate event */ | |
771 | 2433 f = x_window_to_frame (event.window); |
2434 if (event.window == f->display.x->icon_desc) | |
286 | 2435 { |
771 | 2436 refreshicon (f); |
286 | 2437 break; |
2438 } | |
2439 /* If window already needs full redraw, ignore this rectangle. */ | |
771 | 2440 if (expose_all_windows && f->display.x->needs_exposure) |
286 | 2441 break; |
2442 /* Put the event on the queue of rectangles to redraw. */ | |
2443 if (enqueue_event (&event, &x_expose_queue)) | |
2444 /* If it is full, we can't record the rectangle, | |
2445 so redraw this entire window. */ | |
2446 { | |
2447 /* Say must check all windows' needs_exposure flags. */ | |
2448 expose_all_windows = 1; | |
771 | 2449 f->display.x->needs_exposure = 1; |
286 | 2450 } |
2451 break; | |
2452 | |
2453 case ExposeCopy: | |
2454 return; | |
2455 } | |
2456 } | |
2457 } | |
2458 #endif /* HAVE_X11 */ | |
2459 | |
2460 | |
2461 /* Draw a hollow box cursor. Don't change the inside of the box. */ | |
2462 | |
2463 static void | |
771 | 2464 x_draw_box (f) |
2465 struct frame *f; | |
286 | 2466 { |
771 | 2467 int left = f->cursor_x * FONT_WIDTH (f->display.x->font) |
2468 + f->display.x->internal_border_width; | |
2469 int top = f->cursor_y * FONT_HEIGHT (f->display.x->font) | |
2470 + f->display.x->internal_border_width; | |
2471 int width = FONT_WIDTH (f->display.x->font); | |
2472 int height = FONT_HEIGHT (f->display.x->font); | |
286 | 2473 |
2474 #ifdef HAVE_X11 | |
2475 /* Perhaps we should subtract 1 from width and height... */ | |
771 | 2476 XDrawRectangle (x_current_display, f->display.x->window_desc, |
2477 f->display.x->cursor_gc, | |
286 | 2478 left, top, width - 1, height - 1); |
2479 #else | |
771 | 2480 XPixSet (f->display.x->window_desc, |
286 | 2481 left, top, width, 1, |
771 | 2482 f->display.x->cursor_pixel); |
2483 | |
2484 XPixSet (f->display.x->window_desc, | |
286 | 2485 left, top, 1, height, |
771 | 2486 f->display.x->cursor_pixel); |
2487 | |
2488 XPixSet (f->display.x->window_desc, | |
286 | 2489 left+width-1, top, 1, height, |
771 | 2490 f->display.x->cursor_pixel); |
2491 | |
2492 XPixSet (f->display.x->window_desc, | |
286 | 2493 left, top+height-1, width, 1, |
771 | 2494 f->display.x->cursor_pixel); |
286 | 2495 #endif /* HAVE_X11 */ |
2496 } | |
2497 | |
771 | 2498 /* Clear the cursor of frame F to background color, |
286 | 2499 and mark the cursor as not shown. |
2500 This is used when the text where the cursor is | |
2501 is about to be rewritten. */ | |
2502 | |
2503 static void | |
771 | 2504 clear_cursor (f) |
2505 struct frame *f; | |
286 | 2506 { |
2507 int mask; | |
2508 | |
771 | 2509 if (! f->visible |
2510 || f->phys_cursor_x < 0) | |
286 | 2511 return; |
2512 | |
2513 #ifdef HAVE_X11 | |
771 | 2514 x_display_cursor (f, 0); |
286 | 2515 #if 0 |
771 | 2516 XClearArea (x_current_display, f->display.x->window_desc, |
2517 f->phys_cursor_x * FONT_WIDTH (f->display.x->font) | |
2518 + f->display.x->internal_border_width, | |
2519 f->phys_cursor_y * FONT_HEIGHT (f->display.x->font) | |
2520 + f->display.x->internal_border_width, | |
2521 FONT_WIDTH (f->display.x->font) + 1, FONT_HEIGHT (f->display.x->font) + 1, False); | |
286 | 2522 #endif |
2523 #else | |
771 | 2524 XPixSet (f->display.x->window_desc, |
2525 f->phys_cursor_x * FONT_WIDTH (f->display.x->font) + f->display.x->internal_border_width, | |
2526 f->phys_cursor_y * FONT_HEIGHT (f->display.x->font) + f->display.x->internal_border_width, | |
2527 FONT_WIDTH (f->display.x->font), FONT_HEIGHT (f->display.x->font), | |
2528 f->display.x->background_pixel); | |
286 | 2529 #endif /* HAVE_X11 */ |
771 | 2530 f->phys_cursor_x = -1; |
286 | 2531 } |
2532 | |
429 | 2533 static void |
771 | 2534 x_display_bar_cursor (f, on) |
2535 struct frame *f; | |
286 | 2536 int on; |
2537 { | |
771 | 2538 register int phys_x = f->phys_cursor_x; |
2539 register int phys_y = f->phys_cursor_y; | |
286 | 2540 register int x1; |
2541 register int y1; | |
2542 register int y2; | |
2543 | |
771 | 2544 if (! f->visible || (! on && f->phys_cursor_x < 0)) |
286 | 2545 return; |
2546 | |
2547 #ifdef HAVE_X11 | |
2548 if (phys_x >= 0 && | |
771 | 2549 (!on || phys_x != f->cursor_x || phys_y != f->cursor_y)) |
286 | 2550 { |
771 | 2551 x1 = phys_x * FONT_WIDTH (f->display.x->font) |
2552 + f->display.x->internal_border_width; | |
2553 y1 = phys_y * FONT_HEIGHT (f->display.x->font) | |
2554 + f->display.x->internal_border_width - 1; | |
2555 y2 = y1 + FONT_HEIGHT (f->display.x->font) + 1; | |
2556 | |
2557 XDrawLine (x_current_display, f->display.x->window_desc, | |
2558 f->display.x->reverse_gc, x1, y1, x1, y2); | |
2559 | |
2560 f->phys_cursor_x = phys_x = -1; | |
286 | 2561 } |
2562 | |
771 | 2563 if (on && f == x_highlight_frame) |
286 | 2564 { |
771 | 2565 x1 = f->cursor_x * FONT_WIDTH (f->display.x->font) |
2566 + f->display.x->internal_border_width; | |
2567 y1 = f->cursor_y * FONT_HEIGHT (f->display.x->font) | |
2568 + f->display.x->internal_border_width - 1; | |
2569 y2 = y1 + FONT_HEIGHT (f->display.x->font) + 1; | |
2570 | |
2571 XDrawLine (x_current_display, f->display.x->window_desc, | |
2572 f->display.x->cursor_gc, x1, y1, x1, y2); | |
2573 | |
2574 f->phys_cursor_x = f->cursor_x; | |
2575 f->phys_cursor_y = f->cursor_y; | |
286 | 2576 } |
2577 #else /* X10 */ | |
2578 Give it up, dude. | |
2579 #endif /* X10 */ | |
2580 } | |
2581 | |
2582 | |
771 | 2583 /* Redraw the glyph at ROW, COLUMN on frame F, in the style |
429 | 2584 HIGHLIGHT. HIGHLIGHT is as defined for dumpglyphs. Return the |
2585 glyph drawn. */ | |
286 | 2586 |
2587 static void | |
771 | 2588 x_draw_single_glyph (f, row, column, glyph, highlight) |
2589 struct frame *f; | |
286 | 2590 int row, column; |
429 | 2591 GLYPH glyph; |
286 | 2592 int highlight; |
2593 { | |
771 | 2594 dumpglyphs (f, |
2595 (column * FONT_WIDTH (f->display.x->font) | |
2596 + f->display.x->internal_border_width), | |
2597 (row * FONT_HEIGHT (f->display.x->font) | |
2598 + f->display.x->internal_border_width), | |
2599 &glyph, 1, highlight, f->display.x->font); | |
286 | 2600 } |
2601 | |
771 | 2602 /* Turn the displayed cursor of frame F on or off according to ON. |
286 | 2603 If ON is nonzero, where to put the cursor is specified |
771 | 2604 by F->cursor_x and F->cursor_y. */ |
286 | 2605 |
2606 static void | |
771 | 2607 x_display_box_cursor (f, on) |
2608 struct frame *f; | |
286 | 2609 int on; |
2610 { | |
771 | 2611 struct frame_glyphs *current_glyphs = FRAME_CURRENT_GLYPHS (f); |
2612 | |
2613 /* If we're not updating, then we want to use the current frame's | |
708 | 2614 cursor position, not our local idea of where the cursor ought to be. */ |
771 | 2615 if (f != updating_frame) |
708 | 2616 { |
771 | 2617 curs_x = FRAME_CURSOR_X (f); |
2618 curs_y = FRAME_CURSOR_Y (f); | |
708 | 2619 } |
2620 | |
771 | 2621 if (! f->visible) |
286 | 2622 return; |
2623 | |
2624 /* If cursor is off and we want it off, return quickly. */ | |
771 | 2625 if (!on && f->phys_cursor_x < 0) |
286 | 2626 return; |
2627 | |
2628 /* If cursor is currently being shown and we don't want it to be | |
2629 or it is in the wrong place, | |
2630 or we want a hollow box and it's not so, (pout!) | |
2631 erase it. */ | |
771 | 2632 if (f->phys_cursor_x >= 0 |
286 | 2633 && (!on |
771 | 2634 || f->phys_cursor_x != curs_x |
2635 || f->phys_cursor_y != curs_y | |
2636 || (f->display.x->text_cursor_kind != hollow_box_cursor | |
2637 && (f != x_highlight_frame)))) | |
286 | 2638 { |
2639 /* Erase the cursor by redrawing the character underneath it. */ | |
771 | 2640 x_draw_single_glyph (f, f->phys_cursor_y, f->phys_cursor_x, |
2641 f->phys_cursor_glyph, | |
2642 current_glyphs->highlight[f->phys_cursor_y]); | |
2643 f->phys_cursor_x = -1; | |
286 | 2644 } |
2645 | |
2646 /* If we want to show a cursor, | |
2647 or we want a box cursor and it's not so, | |
2648 write it in the right place. */ | |
2649 if (on | |
771 | 2650 && (f->phys_cursor_x < 0 |
2651 || (f->display.x->text_cursor_kind != filled_box_cursor | |
2652 && f == x_highlight_frame))) | |
286 | 2653 { |
771 | 2654 f->phys_cursor_glyph |
708 | 2655 = ((current_glyphs->enable[curs_y] |
2656 && curs_x < current_glyphs->used[curs_y]) | |
2657 ? current_glyphs->glyphs[curs_y][curs_x] | |
429 | 2658 : SPACEGLYPH); |
771 | 2659 if (f != x_highlight_frame) |
286 | 2660 { |
771 | 2661 x_draw_box (f); |
2662 f->display.x->text_cursor_kind = hollow_box_cursor; | |
286 | 2663 } |
2664 else | |
2665 { | |
771 | 2666 x_draw_single_glyph (f, curs_y, curs_x, |
2667 f->phys_cursor_glyph, 2); | |
2668 f->display.x->text_cursor_kind = filled_box_cursor; | |
286 | 2669 } |
2670 | |
771 | 2671 f->phys_cursor_x = curs_x; |
2672 f->phys_cursor_y = curs_y; | |
286 | 2673 } |
2674 | |
771 | 2675 if (updating_frame != f) |
286 | 2676 XFlushQueue (); |
2677 } | |
2678 | |
2679 extern Lisp_Object Vbar_cursor; | |
2680 | |
771 | 2681 x_display_cursor (f, on) |
2682 struct frame *f; | |
286 | 2683 int on; |
2684 { | |
2685 if (EQ (Vbar_cursor, Qnil)) | |
771 | 2686 x_display_box_cursor (f, on); |
286 | 2687 else |
771 | 2688 x_display_bar_cursor (f, on); |
286 | 2689 } |
2690 | |
2691 /* Icons. */ | |
2692 | |
771 | 2693 /* Refresh bitmap kitchen sink icon for frame F |
286 | 2694 when we get an expose event for it. */ |
2695 | |
771 | 2696 refreshicon (f) |
2697 struct frame *f; | |
286 | 2698 { |
2699 #ifdef HAVE_X11 | |
2700 /* Normally, the window manager handles this function. */ | |
2701 #else | |
2702 int mask; | |
2703 | |
771 | 2704 if (f->display.x->icon_bitmap_flag) |
2705 XBitmapBitsPut (f->display.x->icon_desc, 0, 0, sink_width, sink_height, | |
286 | 2706 sink_bits, BlackPixel, WHITE_PIX_DEFAULT, |
2707 icon_bitmap, GXcopy, AllPlanes); | |
2708 else | |
2709 { | |
771 | 2710 extern struct frame *selected_frame; |
286 | 2711 struct Lisp_String *str; |
2712 unsigned char *string; | |
2713 | |
2714 string | |
771 | 2715 = XSTRING (XBUFFER (XWINDOW (f->selected_window)->buffer)->name)->data; |
2716 | |
2717 if (f->display.x->icon_label != string) | |
286 | 2718 { |
771 | 2719 f->display.x->icon_label = string; |
2720 XChangeWindow (f->display.x->icon_desc, | |
286 | 2721 XQueryWidth (string, icon_font_info->id) + 10, |
2722 icon_font_info->height + 10); | |
2723 } | |
2724 | |
771 | 2725 XText (f->display.x->icon_desc, 5, 5, string, |
286 | 2726 str->size, icon_font_info->id, |
2727 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT); | |
2728 } | |
2729 XFlushQueue (); | |
2730 #endif /* HAVE_X11 */ | |
2731 } | |
2732 | |
771 | 2733 /* Make the x-window of frame F use the kitchen-sink icon |
286 | 2734 that's a window generated by Emacs. */ |
2735 | |
2736 int | |
771 | 2737 x_bitmap_icon (f) |
2738 struct frame *f; | |
286 | 2739 { |
2740 int mask; | |
2741 Window icon_window; | |
2742 | |
771 | 2743 if (f->display.x->window_desc == 0) |
286 | 2744 return 1; |
2745 | |
2746 #ifdef HAVE_X11 | |
2747 if (icon_bitmap) | |
2748 XFreePixmap (x_current_display, icon_bitmap); | |
2749 | |
2750 icon_bitmap = | |
771 | 2751 XCreateBitmapFromData (x_current_display, f->display.x->window_desc, |
286 | 2752 gnu_bits, gnu_width, gnu_height); |
771 | 2753 x_wm_set_icon_pixmap (f, icon_bitmap); |
2754 f->display.x->icon_bitmap_flag = 1; | |
286 | 2755 #else |
771 | 2756 if (f->display.x->icon_desc) |
286 | 2757 { |
771 | 2758 XClearIconWindow (f->display.x->window_desc); |
2759 XDestroyWindow (f->display.x->icon_desc); | |
286 | 2760 } |
2761 | |
771 | 2762 icon_window = XCreateWindow (f->display.x->parent_desc, |
286 | 2763 0, 0, sink_width, sink_height, |
2764 2, WhitePixmap, (Pixmap) NULL); | |
2765 | |
2766 if (icon_window == 0) | |
2767 return 1; | |
2768 | |
771 | 2769 XSetIconWindow (f->display.x->window_desc, icon_window); |
286 | 2770 XSelectInput (icon_window, ExposeWindow | UnmapWindow); |
2771 | |
771 | 2772 f->display.x->icon_desc = icon_window; |
2773 f->display.x->icon_bitmap_flag = 1; | |
286 | 2774 |
2775 if (icon_bitmap == 0) | |
2776 icon_bitmap | |
2777 = XStoreBitmap (sink_mask_width, sink_mask_height, sink_mask_bits); | |
2778 #endif /* HAVE_X11 */ | |
2779 | |
2780 return 0; | |
2781 } | |
2782 | |
2783 | |
771 | 2784 /* Make the x-window of frame F use a rectangle with text. */ |
286 | 2785 |
2786 int | |
771 | 2787 x_text_icon (f, icon_name) |
2788 struct frame *f; | |
286 | 2789 char *icon_name; |
2790 { | |
2791 #ifndef HAVE_X11 | |
2792 int mask; | |
2793 int width; | |
2794 Window icon_window; | |
2795 char *X_DefaultValue; | |
2796 Bitmap b1; | |
2797 | |
2798 #ifndef WhitePixel | |
2799 #define WhitePixel 1 | |
2800 #endif | |
2801 | |
2802 #ifndef BlackPixel | |
2803 #define BlackPixel 0 | |
2804 #endif | |
2805 #endif /* not HAVE_X11 */ | |
2806 | |
771 | 2807 if (f->display.x->window_desc == 0) |
286 | 2808 return 1; |
2809 | |
2810 if (icon_font_info == 0) | |
2811 icon_font_info | |
395 | 2812 = XGetFont (XGetDefault (XDISPLAY |
2813 (char *) XSTRING (invocation_name)->data, | |
2814 "BodyFont")); | |
286 | 2815 |
2816 #ifdef HAVE_X11 | |
2817 if (icon_name) | |
771 | 2818 f->display.x->icon_label = icon_name; |
286 | 2819 else |
771 | 2820 if (! f->display.x->icon_label) |
2821 f->display.x->icon_label = " *emacs* "; | |
286 | 2822 |
771 | 2823 XSetIconName (x_current_display, f->display.x->window_desc, |
2824 (char *) f->display.x->icon_label); | |
286 | 2825 |
771 | 2826 f->display.x->icon_bitmap_flag = 0; |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
2827 x_wm_set_icon_pixmap (f, 0); |
286 | 2828 #else |
771 | 2829 if (f->display.x->icon_desc) |
286 | 2830 { |
771 | 2831 XClearIconWindow (XDISPLAY f->display.x->window_desc); |
2832 XDestroyWindow (XDISPLAY f->display.x->icon_desc); | |
286 | 2833 } |
2834 | |
2835 if (icon_name) | |
771 | 2836 f->display.x->icon_label = (unsigned char *) icon_name; |
286 | 2837 else |
771 | 2838 if (! f->display.x->icon_label) |
2839 f->display.x->icon_label = XSTRING (f->name)->data; | |
2840 | |
2841 width = XStringWidth (f->display.x->icon_label, icon_font_info, 0, 0); | |
2842 icon_window = XCreateWindow (f->display.x->parent_desc, | |
2843 f->display.x->left_pos, | |
2844 f->display.x->top_pos, | |
286 | 2845 width + 10, icon_font_info->height + 10, |
2846 2, BlackPixmap, WhitePixmap); | |
2847 | |
2848 if (icon_window == 0) | |
2849 return 1; | |
2850 | |
771 | 2851 XSetIconWindow (f->display.x->window_desc, icon_window); |
286 | 2852 XSelectInput (icon_window, ExposeWindow | ExposeRegion | UnmapWindow | ButtonPressed); |
2853 | |
771 | 2854 f->display.x->icon_desc = icon_window; |
2855 f->display.x->icon_bitmap_flag = 0; | |
2856 f->display.x->icon_label = 0; | |
286 | 2857 #endif /* HAVE_X11 */ |
2858 | |
2859 return 0; | |
2860 } | |
2861 | |
621 | 2862 /* Handling X errors. */ |
2863 | |
2864 /* A handler for SIGPIPE, when it occurs on the X server's connection. | |
2865 This basically does an orderly shutdown of Emacs. */ | |
2866 static SIGTYPE | |
2867 x_death_handler () | |
2868 { | |
2869 if (_Xdebug) | |
2870 abort (); | |
2871 else | |
2872 Fkill_emacs (make_number (70)); | |
2873 } | |
2874 | |
286 | 2875 static char *x_proto_requests[] = |
2876 { | |
2877 "CreateWindow", | |
2878 "ChangeWindowAttributes", | |
2879 "GetWindowAttributes", | |
2880 "DestroyWindow", | |
2881 "DestroySubwindows", | |
2882 "ChangeSaveSet", | |
2883 "ReparentWindow", | |
2884 "MapWindow", | |
2885 "MapSubwindows", | |
2886 "UnmapWindow", | |
2887 "UnmapSubwindows", | |
2888 "ConfigureWindow", | |
2889 "CirculateWindow", | |
2890 "GetGeometry", | |
2891 "QueryTree", | |
2892 "InternAtom", | |
2893 "GetAtomName", | |
2894 "ChangeProperty", | |
2895 "DeleteProperty", | |
2896 "GetProperty", | |
2897 "ListProperties", | |
2898 "SetSelectionOwner", | |
2899 "GetSelectionOwner", | |
2900 "ConvertSelection", | |
2901 "SendEvent", | |
2902 "GrabPointer", | |
2903 "UngrabPointer", | |
2904 "GrabButton", | |
2905 "UngrabButton", | |
2906 "ChangeActivePointerGrab", | |
2907 "GrabKeyboard", | |
2908 "UngrabKeyboard", | |
2909 "GrabKey", | |
2910 "UngrabKey", | |
2911 "AllowEvents", | |
2912 "GrabServer", | |
2913 "UngrabServer", | |
2914 "QueryPointer", | |
2915 "GetMotionEvents", | |
2916 "TranslateCoords", | |
2917 "WarpPointer", | |
2918 "SetInputFocus", | |
2919 "GetInputFocus", | |
2920 "QueryKeymap", | |
2921 "OpenFont", | |
2922 "CloseFont", | |
2923 "QueryFont", | |
2924 "QueryTextExtents", | |
2925 "ListFonts", | |
2926 "ListFontsWithInfo", | |
2927 "SetFontPath", | |
2928 "GetFontPath", | |
2929 "CreatePixmap", | |
2930 "FreePixmap", | |
2931 "CreateGC", | |
2932 "ChangeGC", | |
2933 "CopyGC", | |
2934 "SetDashes", | |
2935 "SetClipRectangles", | |
2936 "FreeGC", | |
2937 "ClearArea", | |
2938 "CopyArea", | |
2939 "CopyPlane", | |
2940 "PolyPoint", | |
2941 "PolyLine", | |
2942 "PolySegment", | |
2943 "PolyRectangle", | |
2944 "PolyArc", | |
2945 "FillPoly", | |
2946 "PolyFillRectangle", | |
2947 "PolyFillArc", | |
2948 "PutImage", | |
2949 "GetImage", | |
2950 "PolyText", | |
2951 "PolyText", | |
2952 "ImageText", | |
2953 "ImageText", | |
2954 "CreateColormap", | |
2955 "FreeColormap", | |
2956 "CopyColormapAndFree", | |
2957 "InstallColormap", | |
2958 "UninstallColormap", | |
2959 "ListInstalledColormaps", | |
2960 "AllocColor", | |
2961 "AllocNamedColor", | |
2962 "AllocColorCells", | |
2963 "AllocColorPlanes", | |
2964 "FreeColors", | |
2965 "StoreColors", | |
2966 "StoreNamedColor", | |
2967 "QueryColors", | |
2968 "LookupColor", | |
2969 "CreateCursor", | |
2970 "CreateGlyphCursor", | |
2971 "FreeCursor", | |
2972 "RecolorCursor", | |
2973 "QueryBestSize", | |
2974 "QueryExtension", | |
2975 "ListExtensions", | |
2976 "ChangeKeyboardMapping", | |
2977 "GetKeyboardMapping", | |
2978 "ChangeKeyboardControl", | |
2979 "GetKeyboardControl", | |
2980 "Bell", | |
2981 "ChangePointerControl", | |
2982 "GetPointerControl", | |
2983 "SetScreenSaver", | |
2984 "GetScreenSaver", | |
2985 "ChangeHosts", | |
2986 "ListHosts", | |
2987 "SetAccessControl", | |
2988 "SetCloseDownMode", | |
2989 "KillClient", | |
2990 "RotateProperties", | |
2991 "ForceScreenSaver", | |
2992 "SetPointerMapping", | |
2993 "GetPointerMapping", | |
2994 "SetModifierMapping", | |
2995 "GetModifierMapping", | |
2996 "NoOperation" | |
2997 }; | |
2998 | |
2999 #define acceptable_x_error_p(type) ((type) == 94) | |
3000 | |
3001 x_handle_error_gracefully (event) | |
3002 XErrorEvent *event; | |
3003 { | |
3004 char error_ptr[128]; | |
3005 char *proto_ptr = x_proto_requests[event->request_code]; | |
3006 char str[128]; | |
3007 | |
3008 XGetErrorText (x_current_display, event->error_code, error_ptr, 128); | |
3009 sprintf (str, "X Protocol Error: %s on request: %s", error_ptr, proto_ptr); | |
3010 TOTALLY_UNBLOCK_INPUT; | |
3011 error (str); | |
3012 } | |
3013 | |
3014 #if 0 | |
3015 extern int x_selection_alloc_error; | |
3016 extern int x_converting_selection; | |
3017 #endif | |
3018 | |
3019 /* Handle X Errors. If the error is not traumatic, | |
3020 just call error (). Otherwise print a (hopefully) interesting | |
3021 message and quit. | |
3022 | |
3023 The arg to Fkill_emacs is an exit status value | |
3024 and also prevents any questions. */ | |
3025 | |
3026 x_error_handler (disp, event) | |
3027 Display *disp; | |
3028 #ifdef HAVE_X11 | |
3029 XErrorEvent *event; | |
3030 | |
3031 #define XlibDisplayIOError (1L << 0) | |
3032 | |
3033 #else | |
3034 struct _XErrorEvent *event; | |
3035 #endif | |
3036 { | |
3037 /* Here we use the standard X handlers. */ | |
3038 | |
3039 BLOCK_INPUT; | |
3040 if (event && event->type == 0) /* 0 is the XError Event type. */ | |
3041 { | |
3042 #if 0 | |
3043 #ifdef HAVE_X11 | |
3044 if (event->request_code == BadAlloc && x_converting_selection) | |
3045 x_selection_alloc_error = 1; | |
3046 else | |
3047 #endif | |
3048 #endif | |
3049 if (acceptable_x_error_p (event->request_code)) | |
3050 x_handle_error_gracefully (event); | |
3051 else | |
3052 _XDefaultError (disp, event); | |
3053 } | |
3054 else | |
3055 { | |
3056 disp->flags |= XlibDisplayIOError; | |
3057 _XDefaultIOError (disp); | |
3058 } | |
3059 UNBLOCK_INPUT; | |
3060 | |
621 | 3061 x_death_handler (); |
286 | 3062 } |
3063 | |
3064 #if 0 | |
3065 static unsigned int x_wire_count; | |
3066 x_trace_wire () | |
3067 { | |
3068 fprintf (stderr, "Lib call: %d\n", ++x_wire_count); | |
3069 } | |
3070 #endif | |
3071 | |
3072 | |
771 | 3073 /* Set the font of the x-window specified by frame F |
286 | 3074 to the font named NEWNAME. This is safe to use |
771 | 3075 even before F has an actual x-window. */ |
286 | 3076 |
3077 #ifdef HAVE_X11 | |
3078 | |
3079 /* A table of all the fonts we have already loaded. */ | |
3080 static XFontStruct **x_font_table; | |
3081 | |
3082 /* The current capacity of x_font_table. */ | |
3083 static int x_font_table_size; | |
3084 | |
3085 /* The number of fonts actually stored in x_font_table. | |
3086 x_font_table[n] is used and valid iff 0 <= n < n_fonts. | |
3087 0 <= n_fonts <= x_font_table_size. */ | |
3088 static int n_fonts; | |
3089 | |
771 | 3090 x_new_font (f, fontname) |
3091 struct frame *f; | |
286 | 3092 register char *fontname; |
3093 { | |
3094 XFontStruct *temp; | |
3095 int already_loaded; | |
3096 int n_matching_fonts; | |
3097 XFontStruct *font_info; | |
3098 char **font_names; | |
3099 | |
3100 /* Get a list of all the fonts that match this name. Once we | |
3101 have a list of matching fonts, we compare them against the fonts | |
3102 we already have by comparing font ids. */ | |
3103 font_names = (char **) XListFontsWithInfo (x_current_display, fontname, | |
3104 1024, &n_matching_fonts, | |
3105 &font_info); | |
3106 /* If the server couldn't find any fonts whose named matched fontname, | |
3107 return an error code. */ | |
3108 if (n_matching_fonts == 0) | |
3109 return 1; | |
3110 | |
429 | 3111 /* See if we've already loaded a matching font. */ |
286 | 3112 { |
3113 int i, j; | |
3114 | |
3115 already_loaded = 0; | |
3116 for (i = 0; i < n_fonts; i++) | |
3117 for (j = 0; j < n_matching_fonts; j++) | |
3118 if (x_font_table[i]->fid == font_info[j].fid) | |
3119 { | |
3120 already_loaded = i; | |
3121 goto found_font; | |
3122 } | |
3123 } | |
3124 found_font: | |
3125 | |
3126 /* If we have, just return it from the table. */ | |
3127 if (already_loaded) | |
771 | 3128 f->display.x->font = x_font_table[already_loaded]; |
429 | 3129 |
286 | 3130 /* Otherwise, load the font and add it to the table. */ |
3131 else | |
3132 { | |
3133 XFontStruct *font; | |
3134 | |
3135 font = (XFontStruct *) XLoadQueryFont (x_current_display, fontname); | |
3136 if (! font) | |
3137 return 1; | |
3138 | |
3139 /* Do we need to create the table? */ | |
3140 if (x_font_table_size == 0) | |
3141 { | |
3142 x_font_table_size = 16; | |
3143 x_font_table | |
3144 = (XFontStruct **) xmalloc (x_font_table_size | |
3145 * sizeof (x_font_table[0])); | |
3146 } | |
3147 /* Do we need to grow the table? */ | |
3148 else if (n_fonts >= x_font_table_size) | |
3149 { | |
429 | 3150 x_font_table_size *= 2; |
286 | 3151 x_font_table |
3152 = (XFontStruct **) xrealloc (x_font_table, | |
3153 (x_font_table_size | |
3154 * sizeof (x_font_table[0]))); | |
3155 } | |
3156 | |
771 | 3157 f->display.x->font = x_font_table[n_fonts++] = font; |
286 | 3158 } |
3159 | |
3160 /* Free the information from XListFontsWithInfo. The data | |
3161 we actually retain comes from XLoadQueryFont. */ | |
3162 XFreeFontInfo (font_names, font_info, n_matching_fonts); | |
3163 | |
771 | 3164 /* Now make the frame display the given font. */ |
3165 if (f->display.x->window_desc != 0) | |
286 | 3166 { |
771 | 3167 XSetFont (x_current_display, f->display.x->normal_gc, |
3168 f->display.x->font->fid); | |
3169 XSetFont (x_current_display, f->display.x->reverse_gc, | |
3170 f->display.x->font->fid); | |
3171 XSetFont (x_current_display, f->display.x->cursor_gc, | |
3172 f->display.x->font->fid); | |
3173 | |
3174 x_set_window_size (f, f->width, f->height); | |
286 | 3175 } |
3176 | |
3177 return 0; | |
3178 } | |
3179 #else | |
771 | 3180 x_new_font (f, newname) |
3181 struct frame *f; | |
286 | 3182 register char *newname; |
3183 { | |
3184 FONT_TYPE *temp; | |
3185 int mask; | |
3186 | |
3187 temp = XGetFont (newname); | |
3188 if (temp == (FONT_TYPE *) 0) | |
3189 return 1; | |
3190 | |
771 | 3191 if (f->display.x->font) |
3192 XLoseFont (f->display.x->font); | |
3193 | |
3194 f->display.x->font = temp; | |
3195 | |
3196 if (f->display.x->window_desc != 0) | |
3197 x_set_window_size (f, f->width, f->height); | |
286 | 3198 |
3199 return 0; | |
3200 } | |
3201 #endif | |
3202 | |
771 | 3203 x_calc_absolute_position (f) |
3204 struct frame *f; | |
286 | 3205 { |
3206 #ifdef HAVE_X11 | |
771 | 3207 if (f->display.x->left_pos < 0) |
3208 f->display.x->left_pos | |
786 | 3209 = XINT (x_screen_width) - PIXEL_WIDTH (f) + f->display.x->left_pos; |
771 | 3210 |
3211 if (f->display.x->top_pos < 0) | |
3212 f->display.x->top_pos | |
786 | 3213 = XINT (x_screen_height) - PIXEL_HEIGHT (f) + f->display.x->top_pos; |
286 | 3214 #else /* X10 */ |
3215 WINDOWINFO_TYPE parentinfo; | |
3216 | |
771 | 3217 XGetWindowInfo (f->display.x->window_desc, &parentinfo); |
3218 | |
3219 if (f->display.x->left_pos < 0) | |
3220 f->display.x->left_pos = parentinfo.width + (f->display.x->left_pos + 1) | |
3221 - PIXEL_WIDTH (f) - 2 * f->display.x->internal_border_width; | |
3222 | |
3223 if (f->display.x->top_pos < 0) | |
3224 f->display.x->top_pos = parentinfo.height + (f->display.x->top_pos + 1) | |
3225 - PIXEL_HEIGHT (f) - 2 * f->display.x->internal_border_width; | |
286 | 3226 #endif /* X10 */ |
3227 } | |
3228 | |
771 | 3229 x_set_offset (f, xoff, yoff) |
3230 struct frame *f; | |
286 | 3231 register int xoff, yoff; |
3232 { | |
771 | 3233 f->display.x->top_pos = yoff; |
3234 f->display.x->left_pos = xoff; | |
3235 x_calc_absolute_position (f); | |
286 | 3236 |
3237 BLOCK_INPUT; | |
771 | 3238 XMoveWindow (XDISPLAY f->display.x->window_desc, |
3239 f->display.x->left_pos, f->display.x->top_pos); | |
286 | 3240 #ifdef HAVE_X11 |
771 | 3241 x_wm_set_size_hint (f, 0); |
286 | 3242 #endif |
3243 UNBLOCK_INPUT; | |
3244 } | |
3245 | |
771 | 3246 /* Call this to change the size of frame F's x-window. */ |
3247 | |
3248 x_set_window_size (f, cols, rows) | |
3249 struct frame *f; | |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3250 int cols, rows; |
286 | 3251 { |
3252 int pixelwidth, pixelheight; | |
3253 int mask; | |
771 | 3254 int ibw = f->display.x->internal_border_width; |
286 | 3255 |
3256 BLOCK_INPUT; | |
3257 | |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3258 check_frame_size (f, &rows, &cols); |
771 | 3259 pixelwidth = (cols * FONT_WIDTH (f->display.x->font) + 2 * ibw |
3260 + f->display.x->v_scrollbar_width); | |
3261 pixelheight = (rows * FONT_HEIGHT (f->display.x->font) + 2 * ibw | |
3262 + f->display.x->h_scrollbar_height); | |
286 | 3263 |
3264 #ifdef HAVE_X11 | |
771 | 3265 x_wm_set_size_hint (f, 0); |
286 | 3266 #endif /* HAVE_X11 */ |
771 | 3267 XChangeWindowSize (f->display.x->window_desc, pixelwidth, pixelheight); |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3268 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3269 /* Now, strictly speaking, we can't be sure that this is accurate, |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3270 but the window manager will get around to dealing with the size |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3271 change request eventually, and we'll hear how it went when the |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3272 ConfigureNotify event gets here. */ |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3273 FRAME_WIDTH (f) = cols; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3274 FRAME_WIDTH (f) = rows; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3275 PIXEL_WIDTH (f) = pixelwidth; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3276 PIXEL_HEIGHT (f) = pixelheight; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3277 |
286 | 3278 XFlushQueue (); |
3279 UNBLOCK_INPUT; | |
3280 } | |
3281 | |
3282 #ifndef HAVE_X11 | |
771 | 3283 x_set_resize_hint (f) |
3284 struct frame *f; | |
286 | 3285 { |
3286 | |
771 | 3287 XSetResizeHint (f->display.x->window_desc, 2 * f->display.x->internal_border_width, |
3288 2 * f->display.x->internal_border_width, | |
3289 FONT_WIDTH (f->display.x->font), FONT_HEIGHT (f->display.x->font)); | |
286 | 3290 } |
3291 #endif /* not HAVE_X11 */ | |
3292 | |
3293 | |
771 | 3294 x_set_mouse_position (f, x, y) |
3295 struct frame *f; | |
286 | 3296 int x, y; |
3297 { | |
3298 int pix_x, pix_y; | |
3299 | |
771 | 3300 x_raise_frame (f); |
286 | 3301 |
3302 if (x < 0) | |
771 | 3303 pix_x = (FRAME_WIDTH (f) |
3304 * FONT_WIDTH (f->display.x->font) | |
3305 + 2 * f->display.x->internal_border_width | |
3306 + f->display.x->v_scrollbar_width) / 2; | |
286 | 3307 else |
771 | 3308 pix_x = x * FONT_WIDTH (f->display.x->font) + 2; /* add 2 pixels to each |
286 | 3309 dimension to move the |
3310 mouse into the char | |
3311 cell */ | |
3312 | |
3313 if (y < 0) | |
771 | 3314 pix_y = (FRAME_HEIGHT (f) |
3315 * FONT_HEIGHT (f->display.x->font) | |
3316 + 2 * f->display.x->internal_border_width | |
3317 + f->display.x->h_scrollbar_height) / 2; | |
286 | 3318 else |
771 | 3319 pix_y = y * FONT_HEIGHT (f->display.x->font) + 2; |
286 | 3320 |
3321 BLOCK_INPUT; | |
3322 x_mouse_x = x; | |
3323 x_mouse_y = y; | |
3324 | |
771 | 3325 XWarpMousePointer (f->display.x->window_desc, pix_x, pix_y); |
286 | 3326 UNBLOCK_INPUT; |
3327 } | |
3328 | |
3329 #ifdef HAVE_X11 | |
771 | 3330 x_focus_on_frame (f) |
3331 struct frame *f; | |
286 | 3332 { |
771 | 3333 x_raise_frame (f); |
369 | 3334 #if 0 |
3335 /* I don't think that the ICCCM allows programs to do things like this | |
3336 without the interaction of the window manager. Whatever you end up | |
771 | 3337 doing with this code, do it to x_unfocus_frame too. */ |
3338 XSetInputFocus (x_current_display, f->display.x->window_desc, | |
286 | 3339 RevertToPointerRoot, CurrentTime); |
369 | 3340 #endif |
286 | 3341 } |
3342 | |
771 | 3343 x_unfocus_frame (f) |
3344 struct frame *f; | |
286 | 3345 { |
369 | 3346 #if 0 |
771 | 3347 /* Look at the remarks in x_focus_on_frame. */ |
3348 if (x_focus_frame == f) | |
286 | 3349 XSetInputFocus (x_current_display, PointerRoot, |
3350 RevertToPointerRoot, CurrentTime); | |
369 | 3351 #endif |
286 | 3352 } |
3353 | |
3354 #endif | |
3355 | |
771 | 3356 /* Raise frame F. */ |
3357 | |
3358 x_raise_frame (f) | |
3359 struct frame *f; | |
286 | 3360 { |
771 | 3361 if (f->visible) |
286 | 3362 { |
3363 BLOCK_INPUT; | |
771 | 3364 XRaiseWindow (XDISPLAY f->display.x->window_desc); |
286 | 3365 XFlushQueue (); |
3366 UNBLOCK_INPUT; | |
3367 } | |
3368 } | |
3369 | |
771 | 3370 /* Lower frame F. */ |
3371 | |
3372 x_lower_frame (f) | |
3373 struct frame *f; | |
286 | 3374 { |
771 | 3375 if (f->visible) |
286 | 3376 { |
3377 BLOCK_INPUT; | |
771 | 3378 XLowerWindow (XDISPLAY f->display.x->window_desc); |
286 | 3379 XFlushQueue (); |
3380 UNBLOCK_INPUT; | |
3381 } | |
3382 } | |
3383 | |
3384 /* Change from withdrawn state to mapped state. */ | |
3385 | |
771 | 3386 x_make_frame_visible (f) |
3387 struct frame *f; | |
286 | 3388 { |
3389 int mask; | |
3390 | |
429 | 3391 BLOCK_INPUT; |
3392 | |
771 | 3393 if (! FRAME_VISIBLE_P (f)) |
286 | 3394 { |
3395 #ifdef HAVE_X11 | |
429 | 3396 if (! EQ (Vx_no_window_manager, Qt)) |
771 | 3397 x_wm_set_window_state (f, NormalState); |
3398 | |
3399 XMapWindow (XDISPLAY f->display.x->window_desc); | |
3400 if (f->display.x->v_scrollbar != 0 || f->display.x->h_scrollbar != 0) | |
3401 XMapSubwindows (x_current_display, f->display.x->window_desc); | |
286 | 3402 #else |
771 | 3403 XMapWindow (XDISPLAY f->display.x->window_desc); |
3404 if (f->display.x->icon_desc != 0) | |
3405 XUnmapWindow (f->display.x->icon_desc); | |
429 | 3406 |
3407 /* Handled by the MapNotify event for X11 */ | |
771 | 3408 f->visible = 1; |
3409 f->iconified = 0; | |
3410 | |
3411 /* NOTE: this may cause problems for the first frame. */ | |
429 | 3412 XTcursor_to (0, 0); |
3413 #endif /* not HAVE_X11 */ | |
3414 } | |
286 | 3415 |
3416 XFlushQueue (); | |
429 | 3417 |
286 | 3418 UNBLOCK_INPUT; |
3419 } | |
3420 | |
3421 /* Change from mapped state to withdrawn state. */ | |
3422 | |
771 | 3423 x_make_frame_invisible (f) |
3424 struct frame *f; | |
286 | 3425 { |
3426 int mask; | |
3427 | |
771 | 3428 if (! f->visible) |
286 | 3429 return; |
3430 | |
3431 BLOCK_INPUT; | |
3432 #ifdef HAVE_X11 | |
3433 #if 0 | |
3434 if (! EQ (Vx_no_window_manager, Qt)) | |
3435 { | |
3436 XUnmapEvent unmap; | |
3437 | |
3438 unmap.type = UnmapNotify; | |
771 | 3439 unmap.window = f->display.x->window_desc; |
286 | 3440 unmap.event = DefaultRootWindow (x_current_display); |
3441 unmap.from_configure = False; | |
3442 XSendEvent (x_current_display, DefaultRootWindow (x_current_display), | |
3443 False, SubstructureRedirectMask|SubstructureNotifyMask, | |
3444 &unmap); | |
3445 } | |
3446 | |
3447 /* The new function below does the same as the above code, plus unmapping | |
3448 the window. Sending the event without actually unmapping can make | |
3449 the window manager start ignoring the window (i.e., no more title bar, | |
3450 icon manager stuff.) */ | |
3451 #endif | |
3452 | |
3453 /* New function available with R4 */ | |
771 | 3454 if (! XWithdrawWindow (x_current_display, f->display.x->window_desc, |
286 | 3455 DefaultScreen (x_current_display))) |
3456 { | |
3457 UNBLOCK_INPUT_RESIGNAL; | |
3458 error ("Can't notify window manager of iconification."); | |
3459 } | |
3460 | |
3461 #else | |
771 | 3462 XUnmapWindow (XDISPLAY f->display.x->window_desc); |
3463 | |
3464 f->visible = 0; /* Handled by the UnMap event for X11 */ | |
3465 if (f->display.x->icon_desc != 0) | |
3466 XUnmapWindow (XDISPLAY f->display.x->icon_desc); | |
286 | 3467 #endif /* not HAVE_X11 */ |
3468 | |
3469 XFlushQueue (); | |
3470 UNBLOCK_INPUT; | |
3471 } | |
3472 | |
3473 /* Window manager communication. Created in Fx_open_connection. */ | |
3474 extern Atom Xatom_wm_change_state; | |
3475 | |
3476 /* Change window state from mapped to iconified. */ | |
3477 | |
771 | 3478 x_iconify_frame (f) |
3479 struct frame *f; | |
286 | 3480 { |
3481 int mask; | |
3482 | |
771 | 3483 if (f->iconified) |
286 | 3484 return; |
3485 | |
3486 BLOCK_INPUT; | |
3487 | |
3488 #ifdef HAVE_X11 | |
3489 if (! EQ (Vx_no_window_manager, Qt)) | |
771 | 3490 if (! XIconifyWindow (x_current_display, f->display.x->window_desc, |
286 | 3491 DefaultScreen (x_current_display))) |
3492 { | |
3493 UNBLOCK_INPUT_RESIGNAL; | |
3494 error ("Can't notify window manager of iconification."); | |
3495 } | |
3496 | |
771 | 3497 f->iconified = 1; |
286 | 3498 |
3499 #if 0 | |
3500 { | |
3501 XClientMessageEvent message; | |
3502 | |
771 | 3503 message.window = f->display.x->window_desc; |
286 | 3504 message.type = ClientMessage; |
3505 message.message_type = Xatom_wm_change_state; | |
3506 message.format = 32; | |
3507 message.data.l[0] = IconicState; | |
3508 | |
3509 if (! XSendEvent (x_current_display, | |
3510 DefaultRootWindow (x_current_display), | |
3511 False, | |
3512 SubstructureRedirectMask | SubstructureNotifyMask, | |
3513 &message)) | |
3514 { | |
3515 UNBLOCK_INPUT_RESIGNAL; | |
3516 error ("Can't notify window manager of iconification."); | |
3517 } | |
3518 } | |
3519 #endif | |
3520 #else /* X10 */ | |
771 | 3521 XUnmapWindow (XDISPLAY f->display.x->window_desc); |
3522 | |
3523 f->visible = 0; /* Handled in the UnMap event for X11. */ | |
3524 if (f->display.x->icon_desc != 0) | |
286 | 3525 { |
771 | 3526 XMapWindow (XDISPLAY f->display.x->icon_desc); |
3527 refreshicon (f); | |
286 | 3528 } |
3529 #endif /* X10 */ | |
3530 | |
3531 XFlushQueue (); | |
3532 UNBLOCK_INPUT; | |
3533 } | |
3534 | |
771 | 3535 /* Destroy the X window of frame F. |
3536 DISPL is the former f->display (since f->display | |
286 | 3537 has already been nulled out). */ |
3538 | |
771 | 3539 x_destroy_window (f, displ) |
3540 struct frame *f; | |
286 | 3541 union display displ; |
3542 { | |
3543 int mask; | |
3544 | |
3545 BLOCK_INPUT; | |
3546 if (displ.x->icon_desc != 0) | |
3547 XDestroyWindow (XDISPLAY displ.x->icon_desc); | |
3548 XDestroyWindow (XDISPLAY displ.x->window_desc); | |
3549 XFlushQueue (); | |
3550 UNBLOCK_INPUT; | |
3551 | |
3552 free (displ.x); | |
771 | 3553 if (f == x_focus_frame) |
3554 x_focus_frame = 0; | |
3555 if (f == x_highlight_frame) | |
3556 x_highlight_frame = 0; | |
286 | 3557 } |
3558 | |
3559 #ifndef HAVE_X11 | |
3560 | |
3561 /* Manage event queues. | |
3562 | |
3563 This code is only used by the X10 support. | |
3564 | |
3565 We cannot leave events in the X queue and get them when we are ready | |
3566 because X does not provide a subroutine to get only a certain kind | |
3567 of event but not block if there are no queued events of that kind. | |
3568 | |
3569 Therefore, we must examine events as they come in and copy events | |
3570 of certain kinds into our private queues. | |
3571 | |
3572 All ExposeRegion events are put in x_expose_queue. | |
3573 All ButtonPressed and ButtonReleased events are put in x_mouse_queue. */ | |
3574 | |
3575 | |
3576 /* Write the event *P_XREP into the event queue *QUEUE. | |
3577 If the queue is full, do nothing, but return nonzero. */ | |
3578 | |
3579 int | |
3580 enqueue_event (p_xrep, queue) | |
3581 register XEvent *p_xrep; | |
3582 register struct event_queue *queue; | |
3583 { | |
3584 int newindex = queue->windex + 1; | |
3585 if (newindex == EVENT_BUFFER_SIZE) | |
3586 newindex = 0; | |
3587 if (newindex == queue->rindex) | |
3588 return -1; | |
3589 queue->xrep[queue->windex] = *p_xrep; | |
3590 queue->windex = newindex; | |
3591 return 0; | |
3592 } | |
3593 | |
3594 /* Fetch the next event from queue *QUEUE and store it in *P_XREP. | |
3595 If *QUEUE is empty, do nothing and return 0. */ | |
3596 | |
3597 int | |
3598 dequeue_event (p_xrep, queue) | |
3599 register XEvent *p_xrep; | |
3600 register struct event_queue *queue; | |
3601 { | |
3602 if (queue->windex == queue->rindex) | |
3603 return 0; | |
3604 *p_xrep = queue->xrep[queue->rindex++]; | |
3605 if (queue->rindex == EVENT_BUFFER_SIZE) | |
3606 queue->rindex = 0; | |
3607 return 1; | |
3608 } | |
3609 | |
3610 /* Return the number of events buffered in *QUEUE. */ | |
3611 | |
3612 int | |
3613 queue_event_count (queue) | |
3614 register struct event_queue *queue; | |
3615 { | |
3616 int tem = queue->windex - queue->rindex; | |
3617 if (tem >= 0) | |
3618 return tem; | |
3619 return EVENT_BUFFER_SIZE + tem; | |
3620 } | |
3621 | |
3622 /* Return nonzero if mouse input is pending. */ | |
3623 | |
3624 int | |
3625 mouse_event_pending_p () | |
3626 { | |
3627 return queue_event_count (&x_mouse_queue); | |
3628 } | |
3629 #endif | |
3630 | |
3631 #ifdef HAVE_X11 | |
3632 | |
771 | 3633 x_wm_set_size_hint (f, prompting) |
3634 struct frame *f; | |
286 | 3635 long prompting; |
3636 { | |
3637 XSizeHints size_hints; | |
771 | 3638 Window window = f->display.x->window_desc; |
286 | 3639 |
3640 size_hints.flags = PResizeInc | PMinSize | PMaxSize; | |
3641 | |
771 | 3642 flexlines = f->height; |
3643 | |
3644 size_hints.x = f->display.x->left_pos; | |
3645 size_hints.y = f->display.x->top_pos; | |
3646 size_hints.height = PIXEL_HEIGHT (f); | |
3647 size_hints.width = PIXEL_WIDTH (f); | |
3648 size_hints.width_inc = FONT_WIDTH (f->display.x->font); | |
3649 size_hints.height_inc = FONT_HEIGHT (f->display.x->font); | |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3650 size_hints.max_width = |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3651 (x_screen_width - ((2 * f->display.x->internal_border_width) |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3652 + f->display.x->v_scrollbar_width)); |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3653 size_hints.max_height = |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3654 (x_screen_height - ((2 * f->display.x->internal_border_width) |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3655 + f->display.x->h_scrollbar_height)); |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3656 { |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3657 int base_width = ((2 * f->display.x->internal_border_width) |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3658 + f->display.x->v_scrollbar_width); |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3659 int base_height = ((2 * f->display.x->internal_border_width) |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3660 + f->display.x->h_scrollbar_height); |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3661 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3662 #ifdef PBaseSize |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3663 size_hints.flags |= PBaseSize; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3664 size_hints.base_width = base_width; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3665 size_hints.base_height = base_height; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3666 #endif |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3667 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3668 { |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3669 int min_rows = 0, min_cols = 0; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3670 check_frame_size (f, &min_rows, &min_cols); |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3671 size_hints.min_width = base_width + min_cols * size_hints.width_inc; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3672 size_hints.min_height = base_height + min_rows * size_hints.height_inc; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3673 } |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3674 } |
286 | 3675 |
3676 if (prompting) | |
3677 size_hints.flags |= prompting; | |
3678 else | |
3679 { | |
3680 XSizeHints hints; /* Sometimes I hate X Windows... */ | |
3681 | |
3682 XGetNormalHints (x_current_display, window, &hints); | |
3683 if (hints.flags & PSize) | |
3684 size_hints.flags |= PSize; | |
3685 if (hints.flags & PPosition) | |
3686 size_hints.flags |= PPosition; | |
3687 if (hints.flags & USPosition) | |
3688 size_hints.flags |= USPosition; | |
3689 if (hints.flags & USSize) | |
3690 size_hints.flags |= USSize; | |
3691 } | |
3692 | |
3693 #if 0 /* R3 */ | |
3694 XSetNormalHints (x_current_display, window, &size_hints); | |
3695 #endif | |
3696 XSetWMNormalHints (x_current_display, window, &size_hints); | |
3697 } | |
3698 | |
3699 /* Used for IconicState or NormalState */ | |
771 | 3700 x_wm_set_window_state (f, state) |
3701 struct frame *f; | |
286 | 3702 int state; |
3703 { | |
771 | 3704 Window window = f->display.x->window_desc; |
286 | 3705 |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3706 x_wm_hints.flags |= StateHint; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3707 x_wm_hints.initial_state = state; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3708 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3709 XSetWMHints (x_current_display, window, &x_wm_hints); |
286 | 3710 } |
3711 | |
771 | 3712 x_wm_set_icon_pixmap (f, icon_pixmap) |
3713 struct frame *f; | |
286 | 3714 Pixmap icon_pixmap; |
3715 { | |
771 | 3716 Window window = f->display.x->window_desc; |
286 | 3717 |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3718 if (icon_pixmap) |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3719 { |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3720 x_wm_hints.flags |= IconPixmapHint; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3721 x_wm_hints.icon_pixmap = icon_pixmap; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3722 } |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3723 else |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3724 x_wm_hints.flags &= ~IconPixmapHint; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3725 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3726 XSetWMHints (x_current_display, window, &x_wm_hints); |
286 | 3727 } |
3728 | |
771 | 3729 x_wm_set_icon_position (f, icon_x, icon_y) |
3730 struct frame *f; | |
286 | 3731 int icon_x, icon_y; |
3732 { | |
771 | 3733 Window window = f->display.x->window_desc; |
286 | 3734 |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3735 x_wm_hints.flags |= IconPositionHint; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3736 x_wm_hints.icon_x = icon_x; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3737 x_wm_hints.icon_y = icon_y; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3738 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3739 XSetWMHints (x_current_display, window, &x_wm_hints); |
286 | 3740 } |
3741 | |
3742 | |
3743 void | |
3744 x_term_init (display_name) | |
3745 char *display_name; | |
3746 { | |
771 | 3747 Lisp_Object frame; |
286 | 3748 char *defaultvalue; |
3749 #ifdef F_SETOWN | |
3750 extern int old_fcntl_owner; | |
3751 #endif | |
369 | 3752 |
771 | 3753 x_focus_frame = x_highlight_frame = 0; |
286 | 3754 |
3755 x_current_display = XOpenDisplay (display_name); | |
3756 if (x_current_display == 0) | |
3757 fatal ("X server %s not responding; check the DISPLAY environment variable or use \"-d\"\n", | |
3758 display_name); | |
3759 | |
3760 #ifdef HAVE_X11 | |
3761 { | |
398 | 3762 int hostname_size = MAXHOSTNAMELEN + 1; |
3763 | |
3764 hostname = (char *) xmalloc (hostname_size); | |
3765 | |
286 | 3766 #if 0 |
3767 XSetAfterFunction (x_current_display, x_trace_wire); | |
3768 #endif | |
3769 | |
395 | 3770 invocation_name = Ffile_name_nondirectory (Fcar (Vcommand_line_args)); |
398 | 3771 |
3772 /* Try to get the host name; if the buffer is too short, try | |
3773 again. Apparently, the only indication gethostname gives of | |
3774 whether the buffer was large enough is the presence or absence | |
3775 of a '\0' in the string. Eech. */ | |
3776 for (;;) | |
3777 { | |
3778 gethostname (hostname, hostname_size - 1); | |
3779 hostname[hostname_size - 1] = '\0'; | |
3780 | |
3781 /* Was the buffer large enough for gethostname to store the '\0'? */ | |
3782 if (strlen (hostname) < hostname_size - 1) | |
3783 break; | |
3784 | |
3785 hostname_size <<= 1; | |
3786 hostname = (char *) xrealloc (hostname, hostname_size); | |
3787 } | |
3788 x_id_name = (char *) xmalloc (XSTRING (invocation_name)->size | |
3789 + strlen (hostname) | |
3790 + 2); | |
3791 sprintf (x_id_name, "%s@%s", XSTRING (invocation_name)->data, hostname); | |
286 | 3792 } |
3793 | |
3794 dup2 (ConnectionNumber (x_current_display), 0); | |
369 | 3795 |
3796 #ifndef SYSV_STREAMS | |
3797 /* Streams somehow keeps track of which descriptor number | |
3798 is being used to talk to X. So it is not safe to substitute | |
3799 descriptor 0. But it is safe to make descriptor 0 a copy of it. */ | |
286 | 3800 close (ConnectionNumber (x_current_display)); |
369 | 3801 ConnectionNumber (x_current_display) = 0; /* Looks a little strange? |
3802 * check the def of the macro; | |
3803 * it is a genuine lvalue */ | |
3804 #endif /* not SYSV_STREAMS */ | |
3805 | |
286 | 3806 #endif /* HAVE_X11 */ |
3807 | |
3808 #ifdef F_SETOWN | |
3809 old_fcntl_owner = fcntl (0, F_GETOWN, 0); | |
3810 #ifdef F_SETOWN_SOCK_NEG | |
3811 fcntl (0, F_SETOWN, -getpid ()); /* stdin is a socket here */ | |
3812 #else | |
3813 fcntl (0, F_SETOWN, getpid ()); | |
3814 #endif /* F_SETOWN_SOCK_NEG */ | |
3815 #endif /* F_SETOWN */ | |
3816 | |
3817 #ifdef SIGIO | |
3818 init_sigio (); | |
3819 #endif | |
3820 | |
3821 /* Must use interrupt input because we cannot otherwise | |
3822 arrange for C-g to be noticed immediately. | |
3823 We cannot connect it to SIGINT. */ | |
3824 Fset_input_mode (Qt, Qnil, Qt, Qnil); | |
3825 | |
3826 expose_all_windows = 0; | |
3827 | |
771 | 3828 clear_frame_hook = XTclear_frame; |
286 | 3829 clear_end_of_line_hook = XTclear_end_of_line; |
3830 ins_del_lines_hook = XTins_del_lines; | |
3831 change_line_highlight_hook = XTchange_line_highlight; | |
3832 insert_glyphs_hook = XTinsert_glyphs; | |
3833 write_glyphs_hook = XTwrite_glyphs; | |
3834 delete_glyphs_hook = XTdelete_glyphs; | |
3835 ring_bell_hook = XTring_bell; | |
3836 reset_terminal_modes_hook = XTreset_terminal_modes; | |
3837 set_terminal_modes_hook = XTset_terminal_modes; | |
3838 update_begin_hook = XTupdate_begin; | |
3839 update_end_hook = XTupdate_end; | |
3840 set_terminal_window_hook = XTset_terminal_window; | |
3841 read_socket_hook = XTread_socket; | |
3842 cursor_to_hook = XTcursor_to; | |
3843 reassert_line_highlight_hook = XTreassert_line_highlight; | |
771 | 3844 frame_rehighlight_hook = XTframe_rehighlight; |
429 | 3845 mouse_position_hook = XTmouse_position; |
286 | 3846 |
771 | 3847 scroll_region_ok = 1; /* we'll scroll partial frames */ |
286 | 3848 char_ins_del_ok = 0; /* just as fast to write the line */ |
3849 line_ins_del_ok = 1; /* we'll just blt 'em */ | |
3850 fast_clear_end_of_line = 1; /* X does this well */ | |
771 | 3851 memory_below_frame = 0; /* we don't remember what scrolls |
286 | 3852 off the bottom */ |
3853 baud_rate = 19200; | |
3854 | |
3855 XHandleError (x_error_handler); | |
3856 XHandleIOError (x_error_handler); | |
3857 | |
3858 /* Disable Window Change signals; they are handled by X events. */ | |
3859 #ifdef SIGWINCH | |
3860 signal (SIGWINCH, SIG_DFL); | |
3861 #endif /* SIGWINCH */ | |
3862 | |
621 | 3863 signal (SIGPIPE, x_death_handler); |
976
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3864 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3865 /* When XSetWMHints eventually gets called, this will indicate that |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3866 we use the "Passive Input" input model. Unless we do this, we |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3867 don't get the Focus{In,Out} events that we need to draw the |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3868 cursor correctly. Accursed bureaucrats. |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3869 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3870 We set this here and leave it, because we know, being decidedly |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3871 non-humble programmers (nay, weigh'd low by our hubris!), that |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3872 Fx_create_frame calls x_icon which begat x_wm_set_window_state |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3873 which begat XSetWMHints, which will get this information to the |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3874 right parties. |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3875 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3876 XWhipsAndChains (x_current_display, IronMaiden, &TheRack); */ |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3877 |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3878 x_wm_hints.input = True; |
cbdfc337ec8f
* xterm.c (x_wm_hints): New variable.
Jim Blandy <jimb@redhat.com>
parents:
786
diff
changeset
|
3879 x_wm_hints.flags |= InputHint; |
286 | 3880 } |
395 | 3881 |
3882 void | |
3883 syms_of_xterm () | |
3884 { | |
3885 staticpro (&invocation_name); | |
3886 invocation_name = Qnil; | |
3887 } | |
286 | 3888 #endif /* HAVE_X11 */ |
3889 #endif /* HAVE_X_WINDOWS */ |