PreRvIcccm.c

Go to the documentation of this file.
00001 /*
00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00003 %                                                                             %
00004 %                                                                             %
00005 %                                                                             %
00006 %                                                                             %
00007 %                      IIIII   CCCC   CCCC   CCCC  M   M                      %
00008 %                        I    C      C      C      MM MM                      %
00009 %                        I    C      C      C      M M M                      %
00010 %                        I    C      C      C      M   M                      %
00011 %                      IIIII   CCCC   CCCC   CCCC  M   M                      %
00012 %                                                                             %
00013 %                     MagickCore X11 Compatibility Methods                    %
00014 %                                                                             %
00015 %                               Software Design                               %
00016 %                                 John Cristy                                 %
00017 %                                December 1994                                %
00018 %                                                                             %
00019 %                                                                             %
00020 %  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
00021 %  dedicated to making software imaging solutions freely available.           %
00022 %                                                                             %
00023 %  You may not use this file except in compliance with the License.  You may  %
00024 %  obtain a copy of the License at                                            %
00025 %                                                                             %
00026 %    http://www.imagemagick.org/script/license.php                            %
00027 %                                                                             %
00028 %  Unless required by applicable law or agreed to in writing, software        %
00029 %  distributed under the License is distributed on an "AS IS" BASIS,          %
00030 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
00031 %  See the License for the specific language governing permissions and        %
00032 %  limitations under the License.                                             %
00033 %                                                                             %
00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00035 %
00036 %
00037 */
00038 
00039 #include "magick/studio.h"
00040 #if defined(MAGICKCORE_X11_DELEGATE)
00041 #include "magick/xwindow-private.h"
00042 
00043 #if defined(PRE_R6_ICCCM)
00044 /*
00045   Compatibility methods for pre X11R6 ICCCM.
00046 */
00047 Status XInitImage(XImage *ximage)
00048 {
00049   Display
00050     display;
00051 
00052   ScreenFormat
00053     screen_format;
00054 
00055   XImage
00056     *created_ximage,
00057     target_ximage;
00058 
00059   /*
00060     Initialize the X image.
00061   */
00062   screen_format.depth=ximage->depth;
00063   screen_format.bits_per_pixel=(int) ximage->bits_per_pixel;
00064   display.byte_order=ximage->byte_order;
00065   display.bitmap_unit=ximage->bitmap_unit;
00066   display.bitmap_bit_order=ximage->bitmap_bit_order;
00067   display.pixmap_format=(&screen_format);
00068   display.nformats=1;
00069   created_ximage=XCreateImage(&display,(Visual *) NULL,ximage->depth,
00070     ximage->format,ximage->xoffset,(char *) NULL,ximage->width,ximage->height,
00071     ximage->bitmap_pad,ximage->bytes_per_line);
00072   if (created_ximage == (XImage *) NULL)
00073     return(0);
00074   target_ximage=(*ximage);
00075   *ximage=(*created_ximage);
00076   created_ximage->data=(char *) NULL;
00077   XDestroyImage(created_ximage);
00078   ximage->red_mask=target_ximage.red_mask;
00079   ximage->green_mask=target_ximage.green_mask;
00080   ximage->blue_mask=target_ximage.blue_mask;
00081   return(1);
00082 }
00083 #endif
00084 
00085 #if defined(PRE_R5_ICCCM)
00086 /*
00087   Compatibility methods for pre X11R5 ICCCM.
00088 */
00089 void XrmCombineDatabase(XrmDatabase source,XrmDatabase *target,
00090   Bool override)
00091 {
00092   XrmMergeDatabases(source,target);
00093 }
00094 
00095 Status XrmCombineFileDatabase(const char *filename,XrmDatabase *target,
00096   Bool override)
00097 {
00098   XrmDatabase
00099     *combined_database,
00100     source;
00101 
00102   source=XrmGetFileDatabase(filename);
00103   if (override == MagickFalse)
00104     XrmMergeDatabases(source,target);
00105   return(1);
00106 }
00107 
00108 XrmDatabase XrmGetDatabase(Display *display)
00109 {
00110   return(display->db);
00111 }
00112 
00113 char *XSetLocaleModifiers(char *modifiers)
00114 {
00115   return((char *) NULL);
00116 }
00117 
00118 Bool XSupportsLocale()
00119 {
00120   return(0);
00121 }
00122 #endif
00123 
00124 #if defined(PRE_R4_ICCCM)
00125 /*
00126   Compatibility methods for pre X11R4 ICCCM.
00127 */
00128 XClassHint *XAllocClassHint)
00129 {
00130   return((XClassHint *) AcquireAlignedMemory(1,sizeof(XClassHint)));
00131 }
00132 
00133 XIconSize *XAllocIconSize)
00134 {
00135   return((XIconSize *) AcquireAlignedMemory(1,sizeof(XIconSize)));
00136 }
00137 
00138 XSizeHints *XAllocSizeHints)
00139 {
00140   return((XSizeHints *) AcquireAlignedMemory(1,sizeof(XSizeHints)));
00141 }
00142 
00143 Status XReconfigureWMWindow(Display *display,Window window,int screen_number,
00144   unsigned int value_mask,XWindowChanges *values)
00145 {
00146   return(XConfigureWindow(display,window,value_mask,values));
00147 }
00148 
00149 XStandardColormap *XAllocStandardColormap)
00150 {
00151   return((XStandardColormap *) AcquireAlignedMemory(1,sizeof(XStandardColormap)));
00152 }
00153 
00154 XWMHints *XAllocWMHints)
00155 {
00156   return((XWMHints *) AcquireAlignedMemory(1,sizeof(XWMHints)));
00157 }
00158 
00159 Status XGetGCValues(Display *display,GC gc,size_t mask,
00160   XGCValues *values)
00161 {
00162   return(MagickTrue);
00163 }
00164 
00165 Status XGetRGBColormaps(Display *display,Window window,
00166   XStandardColormap **colormap,int *count,Atom property)
00167 {
00168   *count=1;
00169   return(XGetStandardColormap(display,window,*colormap,property));
00170 }
00171 
00172 Status XGetWMColormapWindows(Display *display,Window window,
00173   Window **colormap_windows,int *number_windows)
00174 {
00175   Atom
00176     actual_type,
00177     *data,
00178     property;
00179 
00180   int
00181     actual_format,
00182     status;
00183 
00184   size_t
00185     leftover,
00186     number_items;
00187 
00188   property=XInternAtom(display,"WM_COLORMAP_WINDOWS",MagickFalse);
00189   if (property == None)
00190     return(MagickFalse);
00191   /*
00192     Get the window property.
00193   */
00194   *data=(Atom) NULL;
00195   status=XGetWindowProperty(display,window,property,0L,1000000L,MagickFalse,
00196     XA_WINDOW,&actual_type,&actual_format,&number_items,&leftover,
00197     (unsigned char **) &data);
00198   if (status != Success)
00199     return(MagickFalse);
00200   if ((actual_type != XA_WINDOW) || (actual_format != 32))
00201     {
00202       if (data != (Atom *) NULL)
00203         XFree((char *) data);
00204       return(MagickFalse);
00205     }
00206   *colormap_windows=(Window *) data;
00207   *number_windows=(int) number_items;
00208   return(MagickTrue);
00209 }
00210 
00211 Status XGetWMName(Display *display,Window window,XTextProperty *text_property)
00212 {
00213   char
00214     *window_name;
00215 
00216   if (XFetchName(display,window,&window_name) == 0)
00217     return(MagickFalse);
00218   text_property->value=(unsigned char *) window_name;
00219   text_property->encoding=XA_STRING;
00220   text_property->format=8;
00221   text_property->nitems=strlen(window_name);
00222   return(MagickTrue);
00223 }
00224 
00225 char *XResourceManagerString(Display *display)
00226 {
00227   return(display->xdefaults);
00228 }
00229 
00230 void XrmDestroyDatabase(XrmDatabase database)
00231 {
00232 }
00233 
00234 void XSetWMIconName(Display *display,Window window,XTextProperty *property)
00235 {
00236   XSetIconName(display,window,property->value);
00237 }
00238 
00239 void XSetWMName(Display *display,Window window,XTextProperty *property)
00240 {
00241   XStoreName(display,window,property->value);
00242 }
00243 
00244 void XSetWMProperties(Display *display,Window window,
00245   XTextProperty *window_name,XTextProperty *icon_name,char **argv,
00246   int argc,XSizeHints *size_hints,XWMHints *manager_hints,
00247   XClassHint *class_hint)
00248 {
00249   XSetStandardProperties(display,window,window_name->value,icon_name->value,
00250     None,argv,argc,size_hints);
00251   XSetWMHints(display,window,manager_hints);
00252   XSetClassHint(display,window,class_hint);
00253 }
00254 
00255 Status XSetWMProtocols(Display *display,Window window,Atom *protocols,
00256   int count)
00257 {
00258   Atom
00259     wm_protocols;
00260 
00261   wm_protocols=XInternAtom(display,"WM_PROTOCOLS",MagickFalse);
00262   XChangeProperty(display,window,wm_protocols,XA_ATOM,32,PropModeReplace,
00263     (unsigned char *) protocols,count);
00264   return(MagickTrue);
00265 }
00266 
00267 int XStringListToTextProperty(char **argv,int argc,XTextProperty *property)
00268 {
00269   register int
00270     i;
00271 
00272   register unsigned int
00273     number_bytes;
00274 
00275   XTextProperty
00276      protocol;
00277 
00278   number_bytes=0;
00279   for (i=0; i < (ssize_t) argc; i++)
00280     number_bytes+=(unsigned int) ((argv[i] ? strlen(argv[i]) : 0)+1);
00281   protocol.encoding=XA_STRING;
00282   protocol.format=8;
00283   protocol.nitems=0;
00284   if (number_bytes)
00285     protocol.nitems=number_bytes-1;
00286   protocol.value=NULL;
00287   if (number_bytes <= 0)
00288     {
00289       protocol.value=(unsigned char *) AcquireQuantumMemory(1UL,
00290         sizeof(*protocol.value));
00291       if (protocol.value == MagickFalse)
00292         return(MagickFalse);
00293       *protocol.value='\0';
00294     }
00295   else
00296     {
00297       register char
00298         *buffer;
00299 
00300       buffer=(char *) AcquireQuantumMemory(number_bytes,sizeof(*buffer));
00301       if (buffer == (char *) NULL)
00302         return(MagickFalse);
00303       protocol.value=(unsigned char *) buffer;
00304       for (i=0; i < (ssize_t) argc; i++)
00305       {
00306         char
00307           *argument;
00308 
00309         argument=argv[i];
00310         if (argument == MagickFalse)
00311           *buffer++='\0';
00312         else
00313           {
00314             (void) CopyMagickString(buffer,argument,MaxTextExtent);
00315             buffer+=(strlen(argument)+1);
00316           }
00317       }
00318     }
00319   *property=protocol;
00320   return(MagickTrue);
00321 }
00322 
00323 VisualID XVisualIDFromVisual(Visual *visual)
00324 {
00325   return(visual->visualid);
00326 }
00327 
00328 Status XWithdrawWindow(Display *display,Window window,int screen)
00329 {
00330   return(XUnmapWindow(display,window));
00331 }
00332 
00333 int XWMGeometry(Display *display,int screen,char *user_geometry,
00334   char *default_geometry,unsigned int border_width,XSizeHints *size_hints,
00335   int *x,int *y,int *width,int *height,int *gravity)
00336 {
00337   int
00338     status;
00339 
00340   status=XGeometry(display,screen,user_geometry,default_geometry,border_width,
00341     0,0,0,0,x,y,width,height);
00342   *gravity=NorthWestGravity;
00343   return(status);
00344 }
00345 #endif
00346 
00347 #endif