Fix [#26446] Quick extrude (Ctrl+LMB) works only one time

Reported by Michael R

This was one thing I didn't test when accepting patch [#26364]. It is important to not
send repeats of modifier keys.
This commit is contained in:
Nathan Letwory 2011-03-10 18:56:19 +00:00
parent efc697b481
commit d6b43fed31
2 changed files with 98 additions and 1 deletions

@ -454,8 +454,71 @@ GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, WPARAM wParam, LPAR
if (ri.header.dwType == RIM_TYPEKEYBOARD)
{
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
GHOST_ModifierKeys modifiers;
system->retrieveModifierKeys(modifiers);
*keyDown = !(ri.data.keyboard.Flags & RI_KEY_BREAK);
key = this->convertKey(window, ri.data.keyboard.VKey, ri.data.keyboard.MakeCode, (ri.data.keyboard.Flags&(RI_KEY_E1|RI_KEY_E0)));
// extra handling of modifier keys: don't send repeats out from GHOST
if(key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt)
{
bool changed = false;
GHOST_TModifierKeyMask modifier;
switch(key) {
case GHOST_kKeyLeftShift:
{
changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != *keyDown);
modifier = GHOST_kModifierKeyLeftShift;
}
break;
case GHOST_kKeyRightShift:
{
changed = (modifiers.get(GHOST_kModifierKeyRightShift) != *keyDown);
modifier = GHOST_kModifierKeyRightShift;
}
break;
case GHOST_kKeyLeftControl:
{
changed = (modifiers.get(GHOST_kModifierKeyLeftControl) != *keyDown);
modifier = GHOST_kModifierKeyLeftControl;
}
break;
case GHOST_kKeyRightControl:
{
changed = (modifiers.get(GHOST_kModifierKeyRightControl) != *keyDown);
modifier = GHOST_kModifierKeyRightControl;
}
break;
case GHOST_kKeyLeftAlt:
{
changed = (modifiers.get(GHOST_kModifierKeyLeftAlt) != *keyDown);
modifier = GHOST_kModifierKeyLeftAlt;
}
break;
case GHOST_kKeyRightAlt:
{
changed = (modifiers.get(GHOST_kModifierKeyRightAlt) != *keyDown);
modifier = GHOST_kModifierKeyRightAlt;
}
break;
default: break;
}
if(changed)
{
modifiers.set(modifier, *keyDown);
system->storeModifierKeys(modifiers);
}
else
{
key = GHOST_kKeyUnknown;
}
}
if(vk) *vk = ri.data.keyboard.VKey;
};
@ -586,6 +649,7 @@ GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, short vKey, shor
break;
}
}
return key;
}

@ -322,6 +322,14 @@ protected:
*/
virtual GHOST_TKey hardKey(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam, int * keyDown, char * vk);
/**
* Creates modifier key event(s) and updates the key data stored locally (m_modifierKeys).
* With the modifier keys, we want to distinguish left and right keys.
* Sometimes this is not possible (Windows ME for instance). Then, we want
* events generated for both keys.
* @param window The window receiving the event (the active window).
*/
GHOST_EventKey* processModifierKeys(GHOST_IWindow *window);
/**
* Creates mouse button event.
@ -380,6 +388,19 @@ protected:
*/
static void processMinMaxInfo(MINMAXINFO * minmax);
/**
* Returns the local state of the modifier keys (from the message queue).
* @param keys The state of the keys.
*/
inline virtual void retrieveModifierKeys(GHOST_ModifierKeys& keys) const;
/**
* Stores the state of the modifier keys locally.
* For internal use only!
* @param keys The new state of the modifier keys.
*/
inline virtual void storeModifierKeys(const GHOST_ModifierKeys& keys);
/**
* Check current key layout for AltGr
*/
@ -394,7 +415,9 @@ protected:
* Initiates WM_INPUT messages from keyboard
*/
GHOST_TInt32 initKeyboardRawInput(void);
/** The current state of the modifier keys. */
GHOST_ModifierKeys m_modifierKeys;
/** State variable set at initialization. */
bool m_hasPerformanceCounter;
/** High frequency timer variable. */
@ -418,6 +441,16 @@ protected:
#endif
};
inline void GHOST_SystemWin32::retrieveModifierKeys(GHOST_ModifierKeys& keys) const
{
keys = m_modifierKeys;
}
inline void GHOST_SystemWin32::storeModifierKeys(const GHOST_ModifierKeys& keys)
{
m_modifierKeys = keys;
}
inline void GHOST_SystemWin32::handleKeyboardChange(void)
{
m_keylayout = GetKeyboardLayout(0); // get keylayout for current thread