1 /* $Xorg: Xutil.h,v 1.8 2001/02/09 02:03:39 xorgcvs Exp $ */
3 /***********************************************************
5 Copyright 1987, 1998 The Open Group
7 Permission to use, copy, modify, distribute, and sell this software and its
8 documentation for any purpose is hereby granted without fee, provided that
9 the above copyright notice appear in all copies and that both that
10 copyright notice and this permission notice appear in supporting
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of The Open Group shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from The Open Group.
28 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
32 Permission to use, copy, modify, and distribute this software and its
33 documentation for any purpose and without fee is hereby granted,
34 provided that the above copyright notice appear in all copies and that
35 both that copyright notice and this permission notice appear in
36 supporting documentation, and that the name of Digital not be
37 used in advertising or publicity pertaining to distribution of the
38 software without specific, written prior permission.
40 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
48 ******************************************************************/
49 /* $XFree86: xc/lib/X11/Xutil.h,v 3.6 2003/04/13 19:22:20 dawes Exp $ */
54 /* You must include <X11/Xlib.h> before including this file */
56 #include <X11/keysym.h>
59 * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
60 * value (x, y, width, height) was found in the parsed string.
62 #define NoValue 0x0000
65 #define WidthValue 0x0004
66 #define HeightValue 0x0008
67 #define AllValues 0x000F
68 #define XNegative 0x0010
69 #define YNegative 0x0020
72 * new version containing base_width, base_height, and win_gravity fields;
73 * used with WM_NORMAL_HINTS.
76 long flags; /* marks which fields in this structure are defined */
77 int x, y; /* obsolete for new window mgrs, but clients */
78 int width, height; /* should set so old wm's don't mess up */
79 int min_width, min_height;
80 int max_width, max_height;
81 int width_inc, height_inc;
83 int x; /* numerator */
84 int y; /* denominator */
85 } min_aspect, max_aspect;
86 int base_width, base_height; /* added by ICCCM version 1 */
87 int win_gravity; /* added by ICCCM version 1 */
91 * The next block of definitions are for window manager properties that
92 * clients and applications use for communication.
95 /* flags argument in size hints */
96 #define USPosition (1L << 0) /* user specified x, y */
97 #define USSize (1L << 1) /* user specified width, height */
99 #define PPosition (1L << 2) /* program specified position */
100 #define PSize (1L << 3) /* program specified size */
101 #define PMinSize (1L << 4) /* program specified minimum size */
102 #define PMaxSize (1L << 5) /* program specified maximum size */
103 #define PResizeInc (1L << 6) /* program specified resize increments */
104 #define PAspect (1L << 7) /* program specified min and max aspect ratios */
105 #define PBaseSize (1L << 8) /* program specified base for incrementing */
106 #define PWinGravity (1L << 9) /* program specified window gravity */
109 #define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
114 long flags; /* marks which fields in this structure are defined */
115 Bool input; /* does this application rely on the window manager to
116 get keyboard input? */
117 int initial_state; /* see below */
118 Pixmap icon_pixmap; /* pixmap to be used as icon */
119 Window icon_window; /* window to be used as icon */
120 int icon_x, icon_y; /* initial position of icon */
121 Pixmap icon_mask; /* icon mask bitmap */
122 XID window_group; /* id of related window group */
123 /* this structure may be extended in the future */
126 /* definition for flags of XWMHints */
128 #define InputHint (1L << 0)
129 #define StateHint (1L << 1)
130 #define IconPixmapHint (1L << 2)
131 #define IconWindowHint (1L << 3)
132 #define IconPositionHint (1L << 4)
133 #define IconMaskHint (1L << 5)
134 #define WindowGroupHint (1L << 6)
135 #define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \
136 IconPositionHint|IconMaskHint|WindowGroupHint)
137 #define XUrgencyHint (1L << 8)
139 /* definitions for initial window state */
140 #define WithdrawnState 0 /* for windows that are not mapped */
141 #define NormalState 1 /* most applications want to start this way */
142 #define IconicState 3 /* application wants to start as an icon */
145 * Obsolete states no longer defined by ICCCM
147 #define DontCareState 0 /* don't know or care */
148 #define ZoomState 2 /* application wants to start zoomed */
149 #define InactiveState 4 /* application believes it is seldom used; */
150 /* some wm's may put it on inactive menu */
154 * new structure for manipulating TEXT properties; used with WM_NAME,
155 * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.
158 unsigned char *value; /* same as Property routines */
159 Atom encoding; /* prop type */
160 int format; /* prop data format: 8, 16, or 32 */
161 unsigned long nitems; /* number of data items in value */
165 #define XLocaleNotSupported -2
166 #define XConverterNotFound -3
169 XStringStyle, /* STRING */
170 XCompoundTextStyle, /* COMPOUND_TEXT */
171 XTextStyle, /* text in owner's encoding (current locale)*/
172 XStdICCTextStyle, /* STRING, else COMPOUND_TEXT */
173 /* The following is an XFree86 extension, introduced in November 2000 */
174 XUTF8StringStyle /* UTF8_STRING */
178 int min_width, min_height;
179 int max_width, max_height;
180 int width_inc, height_inc;
188 #ifdef XUTIL_DEFINE_FUNCTIONS
189 extern int XDestroyImage(
191 extern unsigned long XGetPixel(
194 extern int XPutPixel(
197 unsigned long pixel);
198 extern XImage *XSubImage(
201 unsigned int width, unsigned int height);
202 extern int XAddPixel(
207 * These macros are used to give some sugar to the image routines so that
208 * naive people are more comfortable with them.
210 #define XDestroyImage(ximage) \
211 ((*((ximage)->f.destroy_image))((ximage)))
212 #define XGetPixel(ximage, x, y) \
213 ((*((ximage)->f.get_pixel))((ximage), (x), (y)))
214 #define XPutPixel(ximage, x, y, pixel) \
215 ((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))
216 #define XSubImage(ximage, x, y, width, height) \
217 ((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))
218 #define XAddPixel(ximage, value) \
219 ((*((ximage)->f.add_pixel))((ximage), (value)))
223 * Compose sequence status structure, used in calling XLookupString.
225 typedef struct _XComposeStatus {
226 XPointer compose_ptr; /* state table pointer */
227 int chars_matched; /* match state */
231 * Keysym macros, used on Keysyms to test for classes of symbols
233 #define IsKeypadKey(keysym) \
234 (((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))
236 #define IsPrivateKeypadKey(keysym) \
237 (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
239 #define IsCursorKey(keysym) \
240 (((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))
242 #define IsPFKey(keysym) \
243 (((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))
245 #define IsFunctionKey(keysym) \
246 (((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))
248 #define IsMiscFunctionKey(keysym) \
249 (((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))
252 #define IsModifierKey(keysym) \
253 ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
254 || (((KeySym)(keysym) >= XK_ISO_Lock) && \
255 ((KeySym)(keysym) <= XK_ISO_Last_Group_Lock)) \
256 || ((KeySym)(keysym) == XK_Mode_switch) \
257 || ((KeySym)(keysym) == XK_Num_Lock))
259 #define IsModifierKey(keysym) \
260 ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
261 || ((KeySym)(keysym) == XK_Mode_switch) \
262 || ((KeySym)(keysym) == XK_Num_Lock))
265 * opaque reference to Region data type
267 typedef struct _XRegion *Region;
269 /* Return values from XRectInRegion() */
271 #define RectangleOut 0
272 #define RectangleIn 1
273 #define RectanglePart 2
277 * Information used by the visual utility routines to find desired visual
278 * type from the many visuals a display may support.
286 #if defined(__cplusplus) || defined(c_plusplus)
287 int c_class; /* C++ */
291 unsigned long red_mask;
292 unsigned long green_mask;
293 unsigned long blue_mask;
298 #define VisualNoMask 0x0
299 #define VisualIDMask 0x1
300 #define VisualScreenMask 0x2
301 #define VisualDepthMask 0x4
302 #define VisualClassMask 0x8
303 #define VisualRedMaskMask 0x10
304 #define VisualGreenMaskMask 0x20
305 #define VisualBlueMaskMask 0x40
306 #define VisualColormapSizeMask 0x80
307 #define VisualBitsPerRGBMask 0x100
308 #define VisualAllMask 0x1FF
311 * This defines a window manager property that clients may use to
312 * share standard color maps of type RGB_COLOR_MAP:
316 unsigned long red_max;
317 unsigned long red_mult;
318 unsigned long green_max;
319 unsigned long green_mult;
320 unsigned long blue_max;
321 unsigned long blue_mult;
322 unsigned long base_pixel;
323 VisualID visualid; /* added by ICCCM version 1 */
324 XID killid; /* added by ICCCM version 1 */
327 #define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */
331 * return codes for XReadBitmapFile and XWriteBitmapFile
333 #define BitmapSuccess 0
334 #define BitmapOpenFailed 1
335 #define BitmapFileInvalid 2
336 #define BitmapNoMemory 3
338 /****************************************************************
342 ****************************************************************/
345 /* Associative lookup table return codes */
347 #define XCSUCCESS 0 /* No error. */
348 #define XCNOMEM 1 /* Out of memory */
349 #define XCNOENT 2 /* No entry in table */
351 typedef int XContext;
353 #define XUniqueContext() ((XContext) XrmUniqueQuark())
354 #define XStringToContext(string) ((XContext) XrmStringToQuark(string))
358 /* The following declarations are alphabetized. */
360 extern XClassHint *XAllocClassHint (
364 extern XIconSize *XAllocIconSize (
368 extern XSizeHints *XAllocSizeHints (
372 extern XStandardColormap *XAllocStandardColormap (
376 extern XWMHints *XAllocWMHints (
382 XRectangle* /* rect_return */
385 extern Region XCreateRegion(
389 extern const char *XDefaultString (void);
391 extern int XDeleteContext(
392 Display* /* display */,
394 XContext /* context */
397 extern int XDestroyRegion(
401 extern int XEmptyRegion(
405 extern int XEqualRegion(
410 extern int XFindContext(
411 Display* /* display */,
413 XContext /* context */,
414 XPointer* /* data_return */
417 extern Status XGetClassHint(
418 Display* /* display */,
420 XClassHint* /* class_hints_return */
423 extern Status XGetIconSizes(
424 Display* /* display */,
426 XIconSize** /* size_list_return */,
427 int* /* count_return */
430 extern Status XGetNormalHints(
431 Display* /* display */,
433 XSizeHints* /* hints_return */
436 extern Status XGetRGBColormaps(
437 Display* /* display */,
439 XStandardColormap** /* stdcmap_return */,
440 int* /* count_return */,
444 extern Status XGetSizeHints(
445 Display* /* display */,
447 XSizeHints* /* hints_return */,
451 extern Status XGetStandardColormap(
452 Display* /* display */,
454 XStandardColormap* /* colormap_return */,
458 extern Status XGetTextProperty(
459 Display* /* display */,
461 XTextProperty* /* text_prop_return */,
465 extern XVisualInfo *XGetVisualInfo(
466 Display* /* display */,
467 long /* vinfo_mask */,
468 XVisualInfo* /* vinfo_template */,
469 int* /* nitems_return */
472 extern Status XGetWMClientMachine(
473 Display* /* display */,
475 XTextProperty* /* text_prop_return */
478 extern XWMHints *XGetWMHints(
479 Display* /* display */,
483 extern Status XGetWMIconName(
484 Display* /* display */,
486 XTextProperty* /* text_prop_return */
489 extern Status XGetWMName(
490 Display* /* display */,
492 XTextProperty* /* text_prop_return */
495 extern Status XGetWMNormalHints(
496 Display* /* display */,
498 XSizeHints* /* hints_return */,
499 long* /* supplied_return */
502 extern Status XGetWMSizeHints(
503 Display* /* display */,
505 XSizeHints* /* hints_return */,
506 long* /* supplied_return */,
510 extern Status XGetZoomHints(
511 Display* /* display */,
513 XSizeHints* /* zhints_return */
516 extern int XIntersectRegion(
519 Region /* dr_return */
522 extern void XConvertCase(
528 extern int XLookupString(
529 XKeyEvent* /* event_struct */,
530 char* /* buffer_return */,
531 int /* bytes_buffer */,
532 KeySym* /* keysym_return */,
533 XComposeStatus* /* status_in_out */
536 extern Status XMatchVisualInfo(
537 Display* /* display */,
541 XVisualInfo* /* vinfo_return */
544 extern int XOffsetRegion(
550 extern Bool XPointInRegion(
556 extern Region XPolygonRegion(
557 XPoint* /* points */,
562 extern int XRectInRegion(
566 unsigned int /* width */,
567 unsigned int /* height */
570 extern int XSaveContext(
571 Display* /* display */,
573 XContext /* context */,
574 _Xconst char* /* data */
577 extern int XSetClassHint(
578 Display* /* display */,
580 XClassHint* /* class_hints */
583 extern int XSetIconSizes(
584 Display* /* display */,
586 XIconSize* /* size_list */,
590 extern int XSetNormalHints(
591 Display* /* display */,
593 XSizeHints* /* hints */
596 extern void XSetRGBColormaps(
597 Display* /* display */,
599 XStandardColormap* /* stdcmaps */,
604 extern int XSetSizeHints(
605 Display* /* display */,
607 XSizeHints* /* hints */,
611 extern int XSetStandardProperties(
612 Display* /* display */,
614 _Xconst char* /* window_name */,
615 _Xconst char* /* icon_name */,
616 Pixmap /* icon_pixmap */,
619 XSizeHints* /* hints */
622 extern void XSetTextProperty(
623 Display* /* display */,
625 XTextProperty* /* text_prop */,
629 extern void XSetWMClientMachine(
630 Display* /* display */,
632 XTextProperty* /* text_prop */
635 extern int XSetWMHints(
636 Display* /* display */,
638 XWMHints* /* wm_hints */
641 extern void XSetWMIconName(
642 Display* /* display */,
644 XTextProperty* /* text_prop */
647 extern void XSetWMName(
648 Display* /* display */,
650 XTextProperty* /* text_prop */
653 extern void XSetWMNormalHints(
654 Display* /* display */,
656 XSizeHints* /* hints */
659 extern void XSetWMProperties(
660 Display* /* display */,
662 XTextProperty* /* window_name */,
663 XTextProperty* /* icon_name */,
666 XSizeHints* /* normal_hints */,
667 XWMHints* /* wm_hints */,
668 XClassHint* /* class_hints */
671 extern void XmbSetWMProperties(
672 Display* /* display */,
674 _Xconst char* /* window_name */,
675 _Xconst char* /* icon_name */,
678 XSizeHints* /* normal_hints */,
679 XWMHints* /* wm_hints */,
680 XClassHint* /* class_hints */
683 extern void Xutf8SetWMProperties(
684 Display* /* display */,
686 _Xconst char* /* window_name */,
687 _Xconst char* /* icon_name */,
690 XSizeHints* /* normal_hints */,
691 XWMHints* /* wm_hints */,
692 XClassHint* /* class_hints */
695 extern void XSetWMSizeHints(
696 Display* /* display */,
698 XSizeHints* /* hints */,
702 extern int XSetRegion(
703 Display* /* display */,
708 extern void XSetStandardColormap(
709 Display* /* display */,
711 XStandardColormap* /* colormap */,
715 extern int XSetZoomHints(
716 Display* /* display */,
718 XSizeHints* /* zhints */
721 extern int XShrinkRegion(
727 extern Status XStringListToTextProperty(
730 XTextProperty* /* text_prop_return */
733 extern int XSubtractRegion(
736 Region /* dr_return */
739 extern int XmbTextListToTextProperty(
743 XICCEncodingStyle style,
744 XTextProperty* text_prop_return
747 extern int XwcTextListToTextProperty(
751 XICCEncodingStyle style,
752 XTextProperty* text_prop_return
755 extern int Xutf8TextListToTextProperty(
759 XICCEncodingStyle style,
760 XTextProperty* text_prop_return
763 extern void XwcFreeStringList(
767 extern Status XTextPropertyToStringList(
768 XTextProperty* /* text_prop */,
769 char*** /* list_return */,
770 int* /* count_return */
773 extern int XmbTextPropertyToTextList(
775 const XTextProperty* text_prop,
780 extern int XwcTextPropertyToTextList(
782 const XTextProperty* text_prop,
783 wchar_t*** list_return,
787 extern int Xutf8TextPropertyToTextList(
789 const XTextProperty* text_prop,
794 extern int XUnionRectWithRegion(
795 XRectangle* /* rectangle */,
796 Region /* src_region */,
797 Region /* dest_region_return */
800 extern int XUnionRegion(
803 Region /* dr_return */
806 extern int XWMGeometry(
807 Display* /* display */,
808 int /* screen_number */,
809 _Xconst char* /* user_geometry */,
810 _Xconst char* /* default_geometry */,
811 unsigned int /* border_width */,
812 XSizeHints* /* hints */,
815 int* /* width_return */,
816 int* /* height_return */,
817 int* /* gravity_return */
820 extern int XXorRegion(
823 Region /* dr_return */
828 #endif /* _XUTIL_H_ */