home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / lib / xinput / XGrDvBut.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-24  |  3.0 KB  |  91 lines

  1. /* $Header: XGrDvBut.c,v 1.5 91/01/24 16:06:18 rws Exp $ */
  2.  
  3. /************************************************************
  4. Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, California, and the 
  5. Massachusetts Institute of Technology, Cambridge, Massachusetts.
  6.  
  7.             All Rights Reserved
  8.  
  9. Permission to use, copy, modify, and distribute this software and its
  10. documentation for any purpose and without fee is hereby granted,
  11. provided that the above copyright notice appear in all copies and that
  12. both that copyright notice and this permission notice appear in
  13. supporting documentation, and that the names of Hewlett-Packard or MIT not be
  14. used in advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.
  16.  
  17. HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  19. HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. ********************************************************/
  26.  
  27. /***********************************************************************
  28.  *
  29.  * XGrabDeviceBut - Grab a button on an extension device.
  30.  *
  31.  */
  32.  
  33. #include "XI.h"
  34. #include "XIproto.h"
  35. #include "Xlibint.h"
  36. #include "XInput.h"
  37. #include "extutil.h"
  38.  
  39. int
  40. XGrabDeviceButton (dpy, dev, button, modifiers, modifier_device, 
  41.     grab_window, owner_events, event_count, event_list, this_device_mode, 
  42.     other_devices_mode)
  43.     register     Display     *dpy;
  44.     XDevice            *dev;
  45.     unsigned     int         button; /* CARD8 */
  46.     unsigned     int         modifiers; /* CARD16 */
  47.     XDevice            *modifier_device;
  48.     Window             grab_window;
  49.     Bool             owner_events;
  50.     unsigned     int         event_count;
  51.     XEventClass         *event_list;
  52.     int             this_device_mode;
  53.     int             other_devices_mode;
  54.     {
  55.     register xGrabDeviceButtonReq *req;
  56.     XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
  57.  
  58.     LockDisplay (dpy);
  59.     if (CheckExtInit(dpy, XInput_Initial_Release) == -1)
  60.     return (NoSuchExtension);
  61.  
  62.     GetReq(GrabDeviceButton, req);
  63.  
  64.     req->reqType = info->codes->major_opcode;
  65.     req->ReqType = X_GrabDeviceButton;
  66.     req->grabbed_device = dev->device_id;
  67.     req->button = button;
  68.     req->modifiers = modifiers;
  69.     if (modifier_device)
  70.     req->modifier_device = modifier_device->device_id;
  71.     else
  72.     req->modifier_device = UseXKeyboard;
  73.     req->grabWindow = grab_window;
  74.     req->ownerEvents = owner_events;
  75.     req->event_count = event_count;
  76.     req->this_device_mode = this_device_mode;
  77.     req->other_devices_mode = other_devices_mode;
  78.     req->length += event_count;
  79.  
  80.     /* note: Data is a macro that uses its arguments multiple
  81.        times, so "nvalues" is changed in a separate assignment
  82.        statement */
  83.  
  84.     event_count <<= 2;
  85.     Data (dpy, (char *) event_list, event_count);
  86.  
  87.     UnlockDisplay(dpy);
  88.     SyncHandle();
  89.     return (Success);
  90.     }
  91.