diff options
author | Mihai Varga <mihai.varga@collabora.com> | 2015-10-04 19:40:13 +0300 |
---|---|---|
committer | Mihai Varga <mihai.mv13@gmail.com> | 2015-10-05 15:02:36 +0300 |
commit | c90c08a65c480a1012182979d5e9218f17a2ba2e (patch) | |
tree | ac2e2ca3d07c6ac7c356fd8e503924fe4184d4d8 /libreofficekit | |
parent | 0326352470aee1a774bb5aa314c4f3625c1372b3 (diff) |
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
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/Library_libreofficekitgtk.mk | 4 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 57 | ||||
-rw-r--r-- | libreofficekit/source/gtk/tilebuffer.hxx | 4 |
3 files changed, 63 insertions, 2 deletions
diff --git a/libreofficekit/Library_libreofficekitgtk.mk b/libreofficekit/Library_libreofficekitgtk.mk index 71a77e9e36a3..7d25abf944b1 100644 --- a/libreofficekit/Library_libreofficekitgtk.mk +++ b/libreofficekit/Library_libreofficekitgtk.mk @@ -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) \ )) diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 2270231b1cf5..2d34e581ae73 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -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 diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx index 5a989fcf2059..668a72007f46 100644 --- a/libreofficekit/source/gtk/tilebuffer.hxx +++ b/libreofficekit/source/gtk/tilebuffer.hxx @@ -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) |