📄 toolkit.h
字号:
/** * toolkit.h - * * Copyright (c) 1998 * Transvirtual Technologies, Inc. All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file. */#ifndef __toolkit_h#define __toolkit_h#include "config.h"#include "config-std.h"#include "config-mem.h"#include "config-setjmp.h"#include <X11/Xlib.h>#include <X11/Xutil.h>#if defined(HAVE_LIBXEXT) && defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SHM_H) && defined(HAVE_X11_EXTENSIONS_XSHM_H)#define USE_XSHM_EXTENSION 1#include <sys/ipc.h>#include <sys/shm.h>#include <X11/extensions/XShm.h>#else#undef USE_XSHM_EXTENSION#define XShmGetImage(A,B,C,D,E,F) 0#define XShmPutImage(A,B,C,D,E,F,G,H,I,J,K) 0#define XShmSegmentInfo void#endif#include <jni.h>#include "../../../../kaffe/kaffevm/gtypes.h"#include "../../../../kaffe/kaffevm/gc.h"#include "../../../../kaffe/kaffevm/thread.h"#include "../../../../kaffe/kaffevm/debug.h"#define DBG_ACTION(A,B)#ifdef HAVE_FCNTL_H#include <fcntl.h>#endif/******************************************************************************* * color conversion structures */#define N_DIRECT 256typedef struct _Rgb2Direct { unsigned char red[N_DIRECT]; unsigned char redPix[N_DIRECT]; int redShift; int nRed; unsigned char green[N_DIRECT]; unsigned char greenPix[N_DIRECT]; int greenShift; int nGreen; unsigned char blue[N_DIRECT]; unsigned char bluePix[N_DIRECT]; int blueShift; int nBlue;} Rgb2Direct;typedef struct _Rgb2True { unsigned int redMask; unsigned int greenMask; unsigned int blueMask; int blueShift; int redShift; int greenShift;} Rgb2True;typedef struct _RgbColor { unsigned char r; unsigned char g; unsigned char b;} RgbColor;typedef struct _Rgb2Pseudo { RgbColor rgb[256]; unsigned char pix[8][8][8];} Rgb2Pseudo;/******************************************************************************* * image handling structures */typedef struct _AlphaImage { /* storage for full alpha channel images */ unsigned char *buf; int width, height;} AlphaImage;#define NO_SHM 0 /* we don't have MIT-Shm support in the X server */#define USE_SHM 1 /* we have support, use it */#define SUSPEND_SHM 2 /* we have support, but it ran out of space */typedef struct _Image { Pixmap pix; /* pixmap for screen images */ XImage *xImg; /* "real" image */ XShmSegmentInfo *shmiImg; /* Shm info for shared mem real image */ XImage *xMask; /* mask image for reduced alpha (on/off) images */ XShmSegmentInfo *shmiMask; /* Shm info for shared mem mask image */ AlphaImage *alpha; /* full alpha channel (for alpha != 0x00 or 0xff) */ int trans; /* transparent index */ int left, top; /* some GIF movies require drawing offsets */ int width, height; /* we need this in case we are a pixmap */ short latency; /* between image flips, for "gif-movies" */ short frame; /* frame number for animations */ struct _Image *next; /* next movie-frame */} Image;/******************************************************************************* * structure to store guessed and computed Frame/Dialog insets (titlebar, borders) */typedef struct _DecoInset { int left; int top; int right; int bottom; char guess;} DecoInset; /******************************************************************************* * We use our own structure instead of directly storing X window handles, to * enable us to attach and query attributes (owners, states, flags..) to particular * X window instances. We could do this by means of X properties, but this might * end up in costly round-trips and even more memory (than we trade for speed here). * It's a must have for our popup key/focus event forwarding (see wnd.c) */typedef struct _WindowRec { Window w; unsigned flags; Window owner;} WindowRec;/******************************************************************************* * this is the master AWT structure (singleton object), glueing it al together */typedef struct _Toolkit { Display *dsp; Window root; char *buf; unsigned int nBuf; int colorMode; /* refers to CM_xx constants, not X visuals */ Rgb2True *tclr; Rgb2Pseudo *pclr; Rgb2Direct *dclr; int shm; int shmThreshold; Cursor cursors[14]; DecoInset frameInsets; DecoInset dialogInsets; XEvent event; char preFetched; char blocking; int pending; int evtId; fd_set rfds; /* used to select-check availability of X input (pthreads) */ Window lastWindow; int srcIdx; WindowRec *windows; int nWindows; Window cbdOwner; Window wakeUp; Window focus; /* this is the real focus, if it is in our process */ Window focusFwd; /* this might be a (owned) window we forward the focus to */ int fwdIdx; /* cached index of the focus forward window */} Toolkit;/******************************************************************************* * global data def/decl */#ifdef MAINToolkit XTk;Toolkit *X = &XTk;Atom WM_PROTOCOLS;Atom WM_DELETE_WINDOW;Atom WM_TAKE_FOCUS;Atom WAKEUP;Atom RETRY_FOCUS;Atom FORWARD_FOCUS;Atom SELECTION_DATA;Atom JAVA_OBJECT;jclass AWTError;JNIEnv *JniEnv;#elseextern Toolkit* X;extern Atom WM_PROTOCOLS;extern Atom WM_DELETE_WINDOW;extern Atom WM_TAKE_FOCUS;extern Atom WAKEUP;extern Atom RETRY_FOCUS;extern Atom FORWARD_FOCUS;extern Atom SELECTION_DATA;extern Atom JAVA_OBJECT;extern jclass AWTError;extern JNIEnv* JniEnv;#endif /* MAIN */extern long StdEvents, PopupEvents;/***************************************************************************************** * heap wrapper macros */static inline void* _awt_malloc_wrapper ( size_t size ){ void *adr; enterUnsafeRegion(); adr = malloc( size); leaveUnsafeRegion(); DBG( AWT_MEM, printf("malloc: %ld -> %p\n", (unsigned long) size, adr)); return adr;}static inline void* _awt_calloc_wrapper ( int n, size_t size ){ void *adr; enterUnsafeRegion(); adr = calloc( n, size); leaveUnsafeRegion(); DBG( AWT_MEM, printf("calloc: %ld,%ld -> %p\n", (unsigned long) n, (unsigned long) size, adr)); return adr;}static inline void _awt_free_wrapper ( void* adr ){ DBG( AWT_MEM, printf("free: %p\n", adr)); enterUnsafeRegion(); free( adr); leaveUnsafeRegion();}#define AWT_MALLOC(_n) \ _awt_malloc_wrapper( _n)#define AWT_CALLOC(_n,_sz) \ _awt_calloc_wrapper( _n, _sz)#define AWT_FREE(_adr) \ _awt_free_wrapper( _adr);/******************************************************************************* * */static inline char* java2CString ( JNIEnv *env, Toolkit* X, jstring jstr ) { jboolean isCopy; register int i; int n = (*env)->GetStringLength( env, jstr); const jchar *jc = (*env)->GetStringChars( env, jstr, &isCopy); if ( n >= X->nBuf ) { if ( X->buf ) AWT_FREE( X->buf); X->buf = AWT_MALLOC( n+1); X->nBuf = n+1; } for ( i=0; i<n; i++ ) X->buf[i] = (char) jc[i]; X->buf[i] = 0; (*env)->ReleaseStringChars( env, jstr, jc); return X->buf;}static inline char* jchar2CString ( Toolkit* X, jchar* jc, int len ) { register int i; int n = len+1; if ( n > X->nBuf ) { if ( X->buf ) AWT_FREE( X->buf);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -