summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-05-08 21:17:00 -0400
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-25 19:23:46 +0200
commit1e1a345a18a4162a7e265cf91bcb0c5dc206d576 (patch)
tree166edf9a85ecfdccaaf9d32db9d7ae77970c1018 /desktop
parent5f4fa7bf17542f74e29082b065b0e7bac6af53ef (diff)
LOK: Minor window event processing cleanup
This reduces the number of json reads we do when compressing window events, which happens quite often. (cherry picked from commit 0bb310d7ce39421ecc4ff90518ffdf6aa01d1b02) Change-Id: I1c85f28867b52cad85445fff8a031b990dad8b56 Reviewed-on: https://gerrit.libreoffice.org/76321 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 27ae125e4098..2db298e3998c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1336,7 +1336,8 @@ bool CallbackFlushHandler::processWindowEvent(CallbackData& aCallbackData)
boost::property_tree::ptree& aTree = aCallbackData.setJson(payload);
const unsigned nLOKWindowId = aTree.get<unsigned>("id", 0);
- if (aTree.get<std::string>("action", "") == "invalidate")
+ const std::string aAction = aTree.get<std::string>("action", "");
+ if (aAction == "invalidate")
{
std::string aRectStr = aTree.get<std::string>("rectangle", "");
// no 'rectangle' field => invalidate all of the window =>
@@ -1347,9 +1348,8 @@ bool CallbackFlushHandler::processWindowEvent(CallbackData& aCallbackData)
if (elem.Type == LOK_CALLBACK_WINDOW)
{
const boost::property_tree::ptree& aOldTree = elem.getJson();
- const unsigned nOldDialogId = aOldTree.get<unsigned>("id", 0);
- if (aOldTree.get<std::string>("action", "") == "invalidate"
- && nLOKWindowId == nOldDialogId)
+ if (nLOKWindowId == aOldTree.get<unsigned>("id", 0)
+ && aOldTree.get<std::string>("action", "") == "invalidate")
{
return true;
}
@@ -1368,10 +1368,9 @@ bool CallbackFlushHandler::processWindowEvent(CallbackData& aCallbackData)
return false;
const boost::property_tree::ptree& aOldTree = elem.getJson();
- const unsigned nOldDialogId = aOldTree.get<unsigned>("id", 0);
- return aOldTree.get<std::string>("action", "") == "invalidate" &&
- nLOKWindowId == nOldDialogId &&
- aOldTree.get<std::string>("rectangle", "").empty();
+ return nLOKWindowId == aOldTree.get<unsigned>("id", 0)
+ && aOldTree.get<std::string>("action", "") == "invalidate"
+ && aOldTree.get<std::string>("rectangle", "").empty();
});
// we found a invalidate-all window callback
@@ -1445,6 +1444,7 @@ bool CallbackFlushHandler::processWindowEvent(CallbackData& aCallbackData)
return false;
});
+ // Do not enqueue if redundant.
if (currentIsRedundant)
{
SAL_INFO("lok.dialog", "Current payload is engulfed by one already in the queue. "
@@ -1458,7 +1458,7 @@ bool CallbackFlushHandler::processWindowEvent(CallbackData& aCallbackData)
assert(aCallbackData.validate() && "Validation after setJson failed!");
}
}
- else if (aTree.get<std::string>("action", "") == "created")
+ else if (aAction == "created")
{
// Remove all previous actions on same dialog, if we are creating it anew.
removeAll([&nLOKWindowId](const queue_type::value_type& elem) {
@@ -1471,7 +1471,7 @@ bool CallbackFlushHandler::processWindowEvent(CallbackData& aCallbackData)
return false;
});
}
- else if (aTree.get<std::string>("action", "") == "size_changed")
+ else if (aAction == "size_changed")
{
// A size change is practically re-creation of the window.
// But at a minimum it's a full invalidation.