Exemplo n.º 1
0
static int motTextSetClipboardAttrib(Ihandle *ih, const char *value)
{
  if (iupStrEqualNoCase(value, "COPY"))
  {
    char *str = XmTextGetSelection(ih->handle);
    if (!str) return 0;

    XmTextCopy(ih->handle, CurrentTime);

    /* do it also for the X clipboard */
    XStoreBytes(iupmot_display, str, strlen(str)+1);
    XtFree(str);
  }
  else if (iupStrEqualNoCase(value, "CUT"))
  {
    char *str = XmTextGetSelection(ih->handle);
    if (!str) return 0;

    /* disable callbacks */
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");

    XmTextCut(ih->handle, CurrentTime);

    /* do it also for the X clipboard */
    XStoreBytes(iupmot_display, str, strlen(str)+1);
    XtFree(str);
    XmTextRemove(ih->handle);

    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else if (iupStrEqualNoCase(value, "PASTE"))
  {
    int size;
    char* str = XFetchBytes(iupmot_display, &size);
    if (!str) return 0;

    /* disable callbacks */
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");

    XmTextPaste(ih->handle); /* TODO: this could force 2 pastes, check in CDE */

    /* do it also for the X clipboard */
    XmTextRemove(ih->handle);
    XmTextInsert(ih->handle, XmTextGetInsertionPosition(ih->handle), str);
    XFree(str);

    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else if (iupStrEqualNoCase(value, "CLEAR"))
  {
    /* disable callbacks */
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");
    XmTextRemove(ih->handle);
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  return 0;
}
Exemplo n.º 2
0
void
SelectionFromVNC(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
  Bool always = False;
  Time t = TimeFromEvent(event);

  if (*num_params != 0) {
    if (strcmp(params[0],"always") == 0) {
      always = True;
    } else if (strcmp(params[0],"new") == 0) {
      always = False;
    } else {
      fprintf(stderr,"Invalid params: SelectionFromVNC(always|new)\n");
      return;
    }
  }

  if (t == CurrentTime) {
    fprintf(stderr,"Error in translations: SelectionFromVNC() must act on "
	    "event with time field\n");
    return;
  }

  if (!serverCutText || (!always && !newServerCutText))
    return;

  newServerCutText = False;

  XStoreBytes(dpy, serverCutText, strlen(serverCutText));
  if (XtOwnSelection(desktop, XA_PRIMARY, t, ConvertSelection, LoseSelection,
		     NULL)) {
    iAmSelectionOwner = True;
  }
}
Exemplo n.º 3
0
bool widgetSetClipboardText(const char *text)
{
	Window selectionOwner;

	// Make sure we are initialised
	widgetInitialiseClipboardX11();

	// Lock the connection
	info.info.x11.lock_func();

	// Copy the text into the root windows cut buffer (for Xterm compatibility)
	XStoreBytes(info.info.x11.display, text, strlen(text) + 1);

	// Set ourself as the owner of the CLIPBOARD atom
	XSetSelectionOwner(info.info.x11.display, XA_CLIPBOARD,
	                   info.info.x11.window, CurrentTime);

	// Check if we acquired ownership or not
	selectionOwner = XGetSelectionOwner(info.info.x11.display, XA_CLIPBOARD);

	// We got ownership
	if (selectionOwner == info.info.x11.window)
	{
		info.info.x11.unlock_func();
		return true;
	}
	// We did not get ownership
	else
	{
		info.info.x11.unlock_func();
		return false;
	}
}
Exemplo n.º 4
0
void Sys_Video_SetClipboardText(void *display, const char *text)
{
	struct display *d;

	d = display;

	XStoreBytes(d->x_disp, text, strlen(text));
}
Exemplo n.º 5
0
void TCOD_sys_clipboard_set(const char *value)
{
	if ( ! value ) return;
	if (!dpy ) dpy = XOpenDisplay(NULL);
	XStoreBytes(dpy,value,strlen(value)+1);
	/* doesn't seem to work without this... */
	int len;
	char *xbuf = XFetchBytes(dpy,&len);
	XFree(xbuf);
}
Exemplo n.º 6
0
void sSetClipboard(const sChar *text,sInt len)
{
  if(len==-1) len=sGetStringLen(text);

  char *dest = new char[(len*4)+1];
  sU32 *convBuffer = new sU32[len+1];
  for(sInt i=0;i<len;i++) // fake-wchar16-to-wchar32 (argh!)
    convBuffer[i] = text[i];
  
  convBuffer[len] = 0;
  wcstombs(dest,(wchar_t *)convBuffer,len*4+1);
  dest[len*4] = 0;
  
  XStoreBytes(sXDisplay(),dest,strlen(dest));
  delete[] dest;
  delete[] convBuffer;
}
Exemplo n.º 7
0
void MSWidget::selectionRequest(const XEvent *pEvent_)
{
#ifndef MS_WINDOWS
  if (pEvent_->xselectionrequest.selection==XA_PRIMARY&&
      pEvent_->xselectionrequest.owner==_window)
   {
     Atom target=convertTarget(pEvent_->xselectionrequest.target);
     if (target==XA_STRING)
      {
	MSString buffer;
	int len=0;
	const char *cp = getPrimarySelection(buffer, len);
	
	if(cp !=0)
	  {
	    Atom property;
	    if (pEvent_->xselectionrequest.property==None) property=XA_PRIMARY;
	    else property=pEvent_->xselectionrequest.property;
	    
	    XChangeProperty(display(),pEvent_->xselectionrequest.requestor,
			    property,target,propertyFormat(target),
			    PropModeAppend,(unsigned const char *)cp,len);

	    XSelectionEvent selectEvent;
	    selectEvent.type=SelectionNotify;
	    selectEvent.property=pEvent_->xselectionrequest.property;
	    selectEvent.display=display();
	    selectEvent.requestor=pEvent_->xselectionrequest.requestor;
	    selectEvent.selection=pEvent_->xselectionrequest.selection;
	    selectEvent.target=pEvent_->xselectionrequest.target;
	    selectEvent.time=pEvent_->xselectionrequest.time;
	    XSendEvent(display(),pEvent_->xselectionrequest.requestor,
		       False,0L,(XEvent *)&selectEvent);
	  }
      }
   }
#else
  MSString buffer;
  int len=0;
  const char *cp = getPrimarySelection(buffer, len);
  XStoreBytes(display(),cp,len);
#endif
}
Exemplo n.º 8
0
Arquivo: List.c Projeto: aosm/X11
/*ARGSUSED*/
static void
Notify(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
    ListWidget lw = (ListWidget)w;
    int item, item_len;
    XawListReturnStruct ret_value;

    /*
     * Find item and if out of range then unhighlight and return
     * 
     * If the current item is unhighlighted then the user has aborted the
     * notify, so unhighlight and return
     */
    if ((CvtToItem(w, event->xbutton.x, event->xbutton.y, &item) == OUT_OF_RANGE)
	|| lw->list.highlight != item) {
#ifndef OLDXAW
	if (!lw->list.show_current || lw->list.selected == NO_HIGHLIGHT)
	    XawListUnhighlight(w);
	else
	    XawListHighlight(w, lw->list.selected);
#else
	XawListUnhighlight(w);
#endif
	return;
    }

    item_len = strlen(lw->list.list[item]);

    if (lw->list.paste)		/* if XtNpasteBuffer set then paste it */
	XStoreBytes(XtDisplay(w), lw->list.list[item], item_len);

#ifndef OLDXAW
    lw->list.selected = item;
#endif
    /*
     * Call Callback function
     */
    ret_value.string = lw->list.list[item];
    ret_value.list_index = item;
    
    XtCallCallbacks(w, XtNcallback, (XtPointer)&ret_value);
}
Exemplo n.º 9
0
void FigListFinishUp(Widget w, int item)
{
    FigListWidget lw = (FigListWidget) w;
    int		  item_len;
    XawListReturnStruct ret_value;

    /* check result of inc/dec */
    if (item >= lw->list.nitems || item < 0)
	return;

    item_len = strlen(lw->list.list[item]);

    if ( lw->list.paste )	/* if XtNpasteBuffer is true then paste it. */
        XStoreBytes(XtDisplay(w), lw->list.list[item], item_len);

    /* call any callbacks */
    ret_value.string = lw->list.list[item];
    ret_value.list_index = item;
    
    XtCallCallbacks( w, XtNcallback, (XtPointer) &ret_value);

    /* highlight new item */
    XawListHighlight(w, item);
}
Exemplo n.º 10
0
bool Clipboard_SetText(const char* str) {
	XStoreBytes(xconn,str,strlen(str));
	return true;
}