1848b8605Smrg/* 2848b8605Smrg Copyright (c) 2009 Apple Inc. 3848b8605Smrg 4848b8605Smrg Permission is hereby granted, free of charge, to any person 5848b8605Smrg obtaining a copy of this software and associated documentation files 6848b8605Smrg (the "Software"), to deal in the Software without restriction, 7848b8605Smrg including without limitation the rights to use, copy, modify, merge, 8848b8605Smrg publish, distribute, sublicense, and/or sell copies of the Software, 9848b8605Smrg and to permit persons to whom the Software is furnished to do so, 10848b8605Smrg subject to the following conditions: 11848b8605Smrg 12848b8605Smrg The above copyright notice and this permission notice shall be 13848b8605Smrg included in all copies or substantial portions of the Software. 14848b8605Smrg 15848b8605Smrg THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16848b8605Smrg EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17848b8605Smrg MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18848b8605Smrg NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT 19848b8605Smrg HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20848b8605Smrg WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21848b8605Smrg OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22848b8605Smrg DEALINGS IN THE SOFTWARE. 23848b8605Smrg 24848b8605Smrg Except as contained in this notice, the name(s) of the above 25848b8605Smrg copyright holders shall not be used in advertising or otherwise to 26848b8605Smrg promote the sale, use or other dealings in this Software without 27848b8605Smrg prior written authorization. 28848b8605Smrg*/ 29848b8605Smrg#include <stdbool.h> 30848b8605Smrg#include <assert.h> 31848b8605Smrg#include <X11/Xlibint.h> 32848b8605Smrg#include <X11/extensions/extutil.h> 33848b8605Smrg#include <X11/extensions/Xext.h> 34848b8605Smrg#include "glxclient.h" 35848b8605Smrg#include "glx_error.h" 36848b8605Smrg 37848b8605Smrgvoid 38848b8605Smrg__glXSendError(Display * dpy, int_fast8_t errorCode, uint_fast32_t resourceID, 39848b8605Smrg uint_fast16_t minorCode, bool coreX11error) 40848b8605Smrg{ 41848b8605Smrg struct glx_display *glx_dpy = __glXInitialize(dpy); 42848b8605Smrg xError error; 43848b8605Smrg 44848b8605Smrg assert(glx_dpy); 45848b8605Smrg 46848b8605Smrg LockDisplay(dpy); 47848b8605Smrg 48848b8605Smrg error.type = X_Error; 49848b8605Smrg 50848b8605Smrg if (coreX11error) { 51848b8605Smrg error.errorCode = errorCode; 52848b8605Smrg } 53848b8605Smrg else { 54848b8605Smrg error.errorCode = glx_dpy->codes->first_error + errorCode; 55848b8605Smrg } 56848b8605Smrg 57848b8605Smrg error.sequenceNumber = dpy->request; 58848b8605Smrg error.resourceID = resourceID; 59848b8605Smrg error.minorCode = minorCode; 60b8e80941Smrg error.majorCode = glx_dpy->majorOpcode; 61848b8605Smrg 62848b8605Smrg _XError(dpy, &error); 63848b8605Smrg 64848b8605Smrg UnlockDisplay(dpy); 65848b8605Smrg} 66848b8605Smrg 67848b8605Smrgvoid 68848b8605Smrg__glXSendErrorForXcb(Display * dpy, const xcb_generic_error_t *err) 69848b8605Smrg{ 70848b8605Smrg xError error; 71848b8605Smrg 72848b8605Smrg LockDisplay(dpy); 73848b8605Smrg 74848b8605Smrg error.type = X_Error; 75848b8605Smrg error.errorCode = err->error_code; 76848b8605Smrg error.sequenceNumber = err->sequence; 77848b8605Smrg error.resourceID = err->resource_id; 78848b8605Smrg error.minorCode = err->minor_code; 79848b8605Smrg error.majorCode = err->major_code; 80848b8605Smrg 81848b8605Smrg _XError(dpy, &error); 82848b8605Smrg 83848b8605Smrg UnlockDisplay(dpy); 84848b8605Smrg} 85