summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerwindow.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2022-02-28 21:54:21 +0200
committerAndrey Lihatskiy <alihatskiy@productengine.com>2022-02-28 21:54:21 +0200
commit73eec8913135127a1d31d3f1dc766f96908f984d (patch)
tree66ae3fec58046505fc80b15352957696d1ab4378 /indra/newview/llviewerwindow.cpp
parentce6dd53f9c364f46e30d0eedb1c6a701fbad8885 (diff)
parent6ca09a94554ec01f5c94ec60fffd01d7e33f3546 (diff)
Merge branch 'master' into DRTVWR-540-maint
# Conflicts: # autobuild.xml # indra/llcommon/llsys.cpp # indra/newview/app_settings/key_bindings.xml # indra/newview/llfloatereditextdaycycle.cpp
Diffstat (limited to 'indra/newview/llviewerwindow.cpp')
-rw-r--r--indra/newview/llviewerwindow.cpp94
1 files changed, 51 insertions, 43 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 544a059fe8..9334fa5c76 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -215,6 +215,7 @@
#if LL_WINDOWS
#include <tchar.h> // For Unicode conversion methods
+#include "llwindowwin32.h" // For AltGr handling
#endif
//
@@ -2893,57 +2894,64 @@ 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;
- if ((mask & alt_gr) != 0
- && key >= 0x30
- && key <= 0x5A
- && (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
+ // ToUnicodeEx works with virtual key codes
+ int res = ToUnicodeEx(raw_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;
+ }
}
}
}