[Libreoffice-commits] online.git: kit/ChildSession.cpp loleaflet/src

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 5 16:44:29 UTC 2020


 kit/ChildSession.cpp                    |   32 ++++++++++++++++++++++++--------
 loleaflet/src/layer/marker/TextInput.js |    4 +---
 2 files changed, 25 insertions(+), 11 deletions(-)

New commits:
commit 9142828282c1147244a4df700ee52d28cf27a37d
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Wed Aug 5 17:16:08 2020 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Aug 5 18:44:10 2020 +0200

    textinput: use a single input message per key on the wire.
    
    Change-Id: Ibd0f7afb98c8ed278751c4b5b46d7ce2467cd71f
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100184
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index dc0e9ec3d..281360654 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1242,15 +1242,25 @@ bool ChildSession::insertFile(const char* /*buffer*/, int /*length*/, const Stri
 bool ChildSession::extTextInputEvent(const char* /*buffer*/, int /*length*/,
                                      const StringVector& tokens)
 {
-    int id, type;
+    int id, type = -1;
     std::string text;
-    if (tokens.size() < 4 ||
-        !getTokenInteger(tokens[1], "id", id) || id < 0 ||
-        !getTokenKeyword(tokens[2], "type",
-                        {{"input", LOK_EXT_TEXTINPUT}, {"end", LOK_EXT_TEXTINPUT_END}},
-                         type) ||
-        !getTokenString(tokens[3], "text", text))
+    bool error = false;
+
+    if (tokens.size() < 3)
+        error = true;
+    else if (!getTokenInteger(tokens[1], "id", id) || id < 0)
+        error = true;
+    else {
+        // back-compat 'type'
+        if (getTokenKeyword(tokens[2], "type",
+                            {{"input", LOK_EXT_TEXTINPUT}, {"end", LOK_EXT_TEXTINPUT_END}},
+                            type))
+            error = !getTokenString(tokens[3], "text", text);
+        else // normal path:
+            error = !getTokenString(tokens[2], "text", text);
+    }
 
+    if (error)
     {
         sendTextFrameAndLogError("error: cmd=" + std::string(tokens[0]) + " kind=syntax");
         return false;
@@ -1260,7 +1270,13 @@ bool ChildSession::extTextInputEvent(const char* /*buffer*/, int /*length*/,
     URI::decode(text, decodedText);
 
     getLOKitDocument()->setView(_viewId);
-    getLOKitDocument()->postWindowExtTextInputEvent(id, type, decodedText.c_str());
+    if (type >= 0)
+        getLOKitDocument()->postWindowExtTextInputEvent(id, type, decodedText.c_str());
+    else
+    {
+        getLOKitDocument()->postWindowExtTextInputEvent(id, LOK_EXT_TEXTINPUT, decodedText.c_str());
+        getLOKitDocument()->postWindowExtTextInputEvent(id, LOK_EXT_TEXTINPUT_END, decodedText.c_str());
+    }
 
     return true;
 }
diff --git a/loleaflet/src/layer/marker/TextInput.js b/loleaflet/src/layer/marker/TextInput.js
index 8e7196e96..1910d93d0 100644
--- a/loleaflet/src/layer/marker/TextInput.js
+++ b/loleaflet/src/layer/marker/TextInput.js
@@ -706,9 +706,7 @@ L.TextInput = L.Layer.extend({
 			var encodedText = encodeURIComponent(text);
 			var winId = this._map.getWinId();
 			this._map._socket.sendMessage(
-				'textinput id=' + winId + ' type=input text=' + encodedText);
-			this._map._socket.sendMessage(
-				'textinput id=' + winId + ' type=end text=' + encodedText);
+				'textinput id=' + winId + ' text=' + encodedText);
 		}
 	},
 


More information about the Libreoffice-commits mailing list