Back to index

plt-scheme  4.2.1
Classes | Defines | Typedefs | Functions
xdnd.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DndClass

Defines

#define XDND_VERSION   3
#define XDND_THREE   3
#define XDND_ENTER_SOURCE_WIN(e)   ((e)->xclient.data.l[0])
#define XDND_ENTER_THREE_TYPES(e)   (((e)->xclient.data.l[1] & 0x1UL) == 0)
#define XDND_ENTER_THREE_TYPES_SET(e, b)   (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x1UL) | (((b) == 0) ? 0 : 0x1UL)
#define XDND_ENTER_VERSION(e)   ((e)->xclient.data.l[1] >> 24)
#define XDND_ENTER_VERSION_SET(e, v)   (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~(0xFF << 24)) | ((v) << 24)
#define XDND_ENTER_TYPE(e, i)   ((e)->xclient.data.l[2 + i]) /* i => (0, 1, 2) */
#define XDND_POSITION_SOURCE_WIN(e)   ((e)->xclient.data.l[0])
#define XDND_POSITION_ROOT_X(e)   ((e)->xclient.data.l[2] >> 16)
#define XDND_POSITION_ROOT_Y(e)   ((e)->xclient.data.l[2] & 0xFFFFUL)
#define XDND_POSITION_ROOT_SET(e, x, y)   (e)->xclient.data.l[2] = ((x) << 16) | ((y) & 0xFFFFUL)
#define XDND_POSITION_TIME(e)   ((e)->xclient.data.l[3])
#define XDND_POSITION_ACTION(e)   ((e)->xclient.data.l[4])
#define XDND_STATUS_TARGET_WIN(e)   ((e)->xclient.data.l[0])
#define XDND_STATUS_WILL_ACCEPT(e)   ((e)->xclient.data.l[1] & 0x1L)
#define XDND_STATUS_WILL_ACCEPT_SET(e, b)   (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x1UL) | (((b) == 0) ? 0 : 0x1UL)
#define XDND_STATUS_WANT_POSITION(e)   ((e)->xclient.data.l[1] & 0x2UL)
#define XDND_STATUS_WANT_POSITION_SET(e, b)   (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x2UL) | (((b) == 0) ? 0 : 0x2UL)
#define XDND_STATUS_RECT_X(e)   ((e)->xclient.data.l[2] >> 16)
#define XDND_STATUS_RECT_Y(e)   ((e)->xclient.data.l[2] & 0xFFFFL)
#define XDND_STATUS_RECT_WIDTH(e)   ((e)->xclient.data.l[3] >> 16)
#define XDND_STATUS_RECT_HEIGHT(e)   ((e)->xclient.data.l[3] & 0xFFFFL)
#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); }
#define XDND_STATUS_ACTION(e)   ((e)->xclient.data.l[4])
#define XDND_LEAVE_SOURCE_WIN(e)   ((e)->xclient.data.l[0])
#define XDND_DROP_SOURCE_WIN(e)   ((e)->xclient.data.l[0])
#define XDND_DROP_TIME(e)   ((e)->xclient.data.l[2])
#define XDND_FINISHED_TARGET_WIN(e)   ((e)->xclient.data.l[0])
#define XDND_DROP_STAGE_IDLE   0
#define XDND_DRAG_STAGE_DRAGGING   1
#define XDND_DRAG_STAGE_ENTERED   2
#define XDND_DROP_STAGE_CONVERTING   3
#define XDND_DROP_STAGE_ENTERED   4

Typedefs

typedef struct _DndClass

Functions

void xdnd_init (DndClass *dnd, Display *display)
void xdnd_set_dnd_aware (DndClass *dnd, Window window, Atom *typelist)
void xdnd_set_dnd_unaware (DndClass *dnd, Window window)
int xdnd_is_dnd_aware (DndClass *dnd, Window window, int *version, Atom *typelist)
void xdnd_set_type_list (DndClass *dnd, Window window, Atom *typelist)
void xdnd_send_enter (DndClass *dnd, Window window, Window from, Atom *typelist)
void xdnd_send_position (DndClass *dnd, Window window, Window from, Atom action, int x, int y, unsigned long etime)
void xdnd_send_status (DndClass *dnd, Window window, Window from, int will_accept, int want_position, int x, int y, int w, int h, Atom action)
void xdnd_send_leave (DndClass *dnd, Window window, Window from)
void xdnd_send_drop (DndClass *dnd, Window window, Window from, unsigned long etime)
void xdnd_send_finished (DndClass *dnd, Window window, Window from, int error)
int xdnd_convert_selection (DndClass *dnd, Window window, Window requester, Atom type)
void xdnd_selection_send (DndClass *dnd, XSelectionRequestEvent *request, unsigned char *data, int length)

Class Documentation

struct _DndClass

Definition at line 72 of file xdnd.h.

Class Members
Atom desired_type
Display * display
Atom * dragger_typelist
Window dragger_window
int dragging_version
Window dropper_window
int internal_drag
int ready_to_drop
XRectangle rectangle
Window root_window
int stage
Atom supported_action
Atom text_uri_list
Time time
int time_out
Atom version
int want_position
int will_accept
int x
Atom Xdnd_NON_PROTOCOL_ATOM
Atom XdndActionAsk
Atom XdndActionCopy
Atom XdndActionDescription
Atom XdndActionLink
Atom XdndActionList
Atom XdndActionMove
Atom XdndActionPrivate
Atom XdndAware
Atom XdndDrop
Atom XdndEnter
Atom XdndFinished
Atom XdndLeave
Atom XdndPosition
Atom XdndSelection
Atom XdndStatus
Atom XdndTypeList
int y

Define Documentation

#define XDND_DRAG_STAGE_DRAGGING   1

Definition at line 98 of file xdnd.h.

#define XDND_DRAG_STAGE_ENTERED   2

Definition at line 99 of file xdnd.h.

#define XDND_DROP_SOURCE_WIN (   e)    ((e)->xclient.data.l[0])

Definition at line 64 of file xdnd.h.

Definition at line 100 of file xdnd.h.

#define XDND_DROP_STAGE_ENTERED   4

Definition at line 101 of file xdnd.h.

#define XDND_DROP_STAGE_IDLE   0

Definition at line 97 of file xdnd.h.

#define XDND_DROP_TIME (   e)    ((e)->xclient.data.l[2])

Definition at line 65 of file xdnd.h.

#define XDND_ENTER_SOURCE_WIN (   e)    ((e)->xclient.data.l[0])

Definition at line 32 of file xdnd.h.

#define XDND_ENTER_THREE_TYPES (   e)    (((e)->xclient.data.l[1] & 0x1UL) == 0)

Definition at line 33 of file xdnd.h.

#define XDND_ENTER_THREE_TYPES_SET (   e,
  b 
)    (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x1UL) | (((b) == 0) ? 0 : 0x1UL)

Definition at line 34 of file xdnd.h.

#define XDND_ENTER_TYPE (   e,
  i 
)    ((e)->xclient.data.l[2 + i]) /* i => (0, 1, 2) */

Definition at line 37 of file xdnd.h.

#define XDND_ENTER_VERSION (   e)    ((e)->xclient.data.l[1] >> 24)

Definition at line 35 of file xdnd.h.

#define XDND_ENTER_VERSION_SET (   e,
 
)    (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~(0xFF << 24)) | ((v) << 24)

Definition at line 36 of file xdnd.h.

#define XDND_FINISHED_TARGET_WIN (   e)    ((e)->xclient.data.l[0])

Definition at line 68 of file xdnd.h.

#define XDND_LEAVE_SOURCE_WIN (   e)    ((e)->xclient.data.l[0])

Definition at line 61 of file xdnd.h.

#define XDND_POSITION_ACTION (   e)    ((e)->xclient.data.l[4])

Definition at line 45 of file xdnd.h.

#define XDND_POSITION_ROOT_SET (   e,
  x,
  y 
)    (e)->xclient.data.l[2] = ((x) << 16) | ((y) & 0xFFFFUL)

Definition at line 43 of file xdnd.h.

#define XDND_POSITION_ROOT_X (   e)    ((e)->xclient.data.l[2] >> 16)

Definition at line 41 of file xdnd.h.

#define XDND_POSITION_ROOT_Y (   e)    ((e)->xclient.data.l[2] & 0xFFFFUL)

Definition at line 42 of file xdnd.h.

#define XDND_POSITION_SOURCE_WIN (   e)    ((e)->xclient.data.l[0])

Definition at line 40 of file xdnd.h.

#define XDND_POSITION_TIME (   e)    ((e)->xclient.data.l[3])

Definition at line 44 of file xdnd.h.

#define XDND_STATUS_ACTION (   e)    ((e)->xclient.data.l[4])

Definition at line 58 of file xdnd.h.

#define XDND_STATUS_RECT_HEIGHT (   e)    ((e)->xclient.data.l[3] & 0xFFFFL)

Definition at line 56 of file xdnd.h.

#define XDND_STATUS_RECT_SET (   e,
  x,
  y,
  w,
 
)    {(e)->xclient.data.l[2] = ((x) << 16) | ((y) & 0xFFFFUL); (e)->xclient.data.l[3] = ((w) << 16) | ((h) & 0xFFFFUL); }

Definition at line 57 of file xdnd.h.

#define XDND_STATUS_RECT_WIDTH (   e)    ((e)->xclient.data.l[3] >> 16)

Definition at line 55 of file xdnd.h.

#define XDND_STATUS_RECT_X (   e)    ((e)->xclient.data.l[2] >> 16)

Definition at line 53 of file xdnd.h.

#define XDND_STATUS_RECT_Y (   e)    ((e)->xclient.data.l[2] & 0xFFFFL)

Definition at line 54 of file xdnd.h.

#define XDND_STATUS_TARGET_WIN (   e)    ((e)->xclient.data.l[0])

Definition at line 48 of file xdnd.h.

#define XDND_STATUS_WANT_POSITION (   e)    ((e)->xclient.data.l[1] & 0x2UL)

Definition at line 51 of file xdnd.h.

#define XDND_STATUS_WANT_POSITION_SET (   e,
  b 
)    (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x2UL) | (((b) == 0) ? 0 : 0x2UL)

Definition at line 52 of file xdnd.h.

#define XDND_STATUS_WILL_ACCEPT (   e)    ((e)->xclient.data.l[1] & 0x1L)

Definition at line 49 of file xdnd.h.

#define XDND_STATUS_WILL_ACCEPT_SET (   e,
  b 
)    (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x1UL) | (((b) == 0) ? 0 : 0x1UL)

Definition at line 50 of file xdnd.h.

#define XDND_THREE   3

Definition at line 31 of file xdnd.h.

#define XDND_VERSION   3

Definition at line 28 of file xdnd.h.


Typedef Documentation

typedef struct _DndClass

Definition at line 70 of file xdnd.h.


Function Documentation

int xdnd_convert_selection ( DndClass *  dnd,
Window  window,
Window  requester,
Atom  type 
)

Definition at line 314 of file xdnd.c.

{
  if (window != XGetSelectionOwner (dnd->display, dnd->XdndSelection)) 
    {
      dnd_debug ("xdnd_convert_selection(): XGetSelectionOwner failed");
      return 1;
    }

  XConvertSelection (dnd->display, dnd->XdndSelection, type,
    dnd->Xdnd_NON_PROTOCOL_ATOM, requester, CurrentTime);
  return 0;
}
void xdnd_init ( DndClass *  dnd,
Display *  display 
)

Definition at line 76 of file xdnd.c.

{
  memset (dnd, 0, sizeof (*dnd));

  dnd->display = display;
  dnd->root_window = DefaultRootWindow (display);
  dnd->version = XDND_VERSION;
  dnd->XdndAware = XInternAtom (dnd->display, "XdndAware", False);
  dnd->XdndSelection = XInternAtom (dnd->display, "XdndSelection", False);
  dnd->XdndEnter = XInternAtom (dnd->display, "XdndEnter", False);
  dnd->XdndLeave = XInternAtom (dnd->display, "XdndLeave", False);
  dnd->XdndPosition = XInternAtom (dnd->display, "XdndPosition", False);
  dnd->XdndDrop = XInternAtom (dnd->display, "XdndDrop", False);
  dnd->XdndFinished = XInternAtom (dnd->display, "XdndFinished", False);
  dnd->XdndStatus = XInternAtom (dnd->display, "XdndStatus", False);
  dnd->XdndActionCopy = XInternAtom (dnd->display, "XdndActionCopy", False);
  dnd->XdndActionMove = XInternAtom (dnd->display, "XdndActionMove", False);
  dnd->XdndActionLink = XInternAtom (dnd->display, "XdndActionLink", False);
  dnd->XdndActionAsk = XInternAtom (dnd->display, "XdndActionAsk", False);
  dnd->XdndActionPrivate=XInternAtom(dnd->display,"XdndActionPrivate",False);
  dnd->XdndTypeList = XInternAtom (dnd->display, "XdndTypeList", False);
  dnd->XdndActionList = XInternAtom (dnd->display, "XdndActionList", False);
  dnd->XdndActionDescription = XInternAtom(dnd->display, "XdndActionDescription", False);
  dnd->text_uri_list = XInternAtom(dnd->display, "text/uri-list", False);
  xdnd_reset(dnd);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int xdnd_is_dnd_aware ( DndClass *  dnd,
Window  window,
int version,
Atom *  typelist 
)

Definition at line 134 of file xdnd.c.

{
  Atom actual;
  int format;
  unsigned long count, remaining;
  unsigned char *data = 0;
  Atom *types, *t;
  int result = 1;

  *version = 0;
  XGetWindowProperty (dnd->display, window, dnd->XdndAware,
    0, 0x8000000L, False, XA_ATOM, &actual, &format,
    &count, &remaining, &data);

  if (actual != XA_ATOM || format != 32 || count == 0 || !data) 
    {
      dnd_debug("XGetWindowProperty failed in xdnd_is_dnd_aware - XdndAware = %ld", dnd->XdndAware);
      if (data)
       XFree(data);
      return 0;
    }

  types = (Atom *) data;
  *version = dnd->version < types[0] ? dnd->version : types[0];       // minimum
  dnd_debug ("Using XDND version %d", *version);
  if (count > 1) 
    {
      result = 0;
      for (t = typelist; *t; t++) 
       {
         unsigned long j;
         for (j = 1; j < count; j++) 
           {
             if (types[j] == *t) 
              {
                result = 1;
                break;
              }
           }
         if (result)
           break;
       }
    }
  XFree(data);
  return result;
}

Here is the call graph for this function:

void xdnd_selection_send ( DndClass *  dnd,
XSelectionRequestEvent *  request,
unsigned char *  data,
int  length 
)

Definition at line 340 of file xdnd.c.

{
  XEvent xevent;

  dnd_debug (" requestor = %ld", request->requestor);
  dnd_debug (" property = %ld", request->property);
  dnd_debug (" length = %d", length);

  XChangeProperty (dnd->display, request->requestor, request->property,
    request->target, 8, PropModeReplace, data, length);

  xevent.xselection.type = SelectionNotify;
  xevent.xselection.property = request->property;
  xevent.xselection.display = request->display;
  xevent.xselection.requestor = request->requestor;
  xevent.xselection.selection = request->selection;
  xevent.xselection.target = request->target;
  xevent.xselection.time = request->time;

  XSendEvent (dnd->display, request->requestor, 0, 0, &xevent);
}
void xdnd_send_drop ( DndClass *  dnd,
Window  window,
Window  from,
unsigned long  etime 
)

Definition at line 278 of file xdnd.c.

{
  XEvent xevent;

  memset (&xevent, 0, sizeof (xevent));

  xevent.xany.type = ClientMessage;
  xevent.xany.display = dnd->display;
  xevent.xclient.window = window;
  xevent.xclient.message_type = dnd->XdndDrop;
  xevent.xclient.format = 32;

  XDND_DROP_SOURCE_WIN (&xevent) = from;
  if (dnd_version_at_least (dnd->dragging_version, 1))
    XDND_DROP_TIME (&xevent) = time;

  XSendEvent (dnd->display, window, 0, 0, &xevent);
}
void xdnd_send_enter ( DndClass *  dnd,
Window  window,
Window  from,
Atom *  typelist 
)

Definition at line 182 of file xdnd.c.

{
  XEvent xevent;
  int n, i;

  n = array_length (typelist);

  memset(&xevent, 0, sizeof (xevent));

  xevent.xany.type = ClientMessage;
  xevent.xany.display = dnd->display;
  xevent.xclient.window = window;
  xevent.xclient.message_type = dnd->XdndEnter;
  xevent.xclient.format = 32;

  XDND_ENTER_SOURCE_WIN (&xevent) = from;
  XDND_ENTER_THREE_TYPES_SET (&xevent, n > XDND_THREE);
  XDND_ENTER_VERSION_SET (&xevent, dnd->version);
  for (i = 0; i < n && i < XDND_THREE; i++)
    {
      XDND_ENTER_TYPE (&xevent, i) = typelist[i];
    }

  XSendEvent (dnd->display, window, 0, 0, &xevent);
}

Here is the call graph for this function:

void xdnd_send_finished ( DndClass *  dnd,
Window  window,
Window  from,
int  error 
)

Definition at line 298 of file xdnd.c.

{
  XEvent xevent;
  memset (&xevent, 0, sizeof (xevent));
  xevent.xany.type = ClientMessage;
  xevent.xany.display = dnd->display;
  xevent.xclient.window = window;                       
  xevent.xclient.message_type = dnd->XdndFinished;
  xevent.xclient.format = 32;

  XDND_FINISHED_TARGET_WIN (&xevent) = from;

  XSendEvent (dnd->display, window, 0, 0, &xevent);
}
void xdnd_send_leave ( DndClass *  dnd,
Window  window,
Window  from 
)

Definition at line 260 of file xdnd.c.

{
  XEvent xevent;

  memset(&xevent, 0, sizeof (xevent));

  xevent.xany.type = ClientMessage;
  xevent.xany.display = dnd->display;
  xevent.xclient.window = window;
  xevent.xclient.message_type = dnd->XdndLeave;
  xevent.xclient.format = 32;

  XDND_LEAVE_SOURCE_WIN (&xevent) = from;

  XSendEvent (dnd->display, window, 0, 0, &xevent);
}
void xdnd_send_position ( DndClass *  dnd,
Window  window,
Window  from,
Atom  action,
int  x,
int  y,
unsigned long  etime 
)

Definition at line 209 of file xdnd.c.

{
  XEvent xevent;

  memset (&xevent, 0, sizeof (xevent));

  xevent.xany.type = ClientMessage;
  xevent.xany.display = dnd->display;
  xevent.xclient.window = window;
  xevent.xclient.message_type = dnd->XdndPosition;
  xevent.xclient.format = 32;

  XDND_POSITION_SOURCE_WIN (&xevent) = from;
  XDND_POSITION_ROOT_SET (&xevent, x, y);
  if (dnd_version_at_least (dnd->dragging_version, 1))
    XDND_POSITION_TIME (&xevent) = time;
  if (dnd_version_at_least (dnd->dragging_version, 2))
    XDND_POSITION_ACTION (&xevent) = action;

  XSendEvent (dnd->display, window, 0, 0, &xevent);
}
void xdnd_send_status ( DndClass *  dnd,
Window  window,
Window  from,
int  will_accept,
int  want_position,
int  x,
int  y,
int  w,
int  h,
Atom  action 
)

Definition at line 233 of file xdnd.c.

{
  XEvent xevent;

  memset (&xevent, 0, sizeof (xevent));

  xevent.xany.type = ClientMessage;
  xevent.xany.display = dnd->display;
  xevent.xclient.window = window;
  xevent.xclient.message_type = dnd->XdndStatus;
  xevent.xclient.format = 32;

  XDND_STATUS_TARGET_WIN (&xevent) = from;
  XDND_STATUS_WILL_ACCEPT_SET (&xevent, will_accept);
  if (will_accept)
    XDND_STATUS_WANT_POSITION_SET (&xevent, want_position);
  if (want_position)
    XDND_STATUS_RECT_SET (&xevent, x, y, w, h);
  if (dnd_version_at_least (dnd->dragging_version, 2))
    if (will_accept)
      XDND_STATUS_ACTION (&xevent) = action;

  XSendEvent (dnd->display, window, 0, 0, &xevent);
}
void xdnd_set_dnd_aware ( DndClass *  dnd,
Window  window,
Atom *  typelist 
)

Definition at line 114 of file xdnd.c.

{
  XChangeProperty (dnd->display, window, dnd->XdndAware, XA_ATOM, 32, 
    PropModeReplace, (unsigned char *) &dnd->version, 1);
  if (typelist) 
    {
      int n = array_length (typelist);
      if (n)
       XChangeProperty (dnd->display, window, dnd->XdndAware, XA_ATOM, 32, 
         PropModeAppend, (unsigned char *) typelist, n);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void xdnd_set_dnd_unaware ( DndClass *  dnd,
Window  window 
)

Definition at line 128 of file xdnd.c.

{
  XDeleteProperty (dnd->display, window, dnd->XdndAware);
}
void xdnd_set_type_list ( DndClass *  dnd,
Window  window,
Atom *  typelist 
)

Definition at line 368 of file xdnd.c.

{
  int n = array_length (typelist);

  XChangeProperty (dnd->display, window, dnd->XdndTypeList, XA_ATOM, 32,
    PropModeReplace, (unsigned char *) typelist, n);
}

Here is the call graph for this function: