"Fossies" - the Fresh Open Source Software Archive

Member "xorg-server-1.20.8/test/xi2/protocol-common.h" (29 Mar 2020, 5264 Bytes) of package /linux/misc/xorg-server-1.20.8.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "protocol-common.h": 1.20.7_vs_1.20.8.

    1 /**
    2  * Copyright © 2009 Red Hat, Inc.
    3  *
    4  *  Permission is hereby granted, free of charge, to any person obtaining a
    5  *  copy of this software and associated documentation files (the "Software"),
    6  *  to deal in the Software without restriction, including without limitation
    7  *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
    8  *  and/or sell copies of the Software, and to permit persons to whom the
    9  *  Software is furnished to do so, subject to the following conditions:
   10  *
   11  *  The above copyright notice and this permission notice (including the next
   12  *  paragraph) shall be included in all copies or substantial portions of the
   13  *  Software.
   14  *
   15  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   16  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   17  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   18  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   19  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   20  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   21  *  DEALINGS IN THE SOFTWARE.
   22  */
   23 
   24 #ifdef HAVE_DIX_CONFIG_H
   25 #include <dix-config.h>
   26 #endif
   27 
   28 #include "scrnintstr.h"
   29 #include "windowstr.h"
   30 #include "exevents.h"
   31 #include <assert.h>
   32 
   33 #include "tests.h"
   34 
   35 #ifndef PROTOCOL_COMMON_H
   36 #define PROTOCOL_COMMON_H
   37 
   38 /* Check default values in a reply */
   39 #define reply_check_defaults(rep, len, type) \
   40     { \
   41         assert((len) >= sz_x##type##Reply); \
   42         assert((rep)->repType == X_Reply); \
   43         assert((rep)->RepType == X_##type); \
   44         assert((rep)->sequenceNumber == CLIENT_SEQUENCE); \
   45         assert((rep)->length >= (sz_x##type##Reply - 32)/4); \
   46     }
   47 
   48 /* initialise default values for request */
   49 #define request_init(req, type) \
   50     { \
   51         (req)->reqType = 128; /* doesn't matter */ \
   52         (req)->ReqType = X_##type; \
   53         (req)->length = (sz_x##type##Req >> 2); \
   54     }
   55 
   56 /* Various defines used in the tests. Some tests may use different values
   57  * than these defaults */
   58 /* default client index */
   59 #define CLIENT_INDEX            1
   60 /* default client mask for resources and windows */
   61 #define CLIENT_MASK             ((CLIENT_INDEX) << CLIENTOFFSET)
   62 /* default client sequence number for replies */
   63 #define CLIENT_SEQUENCE         0x100
   64 /* default root window id */
   65 #define ROOT_WINDOW_ID          0x10
   66 /* default client window id */
   67 #define CLIENT_WINDOW_ID        0x100001
   68 /* invalid window ID. use for BadWindow checks. */
   69 #define INVALID_WINDOW_ID       0x111111
   70 /* initial fake sprite position */
   71 #define SPRITE_X                100
   72 #define SPRITE_Y                200
   73 
   74 /* Various structs used throughout the tests */
   75 
   76 /* The default devices struct, contains one pointer + keyboard and the
   77  * matching master devices. Initialize with init_devices() if needed. */
   78 struct devices {
   79     DeviceIntPtr vcp;
   80     DeviceIntPtr vck;
   81     DeviceIntPtr mouse;
   82     DeviceIntPtr kbd;
   83 
   84     int num_devices;
   85     int num_master_devices;
   86 };
   87 
   88 /**
   89  * The set of default devices available in all tests if necessary.
   90  */
   91 extern struct devices devices;
   92 
   93 /**
   94  * test-specific userdata, passed into the reply handler.
   95  */
   96 extern void *global_userdata;
   97 
   98 /**
   99  * The reply handler called from WriteToClient. Set this handler if you need
  100  * to check the reply values.
  101  */
  102 extern void (*reply_handler) (ClientPtr client, int len, char *data, void *userdata);
  103 
  104 /**
  105  * The default screen used for the windows. Initialized by init_simple().
  106  */
  107 extern ScreenRec screen;
  108 
  109 /**
  110  * Semi-initialized root window. initialized by init().
  111  */
  112 extern WindowRec root;
  113 
  114 /**
  115  * Semi-initialized top-level window. initialized by init().
  116  */
  117 extern WindowRec window;
  118 
  119 /* various simple functions for quick setup */
  120 /**
  121  * Initialize the above struct with default devices and return the struct.
  122  * Usually not needed if you call ::init_simple.
  123  */
  124 struct devices init_devices(void);
  125 
  126 /**
  127  * Init a mostly zeroed out client with default values for index and mask.
  128  */
  129 ClientRec init_client(int request_len, void *request_data);
  130 
  131 /**
  132  * Init a mostly zeroed out window with the given window ID.
  133  * Usually not needed if you call ::init_simple which sets up root and
  134  * window.
  135  */
  136 void init_window(WindowPtr window, WindowPtr parent, int id);
  137 
  138 /**
  139  * Create a very simple setup that provides the minimum values for most
  140  * tests, including a screen, the root and client window and the default
  141  * device setup.
  142  */
  143 void init_simple(void);
  144 
  145 /* Declarations for various overrides in the test files. */
  146 void __wrap_WriteToClient(ClientPtr client, int len, void *data);
  147 int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
  148                           int len, unsigned char *mask);
  149 int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client,
  150                            Mask access);
  151 int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client,
  152                            Mask access);
  153 Bool __wrap_AddResource(XID id, RESTYPE type, void *value);
  154 int __wrap_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
  155 int __real_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
  156 
  157 #endif                          /* PROTOCOL_COMMON_H */