From f236fc2f613484c6daf01c61297133a80a6df22e Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 2 Oct 2012 18:03:21 +0200 Subject: [PATCH 1/5] Fixed X11 hidden cursor mode. --- src/x11_window.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/x11_window.c b/src/x11_window.c index 9cadaeac..ae920e7f 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -238,6 +238,15 @@ static GLboolean createWindow(_GLFWwindow* window, static void hideCursor(_GLFWwindow* window) { + // Un-grab cursor (in windowed mode only; in fullscreen mode we still + // want the cursor grabbed in order to confine the cursor to the window + // area) + if (window->X11.cursorGrabbed && window->mode == GLFW_WINDOWED) + { + XUngrabPointer(_glfwLibrary.X11.display, CurrentTime); + window->X11.cursorGrabbed = GL_FALSE; + } + if (!window->X11.cursorHidden) { XDefineCursor(_glfwLibrary.X11.display, @@ -280,7 +289,7 @@ static void showCursor(_GLFWwindow* window) // Un-grab cursor (in windowed mode only; in fullscreen mode we still // want the cursor grabbed in order to confine the cursor to the window // area) - if (window->X11.cursorGrabbed) + if (window->X11.cursorGrabbed && window->mode == GLFW_WINDOWED) { XUngrabPointer(_glfwLibrary.X11.display, CurrentTime); window->X11.cursorGrabbed = GL_FALSE; From ae5da60c189ece319b2e47a29dffb152411540a7 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 4 Oct 2012 04:05:37 +0200 Subject: [PATCH 2/5] Fixed test for wrong client API. --- src/cocoa_window.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index ed10d384..e3a88901 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -729,7 +729,7 @@ static GLboolean createContext(_GLFWwindow* window, else if (colorBits < 15) colorBits = 15; - if (wndconfig->clientAPI != GLFW_OPENGL_ES_API) + if (wndconfig->clientAPI != GLFW_OPENGL_API) { _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Cocoa/NSOpenGL: NSOpenGL does not support OpenGL ES"); From 2bb62a14679cdf793b1595c420c8c89cac3ae9e3 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 4 Oct 2012 04:08:53 +0200 Subject: [PATCH 3/5] Bug fix formatting. --- src/cocoa_window.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index e3a88901..1ecc9655 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -729,7 +729,7 @@ static GLboolean createContext(_GLFWwindow* window, else if (colorBits < 15) colorBits = 15; - if (wndconfig->clientAPI != GLFW_OPENGL_API) + if (wndconfig->clientAPI == GLFW_OPENGL_ES_API) { _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Cocoa/NSOpenGL: NSOpenGL does not support OpenGL ES"); From 2c6f4329a466c0aeb40ba2344ad0d093dd3c22fa Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 5 Oct 2012 04:00:27 +0200 Subject: [PATCH 4/5] Updated iconification test to use callbacks. --- tests/iconify.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/iconify.c b/tests/iconify.c index 77815358..0ecde623 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -70,16 +70,29 @@ static void key_callback(GLFWwindow window, int key, int action) static void window_size_callback(GLFWwindow window, int width, int height) { - printf("%0.2f Size %ix%i\n", glfwGetTime(), width, height); + printf("%0.2f Window resized to %ix%i\n", glfwGetTime(), width, height); glViewport(0, 0, width, height); } +static void window_focus_callback(GLFWwindow window, int activated) +{ + printf("%0.2f Window %s\n", + glfwGetTime(), + activated ? "activated" : "deactivated"); +} + +static void window_iconify_callback(GLFWwindow window, int iconified) +{ + printf("%0.2f Window %s\n", + glfwGetTime(), + iconified ? "iconified" : "restored"); +} + int main(int argc, char** argv) { int width, height, ch; int mode = GLFW_WINDOWED; - GLboolean active = -1, iconified = -1; GLFWwindow window; while ((ch = getopt(argc, argv, "fh")) != -1) @@ -134,23 +147,17 @@ int main(int argc, char** argv) glfwSetKeyCallback(key_callback); glfwSetWindowSizeCallback(window_size_callback); glfwSetWindowCloseCallback(window_close_callback); + glfwSetWindowFocusCallback(window_focus_callback); + glfwSetWindowIconifyCallback(window_iconify_callback); + + printf("Window is %s and %s\n", + glfwGetWindowParam(window, GLFW_ICONIFIED) ? "iconified" : "restored", + glfwGetWindowParam(window, GLFW_ACTIVE) ? "active" : "inactive"); glEnable(GL_SCISSOR_TEST); while (!closed) { - if (iconified != glfwGetWindowParam(window, GLFW_ICONIFIED) || - active != glfwGetWindowParam(window, GLFW_ACTIVE)) - { - iconified = glfwGetWindowParam(window, GLFW_ICONIFIED); - active = glfwGetWindowParam(window, GLFW_ACTIVE); - - printf("%0.2f %s %s\n", - glfwGetTime(), - iconified ? "Iconified" : "Restored", - active ? "Active" : "Inactive"); - } - glfwGetWindowSize(window, &width, &height); glScissor(0, 0, width, height); From 550b0c177d61380116d8d7326bb79825bf9909a1 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 18 Oct 2012 16:25:15 +0200 Subject: [PATCH 5/5] Added missing initial value. --- src/win32_opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32_opengl.c b/src/win32_opengl.c index 0bcfe452..c326dac7 100644 --- a/src/win32_opengl.c +++ b/src/win32_opengl.c @@ -411,7 +411,7 @@ static GLboolean createContext(_GLFWwindow* window, if (wndconfig->glRobustness) { - int strategy; + int strategy = 0; if (!window->WGL.ARB_create_context_robustness) {