lokdialog: Merge dialog & dialog child mouse event APIs into one

Change-Id: I91aaa6a58f33dd2d817e02533de96e0c8191f2ca
This commit is contained in:
Pranav Kant
2017-12-01 14:27:21 +05:30
parent ae412b57e3
commit b1bcc70d2a
6 changed files with 54 additions and 136 deletions

View File

@@ -556,7 +556,7 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
int nCount, int nCount,
int nButtons, int nButtons,
int nModifier); int nModifier);
static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis, static void doc_postWindowMouseEvent (LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId, unsigned nLOKWindowId,
int nType, int nType,
int nX, int nX,
@@ -564,14 +564,6 @@ static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
int nCount, int nCount,
int nButtons, int nButtons,
int nModifier); 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, static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
const char* pCommand, const char* pCommand,
const char* pArguments, const char* pArguments,
@@ -646,8 +638,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->postKeyEvent = doc_postKeyEvent; m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent; m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent;
m_pDocumentClass->postMouseEvent = doc_postMouseEvent; m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
m_pDocumentClass->postDialogMouseEvent = doc_postDialogMouseEvent; m_pDocumentClass->postWindowMouseEvent = doc_postWindowMouseEvent;
m_pDocumentClass->postDialogChildMouseEvent = doc_postDialogChildMouseEvent;
m_pDocumentClass->postUnoCommand = doc_postUnoCommand; m_pDocumentClass->postUnoCommand = doc_postUnoCommand;
m_pDocumentClass->setTextSelection = doc_setTextSelection; m_pDocumentClass->setTextSelection = doc_setTextSelection;
m_pDocumentClass->getTextSelection = doc_getTextSelection; m_pDocumentClass->getTextSelection = doc_getTextSelection;
@@ -2429,7 +2420,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; SolarMutexGuard aGuard;
@@ -2460,37 +2451,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) static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;

View File

@@ -270,7 +270,7 @@ struct _LibreOfficeKitDocumentClass
int* pArray, int* pArray,
size_t nSize); size_t nSize);
/// Paints dialog with given dialog id to the buffer /// Paints window with given id to the buffer
/// @see lok::Document::paintWindow(). /// @see lok::Document::paintWindow().
void (*paintWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId, void (*paintWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
unsigned char* pBuffer, unsigned char* pBuffer,
@@ -282,14 +282,14 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::postWindowKeyEvent(). /// @see lok::Document::postWindowKeyEvent().
void (*postWindowKeyEvent) (LibreOfficeKitDocument* pThis, void (*postWindowKeyEvent) (LibreOfficeKitDocument* pThis,
unsigned nDialogId, unsigned nWindowId,
int nType, int nType,
int nCharCode, int nCharCode,
int nKeyCode); int nKeyCode);
/// @see lok::Document::postDialogMouseEvent(). /// @see lok::Document::postWindowMouseEvent().
void (*postDialogMouseEvent) (LibreOfficeKitDocument* pThis, void (*postWindowMouseEvent) (LibreOfficeKitDocument* pThis,
unsigned nDialogId, unsigned nWindowId,
int nType, int nType,
int nX, int nX,
int nY, int nY,
@@ -297,16 +297,6 @@ struct _LibreOfficeKitDocumentClass
int nButtons, int nButtons,
int nModifier); 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 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
}; };

View File

@@ -254,14 +254,14 @@ public:
/** /**
* Posts a keyboard event to the dialog * 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 nType Event type, like press or release.
* @param nCharCode contains the Unicode character generated by this event or 0 * @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) * @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);
} }
/** /**
@@ -280,9 +280,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 nWindowId
* @param nType Event type, like down, move or up. * @param nType Event type, like down, move or up.
* @param nX horizontal position in document coordinates * @param nX horizontal position in document coordinates
* @param nY vertical position in document coordinates * @param nY vertical position in document coordinates
@@ -290,28 +290,11 @@ public:
* @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right * @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) * @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) void postWindowMouseEvent(unsigned nWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{ {
mpDoc->pClass->postDialogMouseEvent(mpDoc, nDialogId, nType, nX, nY, nCount, nButtons, nModifier); mpDoc->pClass->postWindowMouseEvent(mpDoc, nWindowId, nType, nX, nY, nCount, nButtons, nModifier);
} }
/**
* Posts a mouse event to the child of a dialog with given id.
*
* @param nDialogId Dialog id
* @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 postDialogChildMouseEvent(unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
mpDoc->pClass->postDialogChildMouseEvent(mpDoc, nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
}
/** /**
* Posts an UNO command to the document. * Posts an UNO command to the document.
* *

View File

@@ -1221,9 +1221,6 @@ public:
void LogicMouseButtonDown(const MouseEvent& rMouseEvent); void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
void LogicMouseButtonUp(const MouseEvent& rMouseEvent); void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
void LogicMouseMove(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 LOKKeyInput(const KeyEvent& rKeyEvent);
void LOKKeyUp(const KeyEvent& rKeyEvent); void LOKKeyUp(const KeyEvent& rKeyEvent);

View File

@@ -162,7 +162,7 @@ gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve
break; break;
} }
priv->m_nLastButtonPressed = nEventButton; priv->m_nLastButtonPressed = nEventButton;
pDocument->pClass->postDialogMouseEvent(pDocument, pDocument->pClass->postWindowMouseEvent(pDocument,
priv->dialogid, priv->dialogid,
LOK_MOUSEEVENT_MOUSEBUTTONDOWN, LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
(pEvent->x), (pEvent->x),
@@ -193,7 +193,7 @@ gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve
break; break;
} }
priv->m_nLastButtonPressed = nEventButton; priv->m_nLastButtonPressed = nEventButton;
pDocument->pClass->postDialogMouseEvent(pDocument, pDocument->pClass->postWindowMouseEvent(pDocument,
priv->dialogid, priv->dialogid,
LOK_MOUSEEVENT_MOUSEBUTTONUP, LOK_MOUSEEVENT_MOUSEBUTTONUP,
(pEvent->x), (pEvent->x),
@@ -223,7 +223,7 @@ gtv_lok_dialog_signal_motion(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve
(int)pixelToTwip(pEvent->x), (int)pixelToTwip(pEvent->x),
(int)pixelToTwip(pEvent->y)); (int)pixelToTwip(pEvent->y));
pDocument->pClass->postDialogMouseEvent(pDocument, pDocument->pClass->postWindowMouseEvent(pDocument,
priv->dialogid, priv->dialogid,
LOK_MOUSEEVENT_MOUSEMOVE, LOK_MOUSEEVENT_MOUSEMOVE,
(pEvent->x), (pEvent->x),
@@ -541,14 +541,14 @@ gtv_lok_dialog_floating_win_signal_button(GtkWidget* /*pDialogChildDrawingArea*/
break; break;
} }
priv->m_nChildLastButtonPressed = nEventButton; priv->m_nChildLastButtonPressed = nEventButton;
pDocument->pClass->postDialogChildMouseEvent(pDocument, pDocument->pClass->postWindowMouseEvent(pDocument,
priv->m_nChildId, priv->m_nChildId,
LOK_MOUSEEVENT_MOUSEBUTTONDOWN, LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
(pEvent->x), (pEvent->x),
(pEvent->y), (pEvent->y),
nCount, nCount,
nEventButton, nEventButton,
priv->m_nChildKeyModifier); priv->m_nChildKeyModifier);
break; break;
} }
@@ -572,14 +572,14 @@ gtv_lok_dialog_floating_win_signal_button(GtkWidget* /*pDialogChildDrawingArea*/
break; break;
} }
priv->m_nChildLastButtonPressed = nEventButton; priv->m_nChildLastButtonPressed = nEventButton;
pDocument->pClass->postDialogChildMouseEvent(pDocument, pDocument->pClass->postWindowMouseEvent(pDocument,
priv->m_nChildId, priv->m_nChildId,
LOK_MOUSEEVENT_MOUSEBUTTONUP, LOK_MOUSEEVENT_MOUSEBUTTONUP,
(pEvent->x), (pEvent->x),
(pEvent->y), (pEvent->y),
nCount, nCount,
nEventButton, nEventButton,
priv->m_nChildKeyModifier); priv->m_nChildKeyModifier);
break; break;
} }
default: default:
@@ -602,14 +602,14 @@ gtv_lok_dialog_floating_win_signal_motion(GtkWidget* /*pDialogDrawingArea*/, Gdk
(int)pixelToTwip(pEvent->x), (int)pixelToTwip(pEvent->x),
(int)pixelToTwip(pEvent->y)); (int)pixelToTwip(pEvent->y));
pDocument->pClass->postDialogChildMouseEvent(pDocument, pDocument->pClass->postWindowMouseEvent(pDocument,
priv->m_nChildId, priv->m_nChildId,
LOK_MOUSEEVENT_MOUSEMOVE, LOK_MOUSEEVENT_MOUSEMOVE,
(pEvent->x), (pEvent->x),
(pEvent->y), (pEvent->y),
1, 1,
priv->m_nChildLastButtonPressed, priv->m_nChildLastButtonPressed,
priv->m_nChildKeyModifier); priv->m_nChildKeyModifier);
return FALSE; return FALSE;
} }

View File

@@ -3223,7 +3223,10 @@ void Window::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
// When we're not doing tiled rendering, then positions must be passed as pixels. // When we're not doing tiled rendering, then positions must be passed as pixels.
assert(comphelper::LibreOfficeKit::isActive()); 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) void Window::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
@@ -3231,7 +3234,10 @@ void Window::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
// When we're not doing tiled rendering, then positions must be passed as pixels. // When we're not doing tiled rendering, then positions must be passed as pixels.
assert(comphelper::LibreOfficeKit::isActive()); 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) void Window::LogicMouseMove(const MouseEvent& rMouseEvent)
@@ -3239,28 +3245,10 @@ void Window::LogicMouseMove(const MouseEvent& rMouseEvent)
// When we're not doing tiled rendering, then positions must be passed as pixels. // When we're not doing tiled rendering, then positions must be passed as pixels.
assert(comphelper::LibreOfficeKit::isActive()); assert(comphelper::LibreOfficeKit::isActive());
ImplWindowFrameProc(this, SalEvent::ExternalMouseMove, &rMouseEvent); if (dynamic_cast<FloatingWindow*>(this) != nullptr)
} ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent);
else
void Window::LogicMouseButtonDownChild(const MouseEvent& rMouseEvent) ImplWindowFrameProc(this, SalEvent::ExternalMouseMove, &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);
} }
void Window::LOKKeyInput(const KeyEvent& rKeyEvent) void Window::LOKKeyInput(const KeyEvent& rKeyEvent)