DndP.h

Go to the documentation of this file.
00001 /***********************************************************/
00002 /* Copyright 1996 Daniel Dardailler.  
00003 Permission to use, copy, modify, distribute, and sell this software
00004 for any purpose is hereby granted without fee, provided that the above
00005 copyright notice appear in all copies and that both that copyright
00006 notice and this permission notice appear in supporting documentation,
00007 and that the name of Daniel Dardailler not be used in advertising or
00008 publicity pertaining to distribution of the software without specific,
00009 written prior permission.  Daniel Dardailler makes no representations
00010 about the suitability of this software for any purpose.  It is
00011 provided "as is" without express or implied warranty.
00012 ************************************************************/
00013 #ifndef _DnDP_h
00014 #define _DnDP_h
00015 
00016 /*** Dnd Protocol stream structures and other low-level stuff */
00017 
00018 #include <Dnd.h>
00019 #include <X11/Xmd.h>
00020 
00021 typedef struct _DndSrcProp {
00022     BYTE                byte_order ;
00023     BYTE                protocol_version ;
00024     CARD16              target_index ;
00025     CARD32              selection ;
00026 } DndSrcProp ;
00027 
00028 typedef struct _DndReceiverProp {
00029     BYTE                byte_order ;
00030     BYTE                protocol_version ;
00031     BYTE                protocol_style ;
00032     BYTE                pad1;
00033     CARD32              proxy_window;
00034     CARD16              num_drop_sites ;
00035     CARD16              pad2;
00036     CARD32              total_size;
00037 } DndReceiverProp ;
00038 
00039 /* need to use some union hack since window and property are in
00040    different order depending on the message ... */
00041 typedef struct _DndTop {
00042     CARD32    src_window;
00043     CARD32    property;
00044 } DndTop ;
00045 
00046 typedef struct _DndPot {
00047     INT16    x;
00048     INT16    y;
00049     CARD32    property;
00050     CARD32    src_window;
00051 } DndPot ;
00052 
00053 typedef struct _DndMessage {
00054     BYTE    reason;
00055     BYTE    byte_order;
00056     CARD16    flags;
00057     CARD32    time;
00058     union {
00059   DndTop top ;
00060   DndPot pot ;
00061     } data ;
00062 } DndMessage ;
00063 
00064 typedef struct {
00065     BYTE  byte_order;
00066     BYTE  protocol_version;
00067     CARD16  num_target_lists;
00068     CARD32  data_size;
00069     /* then come series of CARD16,CARD32,CARD32,CARD32... */
00070 } DndTargets;
00071 
00072 
00073 /* protocol version */
00074 #define DND_PROTOCOL_VERSION 0
00075 
00076 
00077 #define DND_EVENT_TYPE_MASK  ((BYTE)0x80)
00078 #define DND_EVENT_TYPE_SHIFT 7
00079 #define DND_CLEAR_EVENT_TYPE  ((BYTE)0x7F)
00080 
00081 /* message_type is data[0] of the client_message
00082    this return 1 (receiver bit up) or 0 (initiator) */
00083 #define DND_GET_EVENT_TYPE(message_type) \
00084   ((char) (((message_type) & DND_EVENT_TYPE_MASK) >> DND_EVENT_TYPE_SHIFT))
00085 
00086 /* event_type can be 0 (initiator) or 1 (receiver) */
00087 #define DND_SET_EVENT_TYPE(event_type) \
00088   (((BYTE)(event_type) << DND_EVENT_TYPE_SHIFT) & DND_EVENT_TYPE_MASK)
00089 
00090 
00091 #define DND_OPERATION_MASK ((CARD16) 0x000F)
00092 #define DND_OPERATION_SHIFT 0
00093 #define DND_STATUS_MASK ((CARD16) 0x00F0)
00094 #define DND_STATUS_SHIFT 4
00095 #define DND_OPERATIONS_MASK ((CARD16) 0x0F00)
00096 #define DND_OPERATIONS_SHIFT 8
00097 #define DND_COMPLETION_MASK ((CARD16) 0xF000)
00098 #define DND_COMPLETION_SHIFT 12
00099 
00100 #define DND_GET_OPERATION(flags) \
00101   ((unsigned char) \
00102    (((flags) & DND_OPERATION_MASK) >> DND_OPERATION_SHIFT))
00103 
00104 #define DND_SET_OPERATION(operation) \
00105   (((CARD16)(operation) << DND_OPERATION_SHIFT)\
00106    & DND_OPERATION_MASK)
00107 
00108 #define DND_GET_STATUS(flags) \
00109   ((unsigned char) \
00110    (((flags) & DND_STATUS_MASK) >> DND_STATUS_SHIFT))
00111 
00112 #define DND_SET_STATUS(status) \
00113   (((CARD16)(status) << DND_STATUS_SHIFT)\
00114    & DND_STATUS_MASK)
00115 
00116 #define DND_GET_OPERATIONS(flags) \
00117   ((unsigned char) \
00118    (((flags) & DND_OPERATIONS_MASK) >> DND_OPERATIONS_SHIFT))
00119 
00120 #define DND_SET_OPERATIONS(operation) \
00121   (((CARD16)(operation) << DND_OPERATIONS_SHIFT)\
00122    & DND_OPERATIONS_MASK)
00123 
00124 #define DND_GET_COMPLETION(flags) \
00125   ((unsigned char) \
00126    (((flags) & DND_COMPLETION_MASK) >> DND_COMPLETION_SHIFT))
00127 
00128 #define DND_SET_COMPLETION(completion) \
00129   (((CARD16)(completion) << DND_COMPLETION_SHIFT)\
00130    & DND_COMPLETION_MASK)
00131 
00132 
00133 #define SWAP4BYTES(l) {\
00134   struct { unsigned t :32;} bit32;\
00135         char n,  *tp = (char *) &bit32;\
00136   bit32.t = l;\
00137   n = tp[0]; tp[0] = tp[3]; tp[3] = n;\
00138   n = tp[1]; tp[1] = tp[2]; tp[2] = n;\
00139         l = bit32.t;\
00140 }
00141 
00142 #define SWAP2BYTES(s) {\
00143   struct { unsigned t :16; } bit16;\
00144         char n, *tp = (char *) &bit16;\
00145   bit16.t = s;\
00146   n = tp[0]; tp[0] = tp[1]; tp[1] = n;\
00147         s = bit16.t;\
00148 }
00149 
00150 
00153 extern unsigned char _DndByteOrder (void);
00154 
00155 
00156 /***** Targets/Index stuff */
00157 
00158 typedef struct {
00159     int      num_targets;
00160     Atom    *targets;
00161 } DndTargetsTableEntryRec, * DndTargetsTableEntry;
00162 
00163 typedef struct {
00164     int  num_entries;
00165     DndTargetsTableEntry entries;
00166 } DndTargetsTableRec, * DndTargetsTable;
00167 
00168 extern int _DndTargetsToIndex(Display * display, Atom * targets,
00169             int num_targets);
00170 
00171 extern int _DndIndexToTargets(Display * display,
00172             int index,
00173             Atom ** targets);
00174  
00175 #endif /* _DndP_h */

Generated on Sat Dec 12 16:04:53 2009 for KWWidgets by  doxygen 1.6.1