home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / evbl0627.zip / everblue_20010627.zip / x11 / Xlib_RegstFlt.c < prev    next >
C/C++ Source or Header  |  1999-11-02  |  5KB  |  171 lines

  1. /* $XConsortium: RegstFlt.c,v 1.12 94/04/17 20:20:47 rws Exp $ */
  2.  
  3.  /*
  4.   * Copyright 1990, 1991 by OMRON Corporation
  5.   *
  6.   * Permission to use, copy, modify, distribute, and sell this software and its
  7.   * documentation for any purpose is hereby granted without fee, provided that
  8.   * the above copyright notice appear in all copies and that both that
  9.   * copyright notice and this permission notice appear in supporting
  10.   * documentation, and that the name OMRON not be used in
  11.   * advertising or publicity pertaining to distribution of the software without
  12.   * specific, written prior permission.  OMRON makes no representations
  13.   * about the suitability of this software for any purpose.  It is provided
  14.   * "as is" without express or implied warranty.
  15.   *
  16.   * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  17.   * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  18.   * EVENT SHALL OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  19.   * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  20.   * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  21.   * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  22.   * PERFORMANCE OF THIS SOFTWARE. 
  23.   *
  24.   *    Author:    Seiji Kuwari    OMRON Corporation
  25.   *                kuwa@omron.co.jp
  26.   *                kuwa%omron.co.jp@uunet.uu.net
  27.   */                
  28. /*
  29.  
  30. Copyright (c) 1990, 1991  X Consortium
  31.  
  32. Permission is hereby granted, free of charge, to any person obtaining
  33. a copy of this software and associated documentation files (the
  34. "Software"), to deal in the Software without restriction, including
  35. without limitation the rights to use, copy, modify, merge, publish,
  36. distribute, sublicense, and/or sell copies of the Software, and to
  37. permit persons to whom the Software is furnished to do so, subject to
  38. the following conditions:
  39.  
  40. The above copyright notice and this permission notice shall be included
  41. in all copies or substantial portions of the Software.
  42.  
  43. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  44. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  45. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  46. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
  47. OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  48. ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  49. OTHER DEALINGS IN THE SOFTWARE.
  50.  
  51. Except as contained in this notice, the name of the X Consortium shall
  52. not be used in advertising or otherwise to promote the sale, use or
  53. other dealings in this Software without prior written authorization
  54. from the X Consortium.
  55.  
  56. */
  57.  
  58. #include "Xlib_private.h"
  59. #include "Xlcint.h"
  60.  
  61. static void
  62. _XFreeIMFilters(display)
  63.     Display *display;
  64. {
  65.     DBUG_ENTER("_XFreeIMFilters")
  66.     register XFilterEventList fl;
  67.  
  68.     while ((fl = display->im_filters)) {
  69.         display->im_filters = fl->next;
  70.         Xfree((char *)fl);
  71.     }
  72.     DBUG_VOID_RETURN;
  73. }
  74.  
  75. /*
  76.  * Register a filter with the filter machinery by event mask.
  77.  */
  78. void
  79. _XRegisterFilterByMask(display, window, event_mask, filter, client_data)
  80.     Display *display;
  81.     Window window;
  82.     unsigned long event_mask;
  83.     Bool (*filter)(
  84. #if NeedNestedPrototypes
  85.            Display*, Window, XEvent*, XPointer
  86. #endif
  87.            );
  88.     XPointer client_data;
  89. {
  90.     DBUG_ENTER("_XRegisterFilterByMask")
  91.     XFilterEventRec        *rec;
  92.  
  93.     rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec));
  94.     if (!rec)
  95.     DBUG_VOID_RETURN;
  96.     rec->window = window;
  97.     rec->event_mask = event_mask;
  98.     rec->start_type = 0;
  99.     rec->end_type = 0;
  100.     rec->filter = filter;
  101.     rec->client_data = client_data;
  102.     LockDisplay(display);
  103.     rec->next = display->im_filters;
  104.     display->im_filters = rec;
  105.     display->free_funcs->im_filters = _XFreeIMFilters;
  106.     UnlockDisplay(display);
  107.     DBUG_VOID_RETURN;
  108. }
  109.  
  110. /*
  111.  * Register a filter with the filter machinery by type code.
  112.  */
  113. void
  114. _XRegisterFilterByType(display, window, start_type, end_type,
  115.                filter, client_data)
  116.     Display *display;
  117.     Window window;
  118.     int start_type;
  119.     int end_type;
  120.     Bool (*filter)(
  121. #if NeedNestedPrototypes
  122.            Display*, Window, XEvent*, XPointer
  123. #endif
  124.            );
  125.     XPointer client_data;
  126. {
  127.     DBUG_ENTER("_XRegisterFilterByType")
  128.     XFilterEventRec        *rec;
  129.  
  130.     rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec));
  131.     if (!rec)
  132.     DBUG_VOID_RETURN;
  133.     rec->window = window;
  134.     rec->event_mask = 0;
  135.     rec->start_type = start_type;
  136.     rec->end_type = end_type;
  137.     rec->filter = filter;
  138.     rec->client_data = client_data;
  139.     LockDisplay(display);
  140.     rec->next = display->im_filters;
  141.     display->im_filters = rec;
  142.     display->free_funcs->im_filters = _XFreeIMFilters;
  143.     UnlockDisplay(display);
  144.     DBUG_VOID_RETURN;
  145. }
  146.  
  147. void
  148. _XUnregisterFilter(display, window, filter, client_data)
  149.     Display *display;
  150.     Window window;
  151.     Bool (*filter)(
  152. #if NeedNestedPrototypes
  153.            Display*, Window, XEvent*, XPointer
  154. #endif
  155.            );
  156.     XPointer client_data;
  157. {
  158.     DBUG_ENTER("_XUnregisterFilter")
  159.     register XFilterEventList    *prev, fl;
  160.  
  161.     for (prev = &display->im_filters; (fl = *prev); ) {
  162.     if (fl->window == window &&
  163.         fl->filter == filter && fl->client_data == client_data) {
  164.         *prev = fl->next;
  165.         Xfree((char *)fl);
  166.     } else
  167.         prev = &fl->next;
  168.     }
  169.     DBUG_VOID_RETURN;
  170. }
  171.