Add error checks.

This commit is contained in:
siavash 2013-07-06 14:54:53 +04:30
parent 763ec6cbcb
commit cfda347264

View File

@ -37,6 +37,20 @@
#include <limits.h>
// Error handler used when creating a blank cursor
//
static int errorHandler(Display *display, XErrorEvent* event)
{
char buffer[8192];
XGetErrorText(display,
event->error_code,
buffer, sizeof(buffer));
_glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to create a blank cursor: %s", buffer);
return 0;
}
// Translate an X11 key code to a GLFW key code.
//
static int translateKey(int keyCode)
@ -553,7 +567,7 @@ static Cursor createNULLCursor(void)
XColor col;
Cursor cursor;
// TODO: Add error checks
XSetErrorHandler(errorHandler);
cursormask = XCreatePixmap(_glfw.x11.display, _glfw.x11.root, 1, 1, 1);
xgc.function = GXclear;
@ -568,6 +582,9 @@ static Cursor createNULLCursor(void)
XFreePixmap(_glfw.x11.display, cursormask);
XFreeGC(_glfw.x11.display, gc);
XSync(_glfw.x11.display, False);
XSetErrorHandler(NULL);
return cursor;
}