From cfda347264fb43748f6f88bd75573ff369a87343 Mon Sep 17 00:00:00 2001 From: siavash Date: Sat, 6 Jul 2013 14:54:53 +0430 Subject: [PATCH] Add error checks. --- src/x11_init.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/x11_init.c b/src/x11_init.c index d73a504c..709ed04e 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -37,6 +37,20 @@ #include +// 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; }