Added glfwPostEmptyEvent.

This commit is contained in:
Camilla Berglund
2014-02-10 18:16:58 +01:00
parent 9309f75704
commit 1ccc23268c
8 changed files with 84 additions and 0 deletions
+14
View File
@@ -1147,6 +1147,20 @@ void _glfwPlatformWaitEvents(void)
_glfwPlatformPollEvents();
}
void _glfwPlatformPostEmptyEvent(void)
{
NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined
location:NSMakePoint(0, 0)
modifierFlags:0
timestamp:0
windowNumber:0
context:nil
subtype:0
data1:0
data2:0];
[NSApp postEvent:event atStart:YES];
}
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
{
setModeCursor(window);
+5
View File
@@ -539,6 +539,11 @@ void _glfwPlatformPollEvents(void);
*/
void _glfwPlatformWaitEvents(void);
/*! @copydoc glfwPostEmptyEvent
* @ingroup platform
*/
void _glfwPlatformPostEmptyEvent(void);
/*! @copydoc glfwMakeContextCurrent
* @ingroup platform
*/
+6
View File
@@ -1181,6 +1181,12 @@ void _glfwPlatformWaitEvents(void)
_glfwPlatformPollEvents();
}
void _glfwPlatformPostEmptyEvent(void)
{
_GLFWwindow* window = _glfw.windowListHead;
PostMessage(window->win32.handle, WM_NULL, 0, 0);
}
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
{
POINT pos = { (int) xpos, (int) ypos };
+14
View File
@@ -669,6 +669,20 @@ GLFWAPI void glfwPollEvents(void)
GLFWAPI void glfwWaitEvents(void)
{
_GLFW_REQUIRE_INIT();
if (!_glfw.windowListHead)
return;
_glfwPlatformWaitEvents();
}
GLFWAPI void glfwPostEmptyEvent(void)
{
_GLFW_REQUIRE_INIT();
if (!_glfw.windowListHead)
return;
_glfwPlatformPostEmptyEvent();
}
+15
View File
@@ -1305,6 +1305,21 @@ void _glfwPlatformWaitEvents(void)
_glfwPlatformPollEvents();
}
void _glfwPlatformPostEmptyEvent(void)
{
XEvent event;
_GLFWwindow* window = _glfw.windowListHead;
memset(&event, 0, sizeof(event));
event.type = ClientMessage;
event.xclient.window = window->x11.handle;
event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = _glfw.x11._NULL;
XSendEvent(_glfw.x11.display, window->x11.handle, False, 0, &event);
XFlush(_glfw.x11.display);
}
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
{
// Store the new position so it can be recognized later