*** empty log message ***
authorroot <root>
Mon, 30 Jan 2006 02:21:20 +0000 (02:21 +0000)
committerroot <root>
Mon, 30 Jan 2006 02:21:20 +0000 (02:21 +0000)
Changes
src/feature.h
src/init.C
src/rxvtfont.C
src/rxvttoolkit.C
src/rxvttoolkit.h

diff --git a/Changes b/Changes
index 156f00a2d92e19ccd96bc06f31fda4a62dc2bf30..1dd22f1097670d4dd2b586377a064095899c6e63 100644 (file)
--- a/Changes
+++ b/Changes
@@ -23,6 +23,10 @@ DUMB: support tex fonts
           transparent. Long Live Xft!
         - do not include X11/Intrinsic.h anymore, directly use
           Xlib/Xutil/Xresource directly.
+        - replace named colours by xorg's rgb.txt equivalents, to
+          reduce round trip time on startup, and short-cut allocation
+          of rgb:rr/gg/bb.
+        - further RTT optimisations.
 
 7.4  Sat Jan 28 15:26:27 CET 2006
        - screen background wasn't always erased properly when scrolling,
index 4f37584feb542aa10ab0f1858e1ae6f7df7e51fb..52f40abaa9a2706b8380e5b03b31c53c0bb04591 100644 (file)
 /*
  * Define default colours for certain items.  If you have a low colour
  * display, then consider using colours which are already pre-allocated:
+ *
  *   Black             (#000000)
- *   Red3              (#CD0000)       + these
- *   Green3            (#00CD00)       + colours
- *   Yellow3           (#CDCD00)       + are
- *   Blue3             (#0000CD)       + not
- *   Magenta3          (#CD00CD)       + pre-allocated
- *   Cyan3             (#00CDCD)       + if
- *   AntiqueWhite      (#FAEBD7)       + NO_BRIGHTCOLOR
- *   Grey25            (#404040)       + defined
+ *   Red3              (#CD0000)
+ *   Green3            (#00CD00)
+ *   Yellow3           (#CDCD00)
+ *   Blue3             (#0000CD)
+ *   Magenta3          (#CD00CD)
+ *   Cyan3             (#00CDCD)
+ *   AntiqueWhite      (#FAEBD7)
+ *   Grey25            (#404040)
  *   Red               (#FF0000)
  *   Green             (#00FF00)
  *   Yellow            (#FFFF00)
  *   White             (#FFFFFF)
  */
 /* These colours MUST be defined */
-#define COLOR_FOREGROUND       "Black"
-#define COLOR_BACKGROUND       "White"
-#define COLOR_SCROLLBAR                "#B2B2B2"       /* scrollColor match Netscape */
-#define COLOR_SCROLLTROUGH     "#969696"
+#define COLOR_FOREGROUND       "rgb:00/00/00"
+#define COLOR_BACKGROUND       "rgb:ff/ff/ff"
+#define COLOR_SCROLLBAR                "rgb:b2/b2/b2"  /* scrollColor match Netscape */
+#define COLOR_SCROLLTROUGH     "rgb:96/96/96"
 
 /*
  * The cursor colours are special.  Be very careful about setting these:
index fad6894bf8378dc819850e56084dbe218c144207..a46f8662d0c079c39a831b127cca57eb39ff0d7a 100644 (file)
@@ -45,31 +45,31 @@ const char *const def_colorName[] =
     COLOR_FOREGROUND,
     COLOR_BACKGROUND,
     /* low-intensity colors */
-    "Black",                    /* 0: black             (#000000) */
-    "Red3",                     /* 1: red               (#CD0000) */
-    "Green3",                   /* 2: green             (#00CD00) */
-    "Yellow3",                  /* 3: yellow            (#CDCD00) */
-    "Blue3",                    /* 4: blue              (#0000CD) */
-    "Magenta3",                 /* 5: magenta           (#CD00CD) */
-    "Cyan3",                    /* 6: cyan              (#00CDCD) */
-# ifdef XTERM_COLORS
-    "Grey90",                   /* 7: white             (#E5E5E5) */
-# else
-    "AntiqueWhite",             /* 7: white             (#FAEBD7) */
+    "rgb:00/00/00",             // 0: black             (Black)
+    "rgb:cd/00/00",             // 1: red               (Red3)
+    "rgb:00/cd/00",             // 2: green             (Green3)
+    "rgb:cd/cd/00",             // 3: ywlloe            (Yellow3)
+    "rgb:00/00/cd",             // 4: blue              (Blue3)
+    "rgb:cd/00/cd",             // 5: magenta           (Magenta3)
+    "rgb:00/cd/cd",             // 6: cyan              (Cyan3)
+# ifdef XTERM_COLORS                                    
+    "rgb:e5/e5/e5",             // 7: white             (Grey90)
+# else                                                  
+    "rgb:fa/eb/d7",             // 7: white             (AntiqueWhite)
 # endif
     /* high-intensity colors */
 # ifdef XTERM_COLORS
-    "Grey30",                   /* 8: bright black      (#4D4D4D) */
+    "rgb:4d/4d/4d",             // 8: bright black      (Grey30)
 # else
-    "Grey25",                   /* 8: bright black      (#404040) */
+    "rgb:40/40/40",             // 8: bright black      (Grey25)
 # endif
-    "Red",                      /* 1/9: bright red      (#FF0000) */
-    "Green",                    /* 2/10: bright green   (#00FF00) */
-    "Yellow",                   /* 3/11: bright yellow  (#FFFF00) */
-    "Blue",                     /* 4/12: bright blue    (#0000FF) */
-    "Magenta",                  /* 5/13: bright magenta (#FF00FF) */
-    "Cyan",                     /* 6/14: bright cyan    (#00FFFF) */
-    "White",                    /* 7/15: bright white   (#FFFFFF) */
+    "rgb:ff/00/00",             // 1/9: bright red      (Reed)
+    "rgb:00/ff/00",             // 2/10: bright green   (Green)
+    "rgb:ff/ff/00",             // 3/11: bright yellow  (Yellow)
+    "rgb:00/00/ff",             // 4/12: bright blue    (Blue)
+    "rgb:ff/00/ff",             // 5/13: bright magenta (Magenta)
+    "rgb:00/ff/ff",             // 6/14: bright cyan    (Cyan)
+    "rgb:ff/ff/ff",             // 7/15: bright white   (White)
 
     // 88 xterm colours
     "rgb:00/00/00",
@@ -172,7 +172,7 @@ const char *const def_colorName[] =
     NULL,
 #endif
 #if OFF_FOCUS_FADING
-    "black",
+    "rgb:00/00/00",
 #endif
   };
 
index 7fa925c2f01e3054939fac670b1a5063d2884282..42d6f6af21177d6d9c4931c6ab13c075a1acd86f 100644 (file)
@@ -495,18 +495,18 @@ struct rxvt_font_x11 : rxvt_font {
   codeset cs;
   bool enc2b, encm;
 
-  char *get_property (XFontStruct *f, const char *property, const char *repl) const;
+  char *get_property (XFontStruct *f, Atom property, const char *repl) const;
   bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth);
   bool set_properties (rxvt_fontprop &p, XFontStruct *f);
   bool set_properties (rxvt_fontprop &p, const char *name);
 };
 
 char *
-rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const
+rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const
 {
   unsigned long value;
 
-  if (XGetFontProperty (f, XInternAtom (term->xdisp, property, 0), &value))
+  if (XGetFontProperty (f, property, &value))
     return XGetAtomName (term->xdisp, value);
   else
     return rxvt_strdup (repl);
@@ -545,11 +545,11 @@ rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f)
 #endif
 
   unsigned long avgwidth;
-  if (!XGetFontProperty (f, XInternAtom (term->xdisp, "AVERAGE_WIDTH", 0), &avgwidth))
+  if (!XGetFontProperty (f, term->xa [XA_AVERAGE_WIDTH], &avgwidth))
     avgwidth = 0;
 
-  char *weight = get_property (f, "WEIGHT_NAME", "medium");
-  char *slant  = get_property (f, "SLANT", "r");
+  char *weight = get_property (f, term->xa [XA_WEIGHT_NAME], "medium");
+  char *slant  = get_property (f, term->xa [XA_SLANT], "r");
 
   set_properties (p, height, weight, slant, avgwidth);
 
@@ -657,7 +657,7 @@ rxvt_font_x11::load (const rxvt_fontprop &prop)
           if (!f)
             return false;
 
-          char *new_name = get_property (f, "FONT", name);
+          char *new_name = get_property (f, XA_FONT, name);
 
           if (new_name)
             set_name (new_name);
@@ -776,8 +776,8 @@ rxvt_font_x11::load (const rxvt_fontprop &prop)
   if (!f)
     return false;
 
-  char *registry = get_property (f, "CHARSET_REGISTRY", 0);
-  char *encoding = get_property (f, "CHARSET_ENCODING", 0);
+  char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0);
+  char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0);
 
   if (registry && encoding)
     {
@@ -788,7 +788,7 @@ rxvt_font_x11::load (const rxvt_fontprop &prop)
     }
   else
     {
-      const char *charset = get_property (f, "FONT", 0);
+      const char *charset = get_property (f, XA_FONT, 0);
 
       if (!charset)
         charset = name;
index 68c9912373116283d575eda5e4685609545ff48a..75681bd62aaec05a823eb470f88bd9ce9ba1c98e 100644 (file)
 #endif
 
 const char *const xa_names[] =
-  {
-    "TEXT",
-    "COMPOUND_TEXT",
-    "UTF8_STRING",
-    "MULTIPLE",
-    "TARGETS",
-    "TIMESTAMP",
-    "VT_SELECTION",
-    "INCR",
-    "WM_PROTOCOLS",
-    "WM_DELETE_WINDOW",
-    "CLIPBOARD",
+{
+  "TEXT",
+  "COMPOUND_TEXT",
+  "UTF8_STRING",
+  "MULTIPLE",
+  "TARGETS",
+  "TIMESTAMP",
+  "VT_SELECTION",
+  "INCR",
+  "WM_PROTOCOLS",
+  "WM_DELETE_WINDOW",
+  "CLIPBOARD",
+  "AVERAGE_WIDTH",
+  "WEIGHT_NAME",
+  "SLANT",
+  "CHARSET_REGISTRY",
+  "CHARSET_ENCODING",
 #if ENABLE_FRILLS
-    "_MOTIF_WM_HINTS",
+  "_MOTIF_WM_HINTS",
 #endif
 #if ENABLE_EWMH
-    "_NET_WM_PID",
-    "_NET_WM_NAME",
-    "_NET_WM_ICON_NAME",
-    "_NET_WM_PING",
+  "_NET_WM_PID",
+  "_NET_WM_NAME",
+  "_NET_WM_ICON_NAME",
+  "_NET_WM_PING",
 #endif
 #if USE_XIM
-    "WM_LOCALE_NAME",
-    "XIM_SERVERS",
+  "WM_LOCALE_NAME",
+  "XIM_SERVERS",
 #endif
 #ifdef TRANSPARENT
-    "_XROOTPMAP_ID",
-    "ESETROOT_PMAP_ID",
+  "_XROOTPMAP_ID",
+  "ESETROOT_PMAP_ID",
 #endif
 #if ENABLE_XEMBED
-    "_XEMBED",
-    "_XEMBED_INFO",
+  "_XEMBED",
+  "_XEMBED_INFO",
+#endif
+#if !ENABLE_MINIMAL
+  "SCREEN_RESOURCES",
+  "XDCCC_LINEAR_RGB_CORRECTION",
+  "XDCCC_LINEAR_RGB_MATRICES",
+  "WM_COLORMAP_WINDOWS",
+  "WM_STATE",
 #endif
-  };
+};
 
 /////////////////////////////////////////////////////////////////////////////
 
@@ -550,7 +562,15 @@ rxvt_color::set (rxvt_screen *screen, const char *name)
   char eos;
   int mult;
 
-  if (     l == 1+4*1 && 4 == sscanf (name, "#%1hx%1hx%1hx%1hx%c", &r.a, &r.r, &r.g, &r.b, &eos))
+  // shortcutting this saves countless server RTTs for the built-in colours
+  if (l == 3+3*3 && 3 == sscanf (name, "rgb:%hx/%hx/%hx/%hx%c", &r.r, &r.g, &r.b, &r.a, &eos))
+    {
+      r.a  = rxvt_rgba::MAX_CC;
+      mult = rxvt_rgba::MAX_CC / 0x00ff;
+    }
+
+  // parse a number of non-standard ARGB colour specifications
+  else if (     l == 1+4*1 && 4 == sscanf (name, "#%1hx%1hx%1hx%1hx%c", &r.a, &r.r, &r.g, &r.b, &eos))
     mult = rxvt_rgba::MAX_CC / 0x000f;
   else if (l == 1+4*2 && 4 == sscanf (name, "#%2hx%2hx%2hx%2hx%c", &r.a, &r.r, &r.g, &r.b, &eos))
     mult = rxvt_rgba::MAX_CC / 0x00ff;
@@ -558,10 +578,13 @@ rxvt_color::set (rxvt_screen *screen, const char *name)
     mult = rxvt_rgba::MAX_CC / 0xffff;
   else if (l == 4+5*4 && 4 == sscanf (name, "rgba:%hx/%hx/%hx/%hx%c", &r.r, &r.g, &r.b, &r.a, &eos))
     mult = rxvt_rgba::MAX_CC / 0xffff;
+
+  // slow case: server round trip
   else
     return XftColorAllocName (screen->xdisp, screen->visual, screen->cmap, name, &c);
 
   r.r *= mult; r.g *= mult; r.b *= mult; r.a *= mult;
+
   return set (screen, r);
 #else
   XColor xc;
index 1a78b3adb1cb49dbd15420d9672217579ed97b06..d3b8b641edd2b55c384ae0ad30bf31bf56081682 100644 (file)
@@ -30,6 +30,11 @@ enum {
   XA_WM_PROTOCOLS,
   XA_WM_DELETE_WINDOW,
   XA_CLIPBOARD,
+  XA_AVERAGE_WIDTH,
+  XA_WEIGHT_NAME,
+  XA_SLANT,
+  XA_CHARSET_REGISTRY,
+  XA_CHARSET_ENCODING,
 #if ENABLE_FRILLS
   XA_MOTIF_WM_HINTS,
 #endif
@@ -50,6 +55,15 @@ enum {
 #if ENABLE_XEMBED
   XA_XEMBED,
   XA_XEMBED_INFO,
+#endif
+#if !ENABLE_MINIMAL
+  // these are usually allocated by other subsystens, but we do it
+  // here to avoid a server roundtrip.
+  XA_SCREEN_RESOURCES,
+  XA_XDCCC_LINEAR_RGB_CORRECTION,
+  XA_XDCCC_LINEAR_RGB_MATRICES,
+  XA_WM_COLORMAP_WINDOWS,
+  XA_WM_STATE,
 #endif
   NUM_XA
 };