From b391e7f93f008b6f3c30c9bfb9ac0cd93de1a6c2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 22 Apr 2021 00:28:45 +0300 Subject: SL-14977 Extended AltGr to cover oem symbols Typing '}' via 'altgr+=' into a script makes the viewer to derender particles --- indra/newview/llviewerwindow.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerwindow.cpp') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 9c1aa772d8..2396f23e16 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -216,6 +216,7 @@ #if LL_WINDOWS #include // For Unicode conversion methods +#include "llwindowwin32.h" // For AltGr handling #endif // @@ -2766,9 +2767,11 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // of character handling. // Alt Gr can be additionally modified by Shift const MASK alt_gr = MASK_CONTROL | MASK_ALT; + LLWindowWin32 *window = static_cast(mWindow); + U32 raw_key = window->getRawWParam(); if ((mask & alt_gr) != 0 - && key >= 0x30 - && key <= 0x5A + && ((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 { -- cgit v1.2.3 From 01b1f15811da2fb681ab01abd31687a700a24a9b Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 28 Jul 2021 15:42:08 +0300 Subject: SL-15676 Allow Right Alt + Shift + H shortcut to show/hide HUDs when a floater is in focus. --- indra/newview/llviewerwindow.cpp | 94 +++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 45 deletions(-) (limited to 'indra/newview/llviewerwindow.cpp') 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(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(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(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; + } } } } -- cgit v1.2.3 From b078daf4d24d290abdc222e9cd3ef272c93ba5fa Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 19 Oct 2021 20:42:01 +0300 Subject: SL-14977 Fix passing wrong codes to ToUnicodeEx --- indra/newview/llviewerwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewerwindow.cpp') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 9c4eba25bc..783c46a33b 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2916,7 +2916,8 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // 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); + // 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. -- cgit v1.2.3