/[emacs]/emacs/src/xfns.c
ViewVC logotype

Diff of /emacs/src/xfns.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.596 by jhd, Sun Oct 5 12:15:38 2003 UTC revision 1.597 by jhd, Sun Oct 5 16:58:02 2003 UTC
# Line 4275  x_sync (f) Line 4275  x_sync (f)
4275    
4276    
4277  /***********************************************************************  /***********************************************************************
4278                    General X functions exposed to Elisp.
4279     ***********************************************************************/
4280    
4281    DEFUN ("x-send-client-message", Fx_send_client_event,
4282           Sx_send_client_message, 6, 6, 0,
4283           doc: /* Send a client message of MESSAGE-TYPE to window DEST on DISPLAY.
4284    
4285    For DISPLAY, specify either a frame or a display name (a string).
4286    If DISPLAY is nil, that stands for the selected frame's display.
4287    DEST may be an integer, in which case it is a Window id.  The value 0 may
4288    be used to send to the root window of the DISPLAY.
4289    If DEST is a frame the event is sent to the outer window of that frame.
4290    Nil means the currently selected frame.
4291    If DEST is the string "PointerWindow" the event is sent to the window that
4292    contains the pointer.  If DEST is the string "InputFocus" the event is
4293    sent to the window that has the input focus.
4294    FROM is the frame sending the event.  Use nil for currently selected frame.
4295    MESSAGE-TYPE is the name of an Atom as a string.
4296    FORMAT must be one of 8, 16 or 32 and determines the size of the values in
4297    bits.  VALUES is a list of integer and/or strings containing the values to
4298    send.  If a value is a string, it is converted to an Atom and the value of
4299    the Atom is sent.  If more values than fits into the event is given,
4300    the excessive values are ignored.  */)
4301         (display, dest, from, message_type, format, values)
4302         Lisp_Object display, dest, from, message_type, format, values;
4303    {
4304      struct x_display_info *dpyinfo = check_x_display_info (display);
4305      Window wdest;
4306      XEvent event;
4307      Lisp_Object cons;
4308      int i;
4309      int max_nr_values = (int) sizeof (event.xclient.data.b);
4310      struct frame *f = check_x_frame (from);
4311      
4312      CHECK_STRING (message_type);
4313      CHECK_NUMBER (format);
4314      CHECK_CONS (values);
4315    
4316      for (cons = values; CONSP (cons); cons = XCDR (cons))
4317        {
4318          Lisp_Object o = XCAR (cons);
4319    
4320          if (! INTEGERP (o) && ! STRINGP (o))
4321            error ("Bad data in VALUES, must be integer or string");
4322        }
4323    
4324      event.xclient.type = ClientMessage;
4325      event.xclient.format = XFASTINT (format);
4326    
4327      if (event.xclient.format != 8 && event.xclient.format != 16
4328          && event.xclient.format != 32)
4329        error ("FORMAT must be one of 8, 16 or 32");
4330      if (event.xclient.format == 16) max_nr_values /= 2;
4331      if (event.xclient.format == 32) max_nr_values /= 4;
4332      
4333      if (FRAMEP (dest) || NILP (dest))
4334        {
4335          struct frame *fdest = check_x_frame (dest);
4336          wdest = FRAME_OUTER_WINDOW (fdest);
4337        }
4338      else if (STRINGP (dest))
4339        {
4340          if (strcmp (SDATA (dest), "PointerWindow") == 0)
4341            wdest = PointerWindow;
4342          else if (strcmp (SDATA (dest), "InputFocus") == 0)
4343            wdest = InputFocus;
4344          else
4345            error ("DEST as a string must be one of PointerWindow or InputFocus");
4346        }
4347      else
4348        {
4349          CHECK_NUMBER (dest);
4350          wdest = (Window) XFASTINT (dest);
4351          if (wdest == 0) wdest = dpyinfo->root_window;
4352        }
4353    
4354      BLOCK_INPUT;
4355      for (cons = values, i = 0;
4356           CONSP (cons) && i < max_nr_values;
4357           cons = XCDR (cons), ++i)
4358        {
4359          Lisp_Object o = XCAR (cons);
4360          long val;
4361          char *s = 0;
4362    
4363          if (INTEGERP (o))
4364            val = XINT (o);
4365          else if (STRINGP (o))
4366              val = XInternAtom (dpyinfo->display, s = SDATA (o), False);
4367    
4368          if (event.xclient.format == 8)
4369            event.xclient.data.b[i] = (char) val;
4370          else if (event.xclient.format == 16)
4371            event.xclient.data.s[i] = (short) val;
4372          else
4373            event.xclient.data.l[i] = val;
4374        }
4375    
4376      for ( ; i < max_nr_values; ++i)
4377        if (event.xclient.format == 8)
4378          event.xclient.data.b[i] = 0;
4379        else if (event.xclient.format == 16)
4380          event.xclient.data.s[i] = 0;
4381        else
4382          event.xclient.data.l[i] = 0;
4383    
4384      event.xclient.message_type
4385        = XInternAtom (dpyinfo->display, SDATA (message_type), False);
4386      event.xclient.display = dpyinfo->display;
4387      event.xclient.window = FRAME_OUTER_WINDOW (f);
4388    
4389      XSendEvent (dpyinfo->display, wdest, False, 0xffff, &event);
4390    
4391      XFlush (dpyinfo->display);
4392      UNBLOCK_INPUT;
4393    
4394      return Qnil;
4395    }
4396    
4397    /***********************************************************************
4398                              Image types                              Image types
4399   ***********************************************************************/   ***********************************************************************/
4400    
# Line 10974  meaning don't clear the cache.  */); Line 11094  meaning don't clear the cache.  */);
11094    defsubr (&Sx_close_connection);    defsubr (&Sx_close_connection);
11095    defsubr (&Sx_display_list);    defsubr (&Sx_display_list);
11096    defsubr (&Sx_synchronize);    defsubr (&Sx_synchronize);
11097      defsubr (&Sx_send_client_message);
11098    defsubr (&Sx_focus_frame);    defsubr (&Sx_focus_frame);
11099    defsubr (&Sx_backspace_delete_keys_p);    defsubr (&Sx_backspace_delete_keys_p);
11100    

Legend:
Removed from v.1.596  
changed lines
  Added in v.1.597

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26