freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Devel] colormap - ft2demos/graph/x11/grx11.c


From: Taiji Yamada
Subject: [Devel] colormap - ft2demos/graph/x11/grx11.c
Date: Fri, 30 Nov 2001 15:24:49 +0900 (JST)

Dear Sir -
        maintainers of ft2demos/graph/x11/grx11.c,

I came up against small problem at using ftview on some X11
environments, so I made a patch to solve the problem.

In the case of using ftview under X11-PseudoColor visualclass, ftview
often gives up the idea of allocating colors with following message:

        grx11.init_surface: cannot allocate colour

here I hope that ftview does it with more effort. There is X11-general
method of using private colormap and not default colormap when shared
colormap entries are used up.

Attached patch is for using private colormap when ftview cannot
allocate color of default colormap at X11 device.

Main modifications are in lines about 784 and 827. The modification of
lines about 142 is not always necessary if 'done_surface' considers a
termination only and not reentrant by 'init_surface'.


Yours sincerely,

||                                                    Taiji Yamada
|| R&D Team, Kanto Branch, AIHARA Electrical Engineering Co., Ltd.
|| E-mail: address@hidden URL: http://www.aihara.co.jp/~taiji/


--- grx11.c~    Fri Nov 30 14:07:04 2001
+++ grx11.c     Fri Nov 30 14:07:38 2001
@@ -142,6 +142,11 @@
   void  done_surface( grXSurface*  surface )
   {
     XUnmapWindow( display, surface->win );
+    if ( surface->colormap != DefaultColormap( display,
+                                              DefaultScreen( display ) ) ) {
+      XFreeColormap( display, surface->colormap );
+      surface->colormap = DefaultColormap( display, DefaultScreen( display ) );
+    }
   }
 
 
@@ -784,7 +789,16 @@
         color->blue  = 65535 - ( i * 65535 ) / bitmap->grays;
 
         if ( !XAllocColor( display, surface->colormap, color ) )
-          Panic( "grx11.init_surface: cannot allocate colour\n" );
+       {
+          printf( "grx11.init_surface: warning: "
+                 "cannot allocate colour at default colormap\n" );
+         if ( surface->colormap == DefaultColormap( display, screen ) )
+           surface->colormap = XCopyColormapAndFree( display,
+                                                     surface->colormap );
+         if ( !XAllocColor( display, surface->colormap, color ) )
+           Panic( "grx11.init_surface: "
+                  "cannot allocate colour at private colormap\n" );
+       }
 
         if ( step > 1 )
         {
@@ -827,6 +841,8 @@
                                       CWEventMask | CWCursor,
                                     &xswa );
 
+      if ( surface->colormap != DefaultColormap( display, screen ) )
+       XSetWindowColormap( display, surface->win, surface->colormap );
       XMapWindow( display, surface->win );
 
       surface->gc = XCreateGC( display, RootWindow( display, screen ),



reply via email to

[Prev in Thread] Current Thread [Next in Thread]