2015-11-09 11:36:37 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
2023-11-09 19:23:00 +01:00
|
|
|
* Copyright the Collabora Online contributors.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*
|
2015-11-09 11:36:37 +01:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2017-12-20 14:06:26 +01:00
|
|
|
#include <config.h>
|
2017-03-08 17:38:22 +01:00
|
|
|
|
2024-05-08 18:47:53 +02:00
|
|
|
#include "KitQueue.hpp"
|
2024-05-09 16:29:49 +02:00
|
|
|
|
|
|
|
#include <string.h>
|
2020-04-18 12:55:50 +02:00
|
|
|
#include <climits>
|
2015-11-09 11:36:37 +01:00
|
|
|
#include <algorithm>
|
2024-01-05 08:16:13 +01:00
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
2021-05-12 18:55:16 +02:00
|
|
|
#include <iostream>
|
2015-11-09 11:36:37 +01:00
|
|
|
|
2024-04-18 20:47:57 +02:00
|
|
|
#include "JsonUtil.hpp"
|
2016-09-21 01:59:06 +02:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
/* static */ std::string KitQueue::Callback::toString(int view, int type, const std::string payload)
|
|
|
|
{
|
|
|
|
std::ostringstream str;
|
|
|
|
str << view << " " << lokCallbackTypeToString(type) << " "
|
|
|
|
<< COOLProtocol::getAbbreviatedMessage(payload);
|
|
|
|
return str.str();
|
|
|
|
}
|
|
|
|
|
2024-05-09 16:29:49 +02:00
|
|
|
namespace {
|
|
|
|
bool textItem(const KitQueue::Payload &value, const std::string &firstToken, bool &removeText)
|
|
|
|
{
|
|
|
|
size_t offset = firstToken.size(); // in this case a session
|
|
|
|
if (value.size() < offset + 3)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
size_t remaining = value.size() - firstToken.size();
|
|
|
|
|
2024-05-10 12:26:45 +02:00
|
|
|
if (!memcmp(value.data() + offset + 1, "textinput", std::min(remaining - 1, size_t(9))))
|
2024-05-09 16:29:49 +02:00
|
|
|
{
|
|
|
|
removeText = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-05-10 12:26:45 +02:00
|
|
|
if (!memcmp(value.data() + offset + 1, "removetextcontext", std::min(remaining - 1, size_t(17))))
|
2024-05-09 16:29:49 +02:00
|
|
|
{
|
|
|
|
removeText = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-08 18:57:16 +02:00
|
|
|
void KitQueue::put(const Payload& value)
|
2015-11-09 11:36:37 +01:00
|
|
|
{
|
2024-05-08 18:57:16 +02:00
|
|
|
if (value.empty())
|
|
|
|
throw std::runtime_error("Cannot queue empty item.");
|
|
|
|
|
2021-11-18 13:08:14 +01:00
|
|
|
const std::string firstToken = COOLProtocol::getFirstToken(value);
|
2016-09-21 01:59:06 +02:00
|
|
|
|
2024-05-09 16:29:49 +02:00
|
|
|
bool removeText = false;
|
|
|
|
|
2023-06-10 18:54:23 +02:00
|
|
|
if (firstToken == "tilecombine")
|
2024-05-23 15:09:31 +02:00
|
|
|
pushTileCombineRequest(value);
|
2016-09-26 10:35:20 +02:00
|
|
|
|
Get rid of some fragile string literal length counts
Basically, instead of foo.compare(0, 3, "bar") use
LOOLProtocol::getFirstToken(foo)!="bar". Using a separate length of a
string literal is very fragile, it is easy to get the length wrong, or
forget to change it in case the string changes. See
137e677eb0d6af1996701b2bd1b27a6eb3822613.
It isn't entirely sure to me whether was is kept in a message queue
follows LOOL protocol message syntax, but it seems to be so in
practice, so we can use LOOLProtocol::getFirstToken().
Also, calls like msg.compare(0, 4, "tile") add undocumented implicit
requirements that the token in question must be unique as an initial
substring of the first tokens of all messages. It actually isn't,
there is also "tilecombine". But in this case, that was taken care of
by checking for "tilecombine" first. Ugh. Whether that was by accident
or design is hard to say, but at least there was no comment indicating
intentionality.
We still have lots of similar fragile mis-use of std::string::find().
2016-09-26 19:13:50 +02:00
|
|
|
else if (firstToken == "tile")
|
2024-05-23 15:09:31 +02:00
|
|
|
pushTileQueue(value);
|
2016-09-23 10:18:54 +02:00
|
|
|
|
2017-01-20 15:56:47 +01:00
|
|
|
else if (firstToken == "callback")
|
2024-05-09 10:19:44 +02:00
|
|
|
assert(false && "callbacks should not come from the client");
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2024-05-09 16:29:49 +02:00
|
|
|
else if (textItem(value, firstToken, removeText))
|
2024-05-08 18:23:26 +02:00
|
|
|
{
|
2024-05-09 16:29:49 +02:00
|
|
|
StringVector tokens = StringVector::tokenize(value.data(), value.size());
|
|
|
|
|
|
|
|
std::string newMsg = !removeText ? combineTextInput(tokens)
|
|
|
|
: combineRemoveText(tokens);
|
|
|
|
|
2024-05-08 18:23:26 +02:00
|
|
|
if (!newMsg.empty())
|
|
|
|
_queue.emplace_back(newMsg.data(), newMsg.data() + newMsg.size());
|
|
|
|
else
|
|
|
|
_queue.emplace_back(value);
|
|
|
|
}
|
|
|
|
else // not so special
|
|
|
|
_queue.emplace_back(value);
|
2016-09-26 10:35:20 +02:00
|
|
|
}
|
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
void KitQueue::removeTileDuplicate(const TileDesc &desc)
|
2016-09-26 10:35:20 +02:00
|
|
|
{
|
2024-05-23 15:09:31 +02:00
|
|
|
for (size_t i = 0; i < _tileQueue.size(); ++i)
|
2015-11-09 11:36:37 +01:00
|
|
|
{
|
2024-05-23 15:09:31 +02:00
|
|
|
auto& it = _tileQueue[i];
|
2024-05-23 15:40:43 +02:00
|
|
|
if (it == desc)
|
2015-11-09 11:36:37 +01:00
|
|
|
{
|
2024-05-23 15:40:43 +02:00
|
|
|
LOG_TRC("Remove duplicate tile request: " << it.serialize() <<
|
|
|
|
" -> " << desc.serialize());
|
2024-05-23 15:09:31 +02:00
|
|
|
_tileQueue.erase(_tileQueue.begin() + i);
|
2016-09-26 10:35:20 +02:00
|
|
|
break;
|
2015-11-09 11:36:37 +01:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 23:42:50 +02:00
|
|
|
}
|
|
|
|
|
2017-01-20 15:56:47 +01:00
|
|
|
namespace {
|
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
/// Read the viewId from the payload.
|
|
|
|
std::string extractViewId(const std::string& payload)
|
2017-01-20 15:56:47 +01:00
|
|
|
{
|
|
|
|
Poco::JSON::Parser parser;
|
2024-05-09 10:19:44 +02:00
|
|
|
const Poco::Dynamic::Var result = parser.parse(payload);
|
2017-01-20 15:56:47 +01:00
|
|
|
const auto& json = result.extract<Poco::JSON::Object::Ptr>();
|
|
|
|
return json->get("viewId").toString();
|
|
|
|
}
|
|
|
|
|
2017-01-25 12:21:38 +01:00
|
|
|
/// Extract the .uno: command ID from the potential command.
|
|
|
|
std::string extractUnoCommand(const std::string& command)
|
|
|
|
{
|
2021-11-18 13:08:14 +01:00
|
|
|
if (!COOLProtocol::matchPrefix(".uno:", command))
|
2017-01-25 12:21:38 +01:00
|
|
|
return std::string();
|
|
|
|
|
|
|
|
size_t equalPos = command.find('=');
|
|
|
|
if (equalPos != std::string::npos)
|
|
|
|
return command.substr(0, equalPos);
|
|
|
|
|
|
|
|
return command;
|
|
|
|
}
|
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
/// Extract rectangle from the invalidation callback payload
|
2022-08-30 07:27:44 +02:00
|
|
|
bool extractRectangle(const StringVector& tokens, int& x, int& y, int& w, int& h, int& part, int& mode)
|
2017-01-25 18:21:56 +01:00
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
w = INT_MAX;
|
|
|
|
h = INT_MAX;
|
|
|
|
part = 0;
|
2022-08-30 07:27:44 +02:00
|
|
|
mode = 0;
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
if (tokens.size() < 2)
|
2017-01-25 18:21:56 +01:00
|
|
|
return false;
|
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
if (tokens.equals(0, "EMPTY,"))
|
2017-01-25 18:21:56 +01:00
|
|
|
{
|
2024-05-21 15:52:36 +02:00
|
|
|
part = std::atoi(tokens[1].c_str());
|
2017-01-25 18:21:56 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
if (tokens.size() < 5)
|
2017-01-25 18:21:56 +01:00
|
|
|
return false;
|
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
x = std::atoi(tokens[0].c_str());
|
|
|
|
y = std::atoi(tokens[1].c_str());
|
|
|
|
w = std::atoi(tokens[2].c_str());
|
|
|
|
h = std::atoi(tokens[3].c_str());
|
|
|
|
part = std::atoi(tokens[4].c_str());
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
if (tokens.size() == 6)
|
|
|
|
mode = std::atoi(tokens[5].c_str());
|
2022-08-30 07:27:44 +02:00
|
|
|
|
2017-01-25 18:21:56 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-20 15:56:47 +01:00
|
|
|
}
|
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
void KitQueue::putCallback(int view, int type, const std::string &payload)
|
2017-01-20 15:56:47 +01:00
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
if (!elideDuplicateCallback(view, type, payload))
|
|
|
|
_callbacks.emplace_back(view, type, payload);
|
|
|
|
}
|
2017-01-20 15:56:47 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
bool KitQueue::elideDuplicateCallback(int view, int type, const std::string &payload)
|
|
|
|
{
|
|
|
|
const auto callbackType = static_cast<LibreOfficeKitCallbackType>(type);
|
2017-01-24 12:40:30 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
// Nothing to combine in this case:
|
|
|
|
if (_callbacks.size() == 0)
|
|
|
|
return false;
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
switch (callbackType)
|
|
|
|
{
|
|
|
|
case LOK_CALLBACK_INVALIDATE_TILES: // invalidation
|
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
StringVector tokens = StringVector::tokenize(payload);
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
int msgX, msgY, msgW, msgH, msgPart, msgMode;
|
2022-08-30 07:27:44 +02:00
|
|
|
if (!extractRectangle(tokens, msgX, msgY, msgW, msgH, msgPart, msgMode))
|
2024-05-09 10:19:44 +02:00
|
|
|
return false;
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
bool performedMerge = false;
|
2017-01-24 12:40:30 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
// we always travel the entire queue
|
|
|
|
std::size_t i = 0;
|
2024-05-09 10:19:44 +02:00
|
|
|
while (i < _callbacks.size())
|
2017-01-25 18:21:56 +01:00
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
auto& it = _callbacks[i];
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
if (it._type != type || it._view != view)
|
2020-06-03 05:16:47 +02:00
|
|
|
{
|
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
2024-05-09 10:19:44 +02:00
|
|
|
StringVector queuedTokens = StringVector::tokenize(it._payload);
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2022-08-30 07:27:44 +02:00
|
|
|
int queuedX, queuedY, queuedW, queuedH, queuedPart, queuedMode;
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2022-08-30 07:27:44 +02:00
|
|
|
if (!extractRectangle(queuedTokens, queuedX, queuedY, queuedW, queuedH, queuedPart, queuedMode))
|
2020-06-03 05:16:47 +02:00
|
|
|
{
|
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
if (msgPart != queuedPart)
|
2017-01-25 18:21:56 +01:00
|
|
|
{
|
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-08-30 07:27:44 +02:00
|
|
|
if (msgMode != queuedMode)
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
// the invalidation in the queue is fully covered by the payload,
|
2020-06-03 05:16:47 +02:00
|
|
|
// just remove it
|
|
|
|
if (msgX <= queuedX && queuedX + queuedW <= msgX + msgW && msgY <= queuedY
|
|
|
|
&& queuedY + queuedH <= msgY + msgH)
|
|
|
|
{
|
|
|
|
LOG_TRC("Removing smaller invalidation: "
|
2024-05-09 10:19:44 +02:00
|
|
|
<< it._payload << " -> " << ' ' << msgX << ' ' << msgY << ' '
|
2022-08-30 07:27:44 +02:00
|
|
|
<< msgW << ' ' << msgH << ' ' << msgPart << ' ' << msgMode);
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
// remove from the queue
|
2024-05-09 10:19:44 +02:00
|
|
|
_callbacks.erase(_callbacks.begin() + i);
|
2020-06-03 05:16:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
// the invalidation just intersects, join those (if the result is
|
|
|
|
// small)
|
|
|
|
if (TileDesc::rectanglesIntersect(msgX, msgY, msgW, msgH, queuedX, queuedY, queuedW,
|
|
|
|
queuedH))
|
|
|
|
{
|
|
|
|
int joinX = std::min(msgX, queuedX);
|
|
|
|
int joinY = std::min(msgY, queuedY);
|
|
|
|
int joinW = std::max(msgX + msgW, queuedX + queuedW) - joinX;
|
|
|
|
int joinH = std::max(msgY + msgH, queuedY + queuedH) - joinY;
|
|
|
|
|
|
|
|
const int reasonableSizeX = 4 * 3840; // 4x tile at 100% zoom
|
|
|
|
const int reasonableSizeY = 2 * 3840; // 2x tile at 100% zoom
|
|
|
|
if (joinW > reasonableSizeX || joinH > reasonableSizeY)
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
LOG_TRC("Merging invalidations: "
|
2024-05-09 10:19:44 +02:00
|
|
|
<< Callback::toString(view, type, payload) << " and "
|
2022-08-30 07:27:44 +02:00
|
|
|
<< tokens[0] << ' ' << tokens[1] << ' ' << tokens[2] << ' '
|
|
|
|
<< msgX << ' ' << msgY << ' ' << msgW << ' ' << msgH << ' '
|
|
|
|
<< msgPart << ' ' << msgMode << " -> "
|
|
|
|
<< tokens[0] << ' ' << tokens[1] << ' ' << tokens[2] << ' '
|
|
|
|
<< joinX << ' ' << joinY << ' ' << joinW << ' ' << joinH << ' '
|
|
|
|
<< msgPart << ' ' << msgMode);
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
msgX = joinX;
|
|
|
|
msgY = joinY;
|
|
|
|
msgW = joinW;
|
|
|
|
msgH = joinH;
|
|
|
|
performedMerge = true;
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
// remove from the queue
|
2024-05-09 10:19:44 +02:00
|
|
|
_callbacks.erase(_callbacks.begin() + i);
|
2020-06-03 05:16:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
2017-01-25 12:21:38 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
++i;
|
|
|
|
}
|
2017-01-25 12:21:38 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
if (performedMerge)
|
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
std::string newPayload =
|
|
|
|
std::to_string(msgX) + ", " + std::to_string(msgY) + ", " +
|
|
|
|
std::to_string(msgW) + ", " + std::to_string(msgH) + ", " +
|
|
|
|
tokens.cat(' ', 4); // part etc. ...
|
2017-01-25 12:21:38 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
LOG_TRC("Merge result: " << newPayload);
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
_callbacks.emplace_back(view, type, newPayload);
|
|
|
|
return true; // elide the original - use this instead
|
2017-01-25 12:21:38 +01:00
|
|
|
}
|
|
|
|
}
|
2020-06-03 05:16:47 +02:00
|
|
|
break;
|
2017-01-20 15:56:47 +01:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
case LOK_CALLBACK_STATE_CHANGED: // state changed
|
2017-01-20 15:56:47 +01:00
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
std::string unoCommand = extractUnoCommand(payload);
|
2020-06-03 05:16:47 +02:00
|
|
|
if (unoCommand.empty())
|
2024-05-09 10:19:44 +02:00
|
|
|
return false;
|
2020-06-03 05:16:47 +02:00
|
|
|
|
2020-09-21 08:46:38 +02:00
|
|
|
// This is needed because otherwise it creates some problems when
|
|
|
|
// a save occurs while a cell is still edited in Calc.
|
|
|
|
if (unoCommand == ".uno:ModifiedStatus")
|
2024-05-09 10:19:44 +02:00
|
|
|
return false;
|
2023-06-03 21:10:29 +02:00
|
|
|
|
2020-06-03 05:16:47 +02:00
|
|
|
// remove obsolete states of the same .uno: command
|
2024-05-09 10:19:44 +02:00
|
|
|
size_t unoCommandLen = unoCommand.size();
|
|
|
|
for (size_t i = 0; i < _callbacks.size(); ++i)
|
2020-06-03 05:16:47 +02:00
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
Callback& it = _callbacks[i];
|
|
|
|
if (it._type != type || it._view != view)
|
|
|
|
continue;
|
2017-01-20 15:56:47 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
size_t payloadLen = it._payload.size();
|
|
|
|
if (payloadLen < unoCommandLen + 1 ||
|
|
|
|
unoCommand.compare(0, unoCommandLen, it._payload) != 0 ||
|
|
|
|
it._payload[unoCommandLen] != '=')
|
|
|
|
continue;
|
2020-06-03 05:16:47 +02:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
LOG_TRC("Remove obsolete uno command: " << it << " -> "
|
|
|
|
<< Callback::toString(view, type, payload));
|
|
|
|
_callbacks.erase(_callbacks.begin() + i);
|
|
|
|
break;
|
2017-01-20 15:56:47 +01:00
|
|
|
}
|
2020-06-03 05:16:47 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: // the cursor has moved
|
|
|
|
case LOK_CALLBACK_CURSOR_VISIBLE: // the cursor visibility has changed
|
|
|
|
case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE: // setting the indicator value
|
|
|
|
case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: // setting the document size
|
|
|
|
case LOK_CALLBACK_CELL_CURSOR: // the cell cursor has moved
|
|
|
|
case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR: // the view cursor has moved
|
|
|
|
case LOK_CALLBACK_CELL_VIEW_CURSOR: // the view cell cursor has moved
|
|
|
|
case LOK_CALLBACK_VIEW_CURSOR_VISIBLE: // the view cursor visibility has changed
|
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
const bool isViewCallback = (callbackType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR ||
|
|
|
|
callbackType == LOK_CALLBACK_CELL_VIEW_CURSOR ||
|
|
|
|
callbackType == LOK_CALLBACK_VIEW_CURSOR_VISIBLE);
|
2020-06-03 05:16:47 +02:00
|
|
|
|
|
|
|
const std::string viewId
|
2024-05-09 10:19:44 +02:00
|
|
|
= (isViewCallback ? extractViewId(payload) : std::string());
|
2020-06-03 05:16:47 +02:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
for (std::size_t i = 0; i < _callbacks.size(); ++i)
|
2017-01-20 15:56:47 +01:00
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
const auto& it = _callbacks[i];
|
2017-01-20 15:56:47 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
if (it._type != type || it._view != view)
|
2020-06-03 05:16:47 +02:00
|
|
|
continue;
|
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
if (!isViewCallback)
|
2017-01-20 15:56:47 +01:00
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
LOG_TRC("Remove obsolete callback: " << it << " -> "
|
|
|
|
<< Callback::toString(view, type, payload));
|
|
|
|
_callbacks.erase(_callbacks.begin() + i);
|
2017-01-20 15:56:47 +01:00
|
|
|
break;
|
|
|
|
}
|
2024-05-09 10:19:44 +02:00
|
|
|
else if (isViewCallback)
|
2020-06-03 05:16:47 +02:00
|
|
|
{
|
|
|
|
// we additionally need to ensure that the payload is about
|
|
|
|
// the same viewid (otherwise we'd merge them all views into
|
|
|
|
// one)
|
2024-05-09 10:19:44 +02:00
|
|
|
const std::string queuedViewId = extractViewId(it._payload);
|
2020-06-03 05:16:47 +02:00
|
|
|
if (viewId == queuedViewId)
|
|
|
|
{
|
2024-05-09 10:19:44 +02:00
|
|
|
LOG_TRC("Remove obsolete view callback: " << it << " -> "
|
|
|
|
<< Callback::toString(view, type, payload));
|
|
|
|
_callbacks.erase(_callbacks.begin() + i);
|
2020-06-03 05:16:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-01-20 15:56:47 +01:00
|
|
|
}
|
|
|
|
}
|
2020-06-03 05:16:47 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
} // switch
|
2017-01-25 18:21:56 +01:00
|
|
|
|
2024-05-09 10:19:44 +02:00
|
|
|
// Append the new command to the callbacks list
|
|
|
|
return false;
|
2017-01-20 15:56:47 +01:00
|
|
|
}
|
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
int KitQueue::priority(const TileDesc &tile)
|
2016-09-14 23:42:50 +02:00
|
|
|
{
|
2016-09-30 22:38:20 +02:00
|
|
|
for (int i = static_cast<int>(_viewOrder.size()) - 1; i >= 0; --i)
|
2016-09-14 23:42:50 +02:00
|
|
|
{
|
2016-09-30 22:00:20 +02:00
|
|
|
auto& cursor = _cursorPositions[_viewOrder[i]];
|
2018-11-15 09:07:27 +01:00
|
|
|
if (tile.intersectsWithRect(cursor.getX(), cursor.getY(), cursor.getWidth(),
|
|
|
|
cursor.getHeight()))
|
2016-09-30 22:00:20 +02:00
|
|
|
return i;
|
2016-09-14 23:42:50 +02:00
|
|
|
}
|
|
|
|
|
2016-09-30 22:00:20 +02:00
|
|
|
return -1;
|
2015-11-09 11:36:37 +01:00
|
|
|
}
|
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
// FIXME: it's not that clear what good this does for us ...
|
|
|
|
// we process all previews in the same batch of rendering
|
2024-05-08 18:47:53 +02:00
|
|
|
void KitQueue::deprioritizePreviews()
|
2016-10-04 14:23:42 +02:00
|
|
|
{
|
2024-05-23 15:09:31 +02:00
|
|
|
for (size_t i = 0; i < _tileQueue.size(); ++i)
|
2016-10-04 14:23:42 +02:00
|
|
|
{
|
2024-05-23 15:40:43 +02:00
|
|
|
const TileDesc front = _tileQueue.front();
|
2016-10-04 14:23:42 +02:00
|
|
|
|
2017-01-25 19:14:38 +01:00
|
|
|
// stop at the first non-tile or non-'id' (preview) message
|
2024-05-23 15:40:43 +02:00
|
|
|
if (!front.isPreview())
|
2016-10-04 14:23:42 +02:00
|
|
|
break;
|
2016-11-30 03:55:44 +01:00
|
|
|
|
2024-05-23 15:09:31 +02:00
|
|
|
_tileQueue.erase(_tileQueue.begin());
|
|
|
|
_tileQueue.push_back(front);
|
2016-11-30 03:55:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-23 14:40:59 +02:00
|
|
|
KitQueue::Payload KitQueue::pop()
|
2016-09-15 14:40:26 +02:00
|
|
|
{
|
2024-05-23 14:40:59 +02:00
|
|
|
if (_queue.empty())
|
|
|
|
return Payload();
|
|
|
|
|
2024-05-08 20:47:25 +02:00
|
|
|
const Payload front = _queue.front();
|
2016-09-15 14:40:26 +02:00
|
|
|
|
2024-05-23 15:09:31 +02:00
|
|
|
LOG_TRC("KitQueue(" << _queue.size() << ") - pop " <<
|
|
|
|
COOLProtocol::getAbbreviatedMessage(front));
|
|
|
|
|
|
|
|
_queue.erase(_queue.begin());
|
|
|
|
|
|
|
|
return front;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<TileCombined> KitQueue::popWholeTileQueue()
|
|
|
|
{
|
2024-05-23 15:40:43 +02:00
|
|
|
std::vector<TileCombined> result;
|
2024-05-23 15:09:31 +02:00
|
|
|
|
|
|
|
while (!_tileQueue.empty())
|
2024-05-23 15:40:43 +02:00
|
|
|
result.emplace_back(popTileQueue());
|
2024-05-23 15:09:31 +02:00
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
return result;
|
2024-05-23 15:09:31 +02:00
|
|
|
}
|
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
TileCombined KitQueue::popTileQueue()
|
2024-05-23 15:09:31 +02:00
|
|
|
{
|
2024-05-23 15:40:43 +02:00
|
|
|
assert(!_tileQueue.empty());
|
2024-05-23 15:09:31 +02:00
|
|
|
|
|
|
|
LOG_TRC("KitQueue depth: " << _tileQueue.size());
|
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
TileDesc msg = _tileQueue.front();
|
2024-05-23 15:09:31 +02:00
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
std::vector<TileDesc> tiles;
|
2016-10-04 14:23:42 +02:00
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
if (msg.isPreview())
|
2016-11-30 03:55:44 +01:00
|
|
|
{
|
2017-01-25 19:14:38 +01:00
|
|
|
// Don't combine non-tiles or tiles with id.
|
2024-05-23 15:40:43 +02:00
|
|
|
LOG_TRC("KitQueue res: " << msg.serialize());
|
2024-05-23 15:09:31 +02:00
|
|
|
_tileQueue.erase(_tileQueue.begin());
|
2016-11-30 03:55:44 +01:00
|
|
|
|
2017-01-25 19:14:38 +01:00
|
|
|
// de-prioritize the other tiles with id - usually the previews in
|
|
|
|
// Impress
|
2024-05-23 15:40:43 +02:00
|
|
|
deprioritizePreviews();
|
2016-11-30 03:55:44 +01:00
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
return TileCombined(msg);
|
2016-09-15 14:40:26 +02:00
|
|
|
}
|
|
|
|
|
2016-09-23 10:18:54 +02:00
|
|
|
// We are handling a tile; first try to find one that is at the cursor's
|
|
|
|
// position, otherwise handle the one that is at the front
|
2016-09-30 22:00:20 +02:00
|
|
|
int prioritized = 0;
|
|
|
|
int prioritySoFar = -1;
|
2024-05-23 15:09:31 +02:00
|
|
|
for (size_t i = 0; i < _tileQueue.size(); ++i)
|
2016-09-23 10:18:54 +02:00
|
|
|
{
|
2024-05-23 15:40:43 +02:00
|
|
|
auto& prio = _tileQueue[i];
|
2016-09-26 10:12:45 +02:00
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
// FIXME: does this make any sense ?
|
|
|
|
//
|
2016-09-26 10:12:45 +02:00
|
|
|
// avoid starving - stop the search when we reach a non-tile,
|
|
|
|
// otherwise we may keep growing the queue of unhandled stuff (both
|
|
|
|
// tiles and non-tiles)
|
2024-05-23 15:40:43 +02:00
|
|
|
if (prio.isPreview())
|
2016-09-26 10:12:45 +02:00
|
|
|
break;
|
|
|
|
|
2016-11-16 14:47:11 +01:00
|
|
|
const int p = priority(prio);
|
2016-09-30 22:38:20 +02:00
|
|
|
if (p > prioritySoFar)
|
2016-09-23 10:18:54 +02:00
|
|
|
{
|
2016-09-30 22:00:20 +02:00
|
|
|
prioritySoFar = p;
|
|
|
|
prioritized = i;
|
2016-09-23 10:18:54 +02:00
|
|
|
msg = prio;
|
2016-09-30 23:06:26 +02:00
|
|
|
|
|
|
|
// found the highest priority already?
|
|
|
|
if (prioritySoFar == static_cast<int>(_viewOrder.size()) - 1)
|
2016-11-16 14:47:11 +01:00
|
|
|
{
|
2016-09-30 23:06:26 +02:00
|
|
|
break;
|
2016-11-16 14:47:11 +01:00
|
|
|
}
|
2016-09-23 10:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-23 15:09:31 +02:00
|
|
|
_tileQueue.erase(_tileQueue.begin() + prioritized);
|
2016-09-23 10:18:54 +02:00
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
tiles.emplace_back(msg);
|
2016-09-15 14:40:26 +02:00
|
|
|
|
|
|
|
// Combine as many tiles as possible with the top one.
|
2024-05-23 15:09:31 +02:00
|
|
|
for (size_t i = 0; i < _tileQueue.size(); )
|
2016-09-15 14:40:26 +02:00
|
|
|
{
|
2024-05-23 15:09:31 +02:00
|
|
|
auto& it = _tileQueue[i];
|
2024-05-23 15:40:43 +02:00
|
|
|
if (it.isPreview())
|
2016-09-15 14:40:26 +02:00
|
|
|
{
|
2016-09-26 03:30:56 +02:00
|
|
|
// Don't combine non-tiles or tiles with id.
|
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
2016-09-15 14:40:26 +02:00
|
|
|
|
2024-05-23 15:40:43 +02:00
|
|
|
LOG_TRC("Combining candidate: " << it.serialize());
|
2016-09-15 14:40:26 +02:00
|
|
|
|
2016-09-26 03:30:56 +02:00
|
|
|
// Check if it's on the same row.
|
2024-05-23 15:40:43 +02:00
|
|
|
if (tiles[0].canCombine(it))
|
2016-09-26 03:30:56 +02:00
|
|
|
{
|
2024-05-23 15:40:43 +02:00
|
|
|
tiles.emplace_back(it);
|
2024-05-23 15:09:31 +02:00
|
|
|
_tileQueue.erase(_tileQueue.begin() + i);
|
2016-09-26 03:30:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++i;
|
2016-09-21 01:20:23 +02:00
|
|
|
}
|
2016-09-15 14:40:26 +02:00
|
|
|
}
|
2016-09-21 01:20:23 +02:00
|
|
|
|
2024-05-23 15:09:31 +02:00
|
|
|
LOG_TRC("Combined " << tiles.size() << " tiles, leaving " << _tileQueue.size() << " in queue.");
|
2016-09-15 14:40:26 +02:00
|
|
|
|
|
|
|
if (tiles.size() == 1)
|
|
|
|
{
|
2024-05-23 15:40:43 +02:00
|
|
|
LOG_TRC("KitQueue res: " << tiles[0].serialize());
|
|
|
|
return TileCombined(tiles[0]);
|
2016-09-15 14:40:26 +02:00
|
|
|
}
|
|
|
|
|
2022-06-09 20:10:42 +02:00
|
|
|
// n^2 but lists are short.
|
|
|
|
for (size_t i = 0; i < tiles.size() - 1; ++i)
|
|
|
|
{
|
|
|
|
const auto &a = tiles[i];
|
|
|
|
for (size_t j = i + 1; j < tiles.size();)
|
|
|
|
{
|
|
|
|
const auto &b = tiles[j];
|
|
|
|
assert(a.getPart() == b.getPart());
|
2022-08-30 07:27:44 +02:00
|
|
|
assert(a.getEditMode() == b.getEditMode());
|
2022-06-09 20:10:42 +02:00
|
|
|
assert(a.getWidth() == b.getWidth());
|
|
|
|
assert(a.getHeight() == b.getHeight());
|
|
|
|
assert(a.getTileWidth() == b.getTileWidth());
|
|
|
|
assert(a.getTileHeight() == b.getTileHeight());
|
|
|
|
if (a.getTilePosX() == b.getTilePosX() &&
|
|
|
|
a.getTilePosY() == b.getTilePosY())
|
|
|
|
{
|
2024-05-08 18:47:53 +02:00
|
|
|
LOG_TRC("KitQueue: dropping duplicate tile: " <<
|
2022-06-09 20:10:42 +02:00
|
|
|
j << " vs. " << i << " at: " <<
|
|
|
|
a.getTilePosX() << "," << b.getTilePosY());
|
|
|
|
tiles.erase(tiles.begin() + j);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TileCombined combined = TileCombined::create(tiles);
|
|
|
|
assert(!combined.hasDuplicates());
|
2024-05-23 15:40:43 +02:00
|
|
|
LOG_TRC("KitQueue res: " << combined.serialize());
|
|
|
|
return combined;
|
2016-09-15 14:40:26 +02:00
|
|
|
}
|
|
|
|
|
2024-05-08 18:57:16 +02:00
|
|
|
std::string KitQueue::combineTextInput(const StringVector& tokens)
|
|
|
|
{
|
|
|
|
std::string id;
|
|
|
|
std::string text;
|
|
|
|
if (!COOLProtocol::getTokenString(tokens, "id", id) ||
|
|
|
|
!COOLProtocol::getTokenString(tokens, "text", text))
|
|
|
|
return std::string();
|
|
|
|
|
2024-05-08 20:47:25 +02:00
|
|
|
int i = _queue.size() - 1;
|
2024-05-08 18:57:16 +02:00
|
|
|
while (i >= 0)
|
|
|
|
{
|
2024-05-08 20:47:25 +02:00
|
|
|
auto& it = _queue[i];
|
2024-05-08 18:57:16 +02:00
|
|
|
|
|
|
|
const std::string queuedMessage(it.data(), it.size());
|
|
|
|
StringVector queuedTokens = StringVector::tokenize(it.data(), it.size());
|
|
|
|
|
|
|
|
// If any messages of these types are present before the current ("textinput") message,
|
|
|
|
// no combination is possible.
|
|
|
|
if (queuedTokens.size() == 1 ||
|
|
|
|
(queuedTokens.equals(0, tokens, 0) &&
|
|
|
|
(queuedTokens.equals(1, "key") ||
|
|
|
|
queuedTokens.equals(1, "mouse") ||
|
|
|
|
queuedTokens.equals(1, "removetextcontext") ||
|
|
|
|
queuedTokens.equals(1, "windowkey"))))
|
|
|
|
return std::string();
|
|
|
|
|
|
|
|
std::string queuedId;
|
|
|
|
std::string queuedText;
|
|
|
|
if (queuedTokens.equals(0, tokens, 0) &&
|
|
|
|
queuedTokens.equals(1, "textinput") &&
|
|
|
|
COOLProtocol::getTokenString(queuedTokens, "id", queuedId) &&
|
|
|
|
queuedId == id &&
|
|
|
|
COOLProtocol::getTokenString(queuedTokens, "text", queuedText))
|
|
|
|
{
|
|
|
|
// Remove the queued textinput message and combine it with the current one
|
2024-05-08 20:47:25 +02:00
|
|
|
_queue.erase(_queue.begin() + i);
|
2024-05-08 18:57:16 +02:00
|
|
|
|
|
|
|
std::string newMsg;
|
|
|
|
newMsg.reserve(it.size() * 2);
|
|
|
|
newMsg.append(queuedTokens[0]);
|
|
|
|
newMsg.append(" textinput id=");
|
|
|
|
newMsg.append(id);
|
|
|
|
newMsg.append(" text=");
|
|
|
|
newMsg.append(queuedText);
|
|
|
|
newMsg.append(text);
|
|
|
|
|
|
|
|
LOG_TRC("Combined [" << queuedMessage << "] with current message to [" << newMsg
|
|
|
|
<< ']');
|
|
|
|
|
|
|
|
return newMsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2024-05-23 15:09:31 +02:00
|
|
|
void KitQueue::pushTileCombineRequest(const Payload &value)
|
|
|
|
{
|
|
|
|
assert(COOLProtocol::getFirstToken(value) == "tilecombine");
|
|
|
|
|
|
|
|
// Breakup tilecombine and deduplicate (we are re-combining
|
2024-05-23 15:40:43 +02:00
|
|
|
// the tiles inside popTileQueue() again)
|
2024-05-23 15:09:31 +02:00
|
|
|
const std::string msg = std::string(value.data(), value.size());
|
|
|
|
const TileCombined tileCombined = TileCombined::parse(msg);
|
|
|
|
for (const auto& tile : tileCombined.getTiles())
|
|
|
|
{
|
2024-05-23 15:40:43 +02:00
|
|
|
removeTileDuplicate(tile);
|
|
|
|
_tileQueue.emplace_back(tile);
|
2024-05-23 15:09:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KitQueue::pushTileQueue(const Payload &value)
|
|
|
|
{
|
2024-05-23 15:40:43 +02:00
|
|
|
const std::string msg = std::string(value.data(), value.size());
|
|
|
|
const TileDesc desc = TileDesc::parse(msg);
|
|
|
|
removeTileDuplicate(desc);
|
|
|
|
_tileQueue.push_back(desc);
|
2024-05-23 15:09:31 +02:00
|
|
|
}
|
|
|
|
|
2024-05-08 18:57:16 +02:00
|
|
|
std::string KitQueue::combineRemoveText(const StringVector& tokens)
|
|
|
|
{
|
|
|
|
std::string id;
|
|
|
|
int before = 0;
|
|
|
|
int after = 0;
|
|
|
|
if (!COOLProtocol::getTokenString(tokens, "id", id) ||
|
|
|
|
!COOLProtocol::getTokenInteger(tokens, "before", before) ||
|
|
|
|
!COOLProtocol::getTokenInteger(tokens, "after", after))
|
|
|
|
return std::string();
|
|
|
|
|
2024-05-08 20:47:25 +02:00
|
|
|
int i = _queue.size() - 1;
|
2024-05-08 18:57:16 +02:00
|
|
|
while (i >= 0)
|
|
|
|
{
|
2024-05-08 20:47:25 +02:00
|
|
|
auto& it = _queue[i];
|
2024-05-08 18:57:16 +02:00
|
|
|
|
|
|
|
const std::string queuedMessage(it.data(), it.size());
|
|
|
|
StringVector queuedTokens = StringVector::tokenize(it.data(), it.size());
|
|
|
|
|
|
|
|
// If any messages of these types are present before the current (removetextcontext)
|
|
|
|
// message, no combination is possible.
|
|
|
|
if (queuedTokens.size() == 1 ||
|
|
|
|
(queuedTokens.equals(0, tokens, 0) &&
|
|
|
|
(queuedTokens.equals(1, "key") ||
|
|
|
|
queuedTokens.equals(1, "mouse") ||
|
|
|
|
queuedTokens.equals(1, "textinput") ||
|
|
|
|
queuedTokens.equals(1, "windowkey"))))
|
|
|
|
return std::string();
|
|
|
|
|
|
|
|
std::string queuedId;
|
|
|
|
int queuedBefore = 0;
|
|
|
|
int queuedAfter = 0;
|
|
|
|
if (queuedTokens.equals(0, tokens, 0) &&
|
|
|
|
queuedTokens.equals(1, "removetextcontext") &&
|
|
|
|
COOLProtocol::getTokenStringFromMessage(queuedMessage, "id", queuedId) &&
|
|
|
|
queuedId == id &&
|
|
|
|
COOLProtocol::getTokenIntegerFromMessage(queuedMessage, "before", queuedBefore) &&
|
|
|
|
COOLProtocol::getTokenIntegerFromMessage(queuedMessage, "after", queuedAfter))
|
|
|
|
{
|
|
|
|
// Remove the queued removetextcontext message and combine it with the current one
|
2024-05-08 20:47:25 +02:00
|
|
|
_queue.erase(_queue.begin() + i);
|
2024-05-08 18:57:16 +02:00
|
|
|
|
|
|
|
std::string newMsg = queuedTokens[0] + " removetextcontext id=" + id +
|
|
|
|
" before=" + std::to_string(queuedBefore + before) +
|
|
|
|
" after=" + std::to_string(queuedAfter + after);
|
|
|
|
|
|
|
|
LOG_TRC("Combined [" << queuedMessage << "] with current message to [" << newMsg << "]");
|
|
|
|
|
|
|
|
return newMsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KitQueue::updateCursorPosition(int viewId, int part, int x, int y, int width, int height)
|
|
|
|
{
|
|
|
|
const KitQueue::CursorPosition cursorPosition = CursorPosition(part, x, y, width, height);
|
|
|
|
|
|
|
|
auto it = _cursorPositions.lower_bound(viewId);
|
|
|
|
if (it != _cursorPositions.end() && it->first == viewId)
|
|
|
|
{
|
|
|
|
it->second = cursorPosition;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_cursorPositions.insert(it, std::make_pair(viewId, cursorPosition));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move to front, so the current front view
|
|
|
|
// becomes the second.
|
|
|
|
const auto view = std::find(_viewOrder.begin(), _viewOrder.end(), viewId);
|
|
|
|
if (view != _viewOrder.end())
|
|
|
|
_viewOrder.erase(view);
|
|
|
|
|
|
|
|
_viewOrder.push_back(viewId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KitQueue::removeCursorPosition(int viewId)
|
|
|
|
{
|
|
|
|
const auto view = std::find(_viewOrder.begin(), _viewOrder.end(), viewId);
|
|
|
|
if (view != _viewOrder.end())
|
|
|
|
_viewOrder.erase(view);
|
|
|
|
|
|
|
|
_cursorPositions.erase(viewId);
|
|
|
|
}
|
|
|
|
|
2024-05-08 18:47:53 +02:00
|
|
|
void KitQueue::dumpState(std::ostream& oss)
|
2021-05-12 18:55:16 +02:00
|
|
|
{
|
2022-06-09 20:10:42 +02:00
|
|
|
oss << "\ttileQueue:"
|
|
|
|
<< "\n\t\tcursorPositions:";
|
|
|
|
for (const auto &it : _cursorPositions)
|
|
|
|
{
|
|
|
|
oss << "\n\t\t\tviewId: "
|
|
|
|
<< it.first
|
|
|
|
<< " part: " << it.second.getPart()
|
|
|
|
<< " x: " << it.second.getX()
|
|
|
|
<< " y: " << it.second.getY()
|
|
|
|
<< " width: " << it.second.getWidth()
|
|
|
|
<< " height: " << it.second.getHeight();
|
|
|
|
}
|
2021-05-12 18:55:16 +02:00
|
|
|
|
2022-06-09 20:10:42 +02:00
|
|
|
oss << "\n\t\tviewOrder: [";
|
|
|
|
std::string separator;
|
|
|
|
for (const auto& viewId : _viewOrder)
|
|
|
|
{
|
|
|
|
oss << separator << viewId;
|
|
|
|
separator = ", ";
|
|
|
|
}
|
|
|
|
oss << "]\n";
|
2024-02-20 22:23:26 +01:00
|
|
|
|
|
|
|
oss << "\tQueue size: " << _queue.size() << "\n";
|
|
|
|
size_t i = 0;
|
|
|
|
for (Payload &it : _queue)
|
|
|
|
oss << "\t\t" << i++ << ": " << COOLProtocol::getFirstLine(it) << "\n";
|
2024-05-09 10:19:44 +02:00
|
|
|
|
|
|
|
oss << "\tCallbacks size: " << _callbacks.size() << "\n";
|
|
|
|
i = 0;
|
|
|
|
for (auto &it : _callbacks)
|
|
|
|
oss << "\t\t" << i++ << ": " << it << "\n";
|
2021-05-12 18:55:16 +02:00
|
|
|
}
|
|
|
|
|
2015-11-09 11:36:37 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|