summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2021-07-28 15:42:08 +0300
committerMnikolenko Productengine <mnikolenko@productengine.com>2021-07-28 15:42:08 +0300
commit01b1f15811da2fb681ab01abd31687a700a24a9b (patch)
treeffffca5c255a11dd98888915fd78ebc536cbf9c0 /indra
parent3a476a8296c78eef1007c6fdca7188e78f9b6280 (diff)
SL-15676 Allow Right Alt + Shift + H shortcut to show/hide HUDs when a floater is in focus.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llviewerwindow.cpp94
1 files changed, 49 insertions, 45 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 11bdad7e87..9c4eba25bc 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2881,59 +2881,63 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
if (keyboard_focus
&& !gFocusMgr.getKeystrokesOnly())
{
-#ifdef LL_WINDOWS
- // On windows Alt Gr key generates additional Ctrl event, as result handling situations
- // like 'AltGr + D' will result in 'Alt+Ctrl+D'. If it results in WM_CHAR, don't let it
- // pass into menu or it will trigger 'develop' menu assigned to this combination on top
- // of character handling.
- // Alt Gr can be additionally modified by Shift
- const MASK alt_gr = MASK_CONTROL | MASK_ALT;
- LLWindowWin32 *window = static_cast<LLWindowWin32*>(mWindow);
- U32 raw_key = window->getRawWParam();
- if ((mask & alt_gr) != 0
- && ((raw_key >= 0x30 && raw_key <= 0x5A) //0-9, plus normal chartacters
- || (raw_key >= 0xBA && raw_key <= 0xE4)) // Misc/OEM characters that can be covered by AltGr, ex: -, =, ~
- && (GetKeyState(VK_RMENU) & 0x8000) != 0
- && (GetKeyState(VK_RCONTROL) & 0x8000) == 0) // ensure right control is not pressed, only left one
+ LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(keyboard_focus);
+ if (cur_focus && cur_focus->acceptsTextInput())
{
- // Alt Gr key is represented as right alt and left control.
- // Any alt+ctrl combination is treated as Alt Gr by TranslateMessage() and
- // will generate a WM_CHAR message, but here we only treat virtual Alt Graph
- // key by checking if this specific combination has unicode char.
- //
- // I decided to handle only virtual RAlt+LCtrl==AltGr combination to minimize
- // impact on menu, but the right way might be to handle all Alt+Ctrl calls.
-
- BYTE keyboard_state[256];
- if (GetKeyboardState(keyboard_state))
+#ifdef LL_WINDOWS
+ // On windows Alt Gr key generates additional Ctrl event, as result handling situations
+ // like 'AltGr + D' will result in 'Alt+Ctrl+D'. If it results in WM_CHAR, don't let it
+ // pass into menu or it will trigger 'develop' menu assigned to this combination on top
+ // of character handling.
+ // Alt Gr can be additionally modified by Shift
+ const MASK alt_gr = MASK_CONTROL | MASK_ALT;
+ LLWindowWin32 *window = static_cast<LLWindowWin32*>(mWindow);
+ U32 raw_key = window->getRawWParam();
+ if ((mask & alt_gr) != 0
+ && ((raw_key >= 0x30 && raw_key <= 0x5A) //0-9, plus normal chartacters
+ || (raw_key >= 0xBA && raw_key <= 0xE4)) // Misc/OEM characters that can be covered by AltGr, ex: -, =, ~
+ && (GetKeyState(VK_RMENU) & 0x8000) != 0
+ && (GetKeyState(VK_RCONTROL) & 0x8000) == 0) // ensure right control is not pressed, only left one
{
- const int char_count = 6;
- wchar_t chars[char_count];
- HKL layout = GetKeyboardLayout(0);
- // ToUnicodeEx changes buffer state on OS below Win10, which is undesirable,
- // but since we already did a TranslateMessage() in gatherInput(), this
- // should have no negative effect
- int res = ToUnicodeEx(key, 0, keyboard_state, chars, char_count, 1 << 2 /*do not modify buffer flag*/, layout);
- if (res == 1 && chars[0] >= 0x20)
+ // Alt Gr key is represented as right alt and left control.
+ // Any alt+ctrl combination is treated as Alt Gr by TranslateMessage() and
+ // will generate a WM_CHAR message, but here we only treat virtual Alt Graph
+ // key by checking if this specific combination has unicode char.
+ //
+ // I decided to handle only virtual RAlt+LCtrl==AltGr combination to minimize
+ // impact on menu, but the right way might be to handle all Alt+Ctrl calls.
+
+ BYTE keyboard_state[256];
+ if (GetKeyboardState(keyboard_state))
{
- // Let it fall through to character handler and get a WM_CHAR.
- return TRUE;
+ const int char_count = 6;
+ wchar_t chars[char_count];
+ HKL layout = GetKeyboardLayout(0);
+ // ToUnicodeEx changes buffer state on OS below Win10, which is undesirable,
+ // but since we already did a TranslateMessage() in gatherInput(), this
+ // should have no negative effect
+ int res = ToUnicodeEx(key, 0, keyboard_state, chars, char_count, 1 << 2 /*do not modify buffer flag*/, layout);
+ if (res == 1 && chars[0] >= 0x20)
+ {
+ // Let it fall through to character handler and get a WM_CHAR.
+ return TRUE;
+ }
}
}
- }
#endif
- if (!(mask & (MASK_CONTROL | MASK_ALT)))
- {
- // We have keyboard focus, and it's not an accelerator
- if (keyboard_focus && keyboard_focus->wantsKeyUpKeyDown())
- {
- return keyboard_focus->handleKey(key, mask, FALSE);
- }
- else if (key < 0x80)
+ if (!(mask & (MASK_CONTROL | MASK_ALT)))
{
- // Not a special key, so likely (we hope) to generate a character. Let it fall through to character handler first.
- return TRUE;
+ // We have keyboard focus, and it's not an accelerator
+ if (keyboard_focus && keyboard_focus->wantsKeyUpKeyDown())
+ {
+ return keyboard_focus->handleKey(key, mask, FALSE);
+ }
+ else if (key < 0x80)
+ {
+ // Not a special key, so likely (we hope) to generate a character. Let it fall through to character handler first.
+ return TRUE;
+ }
}
}
}