diff --git a/src/Fl_Gl_Overlay.cxx b/src/Fl_Gl_Overlay.cxx
index fcbf5c7bf047ec0e95b7b33ab865113d5e9a17d5..a3518000e030571a2f8f60b5556dc1b6200abc8c 100644
--- a/src/Fl_Gl_Overlay.cxx
+++ b/src/Fl_Gl_Overlay.cxx
@@ -1,5 +1,5 @@
 //
-// "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.16 2001/03/15 22:39:56 easysw Exp $"
+// "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.17 2001/03/20 18:02:52 spitzak Exp $"
 //
 // OpenGL overlay code for the Fast Light Tool Kit (FLTK).
 //
@@ -126,13 +126,6 @@ void Fl_Gl_Window::make_overlay() {
 //static COLORREF *palette;
 extern int fl_overlay_depth;
 
-int Fl_Gl_Window::can_do_overlay() {
-  HDC hdc = Fl_X::i(this)->private_dc;
-  LAYERPLANEDESCRIPTOR pfd;
-
-  return (wglDescribeLayerPlane(hdc, g->pixelformat, 1, sizeof(pfd), &pfd));
-}
-
 void Fl_Gl_Window::make_overlay() {
   if (overlay) return;
 
@@ -168,6 +161,14 @@ void Fl_Gl_Window::make_overlay() {
   return;
 }
 
+int Fl_Gl_Window::can_do_overlay() {
+  if (!g) {
+    g = Fl_Gl_Choice::find(mode_,alist);
+    if (!g) return 0;
+  }
+  return (g->pfd.bReserved & 15) != 0;
+}
+
 ////////////////////////////////////////////////////////////////
 #endif
 
@@ -213,5 +214,5 @@ void Fl_Gl_Window::hide_overlay() {
 #endif
 
 //
-// End of "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.16 2001/03/15 22:39:56 easysw Exp $".
+// End of "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.17 2001/03/20 18:02:52 spitzak Exp $".
 //
diff --git a/src/Fl_arg.cxx b/src/Fl_arg.cxx
index 830cd3e6801d79ad9559507af49fdfb603e61ebf..f531b575df4aecbe23d037929852648ac2b70912 100644
--- a/src/Fl_arg.cxx
+++ b/src/Fl_arg.cxx
@@ -1,5 +1,5 @@
 //
-// "$Id: Fl_arg.cxx,v 1.5.2.7 2001/01/22 15:13:40 easysw Exp $"
+// "$Id: Fl_arg.cxx,v 1.5.2.8 2001/03/20 18:02:52 spitzak Exp $"
 //
 // Optional argument initialization code for the Fast Light Tool Kit (FLTK).
 //
@@ -147,8 +147,6 @@ void Fl_Window::show(int argc, char **argv) {
   // set colors first, so background_pixel is correct:
   static char beenhere;
   if (!beenhere) {
-    beenhere = 1;
-    Fl::get_system_colors(); // opens display!  May call Fl::fatal()
     if (geometry) {
       int flags = 0, gx = x(), gy = y(); unsigned int gw = w(), gh = h();
       flags = XParseGeometry(geometry, &gx, &gy, &gw, &gh);
@@ -168,12 +166,19 @@ void Fl_Window::show(int argc, char **argv) {
     }
   }
 
+  // set the class, which is used by X version of get_system_colors:
   if (name) {xclass(name); name = 0;}
   else if (!xclass()) xclass(filename_name(argv[0]));
+
   if (title) {label(title); title = 0;}
   else if (!label()) label(xclass());
   show();
 
+  if (!beenhere) {
+    beenhere = 1;
+    Fl::get_system_colors(); // opens display!  May call Fl::fatal()
+  }
+
 #ifndef WIN32
   // set the command string, used by state-saving window managers:
   int j;
@@ -352,5 +357,5 @@ int XParseGeometry(const char* string, int* x, int* y,
 #endif // ifdef WIN32
 
 //
-// End of "$Id: Fl_arg.cxx,v 1.5.2.7 2001/01/22 15:13:40 easysw Exp $".
+// End of "$Id: Fl_arg.cxx,v 1.5.2.8 2001/03/20 18:02:52 spitzak Exp $".
 //
diff --git a/src/Fl_get_system_colors.cxx b/src/Fl_get_system_colors.cxx
index ae4caf0123121f57720238fe73d9969341c5504a..5904d84d04daf831250961955b9d7042b9d2b27d 100644
--- a/src/Fl_get_system_colors.cxx
+++ b/src/Fl_get_system_colors.cxx
@@ -1,5 +1,5 @@
 //
-// "$Id: Fl_get_system_colors.cxx,v 1.6.2.6 2001/01/22 15:13:40 easysw Exp $"
+// "$Id: Fl_get_system_colors.cxx,v 1.6.2.7 2001/03/20 18:02:52 spitzak Exp $"
 //
 // System color support for the Fast Light Tool Kit (FLTK).
 //
@@ -58,6 +58,10 @@ const char *fl_fg;
 const char *fl_bg;
 const char *fl_bg2;
 
+static void set_selection_color(uchar r, uchar g, uchar b) {
+  Fl::set_color(FL_SELECTION_COLOR,r,g,b);
+}
+
 #ifdef WIN32
 
 #include <stdio.h>
@@ -103,48 +107,48 @@ void Fl::get_system_colors() {
   getsyscolor(COLOR_WINDOW,	fl_bg2,Fl::background2);
   getsyscolor(COLOR_WINDOWTEXT,	fl_fg, Fl::foreground);
   getsyscolor(COLOR_BTNFACE,	fl_bg, Fl::background);
+  getsyscolor(COLOR_HIGHLIGHT,	0,     set_selection_color);
 }
 
 #else
 
-// For X we should do something. KDE and Gnome store these colors in
-// some standard places, where?
+// Read colors that KDE writes to the xrdb database.
 
-static void
-getsyscolor(const char *arg, void (*func)(uchar,uchar,uchar)) {
-  if (arg) {
-    XColor x;
-    if (!XParseColor(fl_display, fl_colormap, arg, &x))
-      Fl::error("Unknown color: %s", arg);
-    else
-      func(x.red>>8, x.green>>8, x.blue>>8);
-  }
-}
+// XGetDefault does not do the expected thing: it does not like
+// periods in either word. Therefore it cannot match class.Text.background.
+// However *.Text.background is matched by pretending the program is "Text".
+// But this will also match *.background if there is no *.Text.background
+// entry, requiring users to put in both (unless they want the text fields
+// the same color as the windows).
 
-static const char *
-xdefaultcolor (const char *flcol, const char *key1, const char *key2)
+static void
+getsyscolor(const char *key1, const char* key2, const char *arg, void (*func)(uchar,uchar,uchar))
 {
-  if (!flcol)
-    return XGetDefault (fl_display, key1, key2);
+  if (!arg) {
+    arg = XGetDefault (fl_display, key1, key2);
+    if (!arg) return;
+  }
+  XColor x;
+  if (!XParseColor(fl_display, fl_colormap, arg, &x))
+    Fl::error("Unknown color: %s", arg);
   else
-    return flcol;
-}
-
-static void set_selection_color(uchar r, uchar g, uchar b) {
-  Fl::set_color(FL_SELECTION_COLOR,r,g,b);
+    func(x.red>>8, x.green>>8, x.blue>>8);
 }
 
 void Fl::get_system_colors()
 {
   fl_open_display();
-  getsyscolor(xdefaultcolor(fl_bg2, "Entry", "background"), Fl::background2);
-  getsyscolor(xdefaultcolor(fl_bg, "*", "background"), Fl::background);
-  getsyscolor(xdefaultcolor(fl_fg, "*", "foreground"), Fl::foreground);
-  getsyscolor(xdefaultcolor(0,"Text","selectBackground"), set_selection_color);
+  const char* key1 = 0;
+  if (Fl::first_window()) key1 = Fl::first_window()->xclass();
+  if (!key1) key1 = "fltk";
+  getsyscolor(key1,  "background",	fl_bg,	Fl::background);
+  getsyscolor(key1,  "foreground",	fl_fg,	Fl::foreground);
+  getsyscolor("Text","background",	fl_bg2,	Fl::background2);
+  getsyscolor(key1,  "selectBackground",0,	set_selection_color);
 }
 
 #endif
 
 //
-// End of "$Id: Fl_get_system_colors.cxx,v 1.6.2.6 2001/01/22 15:13:40 easysw Exp $".
+// End of "$Id: Fl_get_system_colors.cxx,v 1.6.2.7 2001/03/20 18:02:52 spitzak Exp $".
 //