Example #1
0
/*************************************<->*************************************
 *
 *  static void OwnWMSelections ()
 *
 *
 *  Description:
 *  -----------
 *  Get the selection ownership for each managed screen.  The selection mwm
 *  will own is WM_Si.
 *
 *  Inputs:
 *  ------
 *  
 *  
 *  
 *
 *  Outputs:
 *  ------
 *
 *  Comments:
 *  --------
 *  
 *
 *************************************<->***********************************/
static void
OwnWMSelections ( Time timestamp )
{
  int scr;
  
  
  wmGD.xa_WM = (Atom *) XtMalloc (wmGD.numScreens * (sizeof (Atom)));
  
  for (scr = 0; scr < wmGD.numScreens; scr++)
    {
      if (wmGD.Screens[scr].managed)
	{
	  char wm_scr[8];
	  
 	  sprintf(wm_scr, "WM_S%d", DefaultScreen(DISPLAY));
	  wmGD.xa_WM[scr] = XInternAtom (DISPLAY, wm_scr, False);
	  
#ifdef MWM_WSM
	  /*
	   * This registers the callback to be invoked when a request
	   * is made against a WSM Protocol target.  The request
	   * callback is stored by the WSM Protocol code and is
	   * invoked in the convert routine (WMiConvert) below.
	   * See WSMProcessProtoTargets().
	   */

	  WSMRegisterRequestCallback(DISPLAY, scr, HandleWsmConvertRequest,
				     NULL);
#endif

	  /*
	   * Own the selection through UTM.  This sets-up a convert function
	   * that is invoked when a convert request is made on this selection.
	   * The convert function is specified in the drawing area's
	   * XmNconvertCallback resource.
	   */

	  XtAddCallback(wmGD.Screens[scr].utmShell, XmNconvertCallback,
			WMiConvertCB, NULL);

	  if (! XmeNamedSource(wmGD.Screens[scr].utmShell,
			       wmGD.xa_WM[scr], timestamp))
	    {
	      Warning (((char *)GETMESSAGE(56, 6,
					   "Failed to own WM_nn selection")));
	    }
	  else
	    {
	      PRINT("Owning selection %s\n", wm_scr);
	    }
	}
    }
}
Example #2
0
File: recv.c Project: fjardon/motif
Boolean
WSMDefaultOwnSelection(Widget w, WSMClientType client_type,
		       WSMRequestCallbackFunc request_callback,
		       XtPointer request_data)
{
    Time time;
    Display *dpy = XtDisplay(w);
    Atom own_selection =
	_WSMGetSelectionAtom(dpy, 
			     XScreenNumberOfScreen(XtScreen(w)), client_type);
    
    if (XGetSelectionOwner(dpy, own_selection) != None) {
	/*
	 * Someone out there already owns this selection, we should give
	 * up and return.
	 */

        printf("Error - Someone out there already owns this selection.\n");

	return(False);
    }
    
    if (!XtIsRealized(w)) {
	fprintf(stderr, "%s must be realized, and is not.\n",
		"Programmer Error: Widget passed to WSMDefaultOwnSelection");
	return(False);
    }

    WSMRegisterRequestCallback(dpy, 
 			       XScreenNumberOfScreen(XtScreen(w)),
 			       request_callback, request_data);
    
    time = GetTimestamp(dpy); /* CurrentTime or Zero is a no-no! */

    /*
     * NOTE - w MUST have its XmNconvertCallback set properly,
     *        otherwise, no conversions will be handled!
     */
    XmeNamedSource(w, own_selection, time);

    return(True);
}