Back to index

plt-scheme  4.2.1
xdnd.h
Go to the documentation of this file.
00001 /* 
00002    xdnd.c, xdnd.h - C program library for handling the Xdnd protocol
00003 
00004    Copyright (C) 1998  Paul Sheer
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public
00017    License along with this library; if not, write to the Free Software
00018    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019    02110-1301 USA.
00020 
00021    Further info can also be obtained by emailing the author at,
00022        psheer@obsidian.co.za
00023 */
00024 
00025 #ifndef _X_DND_H
00026 #define _X_DND_H
00027 
00028 #define XDND_VERSION 3
00029 
00030 /* XdndEnter */
00031 #define XDND_THREE 3
00032 #define XDND_ENTER_SOURCE_WIN(e)          ((e)->xclient.data.l[0])
00033 #define XDND_ENTER_THREE_TYPES(e)         (((e)->xclient.data.l[1] & 0x1UL) == 0)
00034 #define XDND_ENTER_THREE_TYPES_SET(e,b)   (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x1UL) | (((b) == 0) ? 0 : 0x1UL)
00035 #define XDND_ENTER_VERSION(e)                    ((e)->xclient.data.l[1] >> 24)
00036 #define XDND_ENTER_VERSION_SET(e,v)              (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~(0xFF << 24)) | ((v) << 24)
00037 #define XDND_ENTER_TYPE(e,i)                     ((e)->xclient.data.l[2 + i])       /* i => (0, 1, 2) */
00038 
00039 /* XdndPosition */
00040 #define XDND_POSITION_SOURCE_WIN(e)              ((e)->xclient.data.l[0])
00041 #define XDND_POSITION_ROOT_X(e)                  ((e)->xclient.data.l[2] >> 16)
00042 #define XDND_POSITION_ROOT_Y(e)                  ((e)->xclient.data.l[2] & 0xFFFFUL)
00043 #define XDND_POSITION_ROOT_SET(e,x,y)     (e)->xclient.data.l[2]  = ((x) << 16) | ((y) & 0xFFFFUL)
00044 #define XDND_POSITION_TIME(e)                    ((e)->xclient.data.l[3])
00045 #define XDND_POSITION_ACTION(e)                  ((e)->xclient.data.l[4])
00046 
00047 /* XdndStatus */
00048 #define XDND_STATUS_TARGET_WIN(e)                ((e)->xclient.data.l[0])
00049 #define XDND_STATUS_WILL_ACCEPT(e)               ((e)->xclient.data.l[1] & 0x1L)
00050 #define XDND_STATUS_WILL_ACCEPT_SET(e,b)  (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x1UL) | (((b) == 0) ? 0 : 0x1UL)
00051 #define XDND_STATUS_WANT_POSITION(e)             ((e)->xclient.data.l[1] & 0x2UL)
00052 #define XDND_STATUS_WANT_POSITION_SET(e,b) (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x2UL) | (((b) == 0) ? 0 : 0x2UL)
00053 #define XDND_STATUS_RECT_X(e)                           ((e)->xclient.data.l[2] >> 16)
00054 #define XDND_STATUS_RECT_Y(e)                           ((e)->xclient.data.l[2] & 0xFFFFL)
00055 #define XDND_STATUS_RECT_WIDTH(e)                ((e)->xclient.data.l[3] >> 16)
00056 #define XDND_STATUS_RECT_HEIGHT(e)               ((e)->xclient.data.l[3] & 0xFFFFL)
00057 #define XDND_STATUS_RECT_SET(e,x,y,w,h)          {(e)->xclient.data.l[2] = ((x) << 16) | ((y) & 0xFFFFUL); (e)->xclient.data.l[3] = ((w) << 16) | ((h) & 0xFFFFUL); }
00058 #define XDND_STATUS_ACTION(e)             ((e)->xclient.data.l[4])
00059 
00060 /* XdndLeave */
00061 #define XDND_LEAVE_SOURCE_WIN(e)   ((e)->xclient.data.l[0])
00062 
00063 /* XdndDrop */
00064 #define XDND_DROP_SOURCE_WIN(e)           ((e)->xclient.data.l[0])
00065 #define XDND_DROP_TIME(e)                 ((e)->xclient.data.l[2])
00066 
00067 /* XdndFinished */
00068 #define XDND_FINISHED_TARGET_WIN(e)       ((e)->xclient.data.l[0])
00069 
00070 typedef struct _DndClass DndClass;
00071 
00072 struct _DndClass {
00073 
00074     Display *display;
00075 
00076     Atom XdndAware;
00077     Atom XdndSelection;
00078     Atom XdndEnter;
00079     Atom XdndLeave;
00080     Atom XdndPosition;
00081     Atom XdndDrop;
00082     Atom XdndFinished;
00083     Atom XdndStatus;
00084     Atom XdndActionCopy;
00085     Atom XdndActionMove;
00086     Atom XdndActionLink;
00087     Atom XdndActionAsk;
00088     Atom XdndActionPrivate;
00089     Atom XdndTypeList;
00090     Atom XdndActionList;
00091     Atom XdndActionDescription;
00092     Atom Xdnd_NON_PROTOCOL_ATOM;
00093     Atom version;
00094     Atom text_uri_list;
00095     Window root_window;
00096 
00097 #define XDND_DROP_STAGE_IDLE              0
00098 #define XDND_DRAG_STAGE_DRAGGING   1
00099 #define XDND_DRAG_STAGE_ENTERED           2
00100 #define XDND_DROP_STAGE_CONVERTING 3
00101 #define XDND_DROP_STAGE_ENTERED           4
00102     int stage;
00103     int dragging_version;
00104     int internal_drag;
00105     int want_position;
00106     int ready_to_drop;
00107     int will_accept;
00108     XRectangle rectangle;
00109     Window dropper_window, dragger_window;
00110     Atom *dragger_typelist;
00111     Atom desired_type;
00112     Atom supported_action;
00113     Time time;
00114 /* drop position from last XdndPosition */
00115     int x, y;
00116 
00117 /* block for only this many seconds on not receiving a XdndFinished from target, default : 10 */
00118     int time_out;
00119 };
00120 
00121 void xdnd_init (DndClass * dnd, Display * display);
00122 void xdnd_set_dnd_aware (DndClass * dnd, Window window, Atom * typelist);
00123 void xdnd_set_dnd_unaware (DndClass * dnd, Window window);
00124 int xdnd_is_dnd_aware (DndClass * dnd, Window window, int *version, Atom * typelist);
00125 void xdnd_set_type_list (DndClass * dnd, Window window, Atom * typelist);
00126 void xdnd_send_enter (DndClass * dnd, Window window, Window from, Atom * typelist);
00127 void xdnd_send_position (DndClass * dnd, Window window, Window from, Atom action, int x, int y, unsigned long etime);
00128 void xdnd_send_status (DndClass * dnd, Window window, Window from, int will_accept,
00129             int want_position, int x, int y, int w, int h, Atom action);
00130 void xdnd_send_leave (DndClass * dnd, Window window, Window from);
00131 void xdnd_send_drop (DndClass * dnd, Window window, Window from, unsigned long etime);
00132 void xdnd_send_finished (DndClass * dnd, Window window, Window from, int error);
00133 int xdnd_convert_selection (DndClass * dnd, Window window, Window requester, Atom type);
00134 void xdnd_selection_send (DndClass * dnd, XSelectionRequestEvent * request, unsigned char *data, int length);
00135 
00136 #endif        /* !_X_DND_H */