summaryrefslogtreecommitdiff
path: root/desktop/inc
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2016-05-15 14:23:47 -0400
committerAshod Nakashian <ashnakash@gmail.com>2016-05-28 20:38:37 +0000
commit692863ac3880c16c127250e5ba590406298b39ab (patch)
tree2ba3fbe60ee0ea6c1a625a22039b35e9f8ac1c25 /desktop/inc
parent91244b95b7826ec5c1075c00e6b4013804c4ab2f (diff)
LOK: improved event handling and fixes
During painting, when notifications are disabled, we could still receive notifications that are imporatant and cannot be suppressed. So certain events are let through during painting. A comment describes this better in the code. Some widgets (notably postit/comment control) emits events in relative (local) coordinates instead of absolute. This is patched in many cases but some cases still exist that are rather hard to patch due to the complex interaction with other parts of the code. These supurious local coordinate updates (notably cursor invalidation) are supressed to avoid the bad side-effects they cause in LOOL. Change-Id: Ie22a316d54ea163c6976ed04314d6ced8247824c Reviewed-on: https://gerrit.libreoffice.org/25013 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com> (cherry picked from commit b5c2a3fdbbf4161b0699ba515f63f98d7607ddf2) Reviewed-on: https://gerrit.libreoffice.org/25424 Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'desktop/inc')
-rw-r--r--desktop/inc/lib/init.hxx39
1 files changed, 28 insertions, 11 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index c0a4462543e0..d337eaa7a287 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -80,13 +80,36 @@ namespace desktop {
void queue(const int type, const char* data)
{
+ const std::string payload(data ? data : "(nil)");
if (m_bPartTilePainting)
{
- // We drop notifications when this is set.
+ // We drop notifications when this is set, except for important ones.
+ // When we issue a complex command (such as .uno:InsertAnnotation)
+ // there will be multiple notifications. On the first invalidation
+ // we will start painting, but other events will get fired
+ // while the complex command in question executes.
+ // We don't want to supress everything here on the wrong assumption
+ // that no new events are fired during painting.
+ if (type != LOK_CALLBACK_STATE_CHANGED &&
+ type != LOK_CALLBACK_INVALIDATE_TILES)
+ {
+ //SAL_WARN("lokevt", "Skipping while painting [" + std::to_string(type) + "]: [" + payload + "].");
+ return;
+ }
+ }
+
+ // Supress invalid payloads.
+ if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
+ payload.find(", 0, 0, ") != std::string::npos)
+ {
+ // The cursor position is often the relative coordinates of the widget
+ // issueing it, instead of the absolute one that we expect.
+ // This is temporary however, and, once the control is created and initialized
+ // correctly, it eventually emits the correct absolute coordinates.
+ //SAL_WARN("lokevt", "Skipping invalid event [" + std::to_string(type) + "]: [" + payload + "].");
return;
}
- const std::string payload(data ? data : "(nil)");
std::unique_lock<std::mutex> lock(m_mutex);
const auto stateIt = m_states.find(type);
@@ -95,19 +118,13 @@ namespace desktop {
// If the state didn't change, it's safe to ignore.
if (stateIt->second == payload)
{
+ //SAL_WARN("lokevt", "Skipping duplicate [" + std::to_string(type) + "]: [" + payload + "].");
return;
}
stateIt->second = payload;
}
- if (type == LOK_CALLBACK_INVALIDATE_TILES &&
- !m_queue.empty() && m_queue.back().first == type && m_queue.back().second == payload)
- {
- // Supress duplicate invalidation only when they are in sequence.
- return;
- }
-
if (type == LOK_CALLBACK_TEXT_SELECTION && payload.empty())
{
// Removing text selection invalidates the start and end as well.
@@ -186,7 +203,7 @@ namespace desktop {
if (m_queue[i].first == type)
{
payload = m_queue[i].second;
- //SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i) + ": [" + payload + "].");
+ //SAL_WARN("lokevt", "Found [" + std::to_string(type) + "] at " + std::to_string(i) + ": [" + payload + "].");
break;
}
}
@@ -196,7 +213,7 @@ namespace desktop {
if (m_queue[i].first == type &&
(!identical || m_queue[i].second == payload))
{
- //SAL_WARN("idle", "Removing [" + std::to_string(type) + "] at " + std::to_string(i) + ": " + m_queue[i].second + "].");
+ //SAL_WARN("lokevt", "Removing [" + std::to_string(type) + "] at " + std::to_string(i) + ": " + m_queue[i].second + "].");
m_queue.erase(m_queue.begin() + i);
}
}