Change resource handling to use property names similar to those used
authorChris Hanson <org/chris-hanson/cph>
Tue, 27 Jun 1989 10:10:01 +0000 (10:10 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 27 Jun 1989 10:10:01 +0000 (10:10 +0000)
by GNU Emacs.

v7/src/microcode/x11base.c
v7/src/microcode/x11graph.c

index 64ee913f35788108126a61972d48a470cbf38a1e..dc05ebdf21a239fe79f408468296b309f8e622d0 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11base.c,v 1.2 1989/06/23 04:34:49 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11base.c,v 1.3 1989/06/27 10:09:48 cph Exp $
 
 Copyright (c) 1989 Massachusetts Institute of Technology
 
@@ -187,17 +187,38 @@ x_decode_color (display, color_map, color_name, default_color)
     return (cdef . pixel);
   return (default_color);
 }
+\f
+char *
+x_get_default (display, resource_name, property_name, class_name, sdefault)
+     Display * display;
+     char * resource_name;
+     char * property_name;
+     char * class_name;
+     char * sdefault;
+{
+  char * result;
+
+  result = (XGetDefault (display, resource_name, property_name));
+  if (result != ((char *) 0))
+    return (result);
+  result = (XGetDefault (display, resource_name, class_name));
+  if (result != ((char *) 0))
+    return (result);
+  return (sdefault);
+}
 
 unsigned long
-x_default_color (display, resource_name, property_name, default_color)
+x_default_color (display, resource_name, property_name, class_name,
+                default_color)
      Display * display;
      char * resource_name;
      char * property_name;
+     char * class_name;
      unsigned long default_color;
 {
-  char * color_name;
-
-  color_name = (XGetDefault (display, resource_name, property_name));
+  char * color_name =
+    (x_get_default
+     (display, resource_name, property_name, class_name, ((char *) 0)));
   if (color_name == ((char *) 0))
     return (default_color);
   return
@@ -207,6 +228,26 @@ x_default_color (display, resource_name, property_name, default_color)
       color_name,
       default_color));
 }
+
+void
+x_set_mouse_colors (display, mouse_cursor, mouse_pixel, background_pixel)
+     Display * display;
+     Cursor mouse_cursor;
+     unsigned long mouse_pixel;
+     unsigned long background_pixel;
+{
+  Colormap color_map = (DefaultColormap (display, (DefaultScreen (display))));
+  XColor mouse_color;
+  XColor background_color;
+
+  (mouse_color . pixel) = mouse_pixel;
+  XQueryColor (display, color_map, (& mouse_color));
+  (background_color . pixel) = background_pixel;
+  XQueryColor (display, color_map, (& background_color));
+  XRecolorCursor
+    (display, mouse_cursor, (& mouse_color), (& background_color));
+  return;
+}
 \f
 void
 x_default_attributes (display, resource_name, attributes)
@@ -216,62 +257,54 @@ x_default_attributes (display, resource_name, attributes)
 {
   int screen_number = (DefaultScreen (display));
 
+  (attributes -> font) =
+    (XLoadQueryFont
+     (display,
+      (x_get_default
+       (display, resource_name, "font", "Font", "9x15"))));
+  if ((attributes -> font) == ((XFontStruct *) 0))
+    error_external_return ();
   {
-    char * font_name;
-
-    font_name = (XGetDefault (display, resource_name, "Font"));
-    if (font_name == ((char *) 0))
-      font_name = "9x15";
-    (attributes -> font) = (XLoadQueryFont (display, font_name));
-    if ((attributes -> font) == ((XFontStruct *) 0))
-      error_external_return ();
+    char * s =
+      (x_get_default
+       (display, resource_name, "borderWidth", "BorderWidth", ((char *) 0)));
+    (attributes -> border_width) = ((s == ((char *) 0)) ? 2 : (atoi (s)));
   }
   {
-    char * s;
-
-    s = (XGetDefault (display, resource_name, "BorderWidth"));
-    (attributes -> border_width) = ((s == ((char *) 0)) ? 2 : (atoi (s)));
-    s = (XGetDefault (display, resource_name, "InternalBorder"));
+    char * s =
+      (x_get_default
+       (display, resource_name,
+       "internalBorder", "BorderWidth", ((char *) 0)));
     (attributes -> internal_border_width) =
-      ((s == ((char *) 0)) ? 4 : (atoi (s)));
+      ((s == ((char *) 0)) ? (attributes -> border_width) : (atoi (s)));
   }
   {
     unsigned long white_pixel = (WhitePixel (display, screen_number));
     unsigned long black_pixel = (BlackPixel (display, screen_number));
+    unsigned long foreground_pixel;
 
     (attributes -> background_pixel) =
-      (x_default_color (display, resource_name, "Background", white_pixel));
-    (attributes -> foreground_pixel) =
-      (x_default_color (display, resource_name, "Foreground", black_pixel));
+      (x_default_color
+       (display, resource_name, "background", "Background", white_pixel));
+    foreground_pixel =
+      (x_default_color
+       (display, resource_name, "foreground", "Foreground", black_pixel));
+    (attributes -> foreground_pixel) = foreground_pixel;
     (attributes -> border_pixel) =
-      (x_default_color (display, resource_name, "BorderColor", black_pixel));
+      (x_default_color
+       (display, resource_name,
+       "borderColor", "BorderColor", foreground_pixel));
     (attributes -> cursor_pixel) =
-      (x_default_color (display, resource_name, "CursorColor", black_pixel));
+      (x_default_color
+       (display, resource_name,
+       "cursorColor", "Foreground", foreground_pixel));
     (attributes -> mouse_pixel) =
-      (x_default_color (display, resource_name, "pointerColor", black_pixel));
+      (x_default_color
+       (display, resource_name,
+       "pointerColor", "Foreground", foreground_pixel));
   }
   return;
 }
-
-void
-x_set_mouse_colors (display, mouse_cursor, mouse_pixel, background_pixel)
-     Display * display;
-     Cursor mouse_cursor;
-     unsigned long mouse_pixel;
-     unsigned long background_pixel;
-{
-  Colormap color_map = (DefaultColormap (display, (DefaultScreen (display))));
-  XColor mouse_color;
-  XColor background_color;
-
-  (mouse_color . pixel) = mouse_pixel;
-  XQueryColor (display, color_map, (& mouse_color));
-  (background_color . pixel) = background_pixel;
-  XQueryColor (display, color_map, (& background_color));
-  XRecolorCursor
-    (display, mouse_cursor, (& mouse_color), (& background_color));
-  return;
-}
 \f
 #define MAKE_GC(gc, fore, back)                                                \
 {                                                                      \
@@ -646,7 +679,7 @@ DEFINE_PRIMITIVE ("X-WINDOW-FLUSH", Prim_x_window_flush, 1, 1, 0)
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
 
-DEFINE_PRIMITIVE ("X-WINDOW-GET-DEFAULT", Prim_x_get_default, 3, 3, 0)
+DEFINE_PRIMITIVE ("X-WINDOW-GET-DEFAULT", Prim_x_window_get_default, 3, 3, 0)
 {
   char * result;
   PRIMITIVE_HEADER (3);
index d05d30fa79e8bfb3c0eaea148c6dbadca5fc675d..01fe69ed1bc9e4284f387f3cc4770dc32544a46c 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.2 1989/06/21 11:44:39 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.3 1989/06/27 10:10:01 cph Rel $
 
 Copyright (c) 1989 Massachusetts Institute of Technology
 
@@ -404,7 +404,8 @@ If third argument SUPPRESS-MAP? is true, do not map the window immediately.")
 
     geometry =
       (((ARG_REF (2)) == SHARP_F)
-       ? (XGetDefault (display, RESOURCE_NAME, "Geometry"))
+       ? (x_get_default
+         (display, RESOURCE_NAME, "geometry", "Geometry", ((char *) 0)))
        : (STRING_ARG (2)));
     result =
       (XGeometry (display, screen_number, geometry,