mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
Store the event time in the global structure
This commit is contained in:
parent
41bca2c3cd
commit
33448e90c4
@ -3231,7 +3231,6 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window
|
|||||||
* key-press, key-release and cursor motion, and the proper place to call this
|
* key-press, key-release and cursor motion, and the proper place to call this
|
||||||
* function is in one of the input callbacks.
|
* function is in one of the input callbacks.
|
||||||
*
|
*
|
||||||
* @param[in] window The window to check for the input event.
|
|
||||||
* @return The value, in seconds, of the last input event occurence.
|
* @return The value, in seconds, of the last input event occurence.
|
||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
@ -3244,7 +3243,7 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window
|
|||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
GLFWAPI double glfwGetEventTime(GLFWwindow* window);
|
GLFWAPI double glfwGetEventTime(void);
|
||||||
|
|
||||||
/*! @brief Processes all pending events.
|
/*! @brief Processes all pending events.
|
||||||
*
|
*
|
||||||
|
@ -96,7 +96,6 @@ typedef struct _GLFWwindowNS
|
|||||||
// This is kept to counteract Cocoa doing the same internally
|
// This is kept to counteract Cocoa doing the same internally
|
||||||
double cursorWarpDeltaX, cursorWarpDeltaY;
|
double cursorWarpDeltaX, cursorWarpDeltaY;
|
||||||
|
|
||||||
double lastEventTime;
|
|
||||||
} _GLFWwindowNS;
|
} _GLFWwindowNS;
|
||||||
|
|
||||||
// Cocoa-specific global data
|
// Cocoa-specific global data
|
||||||
@ -122,6 +121,9 @@ typedef struct _GLFWlibraryNS
|
|||||||
// The window whose disabled cursor mode is active
|
// The window whose disabled cursor mode is active
|
||||||
_GLFWwindow* disabledCursorWindow;
|
_GLFWwindow* disabledCursorWindow;
|
||||||
|
|
||||||
|
// The time of the last event
|
||||||
|
double lastEventTime;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
CFBundleRef bundle;
|
CFBundleRef bundle;
|
||||||
PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource;
|
PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource;
|
||||||
|
@ -433,7 +433,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)mouseDown:(NSEvent *)event
|
- (void)mouseDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
GLFW_MOUSE_BUTTON_LEFT,
|
GLFW_MOUSE_BUTTON_LEFT,
|
||||||
@ -443,14 +443,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)mouseDragged:(NSEvent *)event
|
- (void)mouseDragged:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
[self mouseMoved:event];
|
[self mouseMoved:event];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseUp:(NSEvent *)event
|
- (void)mouseUp:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
GLFW_MOUSE_BUTTON_LEFT,
|
GLFW_MOUSE_BUTTON_LEFT,
|
||||||
@ -460,7 +460,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)mouseMoved:(NSEvent *)event
|
- (void)mouseMoved:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
@ -485,7 +485,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)rightMouseDown:(NSEvent *)event
|
- (void)rightMouseDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
GLFW_MOUSE_BUTTON_RIGHT,
|
GLFW_MOUSE_BUTTON_RIGHT,
|
||||||
@ -495,14 +495,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)rightMouseDragged:(NSEvent *)event
|
- (void)rightMouseDragged:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
[self mouseMoved:event];
|
[self mouseMoved:event];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rightMouseUp:(NSEvent *)event
|
- (void)rightMouseUp:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
GLFW_MOUSE_BUTTON_RIGHT,
|
GLFW_MOUSE_BUTTON_RIGHT,
|
||||||
@ -512,7 +512,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)otherMouseDown:(NSEvent *)event
|
- (void)otherMouseDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
(int) [event buttonNumber],
|
(int) [event buttonNumber],
|
||||||
@ -522,14 +522,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)otherMouseDragged:(NSEvent *)event
|
- (void)otherMouseDragged:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
[self mouseMoved:event];
|
[self mouseMoved:event];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)otherMouseUp:(NSEvent *)event
|
- (void)otherMouseUp:(NSEvent *)event
|
||||||
{
|
{
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
(int) [event buttonNumber],
|
(int) [event buttonNumber],
|
||||||
@ -589,7 +589,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
const int key = translateKey([event keyCode]);
|
const int key = translateKey([event keyCode]);
|
||||||
const int mods = translateFlags([event modifierFlags]);
|
const int mods = translateFlags([event modifierFlags]);
|
||||||
|
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
|
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
|
||||||
|
|
||||||
@ -623,7 +623,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
const int key = translateKey([event keyCode]);
|
const int key = translateKey([event keyCode]);
|
||||||
const int mods = translateFlags([event modifierFlags]);
|
const int mods = translateFlags([event modifierFlags]);
|
||||||
|
|
||||||
window->ns.lastEventTime = [event timestamp];
|
_glfw.ns.lastEventTime = [event timestamp];
|
||||||
|
|
||||||
_glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
|
_glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
|
||||||
}
|
}
|
||||||
@ -1458,10 +1458,10 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
[window->ns.object setLevel:NSNormalWindowLevel];
|
[window->ns.object setLevel:NSNormalWindowLevel];
|
||||||
}
|
}
|
||||||
|
|
||||||
double _glfwPlatformGetEventTime(_GLFWwindow* window)
|
double _glfwPlatformGetEventTime(void)
|
||||||
{
|
{
|
||||||
/* Windows events are stored in seconds */
|
/* Windows events are stored in seconds */
|
||||||
return window->ns.lastEventTime;
|
return _glfw.ns.lastEventTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
void _glfwPlatformPollEvents(void)
|
||||||
|
@ -642,7 +642,7 @@ void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
|
|||||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
|
||||||
double _glfwPlatformGetEventTime(_GLFWwindow* window);
|
double _glfwPlatformGetEventTime(void);
|
||||||
void _glfwPlatformPollEvents(void);
|
void _glfwPlatformPollEvents(void);
|
||||||
void _glfwPlatformWaitEvents(void);
|
void _glfwPlatformWaitEvents(void);
|
||||||
void _glfwPlatformWaitEventsTimeout(double timeout);
|
void _glfwPlatformWaitEventsTimeout(double timeout);
|
||||||
|
@ -87,7 +87,6 @@ typedef struct _GLFWwindowMir
|
|||||||
MirEGLNativeWindowType nativeWindow;
|
MirEGLNativeWindowType nativeWindow;
|
||||||
_GLFWcursor* currentCursor;
|
_GLFWcursor* currentCursor;
|
||||||
|
|
||||||
int64_t lastEventTime;
|
|
||||||
} _GLFWwindowMir;
|
} _GLFWwindowMir;
|
||||||
|
|
||||||
// Mir-specific per-monitor data
|
// Mir-specific per-monitor data
|
||||||
@ -118,6 +117,9 @@ typedef struct _GLFWlibraryMir
|
|||||||
// The window whose disabled cursor mode is active
|
// The window whose disabled cursor mode is active
|
||||||
_GLFWwindow* disabledCursorWindow;
|
_GLFWwindow* disabledCursorWindow;
|
||||||
|
|
||||||
|
// The time of the last event
|
||||||
|
int64_t lastEventTime;
|
||||||
|
|
||||||
} _GLFWlibraryMir;
|
} _GLFWlibraryMir;
|
||||||
|
|
||||||
// Mir-specific per-cursor data
|
// Mir-specific per-cursor data
|
||||||
|
@ -147,7 +147,7 @@ static void handleKeyEvent(const MirKeyboardEvent* key_event, _GLFWwindow* windo
|
|||||||
const long text = _glfwKeySym2Unicode(key_code);
|
const long text = _glfwKeySym2Unicode(key_code);
|
||||||
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
||||||
|
|
||||||
window->mir.lastEventTime = mir_input_event_get_event_time((MirInputEvent *) key_event);
|
_glfw.mir.lastEventTime = mir_input_event_get_event_time((MirInputEvent *) key_event);
|
||||||
|
|
||||||
_glfwInputKey(window, toGLFWKeyCode(scan_code), scan_code, pressed, mods);
|
_glfwInputKey(window, toGLFWKeyCode(scan_code), scan_code, pressed, mods);
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ static void handlePointerButton(_GLFWwindow* window,
|
|||||||
uint32_t newButtonStates = mir_pointer_event_buttons(pointer_event);
|
uint32_t newButtonStates = mir_pointer_event_buttons(pointer_event);
|
||||||
int publicButton = GLFW_MOUSE_BUTTON_LEFT;
|
int publicButton = GLFW_MOUSE_BUTTON_LEFT;
|
||||||
|
|
||||||
window->mir.lastEventTime = mir_input_event_get_event_time((MirEvent *) pointer_event);
|
_glfw.mir.lastEventTime = mir_input_event_get_event_time((MirEvent *) pointer_event);
|
||||||
|
|
||||||
// XOR our old button states our new states to figure out what was added or removed
|
// XOR our old button states our new states to figure out what was added or removed
|
||||||
button = newButtonStates ^ oldButtonStates;
|
button = newButtonStates ^ oldButtonStates;
|
||||||
@ -205,7 +205,7 @@ static void handlePointerMotion(_GLFWwindow* window,
|
|||||||
const int hscroll = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_hscroll);
|
const int hscroll = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_hscroll);
|
||||||
const int vscroll = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_vscroll);
|
const int vscroll = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_vscroll);
|
||||||
|
|
||||||
window->mir.lastEventTime = mir_input_event_get_event_time((MirEvent *) pointer_event);
|
_glfw.mir.lastEventTime = mir_input_event_get_event_time((MirEvent *) pointer_event);
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
@ -638,10 +638,10 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
double _glfwPlatformGetEventTime(_GLFWwindow* window)
|
double _glfwPlatformGetEventTime(void)
|
||||||
{
|
{
|
||||||
/* Mir events are stored in nanoseconds */
|
/* Mir events are stored in nanoseconds */
|
||||||
return (double) window->mir.lastEventTime / 1000000000.0;
|
return (double) _glfw.mir.lastEventTime / 1000000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
void _glfwPlatformPollEvents(void)
|
||||||
|
@ -204,7 +204,7 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
double _glfwPlatformGetEventTime(_GLFWwindow* window)
|
double _glfwPlatformGetEventTime(void)
|
||||||
{
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,6 @@ typedef struct _GLFWwindowWin32
|
|||||||
// The last received cursor position, regardless of source
|
// The last received cursor position, regardless of source
|
||||||
int lastCursorPosX, lastCursorPosY;
|
int lastCursorPosX, lastCursorPosY;
|
||||||
|
|
||||||
LONG lastEventTime;
|
|
||||||
} _GLFWwindowWin32;
|
} _GLFWwindowWin32;
|
||||||
|
|
||||||
// Win32-specific global data
|
// Win32-specific global data
|
||||||
@ -262,6 +261,9 @@ typedef struct _GLFWlibraryWin32
|
|||||||
RAWINPUT* rawInput;
|
RAWINPUT* rawInput;
|
||||||
int rawInputSize;
|
int rawInputSize;
|
||||||
|
|
||||||
|
// The time of the last event
|
||||||
|
LONG lastEventTime;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
PFN_timeGetTime GetTime;
|
PFN_timeGetTime GetTime;
|
||||||
|
@ -552,7 +552,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
case WM_UNICHAR:
|
case WM_UNICHAR:
|
||||||
{
|
{
|
||||||
const GLFWbool plain = (uMsg != WM_SYSCHAR);
|
const GLFWbool plain = (uMsg != WM_SYSCHAR);
|
||||||
window->win32.lastEventTime = GetMessageTime();
|
_glfw.win32.lastEventTime = GetMessageTime();
|
||||||
|
|
||||||
if (uMsg == WM_UNICHAR && wParam == UNICODE_NOCHAR)
|
if (uMsg == WM_UNICHAR && wParam == UNICODE_NOCHAR)
|
||||||
{
|
{
|
||||||
@ -575,7 +575,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
const int scancode = (lParam >> 16) & 0x1ff;
|
const int scancode = (lParam >> 16) & 0x1ff;
|
||||||
const int action = ((lParam >> 31) & 1) ? GLFW_RELEASE : GLFW_PRESS;
|
const int action = ((lParam >> 31) & 1) ? GLFW_RELEASE : GLFW_PRESS;
|
||||||
const int mods = getKeyMods();
|
const int mods = getKeyMods();
|
||||||
window->win32.lastEventTime = GetMessageTime();
|
_glfw.win32.lastEventTime = GetMessageTime();
|
||||||
|
|
||||||
if (key == _GLFW_KEY_INVALID)
|
if (key == _GLFW_KEY_INVALID)
|
||||||
break;
|
break;
|
||||||
@ -610,7 +610,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
case WM_XBUTTONUP:
|
case WM_XBUTTONUP:
|
||||||
{
|
{
|
||||||
int i, button, action;
|
int i, button, action;
|
||||||
window->win32.lastEventTime = GetMessageTime();
|
_glfw.win32.lastEventTime = GetMessageTime();
|
||||||
|
|
||||||
if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
|
if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
|
||||||
button = GLFW_MOUSE_BUTTON_LEFT;
|
button = GLFW_MOUSE_BUTTON_LEFT;
|
||||||
@ -661,7 +661,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
{
|
{
|
||||||
const int x = GET_X_LPARAM(lParam);
|
const int x = GET_X_LPARAM(lParam);
|
||||||
const int y = GET_Y_LPARAM(lParam);
|
const int y = GET_Y_LPARAM(lParam);
|
||||||
window->win32.lastEventTime = GetMessageTime();
|
_glfw.win32.lastEventTime = GetMessageTime();
|
||||||
|
|
||||||
// Disabled cursor motion input is provided by WM_INPUT
|
// Disabled cursor motion input is provided by WM_INPUT
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
@ -1455,10 +1455,10 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
double _glfwPlatformGetEventTime(_GLFWwindow* window)
|
double _glfwPlatformGetEventTime(void)
|
||||||
{
|
{
|
||||||
/* Windows events are stored in milliseconds */
|
/* Windows events are stored in milliseconds */
|
||||||
return (double) window->win32.lastEventTime / 1000.0;
|
return (double) _glfw.win32.lastEventTime / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
void _glfwPlatformPollEvents(void)
|
||||||
|
@ -961,14 +961,11 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle
|
|||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI double glfwGetEventTime(GLFWwindow* handle)
|
GLFWAPI double glfwGetEventTime(void)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
||||||
assert(window != NULL);
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(0.0);
|
_GLFW_REQUIRE_INIT_OR_RETURN(0.0);
|
||||||
|
|
||||||
return _glfwPlatformGetEventTime(window);
|
return _glfwPlatformGetEventTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwPollEvents(void)
|
GLFWAPI void glfwPollEvents(void)
|
||||||
|
@ -83,7 +83,7 @@ static void pointerHandleMotion(void* data,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window->wl.lastEventTime = time;
|
_glfw.wl.lastEventTime = time;
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
@ -110,7 +110,7 @@ static void pointerHandleButton(void* data,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window->wl.lastEventTime = time;
|
_glfw.wl.lastEventTime = time;
|
||||||
_glfw.wl.pointerSerial = serial;
|
_glfw.wl.pointerSerial = serial;
|
||||||
|
|
||||||
/* Makes left, right and middle 0, 1 and 2. Overall order follows evdev
|
/* Makes left, right and middle 0, 1 and 2. Overall order follows evdev
|
||||||
@ -138,7 +138,7 @@ static void pointerHandleAxis(void* data,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window->wl.lastEventTime = time;
|
_glfw.wl.lastEventTime = time;
|
||||||
/* Wayland scroll events are in pointer motion coordinate space (think
|
/* Wayland scroll events are in pointer motion coordinate space (think
|
||||||
* two finger scroll). The factor 10 is commonly used to convert to
|
* two finger scroll). The factor 10 is commonly used to convert to
|
||||||
* "scroll step means 1.0. */
|
* "scroll step means 1.0. */
|
||||||
@ -352,7 +352,7 @@ static void keyboardHandleKey(void* data,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window->wl.lastEventTime = time;
|
_glfw.wl.lastEventTime = time;
|
||||||
keyCode = toGLFWKeyCode(key);
|
keyCode = toGLFWKeyCode(key);
|
||||||
action = state == WL_KEYBOARD_KEY_STATE_PRESSED
|
action = state == WL_KEYBOARD_KEY_STATE_PRESSED
|
||||||
? GLFW_PRESS : GLFW_RELEASE;
|
? GLFW_PRESS : GLFW_RELEASE;
|
||||||
|
@ -101,7 +101,6 @@ typedef struct _GLFWwindowWayland
|
|||||||
struct zwp_locked_pointer_v1* lockedPointer;
|
struct zwp_locked_pointer_v1* lockedPointer;
|
||||||
} pointerLock;
|
} pointerLock;
|
||||||
|
|
||||||
unsigned int lastEventTime;
|
|
||||||
} _GLFWwindowWayland;
|
} _GLFWwindowWayland;
|
||||||
|
|
||||||
// Wayland-specific global data
|
// Wayland-specific global data
|
||||||
@ -143,6 +142,9 @@ typedef struct _GLFWlibraryWayland
|
|||||||
_GLFWwindow* pointerFocus;
|
_GLFWwindow* pointerFocus;
|
||||||
_GLFWwindow* keyboardFocus;
|
_GLFWwindow* keyboardFocus;
|
||||||
|
|
||||||
|
// The time of the last event
|
||||||
|
unsigned int lastEventTime;
|
||||||
|
|
||||||
} _GLFWlibraryWayland;
|
} _GLFWlibraryWayland;
|
||||||
|
|
||||||
// Wayland-specific per-monitor data
|
// Wayland-specific per-monitor data
|
||||||
|
@ -675,9 +675,9 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
"Wayland: Window attribute setting not implemented yet");
|
"Wayland: Window attribute setting not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
double _glfwPlatformGetEventTime(_GLFWwindow* window)
|
double _glfwPlatformGetEventTime(void)
|
||||||
{
|
{
|
||||||
return (double) window->wl.lastEventTime / 1000.0;
|
return (double) _glfw.wl.lastEventTime / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
void _glfwPlatformPollEvents(void)
|
||||||
|
@ -144,8 +144,6 @@ typedef struct _GLFWwindowX11
|
|||||||
// The time of the last KeyPress event
|
// The time of the last KeyPress event
|
||||||
Time lastKeyTime;
|
Time lastKeyTime;
|
||||||
|
|
||||||
// The time of the last event
|
|
||||||
Time lastEventTime;
|
|
||||||
} _GLFWwindowX11;
|
} _GLFWwindowX11;
|
||||||
|
|
||||||
// X11-specific global data
|
// X11-specific global data
|
||||||
@ -179,6 +177,9 @@ typedef struct _GLFWlibraryX11
|
|||||||
// The window whose disabled cursor mode is active
|
// The window whose disabled cursor mode is active
|
||||||
_GLFWwindow* disabledCursorWindow;
|
_GLFWwindow* disabledCursorWindow;
|
||||||
|
|
||||||
|
// The time of the last event
|
||||||
|
Time lastEventTime;
|
||||||
|
|
||||||
// Window manager atoms
|
// Window manager atoms
|
||||||
Atom WM_PROTOCOLS;
|
Atom WM_PROTOCOLS;
|
||||||
Atom WM_STATE;
|
Atom WM_STATE;
|
||||||
|
@ -988,7 +988,7 @@ static void processEvent(XEvent *event)
|
|||||||
const int key = translateKey(keycode);
|
const int key = translateKey(keycode);
|
||||||
const int mods = translateState(event->xkey.state);
|
const int mods = translateState(event->xkey.state);
|
||||||
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
||||||
window->x11.lastEventTime = event->xkey.time;
|
_glfw.x11.lastEventTime = event->xkey.time;
|
||||||
|
|
||||||
if (window->x11.ic)
|
if (window->x11.ic)
|
||||||
{
|
{
|
||||||
@ -1082,7 +1082,7 @@ static void processEvent(XEvent *event)
|
|||||||
{
|
{
|
||||||
const int key = translateKey(keycode);
|
const int key = translateKey(keycode);
|
||||||
const int mods = translateState(event->xkey.state);
|
const int mods = translateState(event->xkey.state);
|
||||||
window->x11.lastEventTime = event->xkey.time;
|
_glfw.x11.lastEventTime = event->xkey.time;
|
||||||
|
|
||||||
if (!_glfw.x11.xkb.detectable)
|
if (!_glfw.x11.xkb.detectable)
|
||||||
{
|
{
|
||||||
@ -1123,7 +1123,7 @@ static void processEvent(XEvent *event)
|
|||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
{
|
{
|
||||||
const int mods = translateState(event->xbutton.state);
|
const int mods = translateState(event->xbutton.state);
|
||||||
window->x11.lastEventTime = event->xbutton.time;
|
_glfw.x11.lastEventTime = event->xbutton.time;
|
||||||
|
|
||||||
if (event->xbutton.button == Button1)
|
if (event->xbutton.button == Button1)
|
||||||
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
|
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
|
||||||
@ -1158,7 +1158,7 @@ static void processEvent(XEvent *event)
|
|||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
{
|
{
|
||||||
const int mods = translateState(event->xbutton.state);
|
const int mods = translateState(event->xbutton.state);
|
||||||
window->x11.lastEventTime = event->xbutton.time;
|
_glfw.x11.lastEventTime = event->xbutton.time;
|
||||||
|
|
||||||
if (event->xbutton.button == Button1)
|
if (event->xbutton.button == Button1)
|
||||||
{
|
{
|
||||||
@ -1215,7 +1215,7 @@ static void processEvent(XEvent *event)
|
|||||||
{
|
{
|
||||||
const int x = event->xmotion.x;
|
const int x = event->xmotion.x;
|
||||||
const int y = event->xmotion.y;
|
const int y = event->xmotion.y;
|
||||||
window->x11.lastEventTime = event->xmotion.time;
|
_glfw.x11.lastEventTime = event->xmotion.time;
|
||||||
|
|
||||||
if (x != window->x11.warpCursorPosX || y != window->x11.warpCursorPosY)
|
if (x != window->x11.warpCursorPosX || y != window->x11.warpCursorPosY)
|
||||||
{
|
{
|
||||||
@ -2300,10 +2300,10 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
XFlush(_glfw.x11.display);
|
XFlush(_glfw.x11.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
double _glfwPlatformGetEventTime(_GLFWwindow* window)
|
double _glfwPlatformGetEventTime(void)
|
||||||
{
|
{
|
||||||
/* X11 events are stored in milliseconds */
|
/* X11 events are stored in milliseconds */
|
||||||
return (double) window->x11.lastEventTime / 1000.0;
|
return (double) _glfw.x11.lastEventTime / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
void _glfwPlatformPollEvents(void)
|
||||||
|
@ -270,7 +270,7 @@ static void window_pos_callback(GLFWwindow* window, int x, int y)
|
|||||||
{
|
{
|
||||||
Slot* slot = glfwGetWindowUserPointer(window);
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
printf("%08x to %i at %0.3f (event time: %0.3f): Window position: %i %i\n",
|
printf("%08x to %i at %0.3f (event time: %0.3f): Window position: %i %i\n",
|
||||||
counter++, slot->number, glfwGetTime(), glfwGetEventTime(window), x, y);
|
counter++, slot->number, glfwGetTime(), glfwGetEventTime(), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow* window, int width, int height)
|
static void window_size_callback(GLFWwindow* window, int width, int height)
|
||||||
@ -337,7 +337,7 @@ static void mouse_button_callback(GLFWwindow* window, int button, int action, in
|
|||||||
{
|
{
|
||||||
Slot* slot = glfwGetWindowUserPointer(window);
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
printf("%08x to %i at %0.3f (event time: %0.3f): Mouse button %i (%s) (with%s) was %s\n",
|
printf("%08x to %i at %0.3f (event time: %0.3f): Mouse button %i (%s) (with%s) was %s\n",
|
||||||
counter++, slot->number, glfwGetTime(), glfwGetEventTime(window), button,
|
counter++, slot->number, glfwGetTime(), glfwGetEventTime(), button,
|
||||||
get_button_name(button),
|
get_button_name(button),
|
||||||
get_mods_name(mods),
|
get_mods_name(mods),
|
||||||
get_action_name(action));
|
get_action_name(action));
|
||||||
@ -347,7 +347,7 @@ static void cursor_position_callback(GLFWwindow* window, double x, double y)
|
|||||||
{
|
{
|
||||||
Slot* slot = glfwGetWindowUserPointer(window);
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
printf("%08x to %i at %0.3f (event time: %0.3f): Cursor position: %f %f\n",
|
printf("%08x to %i at %0.3f (event time: %0.3f): Cursor position: %f %f\n",
|
||||||
counter++, slot->number, glfwGetTime(), glfwGetEventTime(window), x, y);
|
counter++, slot->number, glfwGetTime(), glfwGetEventTime(), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cursor_enter_callback(GLFWwindow* window, int entered)
|
static void cursor_enter_callback(GLFWwindow* window, int entered)
|
||||||
@ -373,7 +373,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
|||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
printf("%08x to %i at %0.3f (event time: %0.3f): Key 0x%04x Scancode 0x%04x (%s) (%s) (with%s) was %s\n",
|
printf("%08x to %i at %0.3f (event time: %0.3f): Key 0x%04x Scancode 0x%04x (%s) (%s) (with%s) was %s\n",
|
||||||
counter++, slot->number, glfwGetTime(), glfwGetEventTime(window), key, scancode,
|
counter++, slot->number, glfwGetTime(), glfwGetEventTime(), key, scancode,
|
||||||
get_key_name(key),
|
get_key_name(key),
|
||||||
name,
|
name,
|
||||||
get_mods_name(mods),
|
get_mods_name(mods),
|
||||||
@ -382,7 +382,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("%08x to %i at %0.3f (event time: %0.3f): Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n",
|
printf("%08x to %i at %0.3f (event time: %0.3f): Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n",
|
||||||
counter++, slot->number, glfwGetTime(), glfwGetEventTime(window), key, scancode,
|
counter++, slot->number, glfwGetTime(), glfwGetEventTime(), key, scancode,
|
||||||
get_key_name(key),
|
get_key_name(key),
|
||||||
get_mods_name(mods),
|
get_mods_name(mods),
|
||||||
get_action_name(action));
|
get_action_name(action));
|
||||||
@ -407,7 +407,7 @@ static void char_callback(GLFWwindow* window, unsigned int codepoint)
|
|||||||
{
|
{
|
||||||
Slot* slot = glfwGetWindowUserPointer(window);
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
printf("%08x to %i at %0.3f (event time: %0.3f): Character 0x%08x (%s) input\n",
|
printf("%08x to %i at %0.3f (event time: %0.3f): Character 0x%08x (%s) input\n",
|
||||||
counter++, slot->number, glfwGetTime(), glfwGetEventTime(window), codepoint,
|
counter++, slot->number, glfwGetTime(), glfwGetEventTime(), codepoint,
|
||||||
get_character_string(codepoint));
|
get_character_string(codepoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user