MagickCore  6.8.5
xwindow-private.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization
3  dedicated to making software imaging solutions freely available.
4 
5  You may not use this file except in compliance with the License.
6  obtain a copy of the License at
7 
8  http://www.imagemagick.org/script/license.php
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  MagickCore X11 window methods.
17 */
18 #ifndef _MAGICKCORE_XWINDOW_PRIVATE_H
19 #define _MAGICKCORE_XWINDOW_PRIVATE_H
20 
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24 
25 #include "magick/draw.h"
26 #include "magick/exception.h"
27 #include "magick/geometry.h"
28 #include "magick/quantize.h"
29 
30 #if defined(MAGICKCORE_X11_DELEGATE)
31 
32 #include <X11/Xos.h>
33 #include <X11/Xlib.h>
34 #include <X11/Xatom.h>
35 #include <X11/cursorfont.h>
36 #include <X11/keysym.h>
37 #include <X11/Xresource.h>
38 #include <X11/Xutil.h>
39 
40 #if defined(__cplusplus) || defined(c_plusplus)
41 # define klass c_class
42 #else
43 # define klass class
44 #endif
45 
46 /*
47  Invoke pre-X11R6 ICCCM routines if XlibSpecificationRelease is not 6.
48 */
49 #if XlibSpecificationRelease < 6
50 #if !defined(PRE_R6_ICCCM)
51 #define PRE_R6_ICCCM
52 #endif
53 #endif
54 /*
55  Invoke pre-X11R5 ICCCM routines if XlibSpecificationRelease is not defined.
56 */
57 #if !defined(XlibSpecificationRelease)
58 #define PRE_R5_ICCCM
59 #endif
60 /*
61  Invoke pre-X11R4 ICCCM routines if PWinGravity is not defined.
62 */
63 #if !defined(PWinGravity)
64 #define PRE_R4_ICCCM
65 #endif
66 
67 #define MaxIconSize 96
68 #define MaxNumberPens 11
69 #define MaxNumberFonts 11
70 #define MaxXWindows 12
71 #undef index
72 
73 #define ThrowXWindowException(severity,tag,context) \
74 { \
75  ExceptionInfo \
76  exception; \
77  \
78  GetExceptionInfo(&exception); \
79  (void) ThrowMagickException(&exception,GetMagickModule(),severity, \
80  tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context, \
81  strerror(errno)); \
82  CatchException(&exception); \
83  (void) DestroyExceptionInfo(&exception); \
84 }
85 #define ThrowXWindowFatalException(severity,tag,context) \
86 { \
87  ThrowXWindowException(severity,tag,context); \
88  _exit(1); \
89 }
90 
91 typedef enum
92 {
93  ForegroundStencil,
94  BackgroundStencil,
95  OpaqueStencil,
96  TransparentStencil
97 } AnnotationStencil;
98 
99 typedef enum
100 {
101  UndefinedElement,
102  PointElement,
103  LineElement,
104  RectangleElement,
105  FillRectangleElement,
106  CircleElement,
107  FillCircleElement,
108  EllipseElement,
109  FillEllipseElement,
110  PolygonElement,
111  FillPolygonElement,
112  ColorElement,
113  MatteElement,
114  TextElement,
115  ImageElement
116 } ElementType;
117 
118 typedef enum
119 {
120  UndefinedColormap,
121  PrivateColormap,
122  SharedColormap
123 } XColormapType;
124 
125 typedef struct _XDrawInfo
126 {
127  int
128  x,
129  y;
130 
131  unsigned int
132  width,
133  height;
134 
135  double
136  degrees;
137 
138  AnnotationStencil
139  stencil;
140 
141  ElementType
142  element;
143 
144  Pixmap
145  stipple;
146 
147  unsigned int
148  line_width;
149 
150  XSegment
151  line_info;
152 
153  unsigned int
154  number_coordinates;
155 
157  rectangle_info;
158 
159  XPoint
160  *coordinate_info;
161 
162  char
163  geometry[MaxTextExtent];
164 } XDrawInfo;
165 
166 typedef enum
167 {
168  DefaultState = 0x0000,
169  EscapeState = 0x0001,
170  ExitState = 0x0002,
171  FormerImageState = 0x0004,
172  ModifierState = 0x0008,
173  MontageImageState = 0x0010,
174  NextImageState = 0x0020,
175  RetainColorsState = 0x0040,
176  SuspendTime = 50,
177  UpdateConfigurationState = 0x0080,
178  UpdateRegionState = 0x0100
179 } XState;
180 
181 typedef struct _XAnnotateInfo
182 {
183  int
184  x,
185  y;
186 
187  unsigned int
188  width,
189  height;
190 
191  double
192  degrees;
193 
194  XFontStruct
195  *font_info;
196 
197  char
198  *text;
199 
200  AnnotationStencil
201  stencil;
202 
203  char
204  geometry[MaxTextExtent];
205 
206  struct _XAnnotateInfo
207  *next,
208  *previous;
209 } XAnnotateInfo;
210 
211 typedef struct _XPixelInfo
212 {
213  ssize_t
214  colors;
215 
216  unsigned long
217  *pixels;
218 
219  XColor
220  foreground_color,
221  background_color,
222  border_color,
223  matte_color,
224  highlight_color,
225  shadow_color,
226  depth_color,
227  trough_color,
228  box_color,
229  pen_color,
230  pen_colors[MaxNumberPens];
231 
232  GC
233  annotate_context,
234  highlight_context,
235  widget_context;
236 
237  unsigned short
238  box_index,
239  pen_index;
240 } XPixelInfo;
241 
242 typedef struct _XResourceInfo
243 {
244  XrmDatabase
245  resource_database;
246 
247  ImageInfo
248  *image_info;
249 
251  *quantize_info;
252 
253  size_t
254  colors;
255 
257  close_server,
258  backdrop;
259 
260  char
261  *background_color,
262  *border_color;
263 
264  char
265  *client_name;
266 
267  XColormapType
268  colormap;
269 
270  unsigned int
271  border_width;
272 
273  size_t
274  delay;
275 
277  color_recovery,
278  confirm_exit,
279  confirm_edit;
280 
281  char
282  *display_gamma;
283 
284  char
285  *font,
286  *font_name[MaxNumberFonts],
287  *foreground_color;
288 
290  display_warnings,
291  gamma_correct;
292 
293  char
294  *icon_geometry;
295 
297  iconic,
298  immutable;
299 
300  char
301  *image_geometry;
302 
303  char
304  *map_type,
305  *matte_color,
306  *name;
307 
308  unsigned int
309  magnify,
310  pause;
311 
312  char
313  *pen_colors[MaxNumberPens];
314 
315  char
316  *text_font,
317  *title;
318 
319  int
320  quantum;
321 
322  unsigned int
323  update;
324 
326  use_pixmap,
327  use_shared_memory;
328 
329  size_t
330  undo_cache;
331 
332  char
333  *visual_type,
334  *window_group,
335  *window_id,
336  *write_filename;
337 
338  Image
339  *copy_image;
340 
341  int
342  gravity;
343 
344  char
345  home_directory[MaxTextExtent];
346 } XResourceInfo;
347 
348 typedef struct _XWindowInfo
349 {
350  Window
351  id;
352 
353  Window
354  root;
355 
356  Visual
357  *visual;
358 
359  unsigned int
360  storage_class,
361  depth;
362 
363  XVisualInfo
364  *visual_info;
365 
366  XStandardColormap
367  *map_info;
368 
369  XPixelInfo
370  *pixel_info;
371 
372  XFontStruct
373  *font_info;
374 
375  GC
376  annotate_context,
377  highlight_context,
378  widget_context;
379 
380  Cursor
381  cursor,
382  busy_cursor;
383 
384  char
385  *name,
386  *geometry,
387  *icon_name,
388  *icon_geometry,
389  *crop_geometry;
390 
391  size_t
392  data,
393  flags;
394 
395  int
396  x,
397  y;
398 
399  unsigned int
400  width,
401  height,
402  min_width,
403  min_height,
404  width_inc,
405  height_inc,
406  border_width;
407 
409  use_pixmap,
410  immutable,
411  shape,
412  shared_memory;
413 
414  int
415  screen;
416 
417  XImage
418  *ximage,
419  *matte_image;
420 
421  Pixmap
422  highlight_stipple,
423  shadow_stipple,
424  pixmap,
425  *pixmaps,
426  matte_pixmap,
427  *matte_pixmaps;
428 
429  XSetWindowAttributes
430  attributes;
431 
432  XWindowChanges
433  window_changes;
434 
435  void
436  *segment_info;
437 
438  long
439  mask;
440 
442  orphan,
443  mapped,
444  stasis;
445 
446  Image
447  *image;
448 
450  destroy;
451 } XWindowInfo;
452 
453 typedef struct _XWindows
454 {
455  Display
456  *display;
457 
458  XStandardColormap
459  *map_info,
460  *icon_map;
461 
462  XVisualInfo
463  *visual_info,
464  *icon_visual;
465 
466  XPixelInfo
467  *pixel_info,
468  *icon_pixel;
469 
470  XFontStruct
471  *font_info;
472 
473  XResourceInfo
474  *icon_resources;
475 
476  XClassHint
477  *class_hints;
478 
479  XWMHints
480  *manager_hints;
481 
482  XWindowInfo
483  context,
484  group_leader,
485  backdrop,
486  icon,
487  image,
488  info,
489  magnify,
490  pan,
491  command,
492  widget,
493  popup;
494 
495  Atom
496  wm_protocols,
497  wm_delete_window,
498  wm_take_focus,
499  im_protocols,
500  im_remote_command,
501  im_update_widget,
502  im_update_colormap,
503  im_former_image,
504  im_retain_colors,
505  im_next_image,
506  im_exit,
507  dnd_protocols;
508 } XWindows;
509 
510 extern MagickExport char
511  *XGetResourceClass(XrmDatabase,const char *,const char *,char *),
512  *XGetResourceInstance(XrmDatabase,const char *,const char *,const char *),
513  *XGetScreenDensity(Display *);
514 
515 extern MagickExport Cursor
516  XMakeCursor(Display *,Window,Colormap,char *,char *);
517 
518 extern MagickExport int
519  XCheckDefineCursor(Display *,Window,Cursor),
520  XError(Display *,XErrorEvent *);
521 
523  XAnnotateImage(Display *,const XPixelInfo *,XAnnotateInfo *,Image *),
524  XComponentGenesis(void),
525  XDrawImage(Display *,const XPixelInfo *,XDrawInfo *,Image *),
526  XGetWindowColor(Display *,XWindows *,char *),
527  XMagickProgressMonitor(const char *,const MagickOffsetType,
528  const MagickSizeType,void *),
529  XMakeImage(Display *,const XResourceInfo *,XWindowInfo *,Image *,unsigned int,
530  unsigned int),
531  XQueryColorDatabase(const char *,XColor *),
532  XRemoteCommand(Display *,const char *,const char *);
533 
534 extern MagickExport void
535  DestroyXResources(void),
536  XBestIconSize(Display *,XWindowInfo *,Image *),
537  XBestPixel(Display *,const Colormap,XColor *,unsigned int,XColor *),
538  XCheckRefreshWindows(Display *,XWindows *),
539  XClientMessage(Display *,const Window,const Atom,const Atom,const Time),
540  XComponentTerminus(void),
541  XConfigureImageColormap(Display *,XResourceInfo *,XWindows *,Image *),
542  XConstrainWindowPosition(Display *,XWindowInfo *),
543  XDelay(Display *,const size_t),
544  XDisplayImageInfo(Display *,const XResourceInfo *,XWindows *,Image *,Image *),
545  XDestroyResourceInfo(XResourceInfo *),
546  XDestroyWindowColors(Display *,Window),
547  XFreeResources(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
548  XFontStruct *,XResourceInfo *,XWindowInfo *),
549  XFreeStandardColormap(Display *,const XVisualInfo *,XStandardColormap *,
550  XPixelInfo *),
551  XHighlightEllipse(Display *,Window,GC,const RectangleInfo *),
552  XHighlightLine(Display *,Window,GC,const XSegment *),
553  XHighlightRectangle(Display *,Window,GC,const RectangleInfo *),
554  XGetAnnotateInfo(XAnnotateInfo *),
555  XGetPixelPacket(Display *,const XVisualInfo *,const XStandardColormap *,
556  const XResourceInfo *,Image *,XPixelInfo *),
557  XGetMapInfo(const XVisualInfo *,const Colormap,XStandardColormap *),
558  XGetResourceInfo(const ImageInfo *,XrmDatabase,const char *,XResourceInfo *),
559  XGetWindowInfo(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
560  XFontStruct *,XResourceInfo *,XWindowInfo *),
561  XMakeMagnifyImage(Display *,XWindows *),
562  XMakeStandardColormap(Display *,XVisualInfo *,XResourceInfo *,Image *,
563  XStandardColormap *,XPixelInfo *),
564  XMakeWindow(Display *,Window,char **,int,XClassHint *,XWMHints *,
565  XWindowInfo *),
566  XQueryPosition(Display *,const Window,int *,int *),
567  XRefreshWindow(Display *,const XWindowInfo *,const XEvent *),
568  XRetainWindowColors(Display *,const Window),
569  XSetCursorState(Display *,XWindows *,const MagickStatusType),
570  XUserPreferences(XResourceInfo *),
571  XWarning(const ExceptionType,const char *,const char *);
572 
573 extern MagickExport Window
574  XWindowByID(Display *,const Window,const size_t),
575  XWindowByName(Display *,const Window,const char *),
576  XWindowByProperty(Display *,const Window,const Atom);
577 
578 extern MagickExport XFontStruct
579  *XBestFont(Display *,const XResourceInfo *,const MagickBooleanType);
580 
581 extern MagickExport XrmDatabase
582  XGetResourceDatabase(Display *,const char *);
583 
584 extern MagickExport XVisualInfo
585  *XBestVisualInfo(Display *,XStandardColormap *,XResourceInfo *);
586 
587 extern MagickExport XWindows
588  *XInitializeWindows(Display *,XResourceInfo *),
589  *XSetWindows(XWindows *);
590 
591 static inline MagickRealType XPixelIntensity(const XColor *pixel)
592 {
594  intensity;
595 
596  if ((pixel->red == pixel->green) && (pixel->green == pixel->blue))
597  return((MagickRealType) pixel->red);
598  intensity=0.298839*pixel->red+0.586811*pixel->green+0.114350*pixel->blue;
599  return(intensity);
600 }
601 #endif
602 
604  XRenderImage(Image *,const DrawInfo *,const PointInfo *,TypeMetric *);
605 
606 #if defined(__cplusplus) || defined(c_plusplus)
607 }
608 #endif
609 
610 #endif