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