From c65278e9dc156ab6ccbcbc7d7a4239d17345f309 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 25 Apr 2007 09:32:12 +0000 Subject: [PATCH] From Martin Aumueller, " a collegue of mine noticed that on Windows and X11 the modifier state (such as Alt or Ctrl) would be applied one key press too late: e.g. press & hold Alt, press a, release Alt, press a, press a would generate the key sequence a, Alt-a, a instead of Alt-a, a, a. The problem is also present on Carbon. Moving the call to setModKeyMask in front of the call to keyPress fixed it for me on Carbon and X11. I suppose that this will fix the problem for Windows as well." --- src/osgViewer/GraphicsWindowCarbon.cpp | 4 ++-- src/osgViewer/GraphicsWindowWin32.cpp | 4 ++-- src/osgViewer/GraphicsWindowX11.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/osgViewer/GraphicsWindowCarbon.cpp b/src/osgViewer/GraphicsWindowCarbon.cpp index a6c68b74a..ac2c8adfb 100644 --- a/src/osgViewer/GraphicsWindowCarbon.cpp +++ b/src/osgViewer/GraphicsWindowCarbon.cpp @@ -974,15 +974,15 @@ bool GraphicsWindowCarbon::handleKeyboardEvent(EventRef theEvent) case kEventRawKeyDown: case kEventRawKeyRepeat: { - getEventQueue()->keyPress(keychar); getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask); + getEventQueue()->keyPress(keychar); break; } case kEventRawKeyUp: { - getEventQueue()->keyRelease(keychar); getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask); + getEventQueue()->keyRelease(keychar); break; } diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 55f2220ac..7c9956b2b 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -1974,8 +1974,8 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W int keySymbol = 0; unsigned int modifierMask = 0; adaptKey(wParam, lParam, keySymbol, modifierMask); - getEventQueue()->keyPress(keySymbol, eventTime); getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask); + getEventQueue()->keyPress(keySymbol, eventTime); } break; @@ -1988,8 +1988,8 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W int keySymbol = 0; unsigned int modifierMask = 0; adaptKey(wParam, lParam, keySymbol, modifierMask); - getEventQueue()->keyRelease(keySymbol, eventTime); getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask); + getEventQueue()->keyRelease(keySymbol, eventTime); } break; diff --git a/src/osgViewer/GraphicsWindowX11.cpp b/src/osgViewer/GraphicsWindowX11.cpp index cc1763d44..fd408aafa 100644 --- a/src/osgViewer/GraphicsWindowX11.cpp +++ b/src/osgViewer/GraphicsWindowX11.cpp @@ -27,7 +27,7 @@ #include #include -#include /* For CARD16 */ +#include /* For CARD16 */ #include @@ -932,8 +932,8 @@ void GraphicsWindowX11::checkEvents() unsigned int modifierMask = 0; adaptKey(ev.xkey, keySymbol, modifierMask); - getEventQueue()->keyPress(keySymbol, eventTime); getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask); + getEventQueue()->keyPress(keySymbol, eventTime); break; } @@ -947,8 +947,8 @@ void GraphicsWindowX11::checkEvents() unsigned int modifierMask = 0; adaptKey(ev.xkey, keySymbol, modifierMask); - getEventQueue()->keyRelease(keySymbol, eventTime); getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask); + getEventQueue()->keyRelease(keySymbol, eventTime); break; }