loleaflet/src/layer/tile/TileLayer.js                   |   13 +++++-
 loleaflet/src/map/handler/Map.Keyboard.js               |    6 ++
 loleaflet/src/map/handler/Map.Mouse.js                  |   33 ++++++++++++----
 loolwsd/LOOLSession.cpp                                 |   10 ++--
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h |    4 +
 5 files changed, 52 insertions(+), 14 deletions(-)

New commits:
commit 14dca89150ca550e8031888b1cd5b1f37ee626da
Author: Mihai Varga <[email protected]>
Date:   Mon Oct 5 15:04:19 2015 +0300

    We now send the mouse button that has been pressed and also they key
    modifiers for actions such as ctrl+click or shift+click

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 86d7f2b..cfe686a 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -191,6 +191,9 @@ L.TileLayer = L.GridLayer.extend({
                else if (textMsg.startsWith('graphicselection:')) {
                        this._onGraphicSelectionMsg(textMsg);
                }
+               else if (textMsg.startsWith('hyperlinkclicked:')) {
+                       this._onHyperlinkClickedMsg(textMsg);
+               }
                else if (textMsg.startsWith('invalidatecursor:')) {
                        this._onInvalidateCursorMsg(textMsg);
                }
@@ -280,6 +283,11 @@ L.TileLayer = L.GridLayer.extend({
                this._onUpdateGraphicSelection();
        },
 
+       _onHyperlinkClickedMsg: function (textMsg) {
+               var link = textMsg.substring(18);
+               window.open(link, '_blank');
+       },
+
        _onInvalidateCursorMsg: function (textMsg) {
                var strTwips = textMsg.match(/\d+/g);
                var topLeftTwips = new L.Point(parseInt(strTwips[0]), 
parseInt(strTwips[1]));
@@ -503,9 +511,10 @@ L.TileLayer = L.GridLayer.extend({
                this._onUpdateGraphicSelection();
        },
 
-       _postMouseEvent: function(type, x, y, count) {
+       _postMouseEvent: function(type, x, y, count, buttons, modifier) {
                L.Socket.sendMessage('mouse type=' + type +
-                               ' x=' + x + ' y=' + y + ' count=' + count);
+                               ' x=' + x + ' y=' + y + ' count=' + count +
+                               ' buttons=' + buttons + ' modifier=' + 
modifier);
        },
 
        _postKeyboardEvent: function(type, charcode, keycode) {
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js 
b/loleaflet/src/map/handler/Map.Keyboard.js
index 987d2b4..98c722d 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -115,6 +115,7 @@ L.Map.Keyboard = L.Handler.extend({
                this._map = map;
                this._setPanOffset(map.options.keyboardPanOffset);
                this._setZoomOffset(map.options.keyboardZoomOffset);
+               this.modifier = 0;
        },
 
        addHooks: function () {
@@ -180,6 +181,11 @@ L.Map.Keyboard = L.Handler.extend({
 
        _onKeyDown: function (e) {
                var docLayer = this._map._docLayer;
+               this.modifier = 0;
+               var shift = e.originalEvent.shiftKey ? this.keyModifier.shift : 
0;
+               var ctrl = e.originalEvent.ctrlKey ? this.keyModifier.ctrl : 0;
+               var alt = e.originalEvent.altKey ? this.keyModifier.alt : 0;
+               this.modifier = shift | ctrl | alt;
                if (e.originalEvent.ctrlKey) {
                        // we prepare for a copy event
                        docLayer._textArea.value = 'dummy text';
diff --git a/loleaflet/src/map/handler/Map.Mouse.js 
b/loleaflet/src/map/handler/Map.Mouse.js
index ac731a8..9fd8ba8 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -23,6 +23,18 @@ L.Map.Mouse = L.Handler.extend({
                        this._onMouseEvent, this);
        },
 
+       LOButtons: {
+               left: 1,
+               middle: 2,
+               right: 4
+       },
+
+       JSButtons: {
+               left: 0,
+               middle: 1,
+               right: 2
+       },
+
        _onMouseEvent: function (e) {
                var docLayer = this._map._docLayer;
                if (!docLayer) {
@@ -39,6 +51,12 @@ L.Map.Mouse = L.Handler.extend({
                        }
                }
 
+               var modifier = this._map.keyboard.modifier;
+               var buttons = 0;
+               buttons |= e.originalEvent.button === this.JSButtons.left ? 
this.LOButtons.left : 0;
+               buttons |= e.originalEvent.button === this.JSButtons.middle ? 
this.LOButtons.middle : 0;
+               buttons |= e.originalEvent.button === this.JSButtons.right ? 
this.LOButtons.right : 0;
+
                if (e.type === 'mousedown') {
                        docLayer._resetPreFetching();
                        this._mouseDown = true;
@@ -47,7 +65,8 @@ L.Map.Mouse = L.Handler.extend({
                        }
                        var mousePos = docLayer._latLngToTwips(e.latlng);
                        this._mouseEventsQueue.push(L.bind(function() {
-                               this._postMouseEvent('buttondown', mousePos.x, 
mousePos.y, 1);}, docLayer));
+                               this._postMouseEvent('buttondown', mousePos.x, 
mousePos.y, 1, buttons, modifier);
+                       }, docLayer));
                        this._holdMouseEvent = 
setTimeout(L.bind(this._executeMouseEvents, this), 500);
                }
                else if (e.type === 'mouseup') {
@@ -82,7 +101,7 @@ L.Map.Mouse = L.Handler.extend({
                                                }
                                        }
                                        this._mouseEventsQueue = [];
-                                       docLayer._postMouseEvent('buttonup', 
mousePos.x, mousePos.y, 1);
+                                       docLayer._postMouseEvent('buttonup', 
mousePos.x, mousePos.y, 1, buttons, modifier);
                                        docLayer._textArea.focus();
                                }, this));
                                this._holdMouseEvent = 
setTimeout(L.bind(this._executeMouseEvents, this), timeOut);
@@ -113,7 +132,7 @@ L.Map.Mouse = L.Handler.extend({
                        }
                        if (!this._map.dragging.enabled()) {
                                mousePos = docLayer._latLngToTwips(e.latlng);
-                               docLayer._postMouseEvent('move', mousePos.x, 
mousePos.y, 1);
+                               docLayer._postMouseEvent('move', mousePos.x, 
mousePos.y, 1, buttons, modifier);
                                for (key in docLayer._selectionHandles) {
                                        handle = 
docLayer._selectionHandles[key];
                                        if (handle._icon) {
@@ -124,10 +143,10 @@ L.Map.Mouse = L.Handler.extend({
                }
                else if (e.type === 'dblclick') {
                        mousePos = docLayer._latLngToTwips(e.latlng);
-                       docLayer._postMouseEvent('buttondown', mousePos.x, 
mousePos.y, 1);
-                       docLayer._postMouseEvent('buttondown', mousePos.x, 
mousePos.y, 2);
-                       docLayer._postMouseEvent('buttonup', mousePos.x, 
mousePos.y, 2);
-                       docLayer._postMouseEvent('buttonup', mousePos.x, 
mousePos.y, 1);
+                       docLayer._postMouseEvent('buttondown', mousePos.x, 
mousePos.y, 1, buttons, modifier);
+                       docLayer._postMouseEvent('buttondown', mousePos.x, 
mousePos.y, 2, buttons, modifier);
+                       docLayer._postMouseEvent('buttonup', mousePos.x, 
mousePos.y, 2, 1, buttons, modifier);
+                       docLayer._postMouseEvent('buttonup', mousePos.x, 
mousePos.y, 1, 1, buttons, modifier);
                }
        },
 
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 5f5d12e..a293cde 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -1025,9 +1025,9 @@ bool ChildProcessSession::keyEvent(const char *buffer, 
int length, StringTokeniz
 
 bool ChildProcessSession::mouseEvent(const char *buffer, int length, 
StringTokenizer& tokens)
 {
-    int type, x, y, count;
+    int type, x, y, count, buttons, modifier;
 
-    if (tokens.count() != 5 ||
+    if (tokens.count() != 7 ||
         !getTokenKeyword(tokens[1], "type",
                          {{"buttondown", LOK_MOUSEEVENT_MOUSEBUTTONDOWN},
                           {"buttonup", LOK_MOUSEEVENT_MOUSEBUTTONUP},
@@ -1035,13 +1035,15 @@ bool ChildProcessSession::mouseEvent(const char 
*buffer, int length, StringToken
                          type) ||
         !getTokenInteger(tokens[2], "x", x) ||
         !getTokenInteger(tokens[3], "y", y) ||
-        !getTokenInteger(tokens[4], "count", count))
+        !getTokenInteger(tokens[4], "count", count),
+        !getTokenInteger(tokens[5], "buttons", buttons),
+        !getTokenInteger(tokens[6], "modifier", modifier))
     {
         sendTextFrame("error: cmd=mouse kind=syntax");
         return false;
     }
 
-    _loKitDocument->pClass->postMouseEvent(_loKitDocument, type, x, y, count);
+    _loKitDocument->pClass->postMouseEvent(_loKitDocument, type, x, y, count, 
buttons, modifier);
 
     return true;
 }
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h 
b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
index d83dd49..83dcc98 100644
--- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
@@ -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,
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to