Merge branch 'master' into clipboard

This commit is contained in:
Camilla Berglund
2012-03-28 14:58:03 +02:00
12 changed files with 163 additions and 20 deletions
-7
View File
@@ -1,11 +1,4 @@
if (_GLFW_X11_GLX)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
${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})
+42
View File
@@ -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;
+27
View File
@@ -262,6 +262,17 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y)
}
//========================================================================
// Register cursor enter/leave events
//========================================================================
void _glfwInputCursorEnter(_GLFWwindow* window, int entered)
{
if (_glfwLibrary.cursorEnterCallback)
_glfwLibrary.cursorEnterCallback(window, entered);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
@@ -557,6 +568,22 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
}
//========================================================================
// Set callback function for cursor enter/leave events
//========================================================================
GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun)
{
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_glfwLibrary.cursorEnterCallback = cbfun;
}
//========================================================================
// Set callback function for scroll events
//========================================================================
+2
View File
@@ -237,6 +237,7 @@ struct _GLFWlibrary
GLFWwindowiconifyfun windowIconifyCallback;
GLFWmousebuttonfun mouseButtonCallback;
GLFWmouseposfun mousePosCallback;
GLFWcursorenterfun cursorEnterCallback;
GLFWscrollfun scrollCallback;
GLFWkeyfun keyCallback;
GLFWcharfun charCallback;
@@ -349,6 +350,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, int entered);
// OpenGL context helpers (opengl.c)
int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
+1 -1
View File
@@ -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
+1
View File
@@ -270,6 +270,7 @@ typedef struct _GLFWwindowWin32
// Various platform specific internal variables
int desiredRefreshRate; // Desired vertical monitor refresh rate
GLboolean cursorCentered;
GLboolean cursorInside;
int oldMouseX, oldMouseY;
} _GLFWwindowWin32;
+20
View File
@@ -997,6 +997,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;
}
+36 -1
View File
@@ -685,7 +685,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)
{
@@ -1186,6 +1187,40 @@ 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, GL_TRUE);
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;
}
if (window->cursorMode == GLFW_CURSOR_HIDDEN)
showMouseCursor(window);
_glfwInputCursorEnter(window, GL_FALSE);
break;
}
case MotionNotify:
{
// The mouse cursor was moved