LOK: added the button type and key modifier to postMouseEvent()
To get a better functionality we need to know the button type (left, right, middle). We also need the key modifier (ctrl, alt, shift) for actions such as ctrl+click (to open a link) or shift+click to select Change-Id: Iaccb93b276f8a6870dd41cc5132dbb85d2bbf71b
This commit is contained in:
parent
0326352470
commit
c90c08a65c
@ -230,7 +230,9 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
|
||||
int nType,
|
||||
int nX,
|
||||
int nY,
|
||||
int nCount);
|
||||
int nCount,
|
||||
int nButtons,
|
||||
int nModifier);
|
||||
static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
|
||||
const char* pCommand,
|
||||
const char* pArguments);
|
||||
@ -925,7 +927,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* /*pThis*/, const char* pC
|
||||
}
|
||||
}
|
||||
|
||||
static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY, int nCount)
|
||||
static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
|
||||
{
|
||||
ITiledRenderable* pDoc = getTiledRenderable(pThis);
|
||||
if (!pDoc)
|
||||
@ -934,7 +936,7 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
|
||||
return;
|
||||
}
|
||||
|
||||
pDoc->postMouseEvent(nType, nX, nY, nCount);
|
||||
pDoc->postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier);
|
||||
}
|
||||
|
||||
static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
|
||||
|
@ -137,7 +137,9 @@ struct _LibreOfficeKitDocumentClass
|
||||
int nType,
|
||||
int nX,
|
||||
int nY,
|
||||
int nCount);
|
||||
int nCount,
|
||||
int nButtons,
|
||||
int nModifier);
|
||||
|
||||
/// @see lok::Document::postUnoCommand
|
||||
void (*postUnoCommand) (LibreOfficeKitDocument* pThis,
|
||||
|
@ -192,9 +192,9 @@ public:
|
||||
* @param nY vertical position in document coordinates
|
||||
* @param nCount number of clicks: 1 for single click, 2 for double click
|
||||
*/
|
||||
inline void postMouseEvent(int nType, int nX, int nY, int nCount)
|
||||
inline void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
|
||||
{
|
||||
mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY, nCount);
|
||||
mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY, nCount, nButtons, nModifier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
*
|
||||
* @see lok::Document::postMouseEvent().
|
||||
*/
|
||||
virtual void postMouseEvent(int nType, int nX, int nY, int nCount) = 0;
|
||||
virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) = 0;
|
||||
|
||||
/**
|
||||
* Sets the start or end of a text selection.
|
||||
|
@ -16,6 +16,10 @@ $(eval $(call gb_Library_add_exception_objects,libreofficekitgtk,\
|
||||
libreofficekit/source/gtk/tilebuffer \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Library_use_externals,libreofficekitgtk,\
|
||||
boost_headers \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Library_add_cxxflags,libreofficekitgtk,\
|
||||
$$(GTK3_CFLAGS) \
|
||||
))
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
||||
#include <LibreOfficeKit/LibreOfficeKitGtk.h>
|
||||
#include <rsc/rsc-vcl-shared-types.hxx>
|
||||
#include <vcl/event.hxx>
|
||||
|
||||
#include "tilebuffer.hxx"
|
||||
|
||||
@ -66,6 +67,10 @@ struct _LOKDocViewPrivate
|
||||
guint32 m_nLastButtonPressTime;
|
||||
/// Time of the last button release.
|
||||
guint32 m_nLastButtonReleaseTime;
|
||||
/// Last pressed button (left, right, middle)
|
||||
guint32 m_nLastButtonPressed;
|
||||
/// Key modifier (ctrl, atl, shift)
|
||||
guint32 m_nKeyModifier;
|
||||
/// Rectangles of the current text selection.
|
||||
std::vector<GdkRectangle> m_aTextSelectionRectangles;
|
||||
/// Position and size of the selection start (as if there would be a cursor caret there).
|
||||
@ -267,6 +272,7 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->m_nKeyModifier = 0;
|
||||
switch (pEvent->keyval)
|
||||
{
|
||||
case GDK_KEY_BackSpace:
|
||||
@ -296,6 +302,21 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
|
||||
case GDK_KEY_Right:
|
||||
nKeyCode = com::sun::star::awt::Key::RIGHT;
|
||||
break;
|
||||
case GDK_KEY_Shift_L:
|
||||
case GDK_KEY_Shift_R:
|
||||
if (pEvent->type == GDK_KEY_PRESS)
|
||||
priv->m_nKeyModifier |= KEY_SHIFT;
|
||||
break;
|
||||
case GDK_KEY_Control_L:
|
||||
case GDK_KEY_Control_R:
|
||||
if (pEvent->type == GDK_KEY_PRESS)
|
||||
priv->m_nKeyModifier |= KEY_MOD1;
|
||||
break;
|
||||
case GDK_KEY_Alt_L:
|
||||
case GDK_KEY_Alt_R:
|
||||
if (pEvent->type == GDK_KEY_PRESS)
|
||||
priv->m_nKeyModifier |= KEY_MOD2;
|
||||
break;
|
||||
default:
|
||||
if (pEvent->keyval >= GDK_KEY_F1 && pEvent->keyval <= GDK_KEY_F26)
|
||||
nKeyCode = com::sun::star::awt::Key::F1 + (pEvent->keyval - GDK_KEY_F1);
|
||||
@ -309,7 +330,6 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
|
||||
if (pEvent->state & GDK_SHIFT_MASK)
|
||||
nKeyCode |= KEY_SHIFT;
|
||||
|
||||
|
||||
if (pEvent->type == GDK_KEY_RELEASE)
|
||||
{
|
||||
GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
|
||||
@ -1060,6 +1080,20 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
|
||||
pLOEvent->m_nPostMouseEventX = pixelToTwip(pEvent->x, priv->m_fZoom);
|
||||
pLOEvent->m_nPostMouseEventY = pixelToTwip(pEvent->y, priv->m_fZoom);
|
||||
pLOEvent->m_nPostMouseEventCount = nCount;
|
||||
switch (pEvent->button)
|
||||
{
|
||||
case 1:
|
||||
pLOEvent->m_nPostMouseEventButton = MOUSE_LEFT;
|
||||
break;
|
||||
case 2:
|
||||
pLOEvent->m_nPostMouseEventButton = MOUSE_MIDDLE;
|
||||
break;
|
||||
case 3:
|
||||
pLOEvent->m_nPostMouseEventButton = MOUSE_RIGHT;
|
||||
break;
|
||||
}
|
||||
pLOEvent->m_nPostMouseEventModifier = priv->m_nKeyModifier;
|
||||
priv->m_nLastButtonPressed = pLOEvent->m_nPostMouseEventButton;
|
||||
g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
|
||||
|
||||
g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), NULL);
|
||||
@ -1078,6 +1112,20 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
|
||||
pLOEvent->m_nPostMouseEventX = pixelToTwip(pEvent->x, priv->m_fZoom);
|
||||
pLOEvent->m_nPostMouseEventY = pixelToTwip(pEvent->y, priv->m_fZoom);
|
||||
pLOEvent->m_nPostMouseEventCount = nCount;
|
||||
switch (pEvent->button)
|
||||
{
|
||||
case 1:
|
||||
pLOEvent->m_nPostMouseEventButton = MOUSE_LEFT;
|
||||
break;
|
||||
case 2:
|
||||
pLOEvent->m_nPostMouseEventButton = MOUSE_MIDDLE;
|
||||
break;
|
||||
case 3:
|
||||
pLOEvent->m_nPostMouseEventButton = MOUSE_RIGHT;
|
||||
break;
|
||||
}
|
||||
pLOEvent->m_nPostMouseEventModifier = priv->m_nKeyModifier;
|
||||
priv->m_nLastButtonPressed = pLOEvent->m_nPostMouseEventButton;
|
||||
g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
|
||||
|
||||
g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), NULL);
|
||||
@ -1182,6 +1230,9 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent)
|
||||
pLOEvent->m_nPostMouseEventX = pixelToTwip(pEvent->x, priv->m_fZoom);
|
||||
pLOEvent->m_nPostMouseEventY = pixelToTwip(pEvent->y, priv->m_fZoom);
|
||||
pLOEvent->m_nPostMouseEventCount = 1;
|
||||
pLOEvent->m_nPostMouseEventButton = priv->m_nLastButtonPressed;
|
||||
pLOEvent->m_nPostMouseEventModifier = priv->m_nKeyModifier;
|
||||
|
||||
g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
|
||||
|
||||
g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), NULL);
|
||||
@ -1218,7 +1269,9 @@ postMouseEventInThread(gpointer data)
|
||||
pLOEvent->m_nPostMouseEventType,
|
||||
pLOEvent->m_nPostMouseEventX,
|
||||
pLOEvent->m_nPostMouseEventY,
|
||||
pLOEvent->m_nPostMouseEventCount);
|
||||
pLOEvent->m_nPostMouseEventCount,
|
||||
pLOEvent->m_nPostMouseEventButton,
|
||||
pLOEvent->m_nPostMouseEventModifier);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -202,6 +202,8 @@ struct LOEvent
|
||||
int m_nPostMouseEventX;
|
||||
int m_nPostMouseEventY;
|
||||
int m_nPostMouseEventCount;
|
||||
int m_nPostMouseEventButton;
|
||||
int m_nPostMouseEventModifier;
|
||||
///@}
|
||||
|
||||
/// @name setGraphicSelection parameters
|
||||
@ -230,6 +232,8 @@ struct LOEvent
|
||||
, m_nPostMouseEventX(0)
|
||||
, m_nPostMouseEventY(0)
|
||||
, m_nPostMouseEventCount(0)
|
||||
, m_nPostMouseEventButton(0)
|
||||
, m_nPostMouseEventModifier(0)
|
||||
, m_nSetGraphicSelectionType(0)
|
||||
, m_nSetGraphicSelectionX(0)
|
||||
, m_nSetGraphicSelectionY(0)
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include <cppuhelper/implbase.hxx>
|
||||
#include <cppuhelper/interfacecontainer.h>
|
||||
#include <svl/itemprop.hxx>
|
||||
#include <vcl/event.hxx>
|
||||
#include <vcl/ITiledRenderable.hxx>
|
||||
#include "drwlayer.hxx"
|
||||
|
||||
@ -398,7 +399,7 @@ public:
|
||||
virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) SAL_OVERRIDE;
|
||||
|
||||
/// @see vcl::ITiledRenderable::postMouseEvent().
|
||||
virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
|
||||
virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons = MOUSE_LEFT, int nModifier = 0) SAL_OVERRIDE;
|
||||
|
||||
/// @see vcl::ITiledRenderable::setTextSelection().
|
||||
virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
|
||||
|
@ -591,7 +591,7 @@ void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
|
||||
}
|
||||
}
|
||||
|
||||
void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount)
|
||||
void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
|
||||
@ -607,7 +607,8 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount)
|
||||
pViewData->SetZoom(Fraction(1, 1), Fraction(1, 1), true);
|
||||
|
||||
// Calc operates in pixels...
|
||||
MouseEvent aEvent(Point(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY()), nCount, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
|
||||
MouseEvent aEvent(Point(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY()), nCount,
|
||||
MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
|
||||
|
||||
switch (nType)
|
||||
{
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <sfx2/sfxbasemodel.hxx>
|
||||
#include <svx/fmdmod.hxx>
|
||||
|
||||
#include <vcl/event.hxx>
|
||||
#include <vcl/ITiledRenderable.hxx>
|
||||
|
||||
#include <editeng/unoipset.hxx>
|
||||
@ -249,7 +250,7 @@ public:
|
||||
/// @see vcl::ITiledRenderable::postKeyEvent().
|
||||
virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::postMouseEvent().
|
||||
virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
|
||||
virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons = MOUSE_LEFT, int nModifier = 0) SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::setTextSelection().
|
||||
virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::getTextSelection().
|
||||
|
@ -2422,7 +2422,7 @@ void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
|
||||
}
|
||||
}
|
||||
|
||||
void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
|
||||
void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
|
||||
@ -2430,7 +2430,8 @@ void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
|
||||
if (!pViewShell)
|
||||
return;
|
||||
|
||||
MouseEvent aEvent(Point(convertTwipToMm100(nX), convertTwipToMm100(nY)), nCount, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
|
||||
MouseEvent aEvent(Point(convertTwipToMm100(nX), convertTwipToMm100(nY)), nCount,
|
||||
MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
|
||||
|
||||
switch (nType)
|
||||
{
|
||||
|
@ -66,6 +66,7 @@
|
||||
#include <editeng/UnoForbiddenCharsTable.hxx>
|
||||
#include <cppuhelper/weak.hxx>
|
||||
#include <cppuhelper/implbase.hxx>
|
||||
#include <vcl/event.hxx>
|
||||
#include <vcl/ITiledRenderable.hxx>
|
||||
#include <com/sun/star/tiledrendering/XTiledRenderable.hpp>
|
||||
|
||||
@ -419,7 +420,7 @@ public:
|
||||
/// @see vcl::ITiledRenderable::postKeyEvent().
|
||||
virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::postMouseEvent().
|
||||
virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
|
||||
virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons = MOUSE_LEFT, int nModifier = 0) SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::setTextSelection().
|
||||
virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::getTextSelection().
|
||||
|
@ -3272,12 +3272,12 @@ void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
|
||||
}
|
||||
}
|
||||
|
||||
void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
|
||||
void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
|
||||
SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
|
||||
MouseEvent aEvent(Point(nX, nY), nCount, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
|
||||
MouseEvent aEvent(Point(nX, nY), nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
|
||||
|
||||
switch (nType)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user