wsd: support resizing of the sidebar

(cherry picked from commit d3a900d3484e4e6690d8c625f1edc73289baba4d)

Change-Id: If7d7b356563f503dfedfb0686c1d1b5be9b7b221
This commit is contained in:
Ashod Nakashian 2018-10-21 19:32:41 -04:00
parent d7ed6988fb
commit 30c3de53f7
4 changed files with 29 additions and 3 deletions

View file

@ -248,6 +248,10 @@ bool ChildSession::_handleInput(const char *buffer, int length)
{
return renderWindow(buffer, length, tokens);
}
else if (tokens[0] == "resizewindow")
{
return resizeWindow(buffer, length, tokens);
}
else if (tokens[0] == "tile" || tokens[0] == "tilecombine")
{
assert(false && "Tile traffic should go through the DocumentBroker-LoKit WS.");
@ -1489,6 +1493,26 @@ bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const st
return true;
}
bool ChildSession::resizeWindow(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens)
{
const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1].c_str(), nullptr, 10) : 0);
getLOKitDocument()->setView(_viewId);
std::string size;
if (tokens.size() > 2 && getTokenString(tokens[2], "size", size))
{
const std::vector<int> sizeParts = LOOLProtocol::tokenizeInts(size, ',');
if (sizeParts.size() == 2)
{
getLOKitDocument()->resizeWindow(winId, sizeParts[0], sizeParts[1]);
return true;
}
}
LOG_WRN("resizewindow command doesn't specify sensible size= attribute.");
return true;
}
bool ChildSession::sendWindowCommand(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens)
{

View file

@ -261,6 +261,7 @@ private:
bool selectText(const char* buffer, int length, const std::vector<std::string>& tokens);
bool selectGraphic(const char* buffer, int length, const std::vector<std::string>& tokens);
bool renderWindow(const char* buffer, int length, const std::vector<std::string>& tokens);
bool resizeWindow(const char* buffer, int length, const std::vector<std::string>& tokens);
bool resetSelection(const char* buffer, int length, const std::vector<std::string>& tokens);
bool saveAs(const char* buffer, int length, const std::vector<std::string>& tokens);
bool setClientPart(const char* buffer, int length, const std::vector<std::string>& tokens);

View file

@ -2279,7 +2279,7 @@ protected:
document.reset();
}
else if (tokens[0] == "tile" || tokens[0] == "tilecombine" || tokens[0] == "canceltiles" ||
tokens[0] == "paintwindow" ||
tokens[0] == "paintwindow" || tokens[0] == "resizewindow" ||
LOOLProtocol::getFirstToken(tokens[0], '-') == "child")
{
if (document)

View file

@ -425,7 +425,8 @@ bool ClientSession::_handleInput(const char *buffer, int length)
tokens[0] != "exportsignanduploaddocument" &&
tokens[0] != "rendershapeselection" &&
tokens[0] != "removesession" &&
tokens[0] != "renamefile")
tokens[0] != "renamefile" &&
tokens[0] != "resizewindow")
{
LOG_ERR("Session [" << getId() << "] got unknown command [" << tokens[0] << "].");
sendTextFrame("error: cmd=" + tokens[0] + " kind=unknown");
@ -1118,7 +1119,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
}
else
return false;
}
}
}
#if !MOBILEAPP
else if (tokens.size() == 3 && tokens[0] == "saveas:")