diff --git a/indra/llwindow/llwindowsdl2.cpp b/indra/llwindow/llwindowsdl2.cpp index 17bf62d7b5..c1f99e39f9 100644 --- a/indra/llwindow/llwindowsdl2.cpp +++ b/indra/llwindow/llwindowsdl2.cpp @@ -393,6 +393,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, // IME - International input compositing, i.e. for Japanese / Chinese text input // Preeditor means here the actual XUI input field currently in use + mIMEEnabled = false; mPreeditor = nullptr; #if LL_X11 @@ -661,7 +662,10 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B // IME - International input compositing, i.e. for Japanese / Chinese text input // Request the IME interface to show over-the-top compositing while typing - SDL_SetHint( SDL_HINT_IME_INTERNAL_EDITING, "1"); + if (mIMEEnabled) + { + SDL_SetHint( SDL_HINT_IME_INTERNAL_EDITING, "1"); + } if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0 ) { @@ -883,7 +887,12 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B glClear(GL_COLOR_BUFFER_BIT); SDL_GL_SwapWindow(mWindow); - SDL_StartTextInput(); + // start text input immediately when IME is not enabled + if (!mIMEEnabled) + { + SDL_StartTextInput(); + } + //make sure multisampling is disabled by default glDisable(GL_MULTISAMPLE_ARB); @@ -1821,7 +1830,7 @@ void LLWindowSDL::gatherInput() mKeyVirtualKey = SDLK_RETURN; } - if (mKeyVirtualKey == SDLK_RETURN) + if (mKeyVirtualKey == SDLK_RETURN && mIMEEnabled) { // block spurious enter key events that break up IME entered lines in teh wrong places U64 eventTimeDiff = LLFrameTimer::getTotalTime() - previousTextinputTime; @@ -2670,11 +2679,32 @@ void LLWindowSDL::toggleVSync(bool enable_vsync) } // +void LLWindowSDL::enableIME(bool b) +{ + mIMEEnabled = b; + + if (mIMEEnabled) + { + SDL_SetHint( SDL_HINT_IME_INTERNAL_EDITING, "1"); + SDL_StopTextInput(); + } + else + { + SDL_SetHint( SDL_HINT_IME_INTERNAL_EDITING, "0"); + SDL_StartTextInput(); + } +} + // IME - International input compositing, i.e. for Japanese / Chinese text input // Put the IME window at the right place (near current text input). // Point coordinates should be the top of the current text line. void LLWindowSDL::setLanguageTextInput(const LLCoordGL& position) { + if (!mIMEEnabled) + { + return; + } + LLCoordWindow win_pos; convertCoords( position, &win_pos ); @@ -2690,6 +2720,11 @@ void LLWindowSDL::setLanguageTextInput(const LLCoordGL& position) // IME - International input compositing, i.e. for Japanese / Chinese text input void LLWindowSDL::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) { + if (!mIMEEnabled) + { + return; + } + if (preeditor != mPreeditor && !b) { // This condition may occur with a call to diff --git a/indra/llwindow/llwindowsdl2.h b/indra/llwindow/llwindowsdl2.h index 05530f8766..83807d12db 100644 --- a/indra/llwindow/llwindowsdl2.h +++ b/indra/llwindow/llwindowsdl2.h @@ -136,6 +136,8 @@ public: /*virtual*/ void setTitle(const std::string& title); + void enableIME(bool b); + static std::vector getDynamicFallbackFontList(); // Not great that these are public, but they have to be accessible @@ -205,6 +207,7 @@ protected: SDL_GLContext mContext; SDL_Cursor* mSDLCursors[UI_CURSOR_COUNT]; LLPreeditor* mPreeditor; + bool mIMEEnabled; std::string mWindowTitle; double mOriginalAspectRatio; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index e3ead578ed..913a057fa7 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -26247,6 +26247,17 @@ Change of this parameter will affect the layout of buttons in notification toast Value -4 + SDL2IMEEnabled + + Comment + Enable the international input method editor for Japanese, Chinese, etc. + Persist + 1 + Type + Boolean + Value + 0 + FSLocalMeshScaleAlwaysMeters Comment diff --git a/indra/newview/fschathistory.cpp b/indra/newview/fschathistory.cpp index 1ca779bd0b..e3923c60e0 100644 --- a/indra/newview/fschathistory.cpp +++ b/indra/newview/fschathistory.cpp @@ -1292,6 +1292,12 @@ void FSChatHistory::setFocus(BOOL b) { LLTextEditor::setFocus(b); + // IME - Don't do anything here if IME is disabled + if (!gSavedSettings.getBOOL("SDL2IMEEnabled")) + { + return; + } + // IME - International input compositing, i.e. for Japanese / Chinese text input updateChatInputLine(); diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index ae1e9773fd..59a80dd4c1 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -805,6 +805,12 @@ BOOL LLFloaterPreference::postBuild() mPopupFilter = getChild("popup_filter"); // + // SDL2 IME support +#if LL_SDL2 + childSetVisible("use_ime", true); +#endif + // + return TRUE; } diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 4a27a83eb9..f5050b79f3 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -32,6 +32,12 @@ // Library includes #include "llwindow.h" // getGamma() +// Handle IME text input getting enabled or disabled +#if LL_SDL2 +#include "llwindowsdl2.h" +#endif +// + // For Listeners #include "llaudioengine.h" #include "llagent.h" @@ -1140,6 +1146,17 @@ void handleFPSTuningStrategyChanged(const LLSD& newValue) // +// Handle IME text input getting enabled or disabled +#if LL_SDL2 +static bool handleSDL2IMEEnabledChanged(const LLSD& newvalue) +{ + ((LLWindowSDL*)gViewerWindow->getWindow())->enableIME(newvalue.asBoolean()); + + return true; +} +#endif +// + //////////////////////////////////////////////////////////////////////////// void settings_setup_listeners() @@ -1406,6 +1423,12 @@ void settings_setup_listeners() gSavedSettings.getControl("FSAutoTuneImpostorByDistEnabled")->getSignal()->connect(boost::bind(&handleUserImpostorByDistEnabledChanged, _2)); gSavedSettings.getControl("FSTuningFPSStrategy")->getSignal()->connect(boost::bind(&handleFPSTuningStrategyChanged, _2)); // + + // Handle IME text input getting enabled or disabled +#if LL_SDL2 + gSavedSettings.getControl("SDL2IMEEnabled")->getSignal()->connect(boost::bind(&handleSDL2IMEEnabledChanged, _2)); +#endif + // } #if TEST_CACHED_CONTROL diff --git a/indra/newview/skins/default/xui/en/panel_preferences_general.xml b/indra/newview/skins/default/xui/en/panel_preferences_general.xml index 4541f0228d..6ae637916e 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_general.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_general.xml @@ -114,6 +114,17 @@ width="130"> (Requires restart) +