Example #1
0
Boolean
WSMProcessProtoTarget(Widget w, Atom target, XtPointer input, 
		      unsigned long input_len, int input_fmt,
		      Atom *return_type, XtPointer *output, 
		      unsigned long *output_len, int *output_fmt)
{
    Display *dpy;
    int scr_num;
    WSMScreenInfo *screen_info;
    WSMRequest request;
    WSMReply reply;    
    
    /*
     * Check the Target to make sure it is valid.
     * Check the format to make sure it is WSM_PROTO_FMT.
     */

    if (!WSMIsKnownTarget(w, target))
	return(False);

    if (input_fmt != WSM_PROTO_FMT) {
	fprintf(stderr, "Format of the request must be %d\n", WSM_PROTO_FMT);
	return(False);
    }

    dpy = XtDisplay(w);
    scr_num = XScreenNumberOfScreen(XtScreen(w));

    /*
     * Unpack up the request from the wire.
     */
    
    _WSMUnpackRequest(dpy, scr_num, (MessageData) input, input_len, 
		      _WSMTargetToReqType(dpy, target), &request);

    /*
     * Call the app's callback function to process the request.
     */

    screen_info = _WSMGetScreenInfo(dpy, scr_num);
    reply.any.type = request.any.type;
    reply.any.allocated = False;
    (*screen_info->request_callback)(w, screen_info->request_data,
				     &request, &reply);
    /*
     * Pack up the reply and send it back.
     */

    *output = (XtPointer) _WSMPackReply(dpy, scr_num, &reply, output_len);
    *output_fmt = WSM_PROTO_FMT;
    *return_type = target;	/* Is this the right return type? */

    FreeRequest(&request);
    FreeReply(&reply);

    return(TRUE);
}
Example #2
0
Atom
_WSMGetSelectionAtom(Display *dpy, int screen_num, WSMClientType send_to)
{
    WSMScreenInfo *screen_info = _WSMGetScreenInfo(dpy, screen_num);

    if (screen_info == NULL)
        return(None);

    switch(send_to) {
    case WSM_WORKSPACE_MANAGER:
        return(screen_info->wsm_selection);
    case WSM_WINDOW_MANAGER:
        return(screen_info->wm_selection);
    default:
        break;
    }

    return(None);
}
Example #3
0
WSMConfigFormatData *
_WSMGetConfigFormat(Display *dpy, int screen_number, WSMConfigFormatType type)
{
    WSMScreenInfo *screen_info = _WSMGetScreenInfo(dpy, screen_number);

    if (screen_info == NULL)
        return(NULL);

    switch(type) {
    case WSM_GLOBAL_FMT:
        return(&(screen_info->global));
    case WSM_WINDOW_FMT:
        return(&(screen_info->window));
    case WSM_ICON_FMT:
        return(&(screen_info->icon));
    default:
        break;
    }

    return(NULL);
}
Example #4
0
void
WSMRegisterRequestCallback(Display *disp, int scr_num,
			   WSMRequestCallbackFunc callback, XtPointer data)
{
    WSMScreenInfo *scr_info;

    scr_info = _WSMGetScreenInfo(disp, scr_num);

    /*
     * Since only one client can own a particular selection, we can hang
     * this data off of the screen data structure.  This is necessary because
     * No data is passed to the ConvertProc by Xm or Xt.
     *
     * NOTE: We do not need to have room for one callback for the WSM and 
     *       one for the WM, since any given client will be one or the other,
     *       not both.
     */
	
    scr_info->request_callback = callback;
    scr_info->request_data = data;
}
Example #5
0
/*----------------------------------------------------------------*
 |                          UTMConvertProc                        |
 | This is the UTM conversion proc called when a request comes in |
 | for the selection owner.                                       |
 |                                                                |
 | NOTE - This function MUST have been set up as the callback for |
 |        the utm widget's XmNconvertCallback procedure!          |
 |                                                                |
 | Arguments: w - The widget making the request.                  |
 |            clientData - not used.                              |
 |            callData - the UTM convert callback structure.      |
 *----------------------------------------------------------------*/
static void
UTMConvertProc(Widget w, XtPointer clientData, XtPointer callData)
{
  int scr = XScreenNumberOfScreen(XtScreen(w));
  XmConvertCallbackStruct *ccs = (XmConvertCallbackStruct *)callData;
  Atom lose_sel = XInternAtom(XtDisplay(w), "_MOTIF_LOSE_SELECTION", False);
  WSMScreenInfo *scrInfo = _WSMGetScreenInfo(XtDisplay(w), scr);

  /*
   * Check if the callback was invoked for the right reason.
   * The reason field is not set to anything interresting by the transfer
   * code, so check the selection.
   */
  if ((!ccs) || ((ccs->selection != scrInfo->wm_selection) &&
		 (ccs->selection != scrInfo->wsm_selection)))
    return;

  if (ccs->target == lose_sel)
    {
      /* Done with the conversion - free any data used. */
    }

  /*
   * Handle a conversion request with parameter data.
   */
  else
    {
      ConvertProc (w, &(ccs->selection), &(ccs->target),
		   ccs->parm,
		   ccs->parm_length,
		   ccs->parm_format,
		   &(ccs->type),
		   &(ccs->value),
		   &(ccs->length),
		   &(ccs->format));
    }
}
Example #6
0
/*ARGSUSED*/
void
_WSMUnpackReply(Display *dpy, int screen_num, MessageData data, 
		unsigned long len, WSMRequestType type, WSMReply *reply)
{
    register int i;
    reply->any.type = type;		/* Save the type. */
    reply->any.allocated = False;

    switch (reply->any.type) {
    case WSM_CONNECT:
        if (data != NULL)
	  reply->connect.version = (short) UnpackCARD8(&data);
	else
	  fprintf(stderr, "Error - Connection request reply data is empty!\n");
	break;
    case WSM_EXTENSIONS:
        {
	    register int num;
	    register String *ptr;

	    num = reply->extensions.num_extensions = UnpackListNum(&data);
	    ptr = (String *) XtMalloc(sizeof(String) * num);
	    reply->extensions.allocated = True;
	    reply->extensions.extensions = ptr;
	    for (i = 0; i < num; i++, ptr++) 
		*ptr = UnpackString(&data);
	}
	break;
    case WSM_CONFIG_FMT:
        {
	    register int types;

	    WSMConfigFormatReply * config_format = &(reply->config_format);
	    WSMConfigFormatData *fmt;
	    WSMScreenInfo *scr_info = _WSMGetScreenInfo(dpy, screen_num);
	    
	    config_format->accepts_diffs = UnpackBoolean(&data);

	    for (types = 0; types < 3; types++) {
		switch(types) {
		case WSM_GLOBAL_FMT:
		    fmt = &(scr_info->global);
		    break;
		case WSM_WINDOW_FMT:
		    fmt = &(scr_info->window);
		    break;
		case WSM_ICON_FMT:
		    fmt = &(scr_info->icon);
		    break;
		}

		fmt->num_attrs = UnpackListNum(&data);
		fmt->attr_list = (WSMAttribute *) 
		    XtMalloc(sizeof(WSMAttribute) * fmt->num_attrs);

		for (i = 0; i < fmt->num_attrs; i++) {
		    String str = UnpackString(&data);
		    fmt->attr_list[i].nameq = XrmStringToQuark(str);
		    XtFree(str);
		    fmt->attr_list[i].size = UnpackCARD8(&data);
		    fmt->attr_list[i].is_list = UnpackCARD8(&data);
		}
	    }

	    /*
	     * No need to allocate this, since they are just pointers
	     * back to global data.
	     */

	    config_format->global_formats = scr_info->global.attr_list;
	    config_format->num_global_formats = scr_info->global.num_attrs;
	    config_format->window_formats = scr_info->window.attr_list;
	    config_format->num_window_formats = scr_info->window.num_attrs;
	    config_format->icon_formats = scr_info->icon.attr_list;
	    config_format->num_icon_formats = scr_info->icon.num_attrs;
	}
	break;
    case WSM_GET_STATE:
	{
	    int num =reply->get_state.num_win_info_list = UnpackListNum(&data);
	    reply->get_state.win_info_list = 
		(WSMWinInfo *) XtMalloc(sizeof(WSMWinInfo) * num);
	    reply->get_state.allocated = True;

	    for (i = 0; i < num; i++) 
		UnpackWinInfo(&data, dpy, screen_num, 
			      reply->get_state.win_info_list + i);
	}
	break;
    case WSM_SET_STATE:
	break;
    case WSM_REG_WINDOW:
	if (data != NULL)
	  {
	    UnpackWinData(&data, dpy, screen_num, WSM_WINDOW_FMT,
			  &(reply->register_window.window_data),
			  &(reply->register_window.num_window_data));
	    reply->register_window.allocated = True;
	  }
	else
	  fprintf(stderr, "Error - Register Window reply data is empty!\n");
	break;
    case WSM_WM_GET_BACKGROUND_WINDOW:
	reply->get_background.window = UnpackWindow(&data);
	break;
    case WSM_WM_SET_BACKGROUND_WINDOW:
	reply->set_background.window = UnpackWindow(&data);
	break;
    case WSM_WM_WINDOWS:
	{
	  int num;

	  num = reply->wm_windows.num_win_entry_list = UnpackListNum(&data);
	  reply->wm_windows.win_entry_list = 
	    (WSMWinEntry *) XtMalloc(sizeof(WSMWinEntry) * num);
	  reply->wm_windows.allocated = True;

	  for (i = 0; i < num; i++) 
	    UnpackWinEntry(&data, dpy, screen_num, 
			   reply->wm_windows.win_entry_list + i);
	}
	break;
    case WSM_WM_FOCUS:
	reply->wm_focus.window = UnpackWindow(&data);
	break;
    case WSM_WM_POINTER:
	reply->wm_pointer.location_flag = UnpackCARD32(&data);
	break;
    default:
	break;
    }
} /* _WSMUnpackReply */