include/vcl/dialog.hxx | 2 libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx | 10 ++ libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx | 2 libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx | 50 ++++++++-- libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx | 15 ++- sw/source/uibase/uno/unotxdoc.cxx | 2 vcl/source/window/dialog.cxx | 25 +---- 7 files changed, 74 insertions(+), 32 deletions(-)
New commits: commit 23e767261983273c5d6efe61396546f694df7af5 Author: Pranav Kant <pran...@collabora.co.uk> Date: Sat Jul 29 18:08:21 2017 +0530 lokdialog: Trigger repaint on all opened dialog with invalidate This is just a hack to temporarily trigger paints for all the opened dialogs whenever a dialog invalidation callback is emitted. This solves the problem for some of the dialogs where hard coded uno command, which we are using as dialog IDs in GTV, doesn't match with the dialog id contained in the payload of the invalidation callback. With this SearchDialog, AcceptChangeTracking and few others are responding well to mouse clicks and invalidate instantaneously while to invalidate and repaint some other dialogs, one needs to refocus them. Change-Id: Iac2acbda60c8e2d0eabe65440f3fbda3ef271d7a diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx index ab28f23578ec..077e2577f384 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx @@ -442,6 +442,16 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, cons return ret; } +// temporary function to invalidate all opened dialogs +// because currently the dialog id returned in dialog invalidation payload +// doesn't match our hard-coded list of dialog ids (uno commands) for some dialogs +GList* +gtv_application_window_get_all_child_windows(GtvApplicationWindow* window) +{ + GtvApplicationWindowPrivate* priv = getPrivate(window); + return priv->m_pChildWindows; +} + GtvApplicationWindow* gtv_application_window_new(GtkApplication* app) { diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx index c16425566967..239471ae4ac8 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx @@ -105,6 +105,8 @@ void gtv_application_window_unregister_child_window(GtvApplicationWindow* window GtkWindow* gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, const gchar* pWinId); +GList* gtv_application_window_get_all_child_windows(GtvApplicationWindow* window); + G_END_DECLS #endif /* GTV_APPLICATION_WINDOW_H */ diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx index 2a620b58000d..7a9fa7712900 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx @@ -63,11 +63,13 @@ pixelToTwip(float fInput) return (fInput / 96 / 1.0 /* zoom */) * 1440.0f; } +#if 0 static float twipToPixel(float fInput) { return fInput / 1440.0f * 96 * 1.0 /* zoom */; } +#endif static void gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer) diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index a549d852c786..8f86ecd43ca7 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -281,14 +281,23 @@ void LOKDocViewSigHandlers::comment(LOKDocView* pDocView, gchar* pComment, gpoin } } -void LOKDocViewSigHandlers::dialogInvalidate(LOKDocView* pDocView, gchar* pDialogId, gpointer) +void LOKDocViewSigHandlers::dialogInvalidate(LOKDocView* pDocView, gchar* /*pDialogId*/, gpointer) { GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); - GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, pDialogId); - if (pDialog) +// GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, pDialogId); + + // temporary hack to invalidate all open dialogs + GList* pChildWins = gtv_application_window_get_all_child_windows(window); + GList* pIt = nullptr; + for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next) + { + gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data)); + } +/* if (pDialog) { gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pDialog)); } +*/ } gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/) commit f8fcade6814df0d924da99b38ab4a73a010f49c7 Author: Pranav Kant <pran...@collabora.co.uk> Date: Sat Jul 29 17:53:11 2017 +0530 lokdialog: Forward mouse events to vcl; enable mouse move The current implementation works well - the mouse events are properly handled by the opened dialog changing the dialog states. However, since the uno commands (dialog IDs) are different from what is returned by LOK_CALLBACK_DIALOG_INVALIDATE, the invalidation doesn't instantaneously, so one have to make the dialog window out-of-focus and then again back to focus to trigger the paint and see the updated dialog state. The mouse coordinates are forwarded in pixels as of now. Enable mouse GDK Motion mask too for mouse move operation. Change-Id: Ia915f734e8cbf4586da2b70da5840fe1568b39bd diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index c9f4395cf890..fb0e0751ddc8 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -72,7 +72,7 @@ public: void paintDialog(VirtualDevice& rDevice); void LogicMouseButtonDown(const MouseEvent& rMouseEvent); void LogicMouseButtonUp(const MouseEvent& rMouseEvent); - void LogicMouseButtonMove(const MouseEvent& rMouseEvent); + void LogicMouseMove(const MouseEvent& rMouseEvent); protected: explicit Dialog( WindowType nType ); diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx index 24773ebfc9a0..2a620b58000d 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx @@ -34,6 +34,7 @@ struct GtvLokDialogPrivate guint32 m_nLastButtonPressTime; guint32 m_nLastButtonReleaseTime; guint32 m_nKeyModifier; + guint32 m_nLastButtonPressed; gchar* dialogid; }; @@ -125,11 +126,12 @@ gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve nEventButton = MOUSE_RIGHT; break; } + priv->m_nLastButtonPressed = nEventButton; pDocument->pClass->postDialogMouseEvent(pDocument, priv->dialogid, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, - pixelToTwip(pEvent->x), - pixelToTwip(pEvent->y), + (pEvent->x), + (pEvent->y), nCount, nEventButton, 0/* Modifier */); @@ -155,12 +157,12 @@ gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve nEventButton = MOUSE_RIGHT; break; } - + priv->m_nLastButtonPressed = nEventButton; pDocument->pClass->postDialogMouseEvent(pDocument, priv->dialogid, LOK_MOUSEEVENT_MOUSEBUTTONUP, - pixelToTwip(pEvent->x), - pixelToTwip(pEvent->y), + (pEvent->x), + (pEvent->y), nCount, nEventButton, 0/* Modifier */); @@ -172,6 +174,33 @@ gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve return FALSE; } +static gboolean +gtv_lok_dialog_signal_motion(GtkWidget* pDialogDrawingArea, GdkEventButton* pEvent) +{ + GtvLokDialog* pDialog = GTV_LOK_DIALOG(gtk_widget_get_toplevel(pDialogDrawingArea)); + GtvLokDialogPrivate* priv = getPrivate(pDialog); + + GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_window_get_transient_for(GTK_WINDOW(pDialog))); + LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(window->lokdocview)); + + g_info("lok_dialog_signal_button: %d, %d (in twips: %d, %d)", + (int)pEvent->x, (int)pEvent->y, + (int)pixelToTwip(pEvent->x), + (int)pixelToTwip(pEvent->y)); + gtk_widget_grab_focus(GTK_WIDGET(pDialog)); + + pDocument->pClass->postDialogMouseEvent(pDocument, + priv->dialogid, + LOK_MOUSEEVENT_MOUSEMOVE, + (pEvent->x), + (pEvent->y), + 1, + priv->m_nLastButtonPressed, + 0/* Modifier */); + + return FALSE; +} + static void gtv_lok_dialog_init(GtvLokDialog* dialog) { @@ -183,14 +212,17 @@ gtv_lok_dialog_init(GtvLokDialog* dialog) priv->m_nLastButtonPressTime = 0; priv->m_nLastButtonReleaseTime = 0; priv->m_nKeyModifier = 0; + priv->m_nLastButtonPressed = 0; gtk_widget_add_events(GTK_WIDGET(priv->pDialogDrawingArea), GDK_BUTTON_PRESS_MASK - |GDK_BUTTON_RELEASE_MASK); + |GDK_BUTTON_RELEASE_MASK + |GDK_BUTTON_MOTION_MASK); g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_draw), nullptr); - g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "button-press-event", G_CALLBACK(gtv_lok_dialog_signal_button), dialog); - g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "button-release-event", G_CALLBACK(gtv_lok_dialog_signal_button), dialog); + g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "button-press-event", G_CALLBACK(gtv_lok_dialog_signal_button), nullptr); + g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "button-release-event", G_CALLBACK(gtv_lok_dialog_signal_button), nullptr); + g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "motion-notify-event", G_CALLBACK(gtv_lok_dialog_signal_motion), nullptr); gtk_container_add(GTK_CONTAINER(pContentArea), priv->pDialogDrawingArea); } diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 16de75378944..095ba9fee5f6 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3616,7 +3616,7 @@ void SwXTextDocument::postDialogMouseEvent(const vcl::DialogID& rDialogID, int n pDialog->LogicMouseButtonUp(aEvent); break; case LOK_MOUSEEVENT_MOUSEMOVE: - //pDialog->LogicMouseMove(aEvent); + pDialog->LogicMouseMove(aEvent); break; default: assert(false); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index de2838b681f5..ee606eae351e 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -36,6 +36,8 @@ #include <rtl/strbuf.hxx> #include <sal/log.hxx> +#include "window.h" + #include <vcl/builder.hxx> #include <vcl/layout.hxx> #include <vcl/svapp.hxx> @@ -867,12 +869,7 @@ void Dialog::LogicMouseButtonDown(const MouseEvent& rMouseEvent) // When we're not doing tiled rendering, then positions must be passed as pixels. assert(comphelper::LibreOfficeKit::isActive()); - Point aPoint = GetPointerPosPixel(); - SetLastMousePos(rMouseEvent.GetPosPixel()); - - MouseButtonDown(rMouseEvent); - - SetPointerPosPixel(aPoint); + ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonDown, &rMouseEvent); } void Dialog::LogicMouseButtonUp(const MouseEvent& rMouseEvent) @@ -880,25 +877,15 @@ void Dialog::LogicMouseButtonUp(const MouseEvent& rMouseEvent) // When we're not doing tiled rendering, then positions must be passed as pixels. assert(comphelper::LibreOfficeKit::isActive()); - Point aPoint = GetPointerPosPixel(); - SetLastMousePos(rMouseEvent.GetPosPixel()); - - MouseButtonUp(rMouseEvent); - - SetPointerPosPixel(aPoint); + ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonUp, &rMouseEvent); } -void Dialog::LogicMouseButtonMove(const MouseEvent& rMouseEvent) +void Dialog::LogicMouseMove(const MouseEvent& rMouseEvent) { // When we're not doing tiled rendering, then positions must be passed as pixels. assert(comphelper::LibreOfficeKit::isActive()); - Point aPoint = GetPointerPosPixel(); - SetLastMousePos(rMouseEvent.GetPosPixel()); - - MouseMove(rMouseEvent); - - SetPointerPosPixel(aPoint); + ImplWindowFrameProc(this, SalEvent::ExternalMouseMove, &rMouseEvent); } void Dialog::ensureRepaint() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits