diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-12-02 13:48:27 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-12-02 13:48:27 +0200 |
commit | 9abac37e42781aaacfc9331627182c2e83f98fd9 (patch) | |
tree | bd7366d36008c0faaa10086a795131f8b8bf1944 /indra/newview | |
parent | dd887e24d5afd103f3b7b5ca756daad50c46953e (diff) |
SL-14438 Fixed Viewer lost ability to assign Masks as keys
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llsetkeybinddialog.cpp | 41 | ||||
-rw-r--r-- | indra/newview/llsetkeybinddialog.h | 6 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 12 |
3 files changed, 46 insertions, 13 deletions
diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp index 4eb76c9d89..a7f005ec19 100644 --- a/indra/newview/llsetkeybinddialog.cpp +++ b/indra/newview/llsetkeybinddialog.cpp @@ -164,14 +164,14 @@ void LLSetKeyBindDialog::setParent(LLKeyBindResponderInterface* parent, LLView* } // static -bool LLSetKeyBindDialog::recordKey(KEY key, MASK mask) +bool LLSetKeyBindDialog::recordKey(KEY key, MASK mask, BOOL down) { if (sRecordKeys) { LLSetKeyBindDialog* dialog = LLFloaterReg::getTypedInstance<LLSetKeyBindDialog>("keybind_dialog", LLSD()); if (dialog && dialog->getVisible()) { - return dialog->recordAndHandleKey(key, mask); + return dialog->recordAndHandleKey(key, mask, down); } else { @@ -182,7 +182,7 @@ bool LLSetKeyBindDialog::recordKey(KEY key, MASK mask) return false; } -bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask) +bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask, BOOL down) { if ((key == 'Q' && mask == MASK_CONTROL) || key == KEY_ESCAPE) @@ -208,13 +208,35 @@ bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask) return false; } - if ((mKeyFilterMask & ALLOW_MASKS) == 0 - && (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT)) + if (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT) { - // mask by themself are not allowed - return false; + // Mask keys get special treatment + if (down == TRUE) + { + // Most keys are handled on 'down' event because menu is handled on 'down' + // masks are exceptions to let other keys be handled + return false; + } + if ((mKeyFilterMask & ALLOW_MASKS) == 0) + { + // Mask by themself are not allowed + return false; + } + // Mask up event often generates things like 'shift key + shift mask', filter it out. + if (key == KEY_CONTROL) + { + mask &= ~MASK_CONTROL; + } + if (key == KEY_SHIFT) + { + mask &= ~MASK_SHIFT; + } + if (key == KEY_ALT) + { + mask &= ~MASK_ALT; + } } - else if ((mKeyFilterMask & ALLOW_KEYS) == 0) + if ((mKeyFilterMask & ALLOW_KEYS) == 0) { // basic keys not allowed return false; @@ -233,6 +255,9 @@ bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask) } setKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); + // Note/Todo: To warranty zero interference we should also consume + // an 'up' event if we recorded on 'down', not just close floater + // on first recorded combination. sRecordKeys = false; closeFloater(); return true; diff --git a/indra/newview/llsetkeybinddialog.h b/indra/newview/llsetkeybinddialog.h index 70190230e4..ec3c813a66 100644 --- a/indra/newview/llsetkeybinddialog.h +++ b/indra/newview/llsetkeybinddialog.h @@ -39,7 +39,7 @@ static const U32 ALLOW_MASK_MOUSE = 2; static const U32 ALLOW_KEYS = 4; //keyboard static const U32 ALLOW_MASK_KEYS = 8; static const U32 ALLOW_MASKS = 16; -static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS; +static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASKS | ALLOW_MASK_KEYS; class LLKeyBindResponderInterface @@ -68,7 +68,7 @@ public: // Wrapper around recordAndHandleKey // It does not record, it handles, but handleKey function is already in use - static bool recordKey(KEY key, MASK mask); + static bool recordKey(KEY key, MASK mask, BOOL down); BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down); static void onCancel(void* user_data); @@ -79,7 +79,7 @@ public: class Updater; private: - bool recordAndHandleKey(KEY key, MASK mask); + bool recordAndHandleKey(KEY key, MASK mask, BOOL down); void setKeyBind(EMouseClickType click, KEY key, MASK mask, bool all_modes); LLKeyBindResponderInterface *pParent; LLCheckBoxCtrl *pCheckBox; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 93f8cce5c7..9c1aa772d8 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2695,6 +2695,13 @@ void LLViewerWindow::draw() // Takes a single keyup event, usually when UI is visible BOOL LLViewerWindow::handleKeyUp(KEY key, MASK mask) { + if (LLSetKeyBindDialog::recordKey(key, mask, FALSE)) + { + LL_DEBUGS() << "KeyUp handled by LLSetKeyBindDialog" << LL_ENDL; + LLViewerEventRecorder::instance().logKeyEvent(key, mask); + return TRUE; + } + LLFocusableElement* keyboard_focus = gFocusMgr.getKeyboardFocus(); if (keyboard_focus @@ -2738,8 +2745,9 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // hide tooltips on keypress LLToolTipMgr::instance().blockToolTips(); - // let menus handle navigation keys for navigation - if (LLSetKeyBindDialog::recordKey(key, mask)) + // Menus get handled on key down instead of key up + // so keybindings have to be recorded before that + if (LLSetKeyBindDialog::recordKey(key, mask, TRUE)) { LL_DEBUGS() << "Key handled by LLSetKeyBindDialog" << LL_ENDL; LLViewerEventRecorder::instance().logKeyEvent(key,mask); |