Example #1
0
File: xdnd.cpp Project: eriser/es
void Dnd::sendFinished()
{
	XEvent xevent;
	memset (&xevent, 0, sizeof (xevent));
	xevent.xany.type = ClientMessage;
	xevent.xany.display = m_pDisplay;
	xevent.xclient.window = m_DragWindow;
	xevent.xclient.message_type = XdndFinished;
	xevent.xclient.format = 32;

	XDND_FINISHED_TARGET_WIN (&xevent) = m_Window;

	XSendEvent (m_pDisplay, m_DragWindow, 0, 0, &xevent);
}
Example #2
0
void
xdnd_send_finished(DndClass * dnd, Window window, Window from, int error)
{
  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);
}
Example #3
0
Bool
wsXDNDProcessSelection(wsWindow* win, XEvent *event)
{
    Atom ret_type;
    int ret_format;
    unsigned long ret_items;
    unsigned long remain_byte;
    char * delme;
    XEvent xevent;

    Window selowner = XGetSelectionOwner(wsDisplay,XA_XdndSelection);

    XGetWindowProperty(wsDisplay, event->xselection.requestor,
            event->xselection.property,
            0, 65536, True, atom_support, &ret_type, &ret_format,
            &ret_items, &remain_byte, (unsigned char **)&delme);

    /*send finished*/
    memset (&xevent, 0, sizeof(xevent));
    xevent.xany.type = ClientMessage;
    xevent.xany.display = wsDisplay;
    xevent.xclient.window = selowner;
    xevent.xclient.message_type = XA_XdndFinished;
    xevent.xclient.format = 32;
    XDND_FINISHED_TARGET_WIN(&xevent) = win->WindowID;
    XSendEvent(wsDisplay, selowner, 0, 0, &xevent);

    if (!delme){
      mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_WS_DDNothing );
      return False;
    }

    {
      /* Handle dropped files */
      char * retain = delme;
      char * files[MAX_DND_FILES];
      int num = 0;

      while(retain < delme + ret_items) {
	if (!strncmp(retain,"file:",5)) {
	  /* add more 2 chars while removing 5 is harmless */
	  retain+=5;
	}

	/* add the "retain" to the list */
	files[num++]=retain;


	/* now check for special characters */
	{
	  int newone = 0;
	  while(retain < (delme + ret_items)){
	    if(*retain == '\r' || *retain == '\n'){
	      *retain=0;
	      newone = 1;
	    } else {
	      if (newone)
		break;
	    }
	    retain++;
	  }
	}

	if (num >= MAX_DND_FILES)
	  break;
      }

      /* Handle the files */
      if(win->DNDHandler){
	win->DNDHandler(num,files);
      }
    }

    free(delme);
    return True;
}