#include "objects-x.h"
#include "buffer.h"
+#include "elhash.h"
#include "events.h"
#include "faces.h"
#include "frame.h"
Lisp_Object Qx_error;
Lisp_Object Qinit_pre_x_win, Qinit_post_x_win;
-/* \e$B@ZJ"\e(B, n. Japanese ritual suicide. */
-int x_seppuku_on_epipe;
-
/* The application class of Emacs. */
Lisp_Object Vx_emacs_application_class;
CONST char *app_class;
CONST char *app_name;
CONST char *disp_name;
- Arg xargs[6];
- Cardinal numargs;
Visual *visual = NULL;
int depth = 8; /* shut up the compiler */
Colormap cmap;
XtNumber (emacs_options), &argc, argv);
speed_up_interrupts ();
- screen = DefaultScreen(dpy);
+ screen = DefaultScreen (dpy);
if (NILP (Vdefault_x_device))
Vdefault_x_device = device;
does not override resources defined elsewhere */
CONST char *data_dir;
char *path;
- XrmDatabase db = XtDatabase (dpy); /* ### XtScreenDatabase(dpy) ? */
+ XrmDatabase db = XtDatabase (dpy); /* #### XtScreenDatabase(dpy) ? */
CONST char *locale = XrmLocaleOfDatabase (db);
if (STRINGP (Vx_app_defaults_directory) &&
XtGetApplicationNameAndClass (dpy, (char **) &app_name, (char **) &app_class);
/* search for a matching visual if requested by the user, or setup the display default */
- numargs = 0;
{
- char *buf1 = (char *)alloca (strlen (app_name) + 17);
+ char *buf1 = (char *)alloca (strlen (app_name) + 17);
char *buf2 = (char *)alloca (strlen (app_class) + 17);
char *type;
XrmValue value;
sprintf (buf2, "%s.EmacsVisual", app_class);
if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)
{
- int cnt = 0, vis_class= PseudoColor;
+ int cnt = 0, vis_class = PseudoColor;
XVisualInfo vinfo;
char *res, *str = (char*)value.addr;
- if (strncmp(str, "StaticGray", 10) == 0) cnt = 10, vis_class = StaticGray;
- else if (strncmp(str, "StaticColor", 11) == 0) cnt = 11, vis_class = StaticColor;
- else if (strncmp(str, "TrueColor", 9) == 0) cnt = 9, vis_class = TrueColor;
- else if (strncmp(str, "GrayScale", 9) == 0) cnt = 9, vis_class = GrayScale;
- else if (strncmp(str, "PseudoColor", 11) == 0) cnt = 11, vis_class = PseudoColor;
- else if (strncmp(str, "DirectColor", 11) == 0) cnt = 11, vis_class = DirectColor;
+#define CHECK_VIS_CLASS(class) \
+ else if (strncmp (str, #class, sizeof (#class) - 1) == 0) \
+ cnt = sizeof (#class) - 1, vis_class = class
+
+ if (1)
+ ;
+ CHECK_VIS_CLASS (StaticGray);
+ CHECK_VIS_CLASS (StaticColor);
+ CHECK_VIS_CLASS (TrueColor);
+ CHECK_VIS_CLASS (GrayScale);
+ CHECK_VIS_CLASS (PseudoColor);
+ CHECK_VIS_CLASS (DirectColor);
+
if (cnt)
{
res = str + cnt;
- depth = atoi(res);
+ depth = atoi (res);
if (depth == 0)
{
- stderr_out("Invalid Depth specification in %s... ignoring...\n",(char*)str);
+ stderr_out ("Invalid Depth specification in %s... ignoring...\n", str);
}
else
{
- if (XMatchVisualInfo(dpy, screen, depth, vis_class, &vinfo))
+ if (XMatchVisualInfo (dpy, screen, depth, vis_class, &vinfo))
{
visual = vinfo.visual;
}
else
{
- stderr_out("Can't match the requested visual %s... using defaults\n",str);
+ stderr_out ("Can't match the requested visual %s... using defaults\n", str);
}
}
}
else
{
- stderr_out("Invalid Visual specification in %s... ignoring.\n",(char*)str);
+ stderr_out( "Invalid Visual specification in %s... ignoring.\n", str);
}
}
if (visual == NULL)
{
- visual = DefaultVisual(dpy, screen);
- depth = DefaultDepth(dpy, screen);
+ visual = DefaultVisual (dpy, screen);
+ depth = DefaultDepth (dpy, screen);
}
/* If we've got the same visual as the default and it's PseudoColor,
check to see if the user specified that we need a private colormap */
- if (visual == DefaultVisual(dpy, screen))
+ if (visual == DefaultVisual (dpy, screen))
{
sprintf (buf1, "%s.privateColormap", app_name);
sprintf (buf2, "%s.PrivateColormap", app_class);
if ((visual->class == PseudoColor) &&
(XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True))
{
- cmap = XCopyColormapAndFree(dpy, DefaultColormap(dpy, screen));
+ cmap = XCopyColormapAndFree (dpy, DefaultColormap (dpy, screen));
}
else
{
- cmap = DefaultColormap(dpy, screen);
+ cmap = DefaultColormap (dpy, screen);
}
}
else
{
/* We have to create a matching colormap anyway...
### think about using standard colormaps (need the Xmu libs?) */
- cmap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone);
- XInstallColormap(dpy, cmap);
+ cmap = XCreateColormap (dpy, RootWindow(dpy, screen), visual, AllocNone);
+ XInstallColormap (dpy, cmap);
}
}
- XtSetArg(xargs[numargs],XtNvisual, visual); numargs++;
- XtSetArg(xargs[numargs],XtNdepth, depth); numargs++;
- XtSetArg(xargs[numargs],XtNcolormap, cmap); numargs++;
- DEVICE_X_VISUAL (d) = visual;
- DEVICE_X_COLORMAP (d) = cmap;
- DEVICE_X_DEPTH (d) = depth;
+ DEVICE_X_VISUAL (d) = visual;
+ DEVICE_X_COLORMAP (d) = cmap;
+ DEVICE_X_DEPTH (d) = depth;
validify_resource_component ((char *) XSTRING_DATA (DEVICE_NAME (d)),
XSTRING_LENGTH (DEVICE_NAME (d)));
- app_shell = XtAppCreateShell (NULL, app_class,
- applicationShellWidgetClass,
- dpy, xargs, numargs);
+
+ {
+ Arg al[3];
+ XtSetArg (al[0], XtNvisual, visual);
+ XtSetArg (al[1], XtNdepth, depth);
+ XtSetArg (al[2], XtNcolormap, cmap);
+
+ app_shell = XtAppCreateShell (NULL, app_class,
+ applicationShellWidgetClass,
+ dpy, al, countof (al));
+ }
DEVICE_XT_APP_SHELL (d) = app_shell;
+
#ifdef HAVE_XIM
XIM_init_device(d);
#endif /* HAVE_XIM */
/* Realize the app_shell so that its window exists for GC creation purposes,
and set it to the size of the root window for child placement purposes */
{
- Screen *scrn = ScreenOfDisplay(dpy, screen);
- int screen_width, screen_height;
- screen_width = WidthOfScreen(scrn);
- screen_height = HeightOfScreen(scrn);
- numargs = 0;
- XtSetArg (xargs[numargs], XtNmappedWhenManaged, False); numargs++;
- XtSetArg (xargs[numargs], XtNx, 0); numargs++;
- XtSetArg (xargs[numargs], XtNy, 0); numargs++;
- XtSetArg (xargs[numargs], XtNwidth, screen_width); numargs++;
- XtSetArg (xargs[numargs], XtNheight, screen_height); numargs++;
- XtSetValues (app_shell, xargs, numargs);
+ Arg al[5];
+ XtSetArg (al[0], XtNmappedWhenManaged, False);
+ XtSetArg (al[1], XtNx, 0);
+ XtSetArg (al[2], XtNy, 0);
+ XtSetArg (al[3], XtNwidth, WidthOfScreen (ScreenOfDisplay (dpy, screen)));
+ XtSetArg (al[4], XtNheight, HeightOfScreen (ScreenOfDisplay (dpy, screen)));
+ XtSetValues (app_shell, al, countof (al));
XtRealizeWidget (app_shell);
}
+
#ifdef HAVE_SESSION
{
int new_argc;
static void
x_mark_device (struct device *d, void (*markobj) (Lisp_Object))
{
- ((markobj) (DEVICE_X_WM_COMMAND_FRAME (d)));
- ((markobj) (DEVICE_X_DATA (d)->x_keysym_map_hashtable));
+ markobj (DEVICE_X_WM_COMMAND_FRAME (d));
+ markobj (DEVICE_X_DATA (d)->x_keysym_map_hash_table);
}
\f
if (DEVICE_X_DATA (d)->x_keysym_map)
XFree ((char *) DEVICE_X_DATA (d)->x_keysym_map);
+ if (DEVICE_XT_APP_SHELL (d))
+ {
+ XtDestroyWidget (DEVICE_XT_APP_SHELL (d));
+ DEVICE_XT_APP_SHELL (d) = NULL;
+ }
+
XtCloseDisplay (display);
DEVICE_X_DISPLAY (d) = 0;
#ifdef FREE_CHECKING
Lisp_Object dev;
struct device *d = get_device_from_display_1 (disp);
- if (d)
- XSETDEVICE (dev, d);
- else
- dev = Qnil;
+ assert (d != NULL);
+ XSETDEVICE (dev, d);
if (NILP (find_nonminibuffer_frame_not_on_device (dev)))
{
{
warn_when_safe
(Qx, Qcritical,
- "I/O Error %d (%s) on display connection \"%s\"\n"
- " after %lu requests (%lu known processed) with "
- "%d events remaining.\n",
+ "I/O Error %d (%s) on display connection\n"
+ " \"%s\" after after %lu requests (%lu known processed)\n"
+ " with %d events remaining.\n"
+ " Throwing to top level.\n",
errno, strerror (errno), DisplayString (disp),
NextRequest (disp) - 1, LastKnownRequestProcessed (disp),
QLength (disp));
}
+ /* According to X specs, we should not return from this function, or
+ Xlib might just decide to exit(). So we mark the offending
+ console for deletion and throw to top level. */
if (d)
enqueue_magic_eval_event (io_error_delete_device, dev);
+ DEVICE_X_BEING_DELETED (d) = 1;
+ Fthrow (Qtop_level, Qnil);
- /* CvE, July 16, 1996, XEmacs 19.14 */
- /* Test for broken pipe error, which indicates X-server has gone down */
- if (errno == EPIPE && x_seppuku_on_epipe)
- {
- /* Most probably X-server has gone down: Avoid infinite loop by just */
- /* exiting */
- /* slb: This sounds really, really dangerous to do by default, so */
- /* I'm adding a guard to avoid doing this as default behavior */
- stderr_out( "\n\nXEmacs exiting on broken pipe (errno %d, %s)\n",
- errno, strerror(errno));
- exit(errno);
- }
-
- return 0;
+ return 0; /* not reached */
}
DEFUN ("x-debug-mode", Fx_debug_mode, 1, 2, 0, /*
return XStringToKeysym (keysym_ext) ? Qt : Qnil;
}
-DEFUN ("x-keysym-hashtable", Fx_keysym_hashtable, 0, 1, 0, /*
-Return a hashtable which contains a hash key for all keysyms which
+DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /*
+Return a hash table which contains a hash key for all keysyms which
name keys on the keyboard. See `x-keysym-on-keyboard-p'.
*/
(device))
if (!DEVICE_X_P (d))
signal_simple_error ("Not an X device", device);
- return DEVICE_X_DATA (d)->x_keysym_map_hashtable;
+ return DEVICE_X_DATA (d)->x_keysym_map_hash_table;
}
DEFUN ("x-keysym-on-keyboard-sans-modifiers-p", Fx_keysym_on_keyboard_sans_modifiers_p,
signal_simple_error ("Not an X device", device);
return (EQ (Qsans_modifiers,
- Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASHTABLE (d), Qnil)) ?
+ Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASH_TABLE (d), Qnil)) ?
Qt : Qnil);
}
if (!DEVICE_X_P (d))
signal_simple_error ("Not an X device", device);
- return (NILP (Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASHTABLE (d), Qnil)) ?
+ return (NILP (Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASH_TABLE (d), Qnil)) ?
Qnil : Qt);
}
DEFSUBR (Fx_server_vendor);
DEFSUBR (Fx_server_version);
DEFSUBR (Fx_valid_keysym_name_p);
- DEFSUBR (Fx_keysym_hashtable);
+ DEFSUBR (Fx_keysym_hash_table);
DEFSUBR (Fx_keysym_on_keyboard_p);
DEFSUBR (Fx_keysym_on_keyboard_sans_modifiers_p);
*/ );
Vx_initial_argv_list = Qnil;
- DEFVAR_BOOL ("x-seppuku-on-epipe", &x_seppuku_on_epipe /*
-When non-nil, terminate XEmacs immediately on SIGPIPE from the X server.
-XEmacs doesn't terminate properly on some systems.
-When this variable is non-nil, XEmacs will commit immediate suicide
-when it gets a sigpipe from the X Server.
-*/ );
- x_seppuku_on_epipe = 0;
-
#if defined(MULE) && (defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET))
DEFVAR_LISP ("x-app-defaults-directory", &Vx_app_defaults_directory /*
Used by the Lisp code to communicate to the low level X initialization