summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-15 10:13:53 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-15 10:41:08 +0200
commitf1d86fc7af53e7bdba9c00df1abd791e92f3321e (patch)
tree8b9592e423a5ce3601ab76a86575caf770cf5219 /libreofficekit
parent3de68db1cd69627f4e529e5621eb97a8ea898aa3 (diff)
lokdocview: implement desktop style click+move selection creation
Change-Id: I69663c0801bc95b8876c8dcbdf68d7a99fec4fb3
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx25
1 files changed, 18 insertions, 7 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 00f4f4b5b9b1..35ce54385634 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -103,6 +103,9 @@ struct LOKDocView_Impl
bool m_bInDragGraphicHandles[8];
///@}
+ /// If text selection is adjusted -> then mouse up event is a NOP.
+ bool m_bTextSelectionAdjusted;
+
/// Callback data, allocated in lok_docview_callback_worker(), released in lok_docview_callback().
struct CallbackData
{
@@ -222,8 +225,8 @@ LOKDocView_Impl::LOKDocView_Impl(LOKDocView* pDocView)
m_pHandleEnd(0),
m_aHandleEndRect({0, 0, 0, 0}),
m_bInDragEndHandle(false),
-
- m_pGraphicHandle(0)
+ m_pGraphicHandle(0),
+ m_bTextSelectionAdjusted(false)
{
memset(&m_aGraphicHandleRects, 0, sizeof(m_aGraphicHandleRects));
memset(&m_bInDragGraphicHandles, 0, sizeof(m_bInDragGraphicHandles));
@@ -415,16 +418,20 @@ gboolean LOKDocView_Impl::signalButtonImpl(GdkEventButton* pEvent)
if ((pEvent->time - m_nLastButtonPressTime) < 250)
nCount++;
m_nLastButtonPressTime = pEvent->time;
+ m_bTextSelectionAdjusted = false;
m_pDocument->pClass->postMouseEvent(m_pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y), nCount);
break;
}
case GDK_BUTTON_RELEASE:
{
- int nCount = 1;
- if ((pEvent->time - m_nLastButtonReleaseTime) < 250)
- nCount++;
- m_nLastButtonReleaseTime = pEvent->time;
- m_pDocument->pClass->postMouseEvent(m_pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y), nCount);
+ if (!m_bTextSelectionAdjusted)
+ {
+ int nCount = 1;
+ if ((pEvent->time - m_nLastButtonReleaseTime) < 250)
+ nCount++;
+ m_nLastButtonReleaseTime = pEvent->time;
+ m_pDocument->pClass->postMouseEvent(m_pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y), nCount);
+ }
break;
}
default:
@@ -505,6 +512,10 @@ gboolean LOKDocView_Impl::signalMotionImpl(GdkEventButton* pEvent)
return FALSE;
}
+ // Otherwise adjust the text selection, as on the desktop.
+ m_pDocument->pClass->setTextSelection(m_pDocument, LOK_SETTEXTSELECTION_END, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
+ m_bTextSelectionAdjusted = true;
+
return FALSE;
}