ClassiCube/misc/x11/min-xutil.h

263 lines
8.1 KiB
C

/***********************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#ifndef _X11_XUTIL_H_
#define _X11_XUTIL_H_
/* You must include <X11/Xlib.h> before including this file */
#include "min-xlib.h"
/* The Xlib structs are full of implicit padding to properly align members.
We can't clean that up without breaking ABI, so tell clang not to bother
complaining about it. */
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#endif
/*
* new version containing base_width, base_height, and win_gravity fields;
* used with WM_NORMAL_HINTS.
*/
typedef struct {
long flags; /* marks which fields in this structure are defined */
int x, y; /* obsolete for new window mgrs, but clients */
int width, height; /* should set so old wm's don't mess up */
int min_width, min_height;
int max_width, max_height;
int width_inc, height_inc;
struct {
int x; /* numerator */
int y; /* denominator */
} min_aspect, max_aspect;
int base_width, base_height; /* added by ICCCM version 1 */
int win_gravity; /* added by ICCCM version 1 */
} XSizeHints;
/*
* The next block of definitions are for window manager properties that
* clients and applications use for communication.
*/
/* flags argument in size hints */
#define USPosition (1L << 0) /* user specified x, y */
#define USSize (1L << 1) /* user specified width, height */
#define PPosition (1L << 2) /* program specified position */
#define PSize (1L << 3) /* program specified size */
#define PMinSize (1L << 4) /* program specified minimum size */
#define PMaxSize (1L << 5) /* program specified maximum size */
#define PResizeInc (1L << 6) /* program specified resize increments */
#define PAspect (1L << 7) /* program specified min and max aspect ratios */
#define PBaseSize (1L << 8) /* program specified base for incrementing */
#define PWinGravity (1L << 9) /* program specified window gravity */
/* obsolete */
#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
typedef struct {
char *res_name;
char *res_class;
} XClassHint;
#ifdef XUTIL_DEFINE_FUNCTIONS
extern int XDestroyImage(
XImage *ximage);
extern int XPutPixel(
XImage *ximage,
int x, int y,
unsigned long pixel);
#else
/*
* These macros are used to give some sugar to the image routines so that
* naive people are more comfortable with them.
*/
#define XDestroyImage(ximage) \
((*((ximage)->f.destroy_image))((ximage)))
#define XPutPixel(ximage, x, y, pixel) \
((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))
#endif
/*
* Keysym macros, used on Keysyms to test for classes of symbols
*/
#define IsKeypadKey(keysym) \
(((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))
#define IsPrivateKeypadKey(keysym) \
(((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
#define IsCursorKey(keysym) \
(((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))
#define IsPFKey(keysym) \
(((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))
#define IsFunctionKey(keysym) \
(((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))
#define IsMiscFunctionKey(keysym) \
(((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))
#ifdef XK_XKB_KEYS
#define IsModifierKey(keysym) \
((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
|| (((KeySym)(keysym) >= XK_ISO_Lock) && \
((KeySym)(keysym) <= XK_ISO_Level5_Lock)) \
|| ((KeySym)(keysym) == XK_Mode_switch) \
|| ((KeySym)(keysym) == XK_Num_Lock))
#else
#define IsModifierKey(keysym) \
((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
|| ((KeySym)(keysym) == XK_Mode_switch) \
|| ((KeySym)(keysym) == XK_Num_Lock))
#endif
/*
* Information used by the visual utility routines to find desired visual
* type from the many visuals a display may support.
*/
typedef struct {
Visual *visual;
VisualID visualid;
int screen;
int depth;
#if defined(__cplusplus) || defined(c_plusplus)
int c_class; /* C++ */
#else
int class;
#endif
unsigned long red_mask;
unsigned long green_mask;
unsigned long blue_mask;
int colormap_size;
int bits_per_rgb;
} XVisualInfo;
#define VisualNoMask 0x0
#define VisualIDMask 0x1
#define VisualScreenMask 0x2
#define VisualDepthMask 0x4
#define VisualClassMask 0x8
#define VisualRedMaskMask 0x10
#define VisualGreenMaskMask 0x20
#define VisualBlueMaskMask 0x40
#define VisualColormapSizeMask 0x80
#define VisualBitsPerRGBMask 0x100
#define VisualAllMask 0x1FF
/*
* Compose sequence status structure, used in calling XLookupString.
*/
typedef struct _XComposeStatus {
XPointer compose_ptr; /* state table pointer */
int chars_matched; /* match state */
} XComposeStatus;
_XFUNCPROTOBEGIN
/* The following declarations are alphabetized. */
extern Status XMatchVisualInfo(
Display* /* display */,
int /* screen */,
int /* depth */,
int /* class */,
XVisualInfo* /* vinfo_return */
);
extern int XSetClassHint(
Display* /* display */,
Window /* w */,
XClassHint* /* class_hints */
);
extern int XSetNormalHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */
);
extern int XSetSizeHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */,
Atom /* property */
);
extern void XSetWMNormalHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */
);
extern void XSetWMSizeHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */,
Atom /* property */
);
extern int XLookupString(
XKeyEvent* /* event_struct */,
char* /* buffer_return */,
int /* bytes_buffer */,
KeySym* /* keysym_return */,
XComposeStatus* /* status_in_out */
);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
_XFUNCPROTOEND
#endif /* _X11_XUTIL_H_ */