Exemplo n.º 1
0
static void dndPosition(XClientMessageEvent *evt)
{
  dprintf((stderr, "dndPosition\n"));

  if (xdndSourceWindow != xdndPosition_sourceWindow(evt))
    {
      dprintf((stderr, "dndPosition: wrong source window\n"));
      return;
    }

  {
    Window root;
    unsigned int x, y, w, h, b, d;
    XGetGeometry(stDisplay, stWindow, &root, &x, &y, &w, &h, &b, &d);
    mousePosition.x= xdndPosition_rootX(evt) - x;
    mousePosition.y= xdndPosition_rootY(evt) - y;
  }

  if (xdndState == XdndStateEntered)
    {
      if (xdndWillAccept)
	recordDragEvent(DragEnter, 1);
      xdndState= XdndStateTracking;
    }

  if (xdndState != XdndStateTracking)
    {
      dprintf((stderr, "dndPosition: wrong state\n"));
      return;
    }

  if (xdndWillAccept)
    {
      Atom action= xdndPosition_action(evt);
      dprintf((stderr, "  action = %ld %s\n", action, XGetAtomName(stDisplay, action)));
      xdndWillAccept= (action == XdndActionMove) | (action == XdndActionCopy)
	|             (action == XdndActionLink) | (action == XdndActionAsk);
    }

  if (xdndWillAccept)
    {
      dprintf((stderr, "accepting\n"));
      dndSendStatus(evt->window, 1, XdndActionCopy);
      recordDragEvent(DragMove, 1);
    }
  else /* won't accept */
    {
      dprintf((stderr, "not accepting\n"));
      dndSendStatus(evt->window, 0, XdndActionPrivate);
    }
}
static enum XdndState dndInPosition(enum XdndState state, XClientMessageEvent *evt)
{
  /*fdebugf((stderr, "Receive XdndPosition (input)\n"));*/

  if (xdndSourceWindow != xdndPosition_sourceWindow(evt))
    {
      fdebugf((stderr, "dndInPosition: wrong source window\n"));
      return XdndStateIdle;
    }

  getMousePosition();

  if ((state != XdndStateEntered) && (state != XdndStateTracking))
    {
      fdebugf((stderr, "dndInPosition: wrong state\n"));
      return XdndStateIdle;
    }
  
  if ((state == XdndStateEntered) && xdndWillAccept)
    recordDragEvent(DragEnter, 1);
  
  if (xdndWillAccept)
    {
      Atom action= xdndPosition_action(evt);
      /*fdebugf((stderr, "  dndInPosition: action = %ld %s\n", action, XGetAtomName(stDisplay, action)));*/
      xdndWillAccept= (action == XdndActionMove) | (action == XdndActionCopy)
	|             (action == XdndActionLink) | (action == XdndActionAsk);
    }

  if (xdndWillAccept)
    {
      /*fdebugf((stderr, "  dndInPosition: accepting\n"));*/
      dndSendStatus(1, XdndActionCopy);
      recordDragEvent(DragMove, 1);
    }
  else /* won't accept */
    {
      /*fdebugf((stderr, "  dndInPosition: not accepting\n"));*/
      dndSendStatus(0, XdndActionPrivate);
    }
  return XdndStateTracking;
}