[Libreoffice-commits] online.git: loolwsd/ChildProcessSession.cpp
Jan Holesovsky
kendy at collabora.com
Mon Feb 8 17:21:29 UTC 2016
loolwsd/ChildProcessSession.cpp | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
New commits:
commit 7c96094c42bc5becbf135301e0abb5cb478a790a
Author: Jan Holesovsky <kendy at collabora.com>
Date: Mon Feb 8 15:44:13 2016 +0100
loolwsd: Make the mouse command in loolwsd compatible with older loleaflet.
diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index 5933856..cd763bb 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -1094,9 +1094,14 @@ bool ChildProcessSession::keyEvent(const char* /*buffer*/, int /*length*/, Strin
bool ChildProcessSession::mouseEvent(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
- int type, x, y, count, buttons, modifier;
+ int type, x, y, count;
+ bool success = true;
- if (tokens.count() != 7 ||
+ // default values for compatibility reasons with older loleaflets
+ int buttons = 0;
+ int modifier = 0;
+
+ if (tokens.count() < 5 ||
!getTokenKeyword(tokens[1], "type",
{{"buttondown", LOK_MOUSEEVENT_MOUSEBUTTONDOWN},
{"buttonup", LOK_MOUSEEVENT_MOUSEBUTTONUP},
@@ -1104,9 +1109,20 @@ bool ChildProcessSession::mouseEvent(const char* /*buffer*/, int /*length*/, Str
type) ||
!getTokenInteger(tokens[2], "x", x) ||
!getTokenInteger(tokens[3], "y", y) ||
- !getTokenInteger(tokens[4], "count", count) ||
- !getTokenInteger(tokens[5], "buttons", buttons) ||
- !getTokenInteger(tokens[6], "modifier", modifier))
+ !getTokenInteger(tokens[4], "count", count))
+ {
+ success = false;
+ }
+
+ // compatibility with older loleaflets
+ if (success && tokens.count() > 5 && !getTokenInteger(tokens[5], "buttons", buttons))
+ success = false;
+
+ // compatibility with older loleaflets
+ if (success && tokens.count() > 6 && !getTokenInteger(tokens[6], "modifier", modifier))
+ success = false;
+
+ if (!success)
{
sendTextFrame("error: cmd=mouse kind=syntax");
return false;
More information about the Libreoffice-commits
mailing list