diff --git a/src/window.c b/src/window.c index cc2f5596..124e7e4d 100644 --- a/src/window.c +++ b/src/window.c @@ -221,8 +221,11 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, return NULL; } - // We need to copy these values before doing anything that can fail, as the - // window hints should be cleared after each call even if it fails + if (width <= 0 || height <= 0) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid window size"); + return GL_FALSE; + } // Set up desired framebuffer config fbconfig.redBits = Max(_glfw.hints.redBits, 0); @@ -260,15 +263,6 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, if (!_glfwIsValidContextConfig(&wndconfig)) return GL_FALSE; - // Save the currently current context so it can be restored later - previous = glfwGetCurrentContext(); - - if (width <= 0 || height <= 0) - { - _glfwInputError(GLFW_INVALID_VALUE, "Invalid window size"); - return GL_FALSE; - } - window = (_GLFWwindow*) calloc(1, sizeof(_GLFWwindow)); if (!window) { @@ -295,6 +289,9 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, window->videoMode.blueBits = fbconfig.blueBits; } + // Save the currently current context so it can be restored later + previous = glfwGetCurrentContext(); + // Open the actual window and create its context if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig)) { diff --git a/src/x11_platform.h b/src/x11_platform.h index 1ffb0e10..a1e51986 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -124,7 +124,9 @@ typedef struct _GLFWlibraryX11 Display* display; int screen; Window root; - Cursor cursor; // Invisible cursor for hidden cursor + + // Invisible cursor for hidden cursor mode + Cursor cursor; Atom wmDeleteWindow; // WM_DELETE_WINDOW atom Atom wmName; // _NET_WM_NAME atom @@ -161,10 +163,9 @@ typedef struct _GLFWlibraryX11 int versionMinor; } xkb; - // Key code LUT (mapping X11 key codes to GLFW key codes) + // LUT for mapping X11 key codes to GLFW key codes int keyCodeLUT[256]; - // Screensaver data struct { GLboolean changed; int timeout; @@ -173,14 +174,12 @@ typedef struct _GLFWlibraryX11 int exposure; } saver; - // Timer data struct { GLboolean monotonic; double resolution; uint64_t base; } timer; - // Selection data struct { Atom atom; Atom formats[_GLFW_CLIPBOARD_FORMAT_COUNT];