diff options
| author | Richard M. Stallman | 1994-10-29 09:43:07 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-10-29 09:43:07 +0000 |
| commit | 7f9c7f949a9e137e4be310474b574003f98e51c5 (patch) | |
| tree | 69b76582067631e676bc8aae3b340fe834997986 /src | |
| parent | a4332c3f491b585a2141be5d8a7f77e592488cd7 (diff) | |
| download | emacs-7f9c7f949a9e137e4be310474b574003f98e51c5.tar.gz emacs-7f9c7f949a9e137e4be310474b574003f98e51c5.zip | |
(x_delete_display): Call XrmDestroyDatabase.
(x_destroy_window): Rewrite to fetch dpyinfo just once.
[USE_X_TOOLKIT]: Make application context explicitly
and support multiple top-level shells.
(x_initialize): Call XtToolkitInitialize, XtCreateApplicationContext;
don't open display or make a shell.
(x_term_init): Call XtOpenDisplay.
(x_scroll_bar_create): Use XMapRaised directly.
(x_make_frame_visible, x_iconify_frame): Likewise.
(XMapWindow): Macro definition deleted.
(METABIT): Macro deleted.
(MAXDESC, FD_SETSIZE, FD_SET, FD_CLEAR, FD_ZERO, FD_ISSET): Likewise.
(x_id_name): Variable deleted.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 156 |
1 files changed, 50 insertions, 106 deletions
diff --git a/src/xterm.c b/src/xterm.c index e70513a24aa..f17efc2c488 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -83,8 +83,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 83 | #include "intervals.h" | 83 | #include "intervals.h" |
| 84 | 84 | ||
| 85 | #ifdef USE_X_TOOLKIT | 85 | #ifdef USE_X_TOOLKIT |
| 86 | extern XtAppContext Xt_app_con; | ||
| 87 | extern Widget Xt_app_shell; | ||
| 88 | extern void free_frame_menubar (); | 86 | extern void free_frame_menubar (); |
| 89 | extern void _XEditResCheckMessages (); | 87 | extern void _XEditResCheckMessages (); |
| 90 | #endif /* USE_X_TOOLKIT */ | 88 | #endif /* USE_X_TOOLKIT */ |
| @@ -100,39 +98,9 @@ extern void _XEditResCheckMessages (); | |||
| 100 | #endif | 98 | #endif |
| 101 | #endif | 99 | #endif |
| 102 | 100 | ||
| 103 | #define XMapWindow XMapRaised /* Raise them when mapping. */ | ||
| 104 | |||
| 105 | #ifdef FD_SET | ||
| 106 | /* We could get this from param.h, but better not to depend on finding that. | ||
| 107 | And better not to risk that it might define other symbols used in this | ||
| 108 | file. */ | ||
| 109 | #ifdef FD_SETSIZE | ||
| 110 | #define MAXDESC FD_SETSIZE | ||
| 111 | #else | ||
| 112 | #define MAXDESC 64 | ||
| 113 | #endif | ||
| 114 | #define SELECT_TYPE fd_set | ||
| 115 | #else /* no FD_SET */ | ||
| 116 | #define MAXDESC 32 | ||
| 117 | #define SELECT_TYPE int | ||
| 118 | |||
| 119 | /* Define the macros to access a single-int bitmap of descriptors. */ | ||
| 120 | #define FD_SET(n, p) (*(p) |= (1 << (n))) | ||
| 121 | #define FD_CLR(n, p) (*(p) &= ~(1 << (n))) | ||
| 122 | #define FD_ISSET(n, p) (*(p) & (1 << (n))) | ||
| 123 | #define FD_ZERO(p) (*(p) = 0) | ||
| 124 | #endif /* no FD_SET */ | ||
| 125 | |||
| 126 | /* For sending Meta-characters. Do we need this? */ | ||
| 127 | #define METABIT 0200 | ||
| 128 | |||
| 129 | #define min(a,b) ((a)<(b) ? (a) : (b)) | 101 | #define min(a,b) ((a)<(b) ? (a) : (b)) |
| 130 | #define max(a,b) ((a)>(b) ? (a) : (b)) | 102 | #define max(a,b) ((a)>(b) ? (a) : (b)) |
| 131 | 103 | ||
| 132 | /* Stuff for dealing with the main icon title. */ | ||
| 133 | |||
| 134 | char *x_id_name; | ||
| 135 | |||
| 136 | /* This is a chain of structures for all the X displays currently in use. */ | 104 | /* This is a chain of structures for all the X displays currently in use. */ |
| 137 | struct x_display_info *x_display_list; | 105 | struct x_display_info *x_display_list; |
| 138 | 106 | ||
| @@ -172,6 +140,11 @@ struct frame *x_focus_event_frame; | |||
| 172 | minibuffer. */ | 140 | minibuffer. */ |
| 173 | static struct frame *x_highlight_frame; | 141 | static struct frame *x_highlight_frame; |
| 174 | 142 | ||
| 143 | #ifdef USE_X_TOOLKIT | ||
| 144 | /* The application context for Xt use. */ | ||
| 145 | XtAppContext Xt_app_con; | ||
| 146 | #endif | ||
| 147 | |||
| 175 | /* During an update, maximum vpos for ins/del line operations to affect. */ | 148 | /* During an update, maximum vpos for ins/del line operations to affect. */ |
| 176 | 149 | ||
| 177 | static int flexlines; | 150 | static int flexlines; |
| @@ -2440,7 +2413,7 @@ x_scroll_bar_create (window, top, left, width, height) | |||
| 2440 | if (! NILP (bar->next)) | 2413 | if (! NILP (bar->next)) |
| 2441 | XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); | 2414 | XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); |
| 2442 | 2415 | ||
| 2443 | XMapWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); | 2416 | XMapRaised (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); |
| 2444 | 2417 | ||
| 2445 | UNBLOCK_INPUT; | 2418 | UNBLOCK_INPUT; |
| 2446 | 2419 | ||
| @@ -3972,33 +3945,6 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 3972 | } | 3945 | } |
| 3973 | } | 3946 | } |
| 3974 | 3947 | ||
| 3975 | #if 0 /* This fails for serial-line connections to the X server, | ||
| 3976 | because the characters arrive one by one, and a partial | ||
| 3977 | command makes select return but gives nothing to read. | ||
| 3978 | We'll have to hope that the bug that this tried to fix | ||
| 3979 | in 1988 has been fixed in Xlib or the X server. */ | ||
| 3980 | #ifdef HAVE_SELECT | ||
| 3981 | if (expected && ! event_found) | ||
| 3982 | { | ||
| 3983 | /* AOJ 880406: if select returns true but XPending doesn't, it means that | ||
| 3984 | there is an EOF condition; in other words, that X has died. | ||
| 3985 | Act as if there had been a hangup. */ | ||
| 3986 | int fd = ConnectionNumber (dpyinfo->display); | ||
| 3987 | SELECT_TYPE mask, junk1, junk2; | ||
| 3988 | EMACS_TIME timeout; | ||
| 3989 | |||
| 3990 | FD_ZERO (&mask); | ||
| 3991 | FD_SET (fd, &mask); | ||
| 3992 | EMACS_SET_SECS_USECS (timeout, 0, 0); | ||
| 3993 | FD_ZERO (&junk1); | ||
| 3994 | FD_ZERO (&junk2); | ||
| 3995 | if (0 != select (fd + 1, &mask, &junk1, &junk2, &timeout) | ||
| 3996 | && !XPending (dpyinfo->display)) | ||
| 3997 | kill (getpid (), SIGHUP); | ||
| 3998 | } | ||
| 3999 | #endif /* HAVE_SELECT */ | ||
| 4000 | #endif /* 0 */ | ||
| 4001 | |||
| 4002 | /* If the focus was just given to an autoraising frame, | 3948 | /* If the focus was just given to an autoraising frame, |
| 4003 | raise it now. */ | 3949 | raise it now. */ |
| 4004 | /* ??? This ought to be able to handle more than one such frame. */ | 3950 | /* ??? This ought to be able to handle more than one such frame. */ |
| @@ -5020,7 +4966,7 @@ x_make_frame_visible (f) | |||
| 5020 | /* This was XtPopup, but that did nothing for an iconified frame. */ | 4966 | /* This was XtPopup, but that did nothing for an iconified frame. */ |
| 5021 | XtMapWidget (f->display.x->widget); | 4967 | XtMapWidget (f->display.x->widget); |
| 5022 | #else /* not USE_X_TOOLKIT */ | 4968 | #else /* not USE_X_TOOLKIT */ |
| 5023 | XMapWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); | 4969 | XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); |
| 5024 | #endif /* not USE_X_TOOLKIT */ | 4970 | #endif /* not USE_X_TOOLKIT */ |
| 5025 | #if 0 /* This seems to bring back scroll bars in the wrong places | 4971 | #if 0 /* This seems to bring back scroll bars in the wrong places |
| 5026 | if the window configuration has changed. They seem | 4972 | if the window configuration has changed. They seem |
| @@ -5246,11 +5192,7 @@ x_iconify_frame (f) | |||
| 5246 | if (!FRAME_VISIBLE_P (f)) | 5192 | if (!FRAME_VISIBLE_P (f)) |
| 5247 | { | 5193 | { |
| 5248 | /* If the frame was withdrawn, before, we must map it. */ | 5194 | /* If the frame was withdrawn, before, we must map it. */ |
| 5249 | XMapWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); | 5195 | XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); |
| 5250 | #if 0 /* We don't have subwindows in the icon. */ | ||
| 5251 | if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) | ||
| 5252 | XMapSubwindows (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); | ||
| 5253 | #endif | ||
| 5254 | } | 5196 | } |
| 5255 | 5197 | ||
| 5256 | f->async_iconified = 1; | 5198 | f->async_iconified = 1; |
| @@ -5265,6 +5207,8 @@ x_iconify_frame (f) | |||
| 5265 | x_destroy_window (f) | 5207 | x_destroy_window (f) |
| 5266 | struct frame *f; | 5208 | struct frame *f; |
| 5267 | { | 5209 | { |
| 5210 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 5211 | |||
| 5268 | BLOCK_INPUT; | 5212 | BLOCK_INPUT; |
| 5269 | 5213 | ||
| 5270 | if (f->display.x->icon_desc != 0) | 5214 | if (f->display.x->icon_desc != 0) |
| @@ -5278,12 +5222,6 @@ x_destroy_window (f) | |||
| 5278 | free_frame_faces (f); | 5222 | free_frame_faces (f); |
| 5279 | XFlush (FRAME_X_DISPLAY (f)); | 5223 | XFlush (FRAME_X_DISPLAY (f)); |
| 5280 | 5224 | ||
| 5281 | FRAME_X_DISPLAY_INFO (f)->reference_count--; | ||
| 5282 | #if 0 | ||
| 5283 | if (FRAME_X_DISPLAY_INFO (f)->reference_count == 0) | ||
| 5284 | free (FRAME_X_DISPLAY_INFO (f)); | ||
| 5285 | #endif | ||
| 5286 | |||
| 5287 | xfree (f->display.x); | 5225 | xfree (f->display.x); |
| 5288 | f->display.x = 0; | 5226 | f->display.x = 0; |
| 5289 | if (f == x_focus_frame) | 5227 | if (f == x_focus_frame) |
| @@ -5291,13 +5229,15 @@ x_destroy_window (f) | |||
| 5291 | if (f == x_highlight_frame) | 5229 | if (f == x_highlight_frame) |
| 5292 | x_highlight_frame = 0; | 5230 | x_highlight_frame = 0; |
| 5293 | 5231 | ||
| 5294 | if (f == FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame) | 5232 | dpyinfo->reference_count--; |
| 5233 | |||
| 5234 | if (f == dpyinfo->mouse_face_mouse_frame) | ||
| 5295 | { | 5235 | { |
| 5296 | FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row | 5236 | dpyinfo->mouse_face_beg_row |
| 5297 | = FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_col = -1; | 5237 | = dpyinfo->mouse_face_beg_col = -1; |
| 5298 | FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row | 5238 | dpyinfo->mouse_face_end_row |
| 5299 | = FRAME_X_DISPLAY_INFO (f)->mouse_face_end_col = -1; | 5239 | = dpyinfo->mouse_face_end_col = -1; |
| 5300 | FRAME_X_DISPLAY_INFO (f)->mouse_face_window = Qnil; | 5240 | dpyinfo->mouse_face_window = Qnil; |
| 5301 | } | 5241 | } |
| 5302 | 5242 | ||
| 5303 | UNBLOCK_INPUT; | 5243 | UNBLOCK_INPUT; |
| @@ -5523,8 +5463,6 @@ x_term_init (display_name, xrm_option, resource_name) | |||
| 5523 | { | 5463 | { |
| 5524 | Lisp_Object frame; | 5464 | Lisp_Object frame; |
| 5525 | char *defaultvalue; | 5465 | char *defaultvalue; |
| 5526 | int argc = 0; | ||
| 5527 | char** argv = 0; | ||
| 5528 | int connection; | 5466 | int connection; |
| 5529 | Display *dpy; | 5467 | Display *dpy; |
| 5530 | struct x_display_info *dpyinfo; | 5468 | struct x_display_info *dpyinfo; |
| @@ -5541,25 +5479,22 @@ x_term_init (display_name, xrm_option, resource_name) | |||
| 5541 | XtSetLanguageProc (NULL, NULL, NULL); | 5479 | XtSetLanguageProc (NULL, NULL, NULL); |
| 5542 | #endif | 5480 | #endif |
| 5543 | 5481 | ||
| 5544 | argv = (char **) XtMalloc (7 * sizeof (char *)); | 5482 | { |
| 5545 | argv[0] = ""; | 5483 | int argc = 0; |
| 5546 | argv[1] = "-display"; | 5484 | char *argv[3]; |
| 5547 | argv[2] = XSTRING (display_name)->data; | 5485 | |
| 5548 | argv[3] = "-name"; | 5486 | argv[0] = ""; |
| 5549 | /* Usually `emacs', but not always. */ | 5487 | argc = 1; |
| 5550 | argv[4] = resource_name; | 5488 | if (xrm_option) |
| 5551 | argc = 5; | 5489 | { |
| 5552 | if (xrm_option) | 5490 | argv[argc++] = "-xrm"; |
| 5553 | { | 5491 | argv[argc++] = xrm_option; |
| 5554 | argv[argc++] = "-xrm"; | 5492 | } |
| 5555 | argv[argc++] = xrm_option; | 5493 | dpy = XtOpenDisplay (Xt_app_con, XSTRING (display_name)->data, |
| 5556 | } | 5494 | resource_name, EMACS_CLASS, |
| 5557 | Xt_app_shell = XtAppInitialize (&Xt_app_con, "Emacs", | 5495 | emacs_options, XtNumber (emacs_options), |
| 5558 | emacs_options, XtNumber (emacs_options), | 5496 | &argc, argv); |
| 5559 | &argc, argv, | 5497 | } |
| 5560 | NULL, NULL, 0); | ||
| 5561 | XtFree ((char *)argv); | ||
| 5562 | dpy = XtDisplay (Xt_app_shell); | ||
| 5563 | 5498 | ||
| 5564 | #else /* not USE_X_TOOLKIT */ | 5499 | #else /* not USE_X_TOOLKIT */ |
| 5565 | #ifdef HAVE_X11R5 | 5500 | #ifdef HAVE_X11R5 |
| @@ -5738,15 +5673,19 @@ x_delete_display (dpyinfo) | |||
| 5738 | 5673 | ||
| 5739 | if (x_display_list == dpyinfo) | 5674 | if (x_display_list == dpyinfo) |
| 5740 | x_display_list = dpyinfo->next; | 5675 | x_display_list = dpyinfo->next; |
| 5741 | { | 5676 | else |
| 5742 | struct x_display_info *tail; | 5677 | { |
| 5678 | struct x_display_info *tail; | ||
| 5743 | 5679 | ||
| 5744 | for (tail = x_display_list; tail; tail = tail->next) | 5680 | for (tail = x_display_list; tail; tail = tail->next) |
| 5745 | if (tail->next == dpyinfo) | 5681 | if (tail->next == dpyinfo) |
| 5746 | tail->next = tail->next->next; | 5682 | tail->next = tail->next->next; |
| 5747 | } | 5683 | } |
| 5748 | 5684 | ||
| 5749 | /* ??? Should free the xrdb slot somehow? */ | 5685 | #ifndef USE_X_TOOLKIT |
| 5686 | /* I'm told Xt does this itself. */ | ||
| 5687 | XrmDestroyDatabase (dpyinfo->xrdb); | ||
| 5688 | #endif | ||
| 5750 | free (dpyinfo->font_table); | 5689 | free (dpyinfo->font_table); |
| 5751 | free (dpyinfo->x_id_name); | 5690 | free (dpyinfo->x_id_name); |
| 5752 | free (dpyinfo); | 5691 | free (dpyinfo); |
| @@ -5796,6 +5735,11 @@ x_initialize () | |||
| 5796 | /* Try to use interrupt input; if we can't, then start polling. */ | 5735 | /* Try to use interrupt input; if we can't, then start polling. */ |
| 5797 | Fset_input_mode (Qt, Qnil, Qt, Qnil); | 5736 | Fset_input_mode (Qt, Qnil, Qt, Qnil); |
| 5798 | 5737 | ||
| 5738 | #ifdef USE_X_TOOLKIT | ||
| 5739 | XtToolkitInitialize (); | ||
| 5740 | Xt_app_con = XtCreateApplicationContext (); | ||
| 5741 | #endif | ||
| 5742 | |||
| 5799 | /* Note that there is no real way portable across R3/R4 to get the | 5743 | /* Note that there is no real way portable across R3/R4 to get the |
| 5800 | original error handler. */ | 5744 | original error handler. */ |
| 5801 | XSetErrorHandler (x_error_quitter); | 5745 | XSetErrorHandler (x_error_quitter); |