4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Copyright © 2009 Red Hat, Inc.
4c221b0da1816acf2ca302b10092df059484468dvboxsync *
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Permission is hereby granted, free of charge, to any person obtaining a
4c221b0da1816acf2ca302b10092df059484468dvboxsync * copy of this software and associated documentation files (the "Software"),
4c221b0da1816acf2ca302b10092df059484468dvboxsync * to deal in the Software without restriction, including without limitation
4c221b0da1816acf2ca302b10092df059484468dvboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
4c221b0da1816acf2ca302b10092df059484468dvboxsync * and/or sell copies of the Software, and to permit persons to whom the
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Software is furnished to do so, subject to the following conditions:
4c221b0da1816acf2ca302b10092df059484468dvboxsync *
4c221b0da1816acf2ca302b10092df059484468dvboxsync * The above copyright notice and this permission notice (including the next
4c221b0da1816acf2ca302b10092df059484468dvboxsync * paragraph) shall be included in all copies or substantial portions of the
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Software.
4c221b0da1816acf2ca302b10092df059484468dvboxsync *
4c221b0da1816acf2ca302b10092df059484468dvboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4c221b0da1816acf2ca302b10092df059484468dvboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4c221b0da1816acf2ca302b10092df059484468dvboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
4c221b0da1816acf2ca302b10092df059484468dvboxsync * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4c221b0da1816acf2ca302b10092df059484468dvboxsync * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
4c221b0da1816acf2ca302b10092df059484468dvboxsync * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
4c221b0da1816acf2ca302b10092df059484468dvboxsync * DEALINGS IN THE SOFTWARE.
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync#ifdef HAVE_DIX_CONFIG_H
4c221b0da1816acf2ca302b10092df059484468dvboxsync#include <dix-config.h>
4c221b0da1816acf2ca302b10092df059484468dvboxsync#endif
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync#include "scrnintstr.h"
4c221b0da1816acf2ca302b10092df059484468dvboxsync#include "windowstr.h"
4c221b0da1816acf2ca302b10092df059484468dvboxsync#include "scrnintstr.h"
4c221b0da1816acf2ca302b10092df059484468dvboxsync#include "exevents.h"
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync#ifndef PROTOCOL_COMMON_H
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define PROTOCOL_COMMON_H
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsyncextern int BadDevice;
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* Check default values in a reply */
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define reply_check_defaults(rep, len, type) \
4c221b0da1816acf2ca302b10092df059484468dvboxsync { \
4c221b0da1816acf2ca302b10092df059484468dvboxsync g_assert((len) >= sz_x##type##Reply); \
4c221b0da1816acf2ca302b10092df059484468dvboxsync g_assert((rep)->repType == X_Reply); \
4c221b0da1816acf2ca302b10092df059484468dvboxsync g_assert((rep)->RepType == X_##type); \
4c221b0da1816acf2ca302b10092df059484468dvboxsync g_assert((rep)->sequenceNumber == CLIENT_SEQUENCE); \
4c221b0da1816acf2ca302b10092df059484468dvboxsync g_assert((rep)->length >= (sz_x##type##Reply - 32)/4); \
4c221b0da1816acf2ca302b10092df059484468dvboxsync }
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* initialise default values for request */
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define request_init(req, type) \
4c221b0da1816acf2ca302b10092df059484468dvboxsync { \
4c221b0da1816acf2ca302b10092df059484468dvboxsync (req)->reqType = 128; /* doesn't matter */ \
4c221b0da1816acf2ca302b10092df059484468dvboxsync (req)->ReqType = X_##type; \
4c221b0da1816acf2ca302b10092df059484468dvboxsync (req)->length = (sz_x##type##Req >> 2); \
4c221b0da1816acf2ca302b10092df059484468dvboxsync }
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* Various defines used in the tests. Some tests may use different values
4c221b0da1816acf2ca302b10092df059484468dvboxsync * than these defaults */
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* default client index */
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define CLIENT_INDEX 1
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* default client mask for resources and windows */
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define CLIENT_MASK ((CLIENT_INDEX) << CLIENTOFFSET)
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* default client sequence number for replies */
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define CLIENT_SEQUENCE 0x100
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* default root window id */
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define ROOT_WINDOW_ID 0x10
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* default client window id */
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define CLIENT_WINDOW_ID 0x100001
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* invalid window ID. use for BadWindow checks. */
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define INVALID_WINDOW_ID 0x111111
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* initial fake sprite position */
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define SPRITE_X 100
4c221b0da1816acf2ca302b10092df059484468dvboxsync#define SPRITE_Y 200
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* Various structs used throughout the tests */
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* The default devices struct, contains one pointer + keyboard and the
4c221b0da1816acf2ca302b10092df059484468dvboxsync * matching master devices. Initialize with init_devices() if needed. */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncstruct devices {
4c221b0da1816acf2ca302b10092df059484468dvboxsync DeviceIntPtr vcp;
4c221b0da1816acf2ca302b10092df059484468dvboxsync DeviceIntPtr vck;
4c221b0da1816acf2ca302b10092df059484468dvboxsync DeviceIntPtr mouse;
4c221b0da1816acf2ca302b10092df059484468dvboxsync DeviceIntPtr kbd;
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync int num_devices;
4c221b0da1816acf2ca302b10092df059484468dvboxsync int num_master_devices;
4c221b0da1816acf2ca302b10092df059484468dvboxsync} devices;
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * The set of default devices available in all tests if necessary.
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncextern struct devices devices;
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * test-specific userdata, passed into the reply handler.
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncextern void *userdata;
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * The reply handler called from WriteToClient. Set this handler if you need
4c221b0da1816acf2ca302b10092df059484468dvboxsync * to check the reply values.
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncvoid (*reply_handler)(ClientPtr client, int len, char *data, void *userdata);
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * The default screen used for the windows. Initialized by init_simple().
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncextern ScreenRec screen;
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Semi-initialized root window. initialized by init().
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncextern WindowRec root;
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Semi-initialized top-level window. initialized by init().
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncextern WindowRec window;
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* various simple functions for quick setup */
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Initialize the above struct with default devices and return the struct.
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Usually not needed if you call ::init_simple.
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncstruct devices init_devices(void);
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Init a mostly zeroed out client with default values for index and mask.
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncClientRec init_client(int request_len, void *request_data);
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Init a mostly zeroed out window with the given window ID.
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Usually not needed if you call ::init_simple which sets up root and
4c221b0da1816acf2ca302b10092df059484468dvboxsync * window.
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncvoid init_window(WindowPtr window, WindowPtr parent, int id);
4c221b0da1816acf2ca302b10092df059484468dvboxsync/**
4c221b0da1816acf2ca302b10092df059484468dvboxsync * Create a very simple setup that provides the minimum values for most
4c221b0da1816acf2ca302b10092df059484468dvboxsync * tests, including a screen, the root and client window and the default
4c221b0da1816acf2ca302b10092df059484468dvboxsync * device setup.
4c221b0da1816acf2ca302b10092df059484468dvboxsync */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncvoid init_simple(void);
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync/* Declarations for various overrides in the test files. */
4c221b0da1816acf2ca302b10092df059484468dvboxsyncvoid __wrap_WriteToClient(ClientPtr client, int len, void *data);
4c221b0da1816acf2ca302b10092df059484468dvboxsyncint __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask);
4c221b0da1816acf2ca302b10092df059484468dvboxsyncint __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access);
4c221b0da1816acf2ca302b10092df059484468dvboxsyncint __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access);
4c221b0da1816acf2ca302b10092df059484468dvboxsyncBool __wrap_AddResource(XID id, RESTYPE type, pointer value);
4c221b0da1816acf2ca302b10092df059484468dvboxsyncint __wrap_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
4c221b0da1816acf2ca302b10092df059484468dvboxsyncint __real_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync
4c221b0da1816acf2ca302b10092df059484468dvboxsync#endif /* PROTOCOL_COMMON_H */
4c221b0da1816acf2ca302b10092df059484468dvboxsync