mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Merge branch 'master' into clipboard
This commit is contained in:
commit
d022e54934
@ -181,6 +181,9 @@ if (_GLFW_COCOA_NSGL)
|
|||||||
${OPENGL_gl_LIBRARY}
|
${OPENGL_gl_LIBRARY}
|
||||||
${IOKIT_FRAMEWORK}
|
${IOKIT_FRAMEWORK}
|
||||||
${CORE_FOUNDATION_FRAMEWORK})
|
${CORE_FOUNDATION_FRAMEWORK})
|
||||||
|
|
||||||
|
set(GLFW_PKG_DEPS "")
|
||||||
|
set(GLFW_PKG_LIBS "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
@ -202,29 +205,34 @@ if (GLFW_BUILD_TESTS)
|
|||||||
endif()
|
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
|
configure_file(${GLFW_SOURCE_DIR}/src/config.h.in
|
||||||
${GLFW_BINARY_DIR}/src/config.h @ONLY)
|
${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
|
install(DIRECTORY include/GL DESTINATION include
|
||||||
FILES_MATCHING PATTERN glfw3.h)
|
FILES_MATCHING PATTERN glfw3.h)
|
||||||
|
|
||||||
install(FILES COPYING.txt readme.html
|
install(FILES COPYING.txt readme.html
|
||||||
DESTINATION share/doc/glfw-${GLFW_VERSION_FULL})
|
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 OR _GLFW_COCOA_NSGL)
|
||||||
|
configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in
|
||||||
|
${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY)
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
install(FILES ${GLFW_BINARY_DIR}/src/libglfw.pc
|
||||||
# -- Documentation generation
|
DESTINATION lib/pkgconfig)
|
||||||
#--------------------------------------------------------------------
|
endif()
|
||||||
configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in"
|
|
||||||
"${GLFW_BINARY_DIR}/docs/Doxyfile"
|
|
||||||
@ONLY)
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Uninstall operation
|
# Uninstall operation
|
||||||
|
@ -487,6 +487,7 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow,int);
|
|||||||
typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
|
typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
|
||||||
typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
|
typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
|
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
|
||||||
|
typedef void (* GLFWcursorenterfun)(GLFWwindow,int);
|
||||||
typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
|
typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWcharfun)(GLFWwindow,int);
|
typedef void (* GLFWcharfun)(GLFWwindow,int);
|
||||||
@ -571,6 +572,7 @@ GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun);
|
|||||||
GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
|
GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
|
||||||
GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun);
|
GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun);
|
||||||
GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun);
|
GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun);
|
||||||
|
GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun);
|
||||||
GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
|
GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
|
||||||
|
|
||||||
/* Joystick input */
|
/* Joystick input */
|
||||||
|
@ -846,6 +846,9 @@ their skills. Special thanks go out to:</p>
|
|||||||
<li>Ralph Eastwood, for the initial design and implementation of the gamma
|
<li>Ralph Eastwood, for the initial design and implementation of the gamma
|
||||||
correction API</li>
|
correction API</li>
|
||||||
|
|
||||||
|
<li>GeO4d, for the implementation of cursor enter/leave notifications on
|
||||||
|
Win32.</li>
|
||||||
|
|
||||||
<li>Gerald Franz, who made GLFW compile under IRIX, and supplied patches
|
<li>Gerald Franz, who made GLFW compile under IRIX, and supplied patches
|
||||||
for the X11 keyboard translation routine</li>
|
for the X11 keyboard translation routine</li>
|
||||||
|
|
||||||
@ -877,7 +880,8 @@ their skills. Special thanks go out to:</p>
|
|||||||
|
|
||||||
<li>Tristam MacDonald, for his bug reports and feedback on the Cocoa port</li>
|
<li>Tristam MacDonald, for his bug reports and feedback on the Cocoa port</li>
|
||||||
|
|
||||||
<li>Hans 'Hanmac' Mackowiak, for adding UTF-8 window title support on X11 and
|
<li>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</li>
|
a fix for the Xkb support</li>
|
||||||
|
|
||||||
<li>David Medlock, for doing the initial Lua port</li>
|
<li>David Medlock, for doing the initial Lua port</li>
|
||||||
|
@ -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
|
include_directories(${GLFW_SOURCE_DIR}/src
|
||||||
${GLFW_BINARY_DIR}/src
|
${GLFW_BINARY_DIR}/src
|
||||||
${glfw_INCLUDE_DIRS})
|
${glfw_INCLUDE_DIRS})
|
||||||
|
@ -292,6 +292,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
@interface GLFWContentView : NSView
|
@interface GLFWContentView : NSView
|
||||||
{
|
{
|
||||||
_GLFWwindow* window;
|
_GLFWwindow* window;
|
||||||
|
NSTrackingArea* trackingArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow;
|
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow;
|
||||||
@ -304,11 +305,22 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self != nil)
|
if (self != nil)
|
||||||
|
{
|
||||||
window = initWindow;
|
window = initWindow;
|
||||||
|
trackingArea = nil;
|
||||||
|
|
||||||
|
[self updateTrackingAreas];
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)dealloc
|
||||||
|
{
|
||||||
|
[trackingArea release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)isOpaque
|
- (BOOL)isOpaque
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
@ -384,6 +396,36 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
_glfwInputMouseClick(window, [event buttonNumber], GLFW_RELEASE);
|
_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
|
- (void)keyDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
NSUInteger i, length;
|
NSUInteger i, length;
|
||||||
|
27
src/input.c
27
src/input.c
@ -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 //////
|
////// 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
|
// Set callback function for scroll events
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -237,6 +237,7 @@ struct _GLFWlibrary
|
|||||||
GLFWwindowiconifyfun windowIconifyCallback;
|
GLFWwindowiconifyfun windowIconifyCallback;
|
||||||
GLFWmousebuttonfun mouseButtonCallback;
|
GLFWmousebuttonfun mouseButtonCallback;
|
||||||
GLFWmouseposfun mousePosCallback;
|
GLFWmouseposfun mousePosCallback;
|
||||||
|
GLFWcursorenterfun cursorEnterCallback;
|
||||||
GLFWscrollfun scrollCallback;
|
GLFWscrollfun scrollCallback;
|
||||||
GLFWkeyfun keyCallback;
|
GLFWkeyfun keyCallback;
|
||||||
GLFWcharfun charCallback;
|
GLFWcharfun charCallback;
|
||||||
@ -349,6 +350,7 @@ void _glfwInputChar(_GLFWwindow* window, int character);
|
|||||||
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
|
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
|
||||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
|
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
|
||||||
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y);
|
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y);
|
||||||
|
void _glfwInputCursorEnter(_GLFWwindow* window, int entered);
|
||||||
|
|
||||||
// OpenGL context helpers (opengl.c)
|
// OpenGL context helpers (opengl.c)
|
||||||
int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
|
int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
|
||||||
|
@ -5,7 +5,7 @@ libdir=${exec_prefix}/lib
|
|||||||
|
|
||||||
Name: GLFW
|
Name: GLFW
|
||||||
Description: A portable library for OpenGL, window and input
|
Description: A portable library for OpenGL, window and input
|
||||||
Version: 3.0.0
|
Version: @GLFW_VERSION_FULL@
|
||||||
URL: http://www.glfw.org/
|
URL: http://www.glfw.org/
|
||||||
Requires.private: @GLFW_PKG_DEPS@
|
Requires.private: @GLFW_PKG_DEPS@
|
||||||
Libs: -L${libdir} -lglfw
|
Libs: -L${libdir} -lglfw
|
@ -270,6 +270,7 @@ typedef struct _GLFWwindowWin32
|
|||||||
// Various platform specific internal variables
|
// Various platform specific internal variables
|
||||||
int desiredRefreshRate; // Desired vertical monitor refresh rate
|
int desiredRefreshRate; // Desired vertical monitor refresh rate
|
||||||
GLboolean cursorCentered;
|
GLboolean cursorCentered;
|
||||||
|
GLboolean cursorInside;
|
||||||
int oldMouseX, oldMouseY;
|
int oldMouseX, oldMouseY;
|
||||||
} _GLFWwindowWin32;
|
} _GLFWwindowWin32;
|
||||||
|
|
||||||
|
@ -997,6 +997,26 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
_glfwInputCursorMotion(window, x, y);
|
_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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,7 +685,8 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
wa.border_pixel = 0;
|
wa.border_pixel = 0;
|
||||||
wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
|
wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
|
||||||
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
|
||||||
ExposureMask | FocusChangeMask | VisibilityChangeMask;
|
ExposureMask | FocusChangeMask | VisibilityChangeMask |
|
||||||
|
EnterWindowMask | LeaveWindowMask;
|
||||||
|
|
||||||
if (wndconfig->mode == GLFW_WINDOWED)
|
if (wndconfig->mode == GLFW_WINDOWED)
|
||||||
{
|
{
|
||||||
@ -1186,6 +1187,40 @@ static void processSingleEvent(void)
|
|||||||
break;
|
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:
|
case MotionNotify:
|
||||||
{
|
{
|
||||||
// The mouse cursor was moved
|
// The mouse cursor was moved
|
||||||
|
@ -275,6 +275,14 @@ 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);
|
printf("%08x at %0.3f: Mouse position: %i %i\n", counter++, glfwGetTime(), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cursor_enter_callback(GLFWwindow window, int entered)
|
||||||
|
{
|
||||||
|
printf("%08x at %0.3f: Cursor %s window\n",
|
||||||
|
counter++,
|
||||||
|
glfwGetTime(),
|
||||||
|
entered ? "entered" : "left");
|
||||||
|
}
|
||||||
|
|
||||||
static void scroll_callback(GLFWwindow window, int x, int y)
|
static void scroll_callback(GLFWwindow window, int x, int y)
|
||||||
{
|
{
|
||||||
printf("%08x at %0.3f: Scroll: %i %i\n", counter++, glfwGetTime(), x, y);
|
printf("%08x at %0.3f: Scroll: %i %i\n", counter++, glfwGetTime(), x, y);
|
||||||
@ -354,6 +362,7 @@ int main(void)
|
|||||||
glfwSetWindowIconifyCallback(window_iconify_callback);
|
glfwSetWindowIconifyCallback(window_iconify_callback);
|
||||||
glfwSetMouseButtonCallback(mouse_button_callback);
|
glfwSetMouseButtonCallback(mouse_button_callback);
|
||||||
glfwSetMousePosCallback(mouse_position_callback);
|
glfwSetMousePosCallback(mouse_position_callback);
|
||||||
|
glfwSetCursorEnterCallback(cursor_enter_callback);
|
||||||
glfwSetScrollCallback(scroll_callback);
|
glfwSetScrollCallback(scroll_callback);
|
||||||
glfwSetKeyCallback(key_callback);
|
glfwSetKeyCallback(key_callback);
|
||||||
glfwSetCharCallback(char_callback);
|
glfwSetCharCallback(char_callback);
|
||||||
|
Loading…
Reference in New Issue
Block a user