DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L1990
Version: 2.0-feature


Related to the problem reported in message
<[EMAIL PROTECTED]>
Using X11 Composite extension with fltk-2.0

See:
http://fltk.org/newsgroups.php?gfltk.general+v:25908
http://fltk.org/newsgroups.php?gfltk.general+v:25978

To fix my problem, I tried to do something uglier than using a global
visual: let each window have it own context: a visual, a colormap and a
graphic context. Since fltk use global variables to store those data, a
lot of code need to be adapted.

The patch provided do the following things:

- renamed xvisual to xvisualinfo and gc to xgc 
  (not really useful change, comestic but broke API).
- XDBE is now enable per window
- per window XVisualInfo, Colormap, GC.

At the end, I'm able to run the test programs, and my own program are able
to use different visuals with window created by FLTK.

There are many issues added by the patch and it's not really the good way
to fix my problem, but it could be a way to improve FLTK 2.0 and a way for
me to discover the internals of the library..


Link: http://www.fltk.org/str.php?L1990
Version: 2.0-feature
Index: OpenGL/gl_start.cxx
===================================================================
--- OpenGL/gl_start.cxx (révision 6140)
+++ OpenGL/gl_start.cxx (copie de travail)
@@ -54,7 +54,7 @@
 #elif defined(__APPLE__)
   gl_choice = c;
 #else
-  xvisual = c->vis;
+  xvisualinfo = c->vis;
   xcolormap = c->colormap;
 #endif
   return true;
@@ -94,7 +94,7 @@
 #elif defined(__APPLE__)
     context = create_gl_context(Window::drawing_window(), gl_choice);
 #else
-    context = create_gl_context(xvisual);
+    context = create_gl_context(xvisualinfo);
 #endif
   }
   set_gl_context(Window::drawing_window(), context);
Index: OpenGL/Fl_Gl_Window.cxx
===================================================================
--- OpenGL/Fl_Gl_Window.cxx     (révision 6140)
+++ OpenGL/Fl_Gl_Window.cxx     (copie de travail)
@@ -148,7 +148,7 @@
 #elif USE_QUARTZ
   Window::create();
 #else
-  CreatedWindow::create(this, gl_choice->vis, gl_choice->colormap, -1);
+  CreatedWindow::create(this, gl_choice->vis, gl_choice->colormap, None, -1);
   //if (overlay && overlay != this) ((GlWindow*)overlay)->show();
   //fltk::flush(); glXWaitGL(); glXWaitX();
 #endif
Index: OpenGL/Fl_Gl_Choice.cxx
===================================================================
--- OpenGL/Fl_Gl_Choice.cxx     (révision 6140)
+++ OpenGL/Fl_Gl_Choice.cxx     (copie de travail)
@@ -189,7 +189,7 @@
   g->vis = vis;
 
   if (/*MaxCmapsOfScreen(ScreenOfDisplay(xdisplay,xscreen))==1 && */
-      vis->visualid == xvisual->visualid &&
+      vis->visualid == xvisualinfo->visualid &&
       !getenv("MESA_PRIVATE_CMAP"))
     g->colormap = xcolormap;
   else
Index: src/fillrect.cxx
===================================================================
--- src/fillrect.cxx    (révision 6140)
+++ src/fillrect.cxx    (copie de travail)
@@ -38,7 +38,7 @@
   cairo_rectangle(cc,x,y,w,h);
   cairo_fill(cc);
 #elif USE_X11
-  if (w && h) XFillRectangle(xdisplay, xwindow, gc, x, y, w, h);
+  if (w && h) XFillRectangle(xdisplay, xwindow, xgc, x, y, w, h);
 #elif defined(_WIN32)
   RECT rect;
   rect.left = x; rect.top = y;  
@@ -66,8 +66,8 @@
   cairo_rectangle(cc,x+.5,y+.5,w-1,h-1);
   cairo_stroke(cc);
 #elif USE_X11
-  if (w && h) XDrawRectangle(xdisplay, xwindow, gc, x, y, w-1, h-1);
-  else XDrawLine(xdisplay, xwindow, gc, x, y, x+w, y+h);
+  if (w && h) XDrawRectangle(xdisplay, xwindow, xgc, x, y, w-1, h-1);
+  else XDrawLine(xdisplay, xwindow, xgc, x, y, x+w, y+h);
 #elif defined(_WIN32)
   setpen();
   POINT pts[4];
@@ -126,7 +126,7 @@
   CGContextStrokePath(quartz_gc);
   if (!line_width_) CGContextSetShouldAntialias(quartz_gc, true);
 #elif USE_X11
-  XDrawLine(xdisplay, xwindow, gc, x, y, x1, y1);
+  XDrawLine(xdisplay, xwindow, xgc, x, y, x1, y1);
 #elif defined(_WIN32)
   setpen();
   MoveToEx(dc, x, y, 0L); 
@@ -164,7 +164,7 @@
   int X = int(floorf(x)+.5); int Y = int(floorf(y)+.5);
   int X1 = int(floorf(x1)+.5); int Y1 = int(floorf(y1)+.5);
 # if USE_X11
-  XDrawLine(xdisplay, xwindow, gc, X, Y, X1, Y1);
+  XDrawLine(xdisplay, xwindow, xgc, X, Y, X1, Y1);
 # elif defined(_WIN32)
   setpen();
   MoveToEx(dc, X, Y, 0L); 
@@ -186,7 +186,7 @@
 #if USE_CAIRO
     fillrect(x,y,1,1);
 #elif USE_X11
-  XDrawPoint(xdisplay, xwindow, gc, x, y);
+  XDrawPoint(xdisplay, xwindow, xgc, x, y);
 #elif defined(_WIN32)
   SetPixel(dc, x, y, current_xpixel);
 #else
@@ -210,7 +210,7 @@
 #if USE_CAIRO
     fillrect(x,y,1,1);
 #elif USE_X11
-  XDrawPoint(xdisplay, xwindow, gc, x, y);
+  XDrawPoint(xdisplay, xwindow, xgc, x, y);
 # elif defined(_WIN32)
   SetPixel(dc, x, y, current_xpixel);
 # else
Index: src/UpBox.cxx
===================================================================
--- src/UpBox.cxx       (révision 6140)
+++ src/UpBox.cxx       (copie de travail)
@@ -52,18 +52,18 @@
     evenstipple = XCreateBitmapFromData(xdisplay, root, pattern, 8, 8);
     oddstipple = XCreateBitmapFromData(xdisplay, root, pattern+1, 8, 8);
   }
-  XSetStipple(xdisplay, gc, (r.x()+r.y()-r1.x()-r1.y())&1 ? oddstipple : 
evenstipple);
-  XSetFillStyle(xdisplay, gc, FillStippled);
-  XSetFunction(xdisplay, gc, GXxor);
-  XSetForeground(xdisplay, gc, 0xffffffff);
+  XSetStipple(xdisplay, xgc, (r.x()+r.y()-r1.x()-r1.y())&1 ? oddstipple : 
evenstipple);
+  XSetFillStyle(xdisplay, xgc, FillStippled);
+  XSetFunction(xdisplay, xgc, GXxor);
+  XSetForeground(xdisplay, xgc, 0xffffffff);
   // X documentation claims a nonzero line width is necessary for stipple
   // to work. Without this the top-left dot is not drawn:
-  XSetLineAttributes(xdisplay, gc, 1, LineSolid, CapButt, JoinMiter);
-  XDrawRectangle(xdisplay, xwindow, gc, r.x(), r.y(), r.w()-1, r.h()-1);
-  XSetFillStyle(xdisplay, gc, FillSolid);
-  XSetFunction(xdisplay, gc, GXcopy);
+  XSetLineAttributes(xdisplay, xgc, 1, LineSolid, CapButt, JoinMiter);
+  XDrawRectangle(xdisplay, xwindow, xgc, r.x(), r.y(), r.w()-1, r.h()-1);
+  XSetFillStyle(xdisplay, xgc, FillSolid);
+  XSetFunction(xdisplay, xgc, GXcopy);
   // put line width back to zero:
-  XSetLineAttributes(xdisplay, gc, 0, LineSolid, CapButt, JoinMiter);
+  XSetLineAttributes(xdisplay, xgc, 0, LineSolid, CapButt, JoinMiter);
 
 #elif defined(_WIN32) || defined(_WIN32_WCE)
 # if 0
Index: src/clip.cxx
===================================================================
--- src/clip.cxx        (révision 6140)
+++ src/clip.cxx        (copie de travail)
@@ -91,8 +91,8 @@
   fl_clip_state_number++;
 #if USE_CAIRO
 #elif USE_X11
-  if (r) XSetRegion(xdisplay, gc, r);
-  else XSetClipMask(xdisplay, gc, 0);
+  if (r) XSetRegion(xdisplay, xgc, r);
+  else XSetClipMask(xdisplay, xgc, 0);
 #if USE_XFT
   if (xftc) {
     XftDrawSetClip(xftc, r);
Index: src/path.cxx
===================================================================
--- src/path.cxx        (révision 6140)
+++ src/path.cxx        (copie de travail)
@@ -690,7 +690,7 @@
 #elif USE_QUARTZ
   // Not implemented!
 #elif USE_X11
-  if (numpoints > 0) XDrawPoints(xdisplay, xwindow, gc, xpoint, numpoints, 0);
+  if (numpoints > 0) XDrawPoints(xdisplay, xwindow, xgc, xpoint, numpoints, 0);
 #elif defined(_WIN32)
   for (int i=0; i<numpoints; i++)
     SetPixel(dc, xpoint[i].x, xpoint[i].y, current_xpixel);
@@ -716,20 +716,20 @@
     const Rectangle& r = circle;
     if (r.w() < 2 || r.h() < 2) {
       if (!r.empty())
-       XFillRectangle(xdisplay, xwindow, gc, r.x(), r.y(), r.w(), r.h());
+       XFillRectangle(xdisplay, xwindow, xgc, r.x(), r.y(), r.w(), r.h());
     } else {
-      XDrawArc(xdisplay, xwindow, gc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
+      XDrawArc(xdisplay, xwindow, xgc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
     }
   }
   int loop_start = 0;
   for (int n = 0; n < loops; n++) {
     int loop_size = loop[n];
-    XDrawLines(xdisplay, xwindow, gc, xpoint+loop_start, loop_size, 0);
+    XDrawLines(xdisplay, xwindow, xgc, xpoint+loop_start, loop_size, 0);
     loop_start += loop_size;
   }
   int loop_size = numpoints-loop_start;
   if (loop_size > 1)
-    XDrawLines(xdisplay, xwindow, gc, xpoint+loop_start, loop_size, 0);
+    XDrawLines(xdisplay, xwindow, xgc, xpoint+loop_start, loop_size, 0);
 #elif defined(_WIN32)
   setpen();
   if (circle_type && circle_start != circle_end) {
@@ -781,13 +781,13 @@
     int A = int(circle_start*64);
     int B = int(circle_end*64)-A;
     const Rectangle& r = circle;
-    XSetArcMode(xdisplay, gc, circle_type == PIE ? ArcPieSlice : ArcChord);
+    XSetArcMode(xdisplay, xgc, circle_type == PIE ? ArcPieSlice : ArcChord);
     if (r.w() < 2 || r.h() < 2) {
       if (!r.empty())
-       XFillRectangle(xdisplay, xwindow, gc, r.x(), r.y(), r.w(), r.h());
+       XFillRectangle(xdisplay, xwindow, xgc, r.x(), r.y(), r.w(), r.h());
     } else {
-      XFillArc(xdisplay, xwindow, gc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
-      XDrawArc(xdisplay, xwindow, gc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
+      XFillArc(xdisplay, xwindow, xgc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
+      XDrawArc(xdisplay, xwindow, xgc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
     }
   }
   if (loops) closepath();
@@ -802,7 +802,7 @@
        xpoint[numpoints++] = xpoint[n];
       }
     }
-    XFillPolygon(xdisplay, xwindow, gc, xpoint, numpoints, 0, 0);
+    XFillPolygon(xdisplay, xwindow, xgc, xpoint, numpoints, 0, 0);
   }
 #elif defined(_WIN32)
   setbrush();
@@ -859,8 +859,8 @@
     int A = int(circle_start*64);
     int B = int(circle_end*64)-A;
     const Rectangle& r = circle;
-    XSetArcMode(xdisplay, gc, circle_type == PIE ? ArcPieSlice : ArcChord);
-    XFillArc(xdisplay, xwindow, gc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
+    XSetArcMode(xdisplay, xgc, circle_type == PIE ? ArcPieSlice : ArcChord);
+    XFillArc(xdisplay, xwindow, xgc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
   }
   closepath();
   if (numpoints > 2) {
@@ -875,7 +875,7 @@
        xpoint[numpoints++] = xpoint[n];
       }
     }
-    XFillPolygon(xdisplay, xwindow, gc, xpoint, numpoints, 0, 0);
+    XFillPolygon(xdisplay, xwindow, xgc, xpoint, numpoints, 0, 0);
     numpoints = saved_points; // throw away the extra points
   }
   setcolor(color);
Index: src/scrollrect.cxx
===================================================================
--- src/scrollrect.cxx  (révision 6140)
+++ src/scrollrect.cxx  (copie de travail)
@@ -145,7 +145,7 @@
   }
   int ox = 0; int oy = 0; transform(ox, oy);
 #if USE_X11
-  XCopyArea(xdisplay, xwindow, xwindow, gc,
+  XCopyArea(xdisplay, xwindow, xwindow, xgc,
            src_x+ox, src_y+oy, src_w, src_h,
            dest_x+ox, dest_y+oy);
 // Synchronous update by waiting for graphics expose events:
Index: src/setvisual.cxx
===================================================================
--- src/setvisual.cxx   (révision 6140)
+++ src/setvisual.cxx   (copie de travail)
@@ -103,7 +103,7 @@
 bool fltk::visual(int flags) {
   open_display();
   // always use default if possible:
-  if (test_visual(*xvisual, flags)) return true;
+  if (test_visual(*xvisualinfo, flags)) return true;
   // get all the visuals:
   XVisualInfo vTemplate;
   int num;
@@ -115,9 +115,9 @@
       found = &visualList[i];
   }
   if (!found) {XFree((void*)visualList); return false;}
-  xvisual = found;
+  xvisualinfo = found;
   xcolormap = XCreateColormap(xdisplay, RootWindow(xdisplay,xscreen),
-                             xvisual->visual, AllocNone);
+                             xvisualinfo->visual, AllocNone);
   return true;
 }
 
Index: src/overlay_rect.cxx
===================================================================
--- src/overlay_rect.cxx        (révision 6140)
+++ src/overlay_rect.cxx        (copie de travail)
@@ -38,10 +38,10 @@
 static void draw_current_rect() {
   if (pr.empty()) return;
 #if USE_X11
-  XSetFunction(xdisplay, gc, GXxor);
-  XSetForeground(xdisplay, gc, 0xffffffff);
+  XSetFunction(xdisplay, xgc, GXxor);
+  XSetForeground(xdisplay, xgc, 0xffffffff);
   strokerect(pr);
-  XSetFunction(xdisplay, gc, GXcopy);
+  XSetFunction(xdisplay, xgc, GXcopy);
 #elif defined(_WIN32)
   int old = SetROP2(dc, R2_NOT);
   strokerect(pr);
Index: src/MenuWindow.cxx
===================================================================
--- src/MenuWindow.cxx  (révision 6140)
+++ src/MenuWindow.cxx  (copie de travail)
@@ -90,6 +90,7 @@
   if (overlay() && fl_find_overlay_visual()) {
     XInstallColormap(xdisplay, fl_overlay_colormap);
     CreatedWindow::create(this, fl_overlay_visual, fl_overlay_colormap,
+                         None,
                          int(fl_transparent_pixel));
   } else
 #endif
@@ -102,7 +103,9 @@
   CreatedWindow *i = CreatedWindow::find(this);
   xwindow = i->xid;
   if (!menugc) menugc = XCreateGC(xdisplay, i->xid, 0, 0);
-  fltk::gc = menugc;
+  fltk::xgc = menugc;
+  fltk::xvisual = fl_overlay_visual;
+  fltk::xcolormap = fl_overlay_colormap;
   fl_overlay = true;
   current_ = this;
   bool expose =
@@ -124,7 +127,7 @@
 #if USE_OVERLAY
   // Fix the colormap flashing on Maximum Impact Graphics by erasing the
   // menu before unmapping it:
-  if (gc && shown()) XClearWindow(xdisplay, xid(this));
+  if (fltk::xgc && shown()) XClearWindow(xdisplay, xid(this));
 #endif
   Window::destroy();
 }
Index: src/own_colormap.cxx
===================================================================
--- src/own_colormap.cxx        (révision 6140)
+++ src/own_colormap.cxx        (copie de travail)
@@ -49,7 +49,7 @@
 void fltk::own_colormap() {
   open_display();
 #if USE_COLORMAP
-  switch (xvisual->c_class) {
+  switch (xvisualinfo->c_class) {
   case GrayScale :
   case PseudoColor :
   case DirectColor :
@@ -63,9 +63,13 @@
   for (i = 0; i < 16; i ++) colors[i].pixel = i;
   XQueryColors(xdisplay, xcolormap, colors, 16);
   // Create a new colormap...
+  /* XXX broken: colormap should apply to a window
+   * the colormap created here won't be stored in CreatedWindow data
+   * if this is not called before ALL windows creation.
+   */
   xcolormap = XCreateColormap(xdisplay,
                              RootWindow(xdisplay,xscreen),
-                             xvisual->visual, AllocNone);
+                             xvisualinfo->visual, AllocNone);
   // Copy those first 16 colors to our own colormap:
   for (i = 0; i < 16; i ++)
     XAllocColor(xdisplay, xcolormap, colors + i);
Index: src/GSave.cxx
===================================================================
--- src/GSave.cxx       (révision 6140)
+++ src/GSave.cxx       (copie de travail)
@@ -61,11 +61,27 @@
 extern fltk::Image* fl_current_Image;
 extern int fl_clip_w, fl_clip_h;
 
+#ifdef USE_X11
+struct GSaveX11
+{
+  XWindow      window;
+  XVisualInfo *visualinfo;
+  Colormap     colormap;
+  GC           gc;
+};
+#endif
+
 GSave::GSave() {
   push_matrix();
   push_no_clip();
 #if USE_X11
-  data[0] = (void*)(xwindow);
+  GSaveX11 *g = new GSaveX11;
+  g->window = xwindow;
+  g->visualinfo = xvisualinfo;
+  g->colormap = xcolormap;
+  g->gc = xgc;
+
+  data[0] = (void*)g;
 #elif defined(_WIN32)
   // make it not destroy the previous dc:
   data[0] = (void*)dc;
@@ -85,7 +101,17 @@
   fl_clip_w = v >> 16;
   fl_clip_h = v & 0xffff;
 #if USE_X11
-  if (data[0]) draw_into((XWindow)(data[0]), fl_clip_w, fl_clip_h);
+  if (data[0]) {
+    GSaveX11 * g = (GSaveX11 *)data[0];
+    if (g->window) {
+      draw_into(g->window, 
+               g->visualinfo,
+               g->colormap,
+               g->gc,
+               fl_clip_w, fl_clip_h);
+    }
+    delete g;
+  }
 #elif defined(_WIN32)
   dc = (HDC)(data[0]);
   DeleteDC(fl_bitmap_dc);
Index: src/x11/readimage.cxx
===================================================================
--- src/x11/readimage.cxx       (révision 6140)
+++ src/x11/readimage.cxx       (copie de travail)
@@ -113,15 +113,15 @@
 
   if (!image->red_mask && image->bits_per_pixel > 12) {
     // Greater than 12 bits must be TrueColor...
-    image->red_mask   = xvisual->visual->red_mask;
-    image->green_mask   = xvisual->visual->green_mask;
-    image->blue_mask   = xvisual->visual->blue_mask;
+    image->red_mask   = xvisualinfo->visual->red_mask;
+    image->green_mask   = xvisualinfo->visual->green_mask;
+    image->blue_mask   = xvisualinfo->visual->blue_mask;
   }
 
   // Check if we have colormap image...
   if (image->red_mask == 0) {
     // Get the colormap entries for this window...
-    maxindex = xvisual->visual->map_entries;
+    maxindex = xvisualinfo->visual->map_entries;
 
     for (i = 0; i < maxindex; i ++) colors[i].pixel = i;
 
Index: src/x11/Image.cxx
===================================================================
--- src/x11/Image.cxx   (révision 6140)
+++ src/x11/Image.cxx   (copie de travail)
@@ -892,7 +892,7 @@
     }
 
   i.format = ZPixmap;
-  i.depth = xvisual->depth;
+  i.depth = xvisualinfo->depth;
 //i.bitmap_unit = 8;
 //i.bitmap_bit_order = MSBFirst;
 //i.bitmap_pad = 8;
@@ -902,7 +902,7 @@
   if (!pfvlist) pfvlist = XListPixmapFormats(xdisplay,&NUM_pfv);
   XPixmapFormatValues *pfv;
   for (pfv = pfvlist; pfv < pfvlist+NUM_pfv; pfv++)
-    if (pfv->depth == xvisual->depth) break;
+    if (pfv->depth == xvisualinfo->depth) break;
   i.bits_per_pixel = pfv->bits_per_pixel;
 
   if (i.bits_per_pixel & 7) bytes_per_pixel = 0; // produce fatal error
@@ -923,7 +923,7 @@
     converter[RGB32] = argb32_to_8;
     return;
   }
-  if (!xvisual->red_mask)
+  if (!xvisualinfo->red_mask)
     fatal("Can't do %d bits_per_pixel colormap",i.bits_per_pixel);
 #endif
 
@@ -995,8 +995,8 @@
     // else fallthrough to failure case:
   default:
     fatal("Can't do %d-bit 0x%x 0x%x 0x%x visual",
-         i.bits_per_pixel, xvisual->red_mask,
-         xvisual->green_mask, xvisual->blue_mask);
+         i.bits_per_pixel, xvisualinfo->red_mask,
+         xvisualinfo->green_mask, xvisualinfo->blue_mask);
   }
   //printf("Use xshm %d\n", use_xshm_pixmaps);
 }
@@ -1201,7 +1201,12 @@
   } else
 #endif
     {ld = ((w_*bytes_per_pixel+scanline_add)&scanline_mask);
-    depth = xvisual->depth;}
+    depth = xvisualinfo->depth;}
+
+  /* XXX depth is given by the current visual
+   * which is hoped to be matching depth for the image usage
+   */
+
   picture = new Picture(w_, h_, depth, ld);
   memused_ += picture->n;
 #if USE_XFT
@@ -1349,6 +1354,7 @@
       i.bytes_per_line = picture->linedelta;
       static GC copygc;
       if (!copygc) copygc = XCreateGC(xdisplay, picture->rgb, 0, 0);
+      /* XXX if gc doesn't match: error */
       XPutImage(xdisplay, picture->rgb, copygc, &i, 0,0,0,0,w(),h());
     }
     if (picture->alpha)
@@ -1387,23 +1393,23 @@
       // There seems to be no way to combine a mask with a clip region,
       // so I just replace it. This will be incorrect if the current
       // clip is not a rectangle
-      XSetClipMask(xdisplay, gc, picture->alpha);
-      XSetClipOrigin(xdisplay, gc, r1.x(), r1.y());
-      XCopyArea(xdisplay, picture->rgb, xwindow, gc,
+      XSetClipMask(xdisplay, xgc, picture->alpha);
+      XSetClipOrigin(xdisplay, xgc, r1.x(), r1.y());
+      XCopyArea(xdisplay, picture->rgb, xwindow, xgc,
                 r.x()-r1.x(), r.y()-r1.y(), r.w(), r.h(), r.x(), r.y());
-      XSetClipOrigin(xdisplay, gc, 0, 0);
+      XSetClipOrigin(xdisplay, xgc, 0, 0);
       fl_restore_clip();
     } else {
       // xbmImage
-      XSetStipple(xdisplay, gc, picture->alpha);
-      XSetTSOrigin(xdisplay, gc, r1.x(), r1.y());
-      XSetFillStyle(xdisplay, gc, FillStippled);
-      XFillRectangle(xdisplay, xwindow, gc, r.x(), r.y(), r.w(), r.h());
-      XSetFillStyle(xdisplay, gc, FillSolid);
+      XSetStipple(xdisplay, xgc, picture->alpha);
+      XSetTSOrigin(xdisplay, xgc, r1.x(), r1.y());
+      XSetFillStyle(xdisplay, xgc, FillStippled);
+      XFillRectangle(xdisplay, xwindow, xgc, r.x(), r.y(), r.w(), r.h());
+      XSetFillStyle(xdisplay, xgc, FillSolid);
     }
   } else if (picture->rgb) {
     // RGB picture with no alpha
-    XCopyArea(xdisplay, picture->rgb, xwindow, gc,
+    XCopyArea(xdisplay, picture->rgb, xwindow, xgc,
               r.x()-r1.x(), r.y()-r1.y(), r.w(), r.h(), r.x(), r.y());
   }
 }
@@ -1424,7 +1430,7 @@
     // initialise
     if (w_ > 0 && h_ > 0) {
       int ld = buffer_linedelta();
-      int depth = xvisual->depth;
+      int depth = xvisualinfo->depth;
       picture = new Picture(w_, h_, depth, ld, true);
       memused_ += picture->n;
       // the copy operation in draw() does not seem to do anything
@@ -1435,7 +1441,7 @@
     }
   }
 
-  draw_into(picture->rgb, picture->w, picture->h);
+  draw_into(picture->rgb, xvisualinfo, xcolormap, xgc, picture->w, picture->h);
 }
 
 ////////////////////////////////////////////////////////////////
@@ -1518,7 +1524,7 @@
   if (buf && conv==direct_32 && !(linedelta&scanline_add)) {
     i.data = (char *)buf;
     i.bytes_per_line = linedelta;
-    XPutImage(xdisplay, xwindow, gc, &i, 0, 0, x, y, w, h);
+    XPutImage(xdisplay, xwindow, xgc, &i, 0, 0, x, y, w, h);
   } else {
     int blocking = h;
     static U32* buffer;        // our storage, always word aligned
@@ -1546,7 +1552,7 @@
          buf += linedelta;
          to += linesize;
        }
-        XPutImage(xdisplay, xwindow, gc, &i, 0, 0, x, y+j-k, w, k);
+        XPutImage(xdisplay, xwindow, xgc, &i, 0, 0, x, y+j-k, w, k);
       }
     } else {
       U32* linebuf = new U32[(r1.w()*delta+3)/4];
@@ -1558,7 +1564,7 @@
          conv(ret, (uchar*)to, w);
          to += linesize;
        }
-        XPutImage(xdisplay, xwindow, gc, &i, 0, 0, x, y+j-k, w, k);
+        XPutImage(xdisplay, xwindow, xgc, &i, 0, 0, x, y+j-k, w, k);
       }
       delete[] linebuf;
     }
Index: src/x11/Font_xlfd.cxx
===================================================================
--- src/x11/Font_xlfd.cxx       (révision 6140)
+++ src/x11/Font_xlfd.cxx       (copie de travail)
@@ -420,17 +420,17 @@
 #endif // X_UTF8_FONT
 
 void fltk::drawtext_transformed(const char *text, int n, float x, float y) {
-  if (font_gc != gc) {
+  if (font_gc != xgc) {
     // I removed this, the user MUST set the font before drawing: (was)
     // if (!current) setfont(HELVETICA, NORMAL_SIZE);
-    font_gc = gc;
-    XSetFont(xdisplay, gc, current->font->fid);
+    font_gc = xgc;
+    XSetFont(xdisplay, xgc, current->font->fid);
   }
   int count;
   XChar2b* buffer = utf8to2b(text,n,&count);
   if (buffer) {
 #if !X_UTF8_FONT
-    XDrawString16(xdisplay, xwindow, gc,
+    XDrawString16(xdisplay, xwindow, xgc,
                  int(floorf(x+.5f)),
                  int(floorf(y+.5f)), buffer, count);
 #else
@@ -453,19 +453,19 @@
       } else
        f = current->font;
       if (f != oldf) {
-        XSetFont(xdisplay, gc, f->fid);
+        XSetFont(xdisplay, xgc, f->fid);
        oldf = f;
       }
-      XDrawString16(xdisplay, xwindow, gc,
+      XDrawString16(xdisplay, xwindow, xgc,
                  int(floorf(x+.5f)),
                  int(floorf(y+.5f)), &buffer[i], 1);
       x += XTextWidth16(f, &buffer[i], 1);
     }
-    XSetFont(xdisplay, gc, current->font->fid);
+    XSetFont(xdisplay, xgc, current->font->fid);
 #endif
     delete[] buffer;
   } else {
-    XDrawString(xdisplay, xwindow, gc,
+    XDrawString(xdisplay, xwindow, xgc,
                int(floorf(x+.5f)),
                int(floorf(y+.5f)), text, n);
   }
Index: src/x11/setcolor.cxx
===================================================================
--- src/x11/setcolor.cxx        (révision 6140)
+++ src/x11/setcolor.cxx        (copie de travail)
@@ -42,7 +42,7 @@
 static void figure_out_visual() {
   beenhere = 1;
   open_display();
-  if (!xvisual->red_mask || !xvisual->green_mask || !xvisual->blue_mask){
+  if (!xvisualinfo->red_mask || !xvisualinfo->green_mask || 
!xvisualinfo->blue_mask){
 #if USE_COLORMAP
     fl_redmask = 0;
     // make sure black & white are allocated:
@@ -57,20 +57,20 @@
   // get the bit masks into a more useful form:
   int i,j,m;
 
-  for (i = 0, m = 1; m; i++, m<<=1) if (xvisual->red_mask & m) break;
-  for (j = i; m; j++, m<<=1) if (!(xvisual->red_mask & m)) break;
+  for (i = 0, m = 1; m; i++, m<<=1) if (xvisualinfo->red_mask & m) break;
+  for (j = i; m; j++, m<<=1) if (!(xvisualinfo->red_mask & m)) break;
   fl_redshift = j-8;
   fl_redbits = j-i; if (fl_redbits > 8) fl_redbits = 8;
   fl_redmask = 0xff << (8-fl_redbits);
 
-  for (i = 0, m = 1; m; i++, m<<=1) if (xvisual->green_mask & m) break;
-  for (j = i; m; j++, m<<=1) if (!(xvisual->green_mask & m)) break;
+  for (i = 0, m = 1; m; i++, m<<=1) if (xvisualinfo->green_mask & m) break;
+  for (j = i; m; j++, m<<=1) if (!(xvisualinfo->green_mask & m)) break;
   fl_greenshift = j-8;
   fl_greenbits = j-i; if (fl_greenbits > 8) fl_greenbits = 8;
   fl_greenmask = 0xff << (8-fl_greenbits);
 
-  for (i = 0, m = 1; m; i++, m<<=1) if (xvisual->blue_mask & m) break;
-  for (j = i; m; j++, m<<=1) if (!(xvisual->blue_mask & m)) break;
+  for (i = 0, m = 1; m; i++, m<<=1) if (xvisualinfo->blue_mask & m) break;
+  for (j = i; m; j++, m<<=1) if (!(xvisualinfo->blue_mask & m)) break;
   fl_blueshift = j-8;
   fl_bluebits = j-i; if (fl_bluebits > 8) fl_bluebits = 8;
   fl_bluemask = 0xff << (8-fl_bluebits);
@@ -195,7 +195,7 @@
 #if USE_OVERLAY | USE_GL_OVERLAY
     if (fl_overlay) numcolors = fl_overlay_visual->colormap_size; else
 #endif
-      numcolors = xvisual->colormap_size;
+      numcolors = xvisualinfo->colormap_size;
     if (!allcolors) allcolors = new XColor[numcolors];
     for (int p = numcolors; p--;) allcolors[p].pixel = p;
     XQueryColors(xdisplay, colormap, allcolors, numcolors);
@@ -249,7 +249,7 @@
   cairo_set_source_rgb(cc,r/255.0,g/255.0,b/255.0);
 #endif
   current_xpixel = xpixel(i);
-  XSetForeground(xdisplay, gc, current_xpixel);
+  XSetForeground(xdisplay, xgc, current_xpixel);
 }
 
 // This is used by setcolor_index()
@@ -347,10 +347,10 @@
     cairo_set_dash(cc, 0, 0, 0);
   }
 #else
-  if (ndashes) XSetDashes(xdisplay, gc, 0, dashes, ndashes);
+  if (ndashes) XSetDashes(xdisplay, xgc, 0, dashes, ndashes);
   static int Cap[4] = {CapButt, CapButt, CapRound, CapProjecting};
   static int Join[4] = {JoinMiter, JoinMiter, JoinRound, JoinBevel};
-  XSetLineAttributes(xdisplay, gc, int(width+.5),
+  XSetLineAttributes(xdisplay, xgc, int(width+.5),
                     ndashes ? LineOnOffDash : LineSolid,
                     Cap[(style>>8)&3], Join[(style>>12)&3]);
 #endif
Index: src/x11/run.cxx
===================================================================
--- src/x11/run.cxx     (révision 6140)
+++ src/x11/run.cxx     (copie de travail)
@@ -519,7 +519,7 @@
 A portable interface to get a TrueColor visual (which is probably
 the only reason to do this) is to call fltk::visual(int).
 */
-XVisualInfo *fltk::xvisual;
+XVisualInfo *fltk::xvisualinfo;
 
 /**
 The colormap being used by FLTK. This is needed as an argument for
@@ -651,7 +651,7 @@
   // construct an XVisualInfo that matches the default Visual:
   XVisualInfo templt; int num;
   templt.visualid = XVisualIDFromVisual(DefaultVisual(d, xscreen));
-  xvisual = XGetVisualInfo(d, VisualIDMask, &templt, &num);
+  xvisualinfo = XGetVisualInfo(d, VisualIDMask, &templt, &num);
   xcolormap = DefaultColormap(d, xscreen);
 #if USE_XIM
   fl_init_xim();
@@ -739,7 +739,7 @@
     }
     if (buffer) {XFree(buffer); buffer = 0;}
 
-    monitor.depth_ = xvisual->depth;
+    monitor.depth_ = xvisualinfo->depth;
 
     // do any screens really return 0 for MM?
     int mm = DisplayWidthMM(xdisplay, xscreen);
@@ -1963,6 +1963,8 @@
 
 extern bool fl_show_iconic; // In Window.cxx, set by iconize() or -i switch
 
+static bool can_xdbe(CreatedWindow *);
+
 /**
 This virtual function may be overridden to use something other than
 FLTK's default code to create the system's window. This must call
@@ -1989,7 +1991,7 @@
 \endcode
 */
 void Window::create() {
-  CreatedWindow::create(this, xvisual, xcolormap, -1);
+  CreatedWindow::create(this, xvisualinfo, xcolormap, xgc, -1);
 }
 
 /**
@@ -2000,7 +2002,9 @@
 color, use -1 to indicate that no background filling should be done.
 */
 void CreatedWindow::create(Window* window,
-                          XVisualInfo *visual, Colormap colormap,
+                          XVisualInfo *visualinfo,
+                          Colormap colormap,
+                          GC gc,
                           int background)
 {
   XSetWindowAttributes attr;
@@ -2081,17 +2085,52 @@
     mask |= CWBackPixel;
   }
 
-  CreatedWindow* x = CreatedWindow::set_xid(window,
-    XCreateWindow(xdisplay,
-                 root,
-                 X, Y, W, H,
-                 0, // borderwidth
-                 visual->depth,
-                 InputOutput,
-                 visual->visual,
-                 mask, &attr));
+  CreatedWindow* x = new CreatedWindow;
+
+  x->backbuffer = 0;
+  x->frontbuffer = 0;
+  x->overlay = false;
+  x->window = window; window->i = x;
+  x->region = 0;
+  x->wait_for_expose = false;
+  x->cursor = None;
+  x->cursor_for = 0;
+  x->next = CreatedWindow::first;
+  CreatedWindow::first = x;
+
+  x->xid = XCreateWindow(xdisplay,
+                        root,
+                        X, Y, W, H,
+                        0, // borderwidth
+                        visualinfo->depth,
+                        InputOutput,
+                        visualinfo->visual,
+                        mask, &attr);
+
   x->current_size.set(X, Y, W, H);
 
+  x->visualinfo = visualinfo;
+  x->colormap = colormap;
+
+  if (gc == None) {
+    if (visualinfo->visualid == xvisualinfo->visualid) {
+      /* if given visual match global visual, use the global gc, */
+      if (!xgc) {
+       xgc = XCreateGC(xdisplay, x->xid, 0, (XGCValues *)0);
+      }
+      x->gc = xgc;
+    } else {
+      /* else create a dedicated gc */
+      x->gc = XCreateGC(xdisplay, x->xid, 0, (XGCValues *)0);
+    }
+  } else {
+    x->gc = gc;
+  }
+
+#if USE_XDBE
+  x->use_xdbe = can_xdbe(x);
+#endif
+
   if (!window->parent() && !window->override()) {
     // send all kinds 'o junk to X Window Manager:
     x->wait_for_expose = true;
@@ -2183,9 +2222,16 @@
 
 /** Set things up so that xid(window) returns \a winxid. Thus you will
 make that Window draw into an existing X window. */
-CreatedWindow* CreatedWindow::set_xid(Window* window, XWindow winxid) {
+CreatedWindow* CreatedWindow::set_xid(Window* window, 
+                                     XWindow winxid,
+                                     XVisualInfo *visualinfo,
+                                     Colormap colormap,
+                                     GC gc) {
   CreatedWindow* x = new CreatedWindow;
   x->xid = winxid;
+  x->visualinfo = visualinfo;
+  x->colormap = colormap;
+  x->gc = gc;
   x->backbuffer = 0;
   x->frontbuffer = 0;
   x->overlay = false;
@@ -2196,6 +2242,11 @@
   x->cursor_for = 0;
   x->next = CreatedWindow::first;
   CreatedWindow::first = x;
+
+#if USE_XDBE
+  x->use_xdbe = can_xdbe(x);
+#endif
+
   return x;
 }
 
@@ -2332,7 +2383,7 @@
 XDrawSomething(xdisplay, xwindow, gc, ...);
 \endcode
 */
-GC fltk::gc;
+GC fltk::xgc;
 
 #if USE_CAIRO
 cairo_t* fltk::cc;
@@ -2367,7 +2418,11 @@
   const Window* window = (const Window*)widget;
   Window::drawing_window_ = window;
   CreatedWindow* i = CreatedWindow::find(window);
-  draw_into(i->frontbuffer ? i->frontbuffer : i->xid, window->w(), 
window->h());
+  draw_into(i->frontbuffer ? i->frontbuffer : i->xid, 
+           i->visualinfo,
+           i->colormap,
+           i->gc,
+           window->w(), window->h());
   translate(x,y);
 }
 
@@ -2378,8 +2433,9 @@
 /** Fltk cairo create surface function accepting a Window* as input */
 cairo_surface_t* fltk::cairo_create_surface(Window* wi) {
   XWindow window = fltk::xid(wi);
+  CreatedWindow *wc = fltk::CreatedWindow::find(wi);
   cairo_surface_t* surface =  cairo_xlib_surface_create(xdisplay, window, 
-                                  xvisual->visual, wi->w(), wi->h());
+                                  wc->visualinfo->visual, wi->w(), wi->h());
   cairo_xlib_surface_set_size(surface, wi->w(), wi->h());
   return surface;
 }
@@ -2396,26 +2452,41 @@
   fltk::stop_drawing() so that it can destroy any temporary structures
   that were created by this.
 */
-void fltk::draw_into(XWindow window, int w, int h) {
+void fltk::draw_into(XWindow window, 
+                    XVisualInfo *visualinfo,
+                    Colormap colormap,
+                    GC gc,
+                    int w, int h) {
   fl_current_Image = 0;
   fl_clip_w = w;
   fl_clip_h = h;
 
   if (xwindow != window) {
-    xwindow = window;
 
-    // The X11 GC structure does not contain the drawable, so only
-    // one is needed and it can be reused all we want:
-    if (!fltk::gc) fltk::gc = XCreateGC(xdisplay, window, 0, 0);
-
 #if USE_XFT
     // It appears that Xft contexts can be reused for different drawables:
-    if (!fltk::xftc)
-      xftc = XftDrawCreate(xdisplay, window, xvisual->visual, xcolormap);
-    else
-      XftDrawChange(xftc, window);
+    if (!fltk::xftc) {
+      xftc = XftDrawCreate(xdisplay, window, 
+                          visualinfo->visual, 
+                          colormap);
+    } else {
+      if (xvisualinfo->visualid == visualinfo->visualid) {
+       XftDrawChange(xftc, window);
+      } else {
+       XftDrawDestroy(xftc);
+
+       xftc = XftDrawCreate(xdisplay, window, 
+                            visualinfo->visual, 
+                            colormap);
+      }
+    }
 #endif
 
+    xwindow = window;
+    xvisualinfo = visualinfo;
+    xcolormap = colormap;
+    xgc = gc;
+
 #if USE_CAIRO
     cairo_status_t cstatus;
     if (cc) {
@@ -2428,7 +2499,8 @@
       cairo_xlib_surface_set_drawable(surface, window, w, h);
     } else {
     CREATE_SURFACE:
-      surface = cairo_xlib_surface_create(xdisplay, window, xvisual->visual, 
w, h);
+      surface = cairo_xlib_surface_create(xdisplay, window, 
+                                         visualinfo->visual, w, h);
       cc = cairo_create(surface);
       // emulate line_style(0):
       cairo_set_line_width(cc, 1);
@@ -2472,26 +2544,35 @@
 #include <X11/extensions/Xdbe.h>
 #undef Window
 
-static bool use_xdbe = false; // true if we are using the XDBE extension
+// Figure out if the current visual can use XDBE and set use_xdbe.
+static bool can_xdbe(CreatedWindow *x) {
 
-// Figure out if the current visual can use XDBE and set use_xdbe.
-static bool can_xdbe() {
   static bool tried = false;
+  static XdbeScreenVisualInfo *dbevisualinfo = NULL;
+
   if (!tried) {
     tried = true;
     int event_base, error_base;
     if (!XdbeQueryExtension(xdisplay, &event_base, &error_base)) return false;
+
     XWindow root = RootWindow(xdisplay, xscreen);
+
     int numscreens = 1;
-    XdbeScreenVisualInfo *a = XdbeGetVisualInfo(xdisplay, &root, &numscreens);
-    if (a) {
-      for (int j = 0; j < a->count; j++)
-       if (a->visinfo[j].visual == xvisual->visualid
-           /*&& a->visinfo[j].perflevel > 0*/) {use_xdbe = true; break;}
-      XdbeFreeVisualInfo(a);
+
+    dbevisualinfo = XdbeGetVisualInfo(xdisplay, &root, &numscreens);
+  }
+   
+  if (dbevisualinfo == NULL) {
+    return false;
+  }
+
+  for (int j = 0; j < dbevisualinfo->count; j++)
+    if (dbevisualinfo->visinfo[j].visual == x->visualinfo->visualid
+         /*&& a->visinfo[j].perflevel > 0*/) {
+      return true;
     }
-  }
-  return use_xdbe;
+
+  return false;
 }
 
 #endif
@@ -2523,7 +2604,7 @@
 
     if (!i->backbuffer) { // we need to create back buffer
 #if USE_XDBE
-      if (can_xdbe()) {
+      if (i->use_xdbe) {
        if (!i->frontbuffer && !parent()) {
          XSetWindowAttributes attr;
          attr.border_pixel = 0;
@@ -2539,8 +2620,8 @@
          i->frontbuffer =
            XCreateWindow(xdisplay, i->xid,
                          0, 0, w(), h(),
-                         0, xvisual->depth, InputOutput,
-                         xvisual->visual, mask, &attr);
+                         0, i->visualinfo->depth, InputOutput,
+                         i->visualinfo->visual, mask, &attr);
          XLowerWindow(xdisplay, i->frontbuffer);
          XMapWindow(xdisplay, i->frontbuffer);
          frontbuffer = i->frontbuffer;
@@ -2550,7 +2631,7 @@
       } else
 #endif
        i->backbuffer =
-         XCreatePixmap(xdisplay, frontbuffer, w(), h(), xvisual->depth);
+         XCreatePixmap(xdisplay, frontbuffer, w(), h(), i->visualinfo->depth);
       set_damage(DAMAGE_ALL); damage = DAMAGE_ALL;
       i->backbuffer_bad = false;
     } else if (i->backbuffer_bad) {
@@ -2562,7 +2643,8 @@
     // draw the back buffer if it needs anything:
     if (damage) {
       // set the graphics context to draw into back buffer:
-      draw_into(i->backbuffer, w(), h());
+      draw_into(i->backbuffer, i->visualinfo, i->colormap, i->gc,
+               w(), h());
       if (damage & DAMAGE_ALL) {
        draw();
       } else {
@@ -2581,7 +2663,7 @@
       }
 #if USE_XDBE
       // use the faster Xdbe swap command for all normal redraw():
-      if (use_xdbe && !eraseoverlay && (damage&~DAMAGE_EXPOSE)) {
+      if (i->use_xdbe && !eraseoverlay && (damage&~DAMAGE_EXPOSE)) {
        XdbeSwapInfo s;
        s.swap_window = frontbuffer;
        s.swap_action = XdbeUndefined;
@@ -2592,11 +2674,11 @@
        return;
       }
 #endif
-      draw_into(frontbuffer, w(), h());
+      draw_into(frontbuffer, i->visualinfo, i->colormap, i->gc, w(), h());
     } else {
       // if damage is zero then expose events were done, just copy
       // the back buffer to the front:
-      draw_into(frontbuffer, w(), h());
+      draw_into(frontbuffer, i->visualinfo, i->colormap, i->gc, w(), h());
       if (!eraseoverlay) {
        clip_region(i->region); i->region = 0;
       }
@@ -2607,7 +2689,7 @@
     // down to the clipped area. Seems to be a pretty bad implementation:
     Rectangle r(w(),h());
     intersect_with_clip(r);
-    XCopyArea(xdisplay, i->backbuffer, frontbuffer, gc,
+    XCopyArea(xdisplay, i->backbuffer, frontbuffer, i->gc,
              r.x(), r.y(), r.w(), r.h(), r.x(), r.y());
     if (i->overlay) draw_overlay();
     clip_region(0);
@@ -2615,7 +2697,7 @@
   }  else {
 
     // Single buffer drawing
-    draw_into(frontbuffer, w(), h());
+    draw_into(frontbuffer, i->visualinfo, i->colormap, i->gc, w(), h());
     unsigned char damage = this->damage();
     if (damage & ~DAMAGE_EXPOSE) {
       set_damage(damage & ~DAMAGE_EXPOSE);
@@ -2636,7 +2718,7 @@
   if (!i || !i->backbuffer) return;
   stop_drawing(i->backbuffer);
 #if USE_XDBE
-  if (use_xdbe) return;
+  if (i->use_xdbe) return;
 #endif
   XFreePixmap(xdisplay, i->backbuffer);
   i->backbuffer = 0;
@@ -2727,7 +2809,7 @@
     // resize the windows used for double-buffering:
     if (layout_damage() & LAYOUT_WH) {
 #if USE_XDBE
-      if (use_xdbe) {
+      if (i->use_xdbe) {
        if (i->frontbuffer) {
          XResizeWindow(xdisplay, i->frontbuffer, w, h);
 # if USE_XFT
Index: test/color_chooser.cxx
===================================================================
--- test/color_chooser.cxx      (révision 6140)
+++ test/color_chooser.cxx      (copie de travail)
@@ -141,10 +141,10 @@
     fltk::open_display();
     XVisualInfo templt; int num;
     templt.visualid = visid;
-    fltk::xvisual= XGetVisualInfo(fltk::xdisplay, VisualIDMask, &templt, &num);
-    if (!fltk::xvisual) fltk::fatal("No visual with id %d",visid);
+    fltk::xvisualinfo = XGetVisualInfo(fltk::xdisplay, VisualIDMask, &templt, 
&num);
+    if (!fltk::xvisualinfo ) fltk::fatal("No visual with id %d",visid);
     fltk::xcolormap = XCreateColormap(fltk::xdisplay, 
RootWindow(fltk::xdisplay,fltk::xscreen),
-                                 fltk::xvisual->visual, AllocNone);
+                                 fltk::xvisualinfo->visual, AllocNone);
     fltk::xpixel(fltk::BLACK); // make sure black is allocated
 #else
     fltk::fatal("Visual id's not supported on this platform");
Index: test/image.cxx
===================================================================
--- test/image.cxx      (révision 6140)
+++ test/image.cxx      (copie de travail)
@@ -259,14 +259,14 @@
     open_display();
     XVisualInfo templt; int num;
     templt.visualid = visid;
-    xvisual = XGetVisualInfo(xdisplay, VisualIDMask, &templt, &num);
-    if (!xvisual) {
+    xvisualinfo = XGetVisualInfo(xdisplay, VisualIDMask, &templt, &num);
+    if (!xvisualinfo) {
       fprintf(stderr, "No visual with id %d, use one of:\n",visid);
       list_visuals();
       exit(1);
     }
     xcolormap = XCreateColormap(xdisplay, RootWindow(xdisplay,xscreen),
-                               xvisual->visual, AllocNone);
+                               xvisualinfo->visual, AllocNone);
     xpixel(BLACK); // make sure black is allocated in overlay visuals
   } else {
     visual(RGB_COLOR);
Index: fltk/x11.h
===================================================================
--- fltk/x11.h  (révision 6140)
+++ fltk/x11.h  (copie de travail)
@@ -91,8 +91,6 @@
 extern FL_API Display* xdisplay;
 extern FL_API XWindow  message_window;
 extern FL_API int      xscreen;
-extern FL_API XVisualInfo* xvisual;
-extern FL_API Colormap xcolormap;
 
 ////////////////////////////////////////////////////////////////
 // event handling:
@@ -117,14 +115,16 @@
 // drawing functions:
 
 extern FL_API XftDraw* xftc;
-extern FL_API GC       gc;
+extern FL_API XVisualInfo* xvisualinfo;
+extern FL_API Colormap xcolormap;
+extern FL_API GC       xgc;
 extern FL_API XWindow  xwindow;
 extern FL_API ulong    current_xpixel;
 extern FL_API ulong    xpixel(Color i);
 extern FL_API void     clip_region(Region);
 extern FL_API Region   clip_region();
 
-extern FL_API void     draw_into(XWindow, int w, int h);
+extern FL_API void     draw_into(XWindow, XVisualInfo *, Colormap, GC, int w, 
int h);
 extern FL_API void     stop_drawing(XWindow);
 
 extern FL_API XFontStruct* xfont();
@@ -144,6 +144,10 @@
   XWindow xid;
   XWindow backbuffer;
   XWindow frontbuffer;
+  XVisualInfo* visualinfo;
+  Colormap     colormap;
+  GC gc;
+  bool use_xdbe; // used for XDBE
   Window *window;
   Region region;
   void expose(const Rectangle&);
@@ -157,9 +161,9 @@
   static CreatedWindow* find(const Window* window) {return window->i;}
   void sendxjunk();
   static void create(Window*,
-                    XVisualInfo*, Colormap,
+                    XVisualInfo*, Colormap, GC,
                     int background = -1);
-  static CreatedWindow* set_xid(Window*, XWindow);
+  static CreatedWindow* set_xid(Window*, XWindow, XVisualInfo *, Colormap, GC);
   Rectangle current_size;
 };
 
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to