From 0b752b84c308b6098e8360350a1b8c4d08f51395 Mon Sep 17 00:00:00 2001
From: Hanmac
Date: Mon, 30 Jan 2012 22:18:05 +0100
Subject: [PATCH 01/16] Added API and X11 implementation of cursor enter and
leave callbacks.
---
include/GL/glfw3.h | 4 ++++
src/input.c | 32 ++++++++++++++++++++++++++++++++
src/internal.h | 4 ++++
src/window.c | 19 +++++++++++++++++++
src/x11_window.c | 34 +++++++++++++++++++++++++++++++++-
5 files changed, 92 insertions(+), 1 deletion(-)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index e49654d1..421adb4a 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -474,6 +474,8 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow,int);
typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
+typedef void (* GLFWcursorenterfun)(GLFWwindow);
+typedef void (* GLFWcursorleavefun)(GLFWwindow);
typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
typedef void (* GLFWcharfun)(GLFWwindow,int);
@@ -574,6 +576,8 @@ GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun);
GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun);
GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
+GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun);
+GLFWAPI void glfwSetCursorLeaveCallback(GLFWcursorleavefun cbfun);
/* Joystick input */
GLFWAPI int glfwGetJoystickParam(int joy, int param);
diff --git a/src/input.c b/src/input.c
index 531bcc7e..2c480424 100644
--- a/src/input.c
+++ b/src/input.c
@@ -436,3 +436,35 @@ GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun)
_glfwLibrary.scrollCallback = cbfun;
}
+
+//========================================================================
+// Set callback function for cursor enter events
+//========================================================================
+
+GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun)
+{
+ if (!_glfwInitialized)
+ {
+ _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
+ return;
+ }
+
+ _glfwLibrary.cursorEnterCallback = cbfun;
+}
+
+
+//========================================================================
+// Set callback function for cursor enter events
+//========================================================================
+
+GLFWAPI void glfwSetCursorLeaveCallback(GLFWcursorleavefun cbfun)
+{
+ if (!_glfwInitialized)
+ {
+ _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
+ return;
+ }
+
+ _glfwLibrary.cursorLeaveCallback = cbfun;
+}
+
diff --git a/src/internal.h b/src/internal.h
index 5992a0f4..a15dbfc6 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -240,6 +240,8 @@ struct _GLFWlibrary
GLFWscrollfun scrollCallback;
GLFWkeyfun keyCallback;
GLFWcharfun charCallback;
+ GLFWcursorenterfun cursorEnterCallback;
+ GLFWcursorleavefun cursorLeaveCallback;
GLFWthreadmodel threading;
GLFWallocator allocator;
@@ -352,6 +354,8 @@ void _glfwInputChar(_GLFWwindow* window, int character);
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y);
+void _glfwInputCursorEnter(_GLFWwindow* window);
+void _glfwInputCursorLeave(_GLFWwindow* window);
// OpenGL context helpers (opengl.c)
int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
diff --git a/src/window.c b/src/window.c
index 88b3dc18..567ec340 100644
--- a/src/window.c
+++ b/src/window.c
@@ -205,6 +205,25 @@ void _glfwInputWindowDamage(_GLFWwindow* window)
_glfwLibrary.windowRefreshCallback(window);
}
+//========================================================================
+// Register cursor enter events
+//========================================================================
+
+void _glfwInputCursorEnter(_GLFWwindow* window)
+{
+ if (_glfwLibrary.cursorEnterCallback)
+ _glfwLibrary.cursorEnterCallback(window);
+}
+
+//========================================================================
+// Register cursor leave events
+//========================================================================
+
+void _glfwInputCursorLeave(_GLFWwindow* window)
+{
+ if (_glfwLibrary.cursorLeaveCallback)
+ _glfwLibrary.cursorLeaveCallback(window);
+}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
diff --git a/src/x11_window.c b/src/x11_window.c
index 641b3c84..cbd844d3 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -679,7 +679,8 @@ static GLboolean createWindow(_GLFWwindow* window,
wa.border_pixel = 0;
wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
- ExposureMask | FocusChangeMask | VisibilityChangeMask;
+ ExposureMask | FocusChangeMask | VisibilityChangeMask |
+ EnterWindowMask | LeaveWindowMask;
if (wndconfig->mode == GLFW_WINDOWED)
{
@@ -1180,6 +1181,37 @@ static void processSingleEvent(void)
break;
}
+ case EnterNotify:
+ {
+ // The mouse cursor enters the Window
+ window = findWindow(event.xcrossing.window);
+ if (window == NULL)
+ {
+ fprintf(stderr, "Cannot find GLFW window structure for EnterNotify event\n");
+ return;
+ }
+ if(window->cursorMode == GLFW_CURSOR_HIDDEN)
+ {
+ hideMouseCursor(window);
+ }
+ _glfwInputCursorEnter(window);
+ break;
+ }
+
+ case LeaveNotify:
+ {
+ // The mouse cursor leave the Window
+ window = findWindow(event.xcrossing.window);
+ if (window == NULL)
+ {
+ fprintf(stderr, "Cannot find GLFW window structure for LeaveNotify event\n");
+ return;
+ }
+ showMouseCursor(window);
+ _glfwInputCursorLeave(window);
+ break;
+ }
+
case MotionNotify:
{
// The mouse cursor was moved
From 1ddafc25a68a52482a4f52d8e3dcb1bd3e9ff331 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 30 Jan 2012 22:30:40 +0100
Subject: [PATCH 02/16] Moved new cursor input code to other cursor input code.
---
include/GL/glfw3.h | 2 +-
src/input.c | 56 ++++++++++++++++++++++++++++++++--------------
src/internal.h | 4 ++--
src/window.c | 19 ----------------
4 files changed, 42 insertions(+), 39 deletions(-)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 421adb4a..5bf080bd 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -575,9 +575,9 @@ GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun);
GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun);
GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun);
-GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun);
GLFWAPI void glfwSetCursorLeaveCallback(GLFWcursorleavefun cbfun);
+GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
/* Joystick input */
GLFWAPI int glfwGetJoystickParam(int joy, int param);
diff --git a/src/input.c b/src/input.c
index 2c480424..903cb054 100644
--- a/src/input.c
+++ b/src/input.c
@@ -146,6 +146,28 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y)
}
+//========================================================================
+// Register cursor enter events
+//========================================================================
+
+void _glfwInputCursorEnter(_GLFWwindow* window)
+{
+ if (_glfwLibrary.cursorEnterCallback)
+ _glfwLibrary.cursorEnterCallback(window);
+}
+
+
+//========================================================================
+// Register cursor leave events
+//========================================================================
+
+void _glfwInputCursorLeave(_GLFWwindow* window)
+{
+ if (_glfwLibrary.cursorLeaveCallback)
+ _glfwLibrary.cursorLeaveCallback(window);
+}
+
+
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
@@ -420,23 +442,6 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
}
-//========================================================================
-// Set callback function for scroll events
-//========================================================================
-
-GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun)
-{
- if (!_glfwInitialized)
- {
- _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
- return;
- }
-
- // Set callback function
- _glfwLibrary.scrollCallback = cbfun;
-}
-
-
//========================================================================
// Set callback function for cursor enter events
//========================================================================
@@ -468,3 +473,20 @@ GLFWAPI void glfwSetCursorLeaveCallback(GLFWcursorleavefun cbfun)
_glfwLibrary.cursorLeaveCallback = cbfun;
}
+
+//========================================================================
+// Set callback function for scroll events
+//========================================================================
+
+GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun)
+{
+ if (!_glfwInitialized)
+ {
+ _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
+ return;
+ }
+
+ // Set callback function
+ _glfwLibrary.scrollCallback = cbfun;
+}
+
diff --git a/src/internal.h b/src/internal.h
index a15dbfc6..db46f6c4 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -237,11 +237,11 @@ struct _GLFWlibrary
GLFWwindowiconifyfun windowIconifyCallback;
GLFWmousebuttonfun mouseButtonCallback;
GLFWmouseposfun mousePosCallback;
+ GLFWcursorenterfun cursorEnterCallback;
+ GLFWcursorleavefun cursorLeaveCallback;
GLFWscrollfun scrollCallback;
GLFWkeyfun keyCallback;
GLFWcharfun charCallback;
- GLFWcursorenterfun cursorEnterCallback;
- GLFWcursorleavefun cursorLeaveCallback;
GLFWthreadmodel threading;
GLFWallocator allocator;
diff --git a/src/window.c b/src/window.c
index 567ec340..88b3dc18 100644
--- a/src/window.c
+++ b/src/window.c
@@ -205,25 +205,6 @@ void _glfwInputWindowDamage(_GLFWwindow* window)
_glfwLibrary.windowRefreshCallback(window);
}
-//========================================================================
-// Register cursor enter events
-//========================================================================
-
-void _glfwInputCursorEnter(_GLFWwindow* window)
-{
- if (_glfwLibrary.cursorEnterCallback)
- _glfwLibrary.cursorEnterCallback(window);
-}
-
-//========================================================================
-// Register cursor leave events
-//========================================================================
-
-void _glfwInputCursorLeave(_GLFWwindow* window)
-{
- if (_glfwLibrary.cursorLeaveCallback)
- _glfwLibrary.cursorLeaveCallback(window);
-}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
From 7e470518ba909381a9cce65011e1d308e998566a Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 30 Jan 2012 22:32:14 +0100
Subject: [PATCH 03/16] Formatting.
---
src/x11_window.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/x11_window.c b/src/x11_window.c
index cbd844d3..ccf049f9 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -1190,10 +1190,10 @@ static void processSingleEvent(void)
fprintf(stderr, "Cannot find GLFW window structure for EnterNotify event\n");
return;
}
- if(window->cursorMode == GLFW_CURSOR_HIDDEN)
- {
+
+ if (window->cursorMode == GLFW_CURSOR_HIDDEN)
hideMouseCursor(window);
- }
+
_glfwInputCursorEnter(window);
break;
}
@@ -1207,7 +1207,9 @@ static void processSingleEvent(void)
fprintf(stderr, "Cannot find GLFW window structure for LeaveNotify event\n");
return;
}
+
showMouseCursor(window);
+
_glfwInputCursorLeave(window);
break;
}
From 1d2a9790c95243b58be03dacdd3e646d866e4ba0 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 30 Jan 2012 22:44:41 +0100
Subject: [PATCH 04/16] Only show cursor on leave in hidden mode.
---
src/x11_window.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/x11_window.c b/src/x11_window.c
index ccf049f9..ad34eb81 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -1208,7 +1208,8 @@ static void processSingleEvent(void)
return;
}
- showMouseCursor(window);
+ if (window->cursorMode == GLFW_CURSOR_HIDDEN)
+ showMouseCursor(window);
_glfwInputCursorLeave(window);
break;
From 3663d62362a0ba92775051e1be2159ce20044c5f Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 30 Jan 2012 22:44:51 +0100
Subject: [PATCH 05/16] Added cursor enter/leave support to events test.
---
tests/events.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tests/events.c b/tests/events.c
index ac758100..292da3ce 100644
--- a/tests/events.c
+++ b/tests/events.c
@@ -274,6 +274,16 @@ static void mouse_position_callback(GLFWwindow window, int x, int y)
printf("%08x at %0.3f: Mouse position: %i %i\n", counter++, glfwGetTime(), x, y);
}
+static void cursor_enter_callback(GLFWwindow window)
+{
+ printf("%08x at %0.3f: Cursor entered window\n", counter++, glfwGetTime());
+}
+
+static void cursor_leave_callback(GLFWwindow window)
+{
+ printf("%08x at %0.3f: Cursor left window\n", counter++, glfwGetTime());
+}
+
static void scroll_callback(GLFWwindow window, int x, int y)
{
printf("%08x at %0.3f: Scroll: %i %i\n", counter++, glfwGetTime(), x, y);
@@ -351,6 +361,8 @@ int main(void)
glfwSetWindowIconifyCallback(window_iconify_callback);
glfwSetMouseButtonCallback(mouse_button_callback);
glfwSetMousePosCallback(mouse_position_callback);
+ glfwSetCursorEnterCallback(cursor_enter_callback);
+ glfwSetCursorLeaveCallback(cursor_leave_callback);
glfwSetScrollCallback(scroll_callback);
glfwSetKeyCallback(key_callback);
glfwSetCharCallback(char_callback);
From e5d85a5cc43649b25a7470e6c29d87849017ea3c Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 30 Jan 2012 22:48:59 +0100
Subject: [PATCH 06/16] Added credit.
---
readme.html | 3 +++
1 file changed, 3 insertions(+)
diff --git a/readme.html b/readme.html
index 4d1f4c72..49eaa376 100644
--- a/readme.html
+++ b/readme.html
@@ -840,6 +840,9 @@ their skills. Special thanks go out to:
Stefan Gustavson, for quick and thorough testing of GLFW on many and
varied operating systems and hardware configurations
+ Hans 'Hanmac' Mackowiak, for the initial implementation of cursor enter
+ and leave callbacks on X11
+
Sylvain Hellegouarch, for support, bug reports and testing
Alex Holkner, for writing the code from which the Compiz/Intel fix was
From c4806b95325c5db87345e494248d181035eb763d Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 30 Jan 2012 22:59:38 +0100
Subject: [PATCH 07/16] Merged cursor enter/leave callbacks.
---
include/GL/glfw3.h | 4 +---
src/input.c | 35 ++++-------------------------------
src/internal.h | 4 +---
src/x11_window.c | 4 ++--
tests/events.c | 13 +++++--------
5 files changed, 13 insertions(+), 47 deletions(-)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 5bf080bd..31d8f199 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -474,8 +474,7 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow,int);
typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
-typedef void (* GLFWcursorenterfun)(GLFWwindow);
-typedef void (* GLFWcursorleavefun)(GLFWwindow);
+typedef void (* GLFWcursorenterfun)(GLFWwindow,int);
typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
typedef void (* GLFWcharfun)(GLFWwindow,int);
@@ -576,7 +575,6 @@ GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun);
GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun);
GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun);
-GLFWAPI void glfwSetCursorLeaveCallback(GLFWcursorleavefun cbfun);
GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
/* Joystick input */
diff --git a/src/input.c b/src/input.c
index 903cb054..01d99de3 100644
--- a/src/input.c
+++ b/src/input.c
@@ -147,24 +147,13 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y)
//========================================================================
-// Register cursor enter events
+// Register cursor enter/leave events
//========================================================================
-void _glfwInputCursorEnter(_GLFWwindow* window)
+void _glfwInputCursorEnter(_GLFWwindow* window, int entered)
{
if (_glfwLibrary.cursorEnterCallback)
- _glfwLibrary.cursorEnterCallback(window);
-}
-
-
-//========================================================================
-// Register cursor leave events
-//========================================================================
-
-void _glfwInputCursorLeave(_GLFWwindow* window)
-{
- if (_glfwLibrary.cursorLeaveCallback)
- _glfwLibrary.cursorLeaveCallback(window);
+ _glfwLibrary.cursorEnterCallback(window, entered);
}
@@ -443,7 +432,7 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
//========================================================================
-// Set callback function for cursor enter events
+// Set callback function for cursor enter/leave events
//========================================================================
GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun)
@@ -458,22 +447,6 @@ GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun)
}
-//========================================================================
-// Set callback function for cursor enter events
-//========================================================================
-
-GLFWAPI void glfwSetCursorLeaveCallback(GLFWcursorleavefun cbfun)
-{
- if (!_glfwInitialized)
- {
- _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
- return;
- }
-
- _glfwLibrary.cursorLeaveCallback = cbfun;
-}
-
-
//========================================================================
// Set callback function for scroll events
//========================================================================
diff --git a/src/internal.h b/src/internal.h
index db46f6c4..cabafeb4 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -238,7 +238,6 @@ struct _GLFWlibrary
GLFWmousebuttonfun mouseButtonCallback;
GLFWmouseposfun mousePosCallback;
GLFWcursorenterfun cursorEnterCallback;
- GLFWcursorleavefun cursorLeaveCallback;
GLFWscrollfun scrollCallback;
GLFWkeyfun keyCallback;
GLFWcharfun charCallback;
@@ -354,8 +353,7 @@ void _glfwInputChar(_GLFWwindow* window, int character);
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y);
-void _glfwInputCursorEnter(_GLFWwindow* window);
-void _glfwInputCursorLeave(_GLFWwindow* window);
+void _glfwInputCursorEnter(_GLFWwindow* window, int entered);
// OpenGL context helpers (opengl.c)
int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
diff --git a/src/x11_window.c b/src/x11_window.c
index ad34eb81..ffe27722 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -1194,7 +1194,7 @@ static void processSingleEvent(void)
if (window->cursorMode == GLFW_CURSOR_HIDDEN)
hideMouseCursor(window);
- _glfwInputCursorEnter(window);
+ _glfwInputCursorEnter(window, GL_TRUE);
break;
}
@@ -1211,7 +1211,7 @@ static void processSingleEvent(void)
if (window->cursorMode == GLFW_CURSOR_HIDDEN)
showMouseCursor(window);
- _glfwInputCursorLeave(window);
+ _glfwInputCursorEnter(window, GL_FALSE);
break;
}
diff --git a/tests/events.c b/tests/events.c
index 292da3ce..f276573e 100644
--- a/tests/events.c
+++ b/tests/events.c
@@ -274,14 +274,12 @@ static void mouse_position_callback(GLFWwindow window, int x, int y)
printf("%08x at %0.3f: Mouse position: %i %i\n", counter++, glfwGetTime(), x, y);
}
-static void cursor_enter_callback(GLFWwindow window)
+static void cursor_enter_callback(GLFWwindow window, int entered)
{
- printf("%08x at %0.3f: Cursor entered window\n", counter++, glfwGetTime());
-}
-
-static void cursor_leave_callback(GLFWwindow window)
-{
- printf("%08x at %0.3f: Cursor left window\n", counter++, glfwGetTime());
+ printf("%08x at %0.3f: Cursor %s window\n",
+ counter++,
+ glfwGetTime(),
+ entered ? "entered" : "left");
}
static void scroll_callback(GLFWwindow window, int x, int y)
@@ -362,7 +360,6 @@ int main(void)
glfwSetMouseButtonCallback(mouse_button_callback);
glfwSetMousePosCallback(mouse_position_callback);
glfwSetCursorEnterCallback(cursor_enter_callback);
- glfwSetCursorLeaveCallback(cursor_leave_callback);
glfwSetScrollCallback(scroll_callback);
glfwSetKeyCallback(key_callback);
glfwSetCharCallback(char_callback);
From 742299faaaa5fc835219d5cc262a9e33614e33ac Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 22 Mar 2012 13:17:44 +0100
Subject: [PATCH 08/16] Merged implementation for Win32.
---
readme.html | 3 +++
src/win32_platform.h | 1 +
src/win32_window.c | 20 ++++++++++++++++++++
3 files changed, 24 insertions(+)
diff --git a/readme.html b/readme.html
index ea2d34da..fd788bae 100644
--- a/readme.html
+++ b/readme.html
@@ -846,6 +846,9 @@ their skills. Special thanks go out to:
Ralph Eastwood, for the initial design and implementation of the gamma
correction API
+ GeO4d, for the implementation of cursor enter/leave notifications on
+ Win32.
+
Gerald Franz, who made GLFW compile under IRIX, and supplied patches
for the X11 keyboard translation routine
diff --git a/src/win32_platform.h b/src/win32_platform.h
index 82b8c9ca..aa551a09 100644
--- a/src/win32_platform.h
+++ b/src/win32_platform.h
@@ -268,6 +268,7 @@ typedef struct _GLFWwindowWin32
// Various platform specific internal variables
int desiredRefreshRate; // Desired vertical monitor refresh rate
GLboolean cursorCentered;
+ GLboolean cursorInside;
int oldMouseX, oldMouseY;
} _GLFWwindowWin32;
diff --git a/src/win32_window.c b/src/win32_window.c
index 0f3c67d0..66326278 100644
--- a/src/win32_window.c
+++ b/src/win32_window.c
@@ -1021,6 +1021,26 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
_glfwInputCursorMotion(window, x, y);
}
+ if (!window->Win32.cursorInside)
+ {
+ TRACKMOUSEEVENT tme;
+ ZeroMemory(&tme, sizeof(tme));
+ tme.cbSize = sizeof(tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = window->Win32.handle;
+ TrackMouseEvent(&tme);
+
+ window->Win32.cursorInside = GL_TRUE;
+ _glfwInputCursorEnter(window, GL_TRUE);
+ }
+
+ return 0;
+ }
+
+ case WM_MOUSELEAVE:
+ {
+ window->Win32.cursorInside = GL_FALSE;
+ _glfwInputCursorEnter(window, GL_FALSE);
return 0;
}
From e53bbfd2dd5b383cfe0e1a7e2b1e4a6630b81956 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 26 Mar 2012 03:06:45 +0200
Subject: [PATCH 09/16] Renamed pkg-config file template.
---
src/CMakeLists.txt | 2 +-
src/{libglfw.pc.cmake => libglfw.pc.in} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename src/{libglfw.pc.cmake => libglfw.pc.in} (100%)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b87ac3b1..7358c8f5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,6 @@
if (_GLFW_X11_GLX)
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc
DESTINATION lib/pkgconfig)
diff --git a/src/libglfw.pc.cmake b/src/libglfw.pc.in
similarity index 100%
rename from src/libglfw.pc.cmake
rename to src/libglfw.pc.in
From 6fd6c5f7e45c0a9a29b9d539a2fb198603e596b6 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 26 Mar 2012 03:11:43 +0200
Subject: [PATCH 10/16] Moved pkg-config file generation.
---
CMakeLists.txt | 6 ++++++
src/CMakeLists.txt | 7 -------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 522aaf76..665f8c64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -154,6 +154,12 @@ if (_GLFW_X11_GLX)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(_GLFW_USE_LINUX_JOYSTICKS 1)
endif()
+
+ configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in
+ ${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY)
+
+ install(FILES ${GLFW_BINARY_DIR}/src/libglfw.pc
+ DESTINATION lib/pkgconfig)
endif()
#--------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7358c8f5..26471f93 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,11 +1,4 @@
-if (_GLFW_X11_GLX)
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.in
- ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc
- DESTINATION lib/pkgconfig)
-endif()
-
include_directories(${GLFW_SOURCE_DIR}/src
${GLFW_BINARY_DIR}/src
${glfw_INCLUDE_DIRS})
From fd6bc698c0d695b47c587549a77559f846ca91c6 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 26 Mar 2012 12:54:50 +0200
Subject: [PATCH 11/16] Moved file generation around.
---
CMakeLists.txt | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 665f8c64..aab5c293 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -154,12 +154,6 @@ if (_GLFW_X11_GLX)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(_GLFW_USE_LINUX_JOYSTICKS 1)
endif()
-
- configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in
- ${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY)
-
- install(FILES ${GLFW_BINARY_DIR}/src/libglfw.pc
- DESTINATION lib/pkgconfig)
endif()
#--------------------------------------------------------------------
@@ -208,29 +202,34 @@ if (GLFW_BUILD_TESTS)
endif()
#--------------------------------------------------------------------
-# Create shared configuration header
+# Create generated files
#--------------------------------------------------------------------
+configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in"
+ "${GLFW_BINARY_DIR}/docs/Doxyfile" @ONLY)
+
configure_file(${GLFW_SOURCE_DIR}/src/config.h.in
${GLFW_BINARY_DIR}/src/config.h @ONLY)
#--------------------------------------------------------------------
-# Install standard files
+# Install header and documentation
+# The src directory's CMakeLists.txt file installs the library
#--------------------------------------------------------------------
-
install(DIRECTORY include/GL DESTINATION include
FILES_MATCHING PATTERN glfw3.h)
install(FILES COPYING.txt readme.html
DESTINATION share/doc/glfw-${GLFW_VERSION_FULL})
-# The src directory's CMakeLists.txt file installs the library
+#--------------------------------------------------------------------
+# Create and install pkg-config file on supported platforms
+#--------------------------------------------------------------------
+if (_GLFW_X11_GLX)
+ configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in
+ ${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY)
-#--------------------------------------------------------------------
-# -- Documentation generation
-#--------------------------------------------------------------------
-configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in"
- "${GLFW_BINARY_DIR}/docs/Doxyfile"
- @ONLY)
+ install(FILES ${GLFW_BINARY_DIR}/src/libglfw.pc
+ DESTINATION lib/pkgconfig)
+endif()
#--------------------------------------------------------------------
# Uninstall operation
From 2a8324955cc3630807c3f51ff0e4daf1a00f8364 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 26 Mar 2012 13:14:06 +0200
Subject: [PATCH 12/16] Formatting.
---
CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aab5c293..01b50a6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -204,8 +204,8 @@ endif()
#--------------------------------------------------------------------
# Create generated files
#--------------------------------------------------------------------
-configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in"
- "${GLFW_BINARY_DIR}/docs/Doxyfile" @ONLY)
+configure_file(${GLFW_SOURCE_DIR}/docs/Doxyfile.in
+ ${GLFW_BINARY_DIR}/docs/Doxyfile @ONLY)
configure_file(${GLFW_SOURCE_DIR}/src/config.h.in
${GLFW_BINARY_DIR}/src/config.h @ONLY)
From 92758e4ac0cccc1cf9cf30fd23a5bdcf76498bee Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 26 Mar 2012 13:15:37 +0200
Subject: [PATCH 13/16] Made pkg-config file use version variable.
---
src/libglfw.pc.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libglfw.pc.in b/src/libglfw.pc.in
index f83ad126..be6275aa 100644
--- a/src/libglfw.pc.in
+++ b/src/libglfw.pc.in
@@ -5,7 +5,7 @@ libdir=${exec_prefix}/lib
Name: GLFW
Description: A portable library for OpenGL, window and input
-Version: 3.0.0
+Version: @GLFW_VERSION_FULL@
URL: http://www.glfw.org/
Requires.private: @GLFW_PKG_DEPS@
Libs: -L${libdir} -lglfw
From ee1d71adf3d372ea039fd7033f6683cf7b2864cb Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 26 Mar 2012 13:35:14 +0200
Subject: [PATCH 14/16] Added OS X support to pkg-config file.
---
CMakeLists.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aab5c293..93970833 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -181,6 +181,9 @@ if (_GLFW_COCOA_NSGL)
${OPENGL_gl_LIBRARY}
${IOKIT_FRAMEWORK}
${CORE_FOUNDATION_FRAMEWORK})
+
+ set(GLFW_PKG_DEPS "")
+ set(GLFW_PKG_LIBS "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation")
endif()
#--------------------------------------------------------------------
@@ -223,7 +226,7 @@ install(FILES COPYING.txt readme.html
#--------------------------------------------------------------------
# Create and install pkg-config file on supported platforms
#--------------------------------------------------------------------
-if (_GLFW_X11_GLX)
+if (_GLFW_X11_GLX OR _GLFW_COCOA_NSGL)
configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in
${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY)
From 8e4e70d7a476d285dc4c46ee03b8766aa75eab5b Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 26 Mar 2012 14:46:42 +0200
Subject: [PATCH 15/16] Implemented cursor enter/leave for OS X.
---
src/cocoa_window.m | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 98c220ed..5cd7ee3e 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -292,6 +292,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
@interface GLFWContentView : NSView
{
_GLFWwindow* window;
+ NSTrackingArea* trackingArea;
}
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow;
@@ -304,11 +305,22 @@ static int convertMacKeyCode(unsigned int macKeyCode)
{
self = [super init];
if (self != nil)
+ {
window = initWindow;
+ trackingArea = nil;
+
+ [self updateTrackingAreas];
+ }
return self;
}
+-(void)dealloc
+{
+ [trackingArea release];
+ [super dealloc];
+}
+
- (BOOL)isOpaque
{
return YES;
@@ -384,6 +396,36 @@ static int convertMacKeyCode(unsigned int macKeyCode)
_glfwInputMouseClick(window, [event buttonNumber], GLFW_RELEASE);
}
+- (void)mouseExited:(NSEvent *)event
+{
+ _glfwInputCursorEnter(window, GL_FALSE);
+}
+
+- (void)mouseEntered:(NSEvent *)event
+{
+ _glfwInputCursorEnter(window, GL_TRUE);
+}
+
+- (void)updateTrackingAreas
+{
+ if (trackingArea != nil)
+ {
+ [self removeTrackingArea:trackingArea];
+ [trackingArea release];
+ }
+
+ NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
+ NSTrackingActiveAlways |
+ NSTrackingInVisibleRect;
+
+ trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
+ options:options
+ owner:self
+ userInfo:nil];
+
+ [self addTrackingArea:trackingArea];
+}
+
- (void)keyDown:(NSEvent *)event
{
NSUInteger i, length;
From a8bcae8efaf3695482d65bda35249a387267d1d0 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 26 Mar 2012 16:55:31 +0200
Subject: [PATCH 16/16] Merged credit entries.
---
readme.html | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/readme.html b/readme.html
index 6e098a05..d8f22094 100644
--- a/readme.html
+++ b/readme.html
@@ -858,9 +858,6 @@ their skills. Special thanks go out to:
Stefan Gustavson, for quick and thorough testing of GLFW on many and
varied operating systems and hardware configurations
- Hans 'Hanmac' Mackowiak, for the initial implementation of cursor enter
- and leave callbacks on X11
-
Sylvain Hellegouarch, for support, bug reports and testing
Alex Holkner, for writing the code from which the Compiz/Intel fix was
@@ -883,7 +880,8 @@ their skills. Special thanks go out to:
Tristam MacDonald, for his bug reports and feedback on the Cocoa port
- Hans 'Hanmac' Mackowiak, for adding UTF-8 window title support on X11 and
+ Hans 'Hanmac' Mackowiak, for the initial implementation of cursor
+ enter/leave callbacks on X11, adding UTF-8 window title support on X11 and
a fix for the Xkb support
David Medlock, for doing the initial Lua port