comparison src/device-x.c @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 56c54cf7c5b6
children 54cc21c15cbb
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
97 97
98 /************************************************************************/ 98 /************************************************************************/
99 /* helper functions */ 99 /* helper functions */
100 /************************************************************************/ 100 /************************************************************************/
101 101
102 static struct device * 102 struct device *
103 get_device_from_display_1 (Display *dpy) 103 get_device_from_display (Display *dpy)
104 { 104 {
105 Lisp_Object devcons, concons; 105 Lisp_Object devcons, concons;
106 106
107 DEVICE_LOOP_NO_BREAK (devcons, concons) 107 DEVICE_LOOP_NO_BREAK (devcons, concons)
108 { 108 {
109 struct device *d = XDEVICE (XCAR (devcons)); 109 struct device *d = XDEVICE (XCAR (devcons));
110 if (DEVICE_X_P (d) && DEVICE_X_DISPLAY (d) == dpy) 110 if (DEVICE_X_P (d) && DEVICE_X_DISPLAY (d) == dpy)
111 return d; 111 return d;
112 } 112 }
113 113
114 return 0; 114 /* Only devices we are actually managing should ever be used as an
115 } 115 argument to this function. */
116 116 abort ();
117 struct device * 117
118 get_device_from_display (Display *dpy) 118 return 0; /* suppress compiler warning */
119 {
120 struct device *d = get_device_from_display_1 (dpy);
121
122 if (!d) {
123 /* This isn't one of our displays. Let's crash? */
124 stderr_out
125 ("\n%s: Fatal X Condition. Asked about display we don't own: \"%s\"\n",
126 (STRINGP (Vinvocation_name) ?
127 (char *) XSTRING_DATA (Vinvocation_name) : "xemacs"),
128 DisplayString (dpy) ? DisplayString (dpy) : "???");
129 abort();
130 }
131
132 return d;
133 } 119 }
134 120
135 struct device * 121 struct device *
136 decode_x_device (Lisp_Object device) 122 decode_x_device (Lisp_Object device)
137 { 123 {
236 XSETDEVICE (device, d); 222 XSETDEVICE (device, d);
237 display = DEVICE_CONNECTION (d); 223 display = DEVICE_CONNECTION (d);
238 224
239 allocate_x_device_struct (d); 225 allocate_x_device_struct (d);
240 226
227 if (NILP (Vdefault_x_device))
228 Vdefault_x_device = device;
229
241 make_argc_argv (Vx_initial_argv_list, &argc, &argv); 230 make_argc_argv (Vx_initial_argv_list, &argc, &argv);
242 231
243 if (STRINGP (Vx_emacs_application_class) && 232 if (STRINGP (Vx_emacs_application_class) &&
244 XSTRING_LENGTH (Vx_emacs_application_class) > 0) 233 XSTRING_LENGTH (Vx_emacs_application_class) > 0)
245 GET_C_STRING_CTEXT_DATA_ALLOCA (Vx_emacs_application_class, app_class); 234 GET_C_STRING_CTEXT_DATA_ALLOCA (Vx_emacs_application_class, app_class);
259 { 248 {
260 suppress_early_backtrace = 1; 249 suppress_early_backtrace = 1;
261 signal_simple_error ("X server not responding\n", display); 250 signal_simple_error ("X server not responding\n", display);
262 } 251 }
263 252
264 if (NILP (Vdefault_x_device)) 253 #ifdef MULE
265 Vdefault_x_device = device; 254 {
255 /* Read in locale-specific resources from
256 data-directory/app-defaults/$LANG/emacs-application-class.
257 This is in addition to the standard app-defaults files, and
258 does not override resources defined elsewhere */
259 CONST char *data_dir;
260 char path[MAXPATHLEN];
261 XrmDatabase db = XtDatabase (dpy); /* ### XtScreenDatabase(dpy) ? */
262 CONST char *locale = XrmLocaleOfDatabase (db);
263
264 if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0)
265 GET_C_STRING_FILENAME_DATA_ALLOCA (Vdata_directory, data_dir);
266 sprintf (path, "%sapp-defaults/%s/%s", data_dir, locale, app_class);
267 if (!access (path, R_OK))
268 XrmCombineFileDatabase (path, &db, False);
269 }
270 #endif
266 271
267 if (NILP (DEVICE_NAME (d))) 272 if (NILP (DEVICE_NAME (d)))
268 DEVICE_NAME (d) = display; 273 DEVICE_NAME (d) = display;
269 274
270 /* We're going to modify the string in-place, so be a nice XEmacs */ 275 /* We're going to modify the string in-place, so be a nice XEmacs */
274 validify_resource_string ((char *) XSTRING_DATA (DEVICE_NAME (d))); 279 validify_resource_string ((char *) XSTRING_DATA (DEVICE_NAME (d)));
275 DEVICE_XT_APP_SHELL (d) = XtAppCreateShell (NULL, app_class, 280 DEVICE_XT_APP_SHELL (d) = XtAppCreateShell (NULL, app_class,
276 applicationShellWidgetClass, 281 applicationShellWidgetClass,
277 dpy, NULL, 0); 282 dpy, NULL, 0);
278 283
284 #ifdef HAVE_XIM
285 XIM_init_device(d);
286 #endif /* HAVE_XIM */
279 287
280 Vx_initial_argv_list = make_arg_list (argc, argv); 288 Vx_initial_argv_list = make_arg_list (argc, argv);
281 free_argc_argv (argv); 289 free_argc_argv (argv);
282 290
283 DEVICE_X_WM_COMMAND_FRAME (d) = Qnil; 291 DEVICE_X_WM_COMMAND_FRAME (d) = Qnil;
368 Lisp_Object devcons, concons; 376 Lisp_Object devcons, concons;
369 /* #### handle deleting last X device */ 377 /* #### handle deleting last X device */
370 Vdefault_x_device = Qnil; 378 Vdefault_x_device = Qnil;
371 DEVICE_LOOP_NO_BREAK (devcons, concons) 379 DEVICE_LOOP_NO_BREAK (devcons, concons)
372 { 380 {
373 if (DEVICE_X_P (XDEVICE (XCAR (devcons))) && 381 if (DEVICE_X_P (XDEVICE (XCAR (devcons))))
374 !EQ (device, XCAR (devcons)))
375 { 382 {
376 Vdefault_x_device = XCAR (devcons); 383 Vdefault_x_device = XCAR (devcons);
377 goto double_break; 384 goto double_break;
378 } 385 }
379 } 386 }
591 int 598 int
592 x_IO_error_handler (Display *disp) 599 x_IO_error_handler (Display *disp)
593 { 600 {
594 /* This function can GC */ 601 /* This function can GC */
595 Lisp_Object dev; 602 Lisp_Object dev;
596 struct device *d = get_device_from_display_1 (disp); 603 struct device *d = get_device_from_display (disp);
597 604 XSETDEVICE (dev, d);
598 if (d)
599 XSETDEVICE (dev, d);
600 else
601 dev = Qnil;
602 605
603 if (NILP (find_nonminibuffer_frame_not_on_device (dev))) 606 if (NILP (find_nonminibuffer_frame_not_on_device (dev)))
604 { 607 {
605 /* We're going down. */ 608 /* We're going down. */
606 stderr_out 609 stderr_out
624 errno, strerror (errno), DisplayString (disp), 627 errno, strerror (errno), DisplayString (disp),
625 NextRequest (disp) - 1, LastKnownRequestProcessed (disp), 628 NextRequest (disp) - 1, LastKnownRequestProcessed (disp),
626 QLength (disp)); 629 QLength (disp));
627 } 630 }
628 631
629 if (d) 632 enqueue_magic_eval_event (io_error_delete_device, dev);
630 enqueue_magic_eval_event (io_error_delete_device, dev);
631 633
632 return 0; 634 return 0;
633 } 635 }
634 636
635 DEFUN ("x-debug-mode", Fx_debug_mode, 1, 2, 0, /* 637 DEFUN ("x-debug-mode", Fx_debug_mode, 1, 2, 0, /*