summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-12-01 14:27:21 +0530
committerJan Holesovsky <kendy@collabora.com>2017-12-04 13:03:08 +0100
commit9d2b7628d901bed92fc2a490084b0ac51aa6691b (patch)
treec1162f2709667eade6f8c0c5fcc697a1d8477776
parentb4d5eb3837f51096933332ed058657bd092696af (diff)
lokdialog: Merge dialog & dialog child mouse event APIs into one
Change-Id: I91aaa6a58f33dd2d817e02533de96e0c8191f2ca
-rw-r--r--desktop/source/lib/init.cxx46
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h20
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx31
-rw-r--r--include/vcl/window.hxx3
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx54
-rw-r--r--vcl/source/window/window.cxx36
6 files changed, 54 insertions, 136 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 849b2e516b53..76748a87a317 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -576,7 +576,7 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
int nCount,
int nButtons,
int nModifier);
-static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
+static void doc_postWindowMouseEvent (LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
int nType,
int nX,
@@ -584,14 +584,6 @@ static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
int nCount,
int nButtons,
int nModifier);
-static void doc_postDialogChildMouseEvent (LibreOfficeKitDocument* pThis,
- unsigned nLOKWindowId,
- int nType,
- int nX,
- int nY,
- int nCount,
- int nButtons,
- int nModifier);
static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
const char* pCommand,
const char* pArguments,
@@ -666,8 +658,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent;
m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
- m_pDocumentClass->postDialogMouseEvent = doc_postDialogMouseEvent;
- m_pDocumentClass->postDialogChildMouseEvent = doc_postDialogChildMouseEvent;
+ m_pDocumentClass->postWindowMouseEvent = doc_postWindowMouseEvent;
m_pDocumentClass->postUnoCommand = doc_postUnoCommand;
m_pDocumentClass->setTextSelection = doc_setTextSelection;
m_pDocumentClass->getTextSelection = doc_getTextSelection;
@@ -2456,7 +2447,7 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
}
}
-static void doc_postDialogMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+static void doc_postWindowMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
SolarMutexGuard aGuard;
@@ -2487,37 +2478,6 @@ static void doc_postDialogMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned
}
}
-static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
-{
- SolarMutexGuard aGuard;
-
- VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
- if (!pWindow)
- {
- gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
- return;
- }
-
- Point aPos(nX, nY);
- MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
-
- switch (nType)
- {
- case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
- pWindow->LogicMouseButtonDownChild(aEvent);
- break;
- case LOK_MOUSEEVENT_MOUSEBUTTONUP:
- pWindow->LogicMouseButtonUpChild(aEvent);
- break;
- case LOK_MOUSEEVENT_MOUSEMOVE:
- pWindow->LogicMouseMoveChild(aEvent);
- break;
- default:
- assert(false);
- break;
- }
-}
-
static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
{
SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 9af42a1e3e5c..69b20106314c 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -259,7 +259,7 @@ struct _LibreOfficeKitDocumentClass
int* pArray,
size_t nSize);
- /// Paints dialog with given dialog id to the buffer
+ /// Paints window with given id to the buffer
/// @see lok::Document::paintWindow().
void (*paintWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
unsigned char* pBuffer,
@@ -271,14 +271,14 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::postWindowKeyEvent().
void (*postWindowKeyEvent) (LibreOfficeKitDocument* pThis,
- unsigned nDialogId,
+ unsigned nWindowId,
int nType,
int nCharCode,
int nKeyCode);
- /// @see lok::Document::postDialogMouseEvent().
- void (*postDialogMouseEvent) (LibreOfficeKitDocument* pThis,
- unsigned nDialogId,
+ /// @see lok::Document::postWindowMouseEvent().
+ void (*postWindowMouseEvent) (LibreOfficeKitDocument* pThis,
+ unsigned nWindowId,
int nType,
int nX,
int nY,
@@ -286,16 +286,6 @@ struct _LibreOfficeKitDocumentClass
int nButtons,
int nModifier);
- /// @see lok::Document::postDialogChildMouseEvent().
- void (*postDialogChildMouseEvent) (LibreOfficeKitDocument* pThis,
- unsigned nDialogId,
- int nType,
- int nX,
- int nY,
- int nCount,
- int nButtons,
- int nModifier);
-
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 4f3d4751b46c..7bdd2c470092 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -253,14 +253,14 @@ public:
/**
* Posts a keyboard event to the dialog
*
- * @param nDialogId Dialog id on which key event should be posted
+ * @param nWindowId
* @param nType Event type, like press or release.
* @param nCharCode contains the Unicode character generated by this event or 0
* @param nKeyCode contains the integer code representing the key of the event (non-zero for control keys)
*/
- void postWindowKeyEvent(unsigned nDialogId, int nType, int nCharCode, int nKeyCode)
+ void postWindowKeyEvent(unsigned nWindowId, int nType, int nCharCode, int nKeyCode)
{
- mpDoc->pClass->postWindowKeyEvent(mpDoc, nDialogId, nType, nCharCode, nKeyCode);
+ mpDoc->pClass->postWindowKeyEvent(mpDoc, nWindowId, nType, nCharCode, nKeyCode);
}
/**
@@ -279,25 +279,9 @@ public:
}
/**
- * Posts a mouse event to the dialog with given id.
+ * Posts a mouse event to the window with given id.
*
- * @param nDialogId Dialog id where mouse event is to be posted
- * @param nType Event type, like down, move or up.
- * @param nX horizontal position in document coordinates
- * @param nY vertical position in document coordinates
- * @param nCount number of clicks: 1 for single click, 2 for double click
- * @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right
- * @param nModifier: which keyboard modifier: (see include/vcl/vclenum.hxx for possible values)
- */
- void postDialogMouseEvent(unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
- {
- mpDoc->pClass->postDialogMouseEvent(mpDoc, nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
- }
-
- /**
- * Posts a mouse event to the child of a dialog with given id.
- *
- * @param nDialogId Dialog id
+ * @param nWindowId
* @param nType Event type, like down, move or up.
* @param nX horizontal position in document coordinates
* @param nY vertical position in document coordinates
@@ -305,12 +289,11 @@ public:
* @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right
* @param nModifier: which keyboard modifier: (see include/vcl/vclenum.hxx for possible values)
*/
- void postDialogChildMouseEvent(unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+ void postWindowMouseEvent(unsigned nWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
- mpDoc->pClass->postDialogChildMouseEvent(mpDoc, nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
+ mpDoc->pClass->postWindowMouseEvent(mpDoc, nWindowId, nType, nX, nY, nCount, nButtons, nModifier);
}
-
/**
* Posts an UNO command to the document.
*
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 9b52a4da7810..c17c8ab3b108 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1222,9 +1222,6 @@ public:
void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
void LogicMouseMove(const MouseEvent& rMouseEvent);
- void LogicMouseButtonDownChild(const MouseEvent& rMouseEvent);
- void LogicMouseButtonUpChild(const MouseEvent& rMouseEvent);
- void LogicMouseMoveChild(const MouseEvent& rMouseEvent);
void LOKKeyInput(const KeyEvent& rKeyEvent);
void LOKKeyUp(const KeyEvent& rKeyEvent);
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index b5d97805f9bc..5770e1349305 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -162,7 +162,7 @@ gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve
break;
}
priv->m_nLastButtonPressed = nEventButton;
- pDocument->pClass->postDialogMouseEvent(pDocument,
+ pDocument->pClass->postWindowMouseEvent(pDocument,
priv->dialogid,
LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
(pEvent->x),
@@ -193,7 +193,7 @@ gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve
break;
}
priv->m_nLastButtonPressed = nEventButton;
- pDocument->pClass->postDialogMouseEvent(pDocument,
+ pDocument->pClass->postWindowMouseEvent(pDocument,
priv->dialogid,
LOK_MOUSEEVENT_MOUSEBUTTONUP,
(pEvent->x),
@@ -223,7 +223,7 @@ gtv_lok_dialog_signal_motion(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve
(int)pixelToTwip(pEvent->x),
(int)pixelToTwip(pEvent->y));
- pDocument->pClass->postDialogMouseEvent(pDocument,
+ pDocument->pClass->postWindowMouseEvent(pDocument,
priv->dialogid,
LOK_MOUSEEVENT_MOUSEMOVE,
(pEvent->x),
@@ -541,14 +541,14 @@ gtv_lok_dialog_floating_win_signal_button(GtkWidget* /*pDialogChildDrawingArea*/
break;
}
priv->m_nChildLastButtonPressed = nEventButton;
- pDocument->pClass->postDialogChildMouseEvent(pDocument,
- priv->m_nChildId,
- LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
- (pEvent->x),
- (pEvent->y),
- nCount,
- nEventButton,
- priv->m_nChildKeyModifier);
+ pDocument->pClass->postWindowMouseEvent(pDocument,
+ priv->m_nChildId,
+ LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+ (pEvent->x),
+ (pEvent->y),
+ nCount,
+ nEventButton,
+ priv->m_nChildKeyModifier);
break;
}
@@ -572,14 +572,14 @@ gtv_lok_dialog_floating_win_signal_button(GtkWidget* /*pDialogChildDrawingArea*/
break;
}
priv->m_nChildLastButtonPressed = nEventButton;
- pDocument->pClass->postDialogChildMouseEvent(pDocument,
- priv->m_nChildId,
- LOK_MOUSEEVENT_MOUSEBUTTONUP,
- (pEvent->x),
- (pEvent->y),
- nCount,
- nEventButton,
- priv->m_nChildKeyModifier);
+ pDocument->pClass->postWindowMouseEvent(pDocument,
+ priv->m_nChildId,
+ LOK_MOUSEEVENT_MOUSEBUTTONUP,
+ (pEvent->x),
+ (pEvent->y),
+ nCount,
+ nEventButton,
+ priv->m_nChildKeyModifier);
break;
}
default:
@@ -602,14 +602,14 @@ gtv_lok_dialog_floating_win_signal_motion(GtkWidget* /*pDialogDrawingArea*/, Gdk
(int)pixelToTwip(pEvent->x),
(int)pixelToTwip(pEvent->y));
- pDocument->pClass->postDialogChildMouseEvent(pDocument,
- priv->m_nChildId,
- LOK_MOUSEEVENT_MOUSEMOVE,
- (pEvent->x),
- (pEvent->y),
- 1,
- priv->m_nChildLastButtonPressed,
- priv->m_nChildKeyModifier);
+ pDocument->pClass->postWindowMouseEvent(pDocument,
+ priv->m_nChildId,
+ LOK_MOUSEEVENT_MOUSEMOVE,
+ (pEvent->x),
+ (pEvent->y),
+ 1,
+ priv->m_nChildLastButtonPressed,
+ priv->m_nChildKeyModifier);
return FALSE;
}
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 36faa9a32f20..0bc0fe7bd33b 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3260,7 +3260,10 @@ void Window::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
// When we're not doing tiled rendering, then positions must be passed as pixels.
assert(comphelper::LibreOfficeKit::isActive());
- ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonDown, &rMouseEvent);
+ if (dynamic_cast<FloatingWindow*>(this) != nullptr)
+ ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent);
+ else
+ ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonDown, &rMouseEvent);
}
void Window::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
@@ -3268,7 +3271,10 @@ void Window::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
// When we're not doing tiled rendering, then positions must be passed as pixels.
assert(comphelper::LibreOfficeKit::isActive());
- ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonUp, &rMouseEvent);
+ if (dynamic_cast<FloatingWindow*>(this) != nullptr)
+ ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent);
+ else
+ ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonUp, &rMouseEvent);
}
void Window::LogicMouseMove(const MouseEvent& rMouseEvent)
@@ -3276,28 +3282,10 @@ void Window::LogicMouseMove(const MouseEvent& rMouseEvent)
// When we're not doing tiled rendering, then positions must be passed as pixels.
assert(comphelper::LibreOfficeKit::isActive());
- ImplWindowFrameProc(this, SalEvent::ExternalMouseMove, &rMouseEvent);
-}
-
-void Window::LogicMouseButtonDownChild(const MouseEvent& rMouseEvent)
-{
- assert(comphelper::LibreOfficeKit::isActive());
-
- ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent);
-}
-
-void Window::LogicMouseButtonUpChild(const MouseEvent& rMouseEvent)
-{
- assert(comphelper::LibreOfficeKit::isActive());
-
- ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent);
-}
-
-void Window::LogicMouseMoveChild(const MouseEvent& rMouseEvent)
-{
- assert(comphelper::LibreOfficeKit::isActive());
-
- ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent);
+ if (dynamic_cast<FloatingWindow*>(this) != nullptr)
+ ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent);
+ else
+ ImplWindowFrameProc(this, SalEvent::ExternalMouseMove, &rMouseEvent);
}
void Window::LOKKeyInput(const KeyEvent& rKeyEvent)