blob: 7a68fe2641e4b6f5eb6bb050ac4432ac52e97a99 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy7e41fe82010-12-04 23:12:08 +00002 Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization
cristy3ed852e2009-09-05 21:47:34 +00003 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)
22extern "C" {
23#endif
24
25#if defined(MAGICKCORE_X11_DELEGATE)
26
27#include <X11/Xos.h>
28#include <X11/Xlib.h>
29#include <X11/Xatom.h>
30#include <X11/cursorfont.h>
31#include <X11/keysym.h>
32#include <X11/Xresource.h>
33#include <X11/Xutil.h>
cristy4c08aed2011-07-01 19:47:50 +000034#include "MagickCore/exception.h"
35#include "MagickCore/geometry.h"
36#include "MagickCore/quantize.h"
cristy3ed852e2009-09-05 21:47:34 +000037
38#if defined(__cplusplus) || defined(c_plusplus)
39# define klass c_class
40#else
41# define klass class
42#endif
43
44/*
45 Invoke pre-X11R6 ICCCM routines if XlibSpecificationRelease is not 6.
46*/
47#if XlibSpecificationRelease < 6
48#if !defined(PRE_R6_ICCCM)
49#define PRE_R6_ICCCM
50#endif
51#endif
52/*
53 Invoke pre-X11R5 ICCCM routines if XlibSpecificationRelease is not defined.
54*/
55#if !defined(XlibSpecificationRelease)
56#define PRE_R5_ICCCM
57#endif
58/*
59 Invoke pre-X11R4 ICCCM routines if PWinGravity is not defined.
60*/
61#if !defined(PWinGravity)
62#define PRE_R4_ICCCM
63#endif
64
65#define MaxIconSize 96
66#define MaxNumberPens 11
67#define MaxNumberFonts 11
68#define MaxXWindows 12
69#undef index
70
71#define ThrowXWindowException(severity,tag,context) \
72{ \
73 ExceptionInfo \
74 exception; \
75 \
76 GetExceptionInfo(&exception); \
77 (void) ThrowMagickException(&exception,GetMagickModule(),severity, \
78 tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context, \
79 strerror(errno)); \
80 CatchException(&exception); \
81 (void) DestroyExceptionInfo(&exception); \
82}
83#define ThrowXWindowFatalException(severity,tag,context) \
84{ \
85 ThrowXWindowException(severity,tag,context); \
86 _exit(1); \
87}
88
89typedef enum
90{
91 ForegroundStencil,
92 BackgroundStencil,
93 OpaqueStencil,
94 TransparentStencil
95} AnnotationStencil;
96
97typedef enum
98{
99 UndefinedElement,
100 PointElement,
101 LineElement,
102 RectangleElement,
103 FillRectangleElement,
104 CircleElement,
105 FillCircleElement,
106 EllipseElement,
107 FillEllipseElement,
108 PolygonElement,
109 FillPolygonElement,
110 ColorElement,
111 MatteElement,
112 TextElement,
113 ImageElement
114} ElementType;
115
116typedef enum
117{
118 UndefinedColormap,
119 PrivateColormap,
120 SharedColormap
121} XColormapType;
122
123typedef struct _XDrawInfo
124{
125 int
126 x,
127 y;
128
129 unsigned int
130 width,
131 height;
132
133 double
134 degrees;
135
136 AnnotationStencil
137 stencil;
138
139 ElementType
140 element;
141
142 Pixmap
143 stipple;
144
145 unsigned int
146 line_width;
147
148 XSegment
149 line_info;
150
151 unsigned int
152 number_coordinates;
153
154 RectangleInfo
155 rectangle_info;
156
157 XPoint
158 *coordinate_info;
159
160 char
161 geometry[MaxTextExtent];
162} XDrawInfo;
163
164typedef enum
165{
166 DefaultState = 0x0000,
167 EscapeState = 0x0001,
168 ExitState = 0x0002,
169 FormerImageState = 0x0004,
170 ModifierState = 0x0008,
171 MontageImageState = 0x0010,
172 NextImageState = 0x0020,
173 RetainColorsState = 0x0040,
174 SuspendTime = 50,
175 UpdateConfigurationState = 0x0080,
176 UpdateRegionState = 0x0100
177} XState;
178
179typedef struct _XAnnotateInfo
180{
181 int
182 x,
183 y;
184
185 unsigned int
186 width,
187 height;
188
189 double
190 degrees;
191
192 XFontStruct
193 *font_info;
194
195 char
196 *text;
197
198 AnnotationStencil
199 stencil;
200
201 char
202 geometry[MaxTextExtent];
203
204 struct _XAnnotateInfo
205 *next,
206 *previous;
207} XAnnotateInfo;
208
209typedef struct _XPixelInfo
210{
cristyf2faecf2010-05-28 19:19:36 +0000211 ssize_t
212 colors;
213
214 unsigned long
cristy3ed852e2009-09-05 21:47:34 +0000215 *pixels;
216
217 XColor
218 foreground_color,
219 background_color,
220 border_color,
221 matte_color,
222 highlight_color,
223 shadow_color,
224 depth_color,
225 trough_color,
226 box_color,
227 pen_color,
228 pen_colors[MaxNumberPens];
229
230 GC
231 annotate_context,
232 highlight_context,
233 widget_context;
234
235 unsigned short
236 box_index,
237 pen_index;
238} XPixelInfo;
239
cristye3099b72011-09-08 18:21:13 +0000240typedef struct _XResourceInfo
cristy3ed852e2009-09-05 21:47:34 +0000241{
242 XrmDatabase
243 resource_database;
244
245 ImageInfo
246 *image_info;
247
248 QuantizeInfo
249 *quantize_info;
250
cristybb503372010-05-27 20:51:26 +0000251 size_t
cristy3ed852e2009-09-05 21:47:34 +0000252 colors;
253
254 MagickBooleanType
255 close_server,
256 backdrop;
257
258 char
259 *background_color,
260 *border_color;
261
262 char
263 *client_name;
264
265 XColormapType
266 colormap;
267
268 unsigned int
269 border_width;
270
cristybb503372010-05-27 20:51:26 +0000271 size_t
cristy3ed852e2009-09-05 21:47:34 +0000272 delay;
273
274 MagickBooleanType
275 color_recovery,
276 confirm_exit,
277 confirm_edit;
278
279 char
280 *display_gamma;
281
282 char
283 *font,
284 *font_name[MaxNumberFonts],
285 *foreground_color;
286
287 MagickBooleanType
288 display_warnings,
289 gamma_correct;
290
291 char
292 *icon_geometry;
293
294 MagickBooleanType
295 iconic,
296 immutable;
297
298 char
299 *image_geometry;
300
301 char
302 *map_type,
303 *matte_color,
304 *name;
305
306 unsigned int
307 magnify,
308 pause;
309
310 char
311 *pen_colors[MaxNumberPens];
312
313 char
314 *text_font,
315 *title;
316
317 int
318 quantum;
319
320 unsigned int
321 update;
322
323 MagickBooleanType
324 use_pixmap,
325 use_shared_memory;
326
cristybb503372010-05-27 20:51:26 +0000327 size_t
cristy3ed852e2009-09-05 21:47:34 +0000328 undo_cache;
329
330 char
331 *visual_type,
332 *window_group,
333 *window_id,
334 *write_filename;
335
336 Image
337 *copy_image;
338
339 int
340 gravity;
341
342 char
343 home_directory[MaxTextExtent];
cristye3099b72011-09-08 18:21:13 +0000344} XResourceInfo;
cristy3ed852e2009-09-05 21:47:34 +0000345
346typedef struct _XWindowInfo
347{
348 Window
349 id;
350
351 Window
352 root;
353
354 Visual
355 *visual;
356
357 unsigned int
358 storage_class,
359 depth;
360
361 XVisualInfo
362 *visual_info;
363
364 XStandardColormap
365 *map_info;
366
367 XPixelInfo
368 *pixel_info;
369
370 XFontStruct
371 *font_info;
372
373 GC
374 annotate_context,
375 highlight_context,
376 widget_context;
377
378 Cursor
379 cursor,
380 busy_cursor;
381
382 char
383 *name,
384 *geometry,
385 *icon_name,
386 *icon_geometry,
387 *crop_geometry;
388
cristybb503372010-05-27 20:51:26 +0000389 size_t
cristy3ed852e2009-09-05 21:47:34 +0000390 data,
391 flags;
392
393 int
394 x,
395 y;
396
397 unsigned int
398 width,
399 height,
400 min_width,
401 min_height,
402 width_inc,
403 height_inc,
404 border_width;
405
406 MagickBooleanType
407 use_pixmap,
408 immutable,
409 shape,
410 shared_memory;
411
412 int
413 screen;
414
415 XImage
416 *ximage,
417 *matte_image;
418
419 Pixmap
420 highlight_stipple,
421 shadow_stipple,
422 pixmap,
423 *pixmaps,
424 matte_pixmap,
425 *matte_pixmaps;
426
427 XSetWindowAttributes
428 attributes;
429
430 XWindowChanges
431 window_changes;
432
433 void
434 *segment_info;
435
cristy8891f9c2010-06-04 23:32:17 +0000436 long
cristy3ed852e2009-09-05 21:47:34 +0000437 mask;
438
439 MagickBooleanType
440 orphan,
441 mapped,
442 stasis;
443
444 Image
445 *image;
446
447 MagickBooleanType
448 destroy;
449} XWindowInfo;
450
451typedef struct _XWindows
452{
453 Display
454 *display;
455
456 XStandardColormap
457 *map_info,
458 *icon_map;
459
460 XVisualInfo
461 *visual_info,
462 *icon_visual;
463
464 XPixelInfo
465 *pixel_info,
466 *icon_pixel;
467
468 XFontStruct
469 *font_info;
470
471 XResourceInfo
472 *icon_resources;
473
474 XClassHint
475 *class_hints;
476
477 XWMHints
478 *manager_hints;
479
480 XWindowInfo
481 context,
482 group_leader,
483 backdrop,
484 icon,
485 image,
486 info,
487 magnify,
488 pan,
489 command,
490 widget,
491 popup;
492
493 Atom
494 wm_protocols,
495 wm_delete_window,
496 wm_take_focus,
497 im_protocols,
498 im_remote_command,
499 im_update_widget,
500 im_update_colormap,
501 im_former_image,
502 im_retain_colors,
503 im_next_image,
504 im_exit,
505 dnd_protocols;
506} XWindows;
507
cristybcbda3f2011-09-03 13:01:22 +0000508extern MagickPrivate Cursor
cristy3ed852e2009-09-05 21:47:34 +0000509 XMakeCursor(Display *,Window,Colormap,char *,char *);
510
cristybcbda3f2011-09-03 13:01:22 +0000511extern MagickPrivate int
512 XCheckDefineCursor(Display *,Window,Cursor);
cristy3ed852e2009-09-05 21:47:34 +0000513
cristybcbda3f2011-09-03 13:01:22 +0000514extern MagickPrivate MagickBooleanType
cristy7c3af952011-10-20 16:04:16 +0000515 XAnnotateImage(Display *,const XPixelInfo *,XAnnotateInfo *,Image *,
516 ExceptionInfo *),
cristybcbda3f2011-09-03 13:01:22 +0000517 XComponentGenesis(void),
cristy6710d842011-10-20 23:23:00 +0000518 XDrawImage(Display *,const XPixelInfo *,XDrawInfo *,Image *,ExceptionInfo *),
519 XGetWindowColor(Display *,XWindows *,char *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +0000520 XMagickProgressMonitor(const char *,const MagickOffsetType,
521 const MagickSizeType,void *),
522 XMakeImage(Display *,const XResourceInfo *,XWindowInfo *,Image *,unsigned int,
cristy051718b2011-08-28 22:49:25 +0000523 unsigned int,ExceptionInfo *),
cristy9950d572011-10-01 18:22:35 +0000524 XQueryColorCompliance(const char *,XColor *);
cristy3ed852e2009-09-05 21:47:34 +0000525
cristybcbda3f2011-09-03 13:01:22 +0000526extern MagickPrivate void
cristy3ed852e2009-09-05 21:47:34 +0000527 XBestIconSize(Display *,XWindowInfo *,Image *),
528 XBestPixel(Display *,const Colormap,XColor *,unsigned int,XColor *),
529 XCheckRefreshWindows(Display *,XWindows *),
530 XClientMessage(Display *,const Window,const Atom,const Atom,const Time),
cristybcbda3f2011-09-03 13:01:22 +0000531 XComponentTerminus(void),
cristy6710d842011-10-20 23:23:00 +0000532 XConfigureImageColormap(Display *,XResourceInfo *,XWindows *,Image *,
533 ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +0000534 XConstrainWindowPosition(Display *,XWindowInfo *),
cristybb503372010-05-27 20:51:26 +0000535 XDelay(Display *,const size_t),
cristy6710d842011-10-20 23:23:00 +0000536 XDisplayImageInfo(Display *,const XResourceInfo *,XWindows *,Image *,Image *,
537 ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +0000538 XDestroyWindowColors(Display *,Window),
cristy3ed852e2009-09-05 21:47:34 +0000539 XFreeResources(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
540 XFontStruct *,XResourceInfo *,XWindowInfo *),
541 XFreeStandardColormap(Display *,const XVisualInfo *,XStandardColormap *,
542 XPixelInfo *),
543 XHighlightEllipse(Display *,Window,GC,const RectangleInfo *),
544 XHighlightLine(Display *,Window,GC,const XSegment *),
545 XHighlightRectangle(Display *,Window,GC,const RectangleInfo *),
546 XGetAnnotateInfo(XAnnotateInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000547 XGetPixelInfo(Display *,const XVisualInfo *,const XStandardColormap *,
cristy3ed852e2009-09-05 21:47:34 +0000548 const XResourceInfo *,Image *,XPixelInfo *),
549 XGetMapInfo(const XVisualInfo *,const Colormap,XStandardColormap *),
cristy3ed852e2009-09-05 21:47:34 +0000550 XGetWindowInfo(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
551 XFontStruct *,XResourceInfo *,XWindowInfo *),
cristy6710d842011-10-20 23:23:00 +0000552 XMakeMagnifyImage(Display *,XWindows *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +0000553 XMakeStandardColormap(Display *,XVisualInfo *,XResourceInfo *,Image *,
cristy6710d842011-10-20 23:23:00 +0000554 XStandardColormap *,XPixelInfo *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +0000555 XMakeWindow(Display *,Window,char **,int,XClassHint *,XWMHints *,
556 XWindowInfo *),
557 XQueryPosition(Display *,const Window,int *,int *),
558 XRefreshWindow(Display *,const XWindowInfo *,const XEvent *),
cristy3ed852e2009-09-05 21:47:34 +0000559 XSetCursorState(Display *,XWindows *,const MagickStatusType),
560 XUserPreferences(XResourceInfo *),
561 XWarning(const ExceptionType,const char *,const char *);
562
cristybcbda3f2011-09-03 13:01:22 +0000563extern MagickPrivate Window
cristybb503372010-05-27 20:51:26 +0000564 XWindowByID(Display *,const Window,const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000565 XWindowByName(Display *,const Window,const char *),
566 XWindowByProperty(Display *,const Window,const Atom);
567
cristybcbda3f2011-09-03 13:01:22 +0000568extern MagickPrivate XFontStruct
cristy3ed852e2009-09-05 21:47:34 +0000569 *XBestFont(Display *,const XResourceInfo *,const MagickBooleanType);
570
cristybcbda3f2011-09-03 13:01:22 +0000571extern MagickPrivate XVisualInfo
cristy3ed852e2009-09-05 21:47:34 +0000572 *XBestVisualInfo(Display *,XStandardColormap *,XResourceInfo *);
573
cristybcbda3f2011-09-03 13:01:22 +0000574extern MagickPrivate XWindows
cristy3ed852e2009-09-05 21:47:34 +0000575 *XInitializeWindows(Display *,XResourceInfo *),
576 *XSetWindows(XWindows *);
577
cristye3099b72011-09-08 18:21:13 +0000578extern MagickExport char
579 *XGetResourceClass(XrmDatabase,const char *,const char *,char *),
580 *XGetResourceInstance(XrmDatabase,const char *,const char *,const char *),
581 *XGetScreenDensity(Display *);
582
583extern MagickExport int
584 XError(Display *,XErrorEvent *);
585
586extern MagickExport MagickBooleanType
587 XRemoteCommand(Display *,const char *,const char *);
588
589extern MagickExport void
590 DestroyXResources(void),
591 XDestroyResourceInfo(XResourceInfo *),
592 XGetResourceInfo(const ImageInfo *,XrmDatabase,const char *,XResourceInfo *),
593 XRetainWindowColors(Display *,const Window);
594
595extern MagickExport XrmDatabase
596 XGetResourceDatabase(Display *,const char *);
597
cristy3ed852e2009-09-05 21:47:34 +0000598static inline MagickRealType XPixelIntensity(const XColor *pixel)
599{
600 MagickRealType
601 intensity;
602
603 intensity=0.299*pixel->red+0.587*pixel->green+0.114*pixel->blue;
604 return(intensity);
605}
606
607#endif
608
609#if defined(__cplusplus) || defined(c_plusplus)
610}
611#endif
612
613#endif