[Libreoffice-commits] core.git: Branch 'feature/lok_dialog2' - 9 commits - desktop/source include/LibreOfficeKit include/sfx2 include/vcl libreofficekit/qa libreofficekit/source sfx2/source vcl/source

Pranav Kant pranavk at collabora.co.uk
Fri Dec 1 10:25:32 UTC 2017


 desktop/source/lib/init.cxx                                         |  109 +-----
 include/LibreOfficeKit/LibreOfficeKit.h                             |   32 -
 include/LibreOfficeKit/LibreOfficeKit.hxx                           |   58 ---
 include/LibreOfficeKit/LibreOfficeKitEnums.h                        |   27 -
 include/sfx2/lokhelper.hxx                                          |    6 
 include/sfx2/viewsh.hxx                                             |    1 
 include/vcl/IDialogRenderable.hxx                                   |    2 
 include/vcl/dialog.hxx                                              |    5 
 include/vcl/floatwin.hxx                                            |    2 
 include/vcl/window.hxx                                              |    7 
 libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx         |   37 +-
 libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx         |    4 
 libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx                    |   19 -
 libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx                    |   23 +
 libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx                 |  179 +++++-----
 libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx                 |    6 
 libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx |  110 ++----
 libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx |    3 
 libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx               |   60 +++
 libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.hxx               |    6 
 libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx            |   34 +
 libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.hxx            |    2 
 libreofficekit/qa/gtktiledviewer/gtv.ui                             |   49 ++
 libreofficekit/source/gtk/lokdocview.cxx                            |   55 ---
 sfx2/source/dialog/basedlgs.cxx                                     |    3 
 sfx2/source/dialog/tabdlg.cxx                                       |    1 
 sfx2/source/view/lokhelper.cxx                                      |   20 -
 sfx2/source/view/viewsh.cxx                                         |    5 
 vcl/source/control/ctrl.cxx                                         |    2 
 vcl/source/window/dialog.cxx                                        |   23 -
 vcl/source/window/floatwin.cxx                                      |   35 +
 vcl/source/window/window.cxx                                        |  111 ++----
 32 files changed, 490 insertions(+), 546 deletions(-)

New commits:
commit 0d4baee564982711ec628afb207bdd632613654f
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Dec 1 14:27:21 2017 +0530

    lokdialog: Merge dialog & dialog child mouse event APIs into one
    
    Change-Id: I91aaa6a58f33dd2d817e02533de96e0c8191f2ca

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 05cf36165a96..0b3cc7ab8a68 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -555,7 +555,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,
@@ -563,14 +563,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,
@@ -644,8 +636,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;
@@ -2425,7 +2416,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;
 
@@ -2456,37 +2447,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 d3ef5855b8bc..ccd1f1d89e2f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -266,7 +266,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,
@@ -278,14 +278,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,
@@ -293,16 +293,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 bc8969f3c0ad..2ee1cb4dd678 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -254,14 +254,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);
     }
 
     /**
@@ -280,25 +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 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
@@ -306,12 +290,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 5ca62f2d75f1..644d9c16e37e 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1226,9 +1226,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 f6fddbba73d0..5db79514aa4a 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 d35b4973a564..aa26519288d2 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3248,7 +3248,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)
@@ -3256,7 +3259,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)
@@ -3264,28 +3270,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)
commit 68c47eee5532b86693379eeafe3fe96a708eefbe
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Dec 1 14:19:30 2017 +0530

    lokdialog: Rename postDialogKeyEvent -> postWindowKeyEvent
    
    Change-Id: I78b434106fbef153adde255d4fcc8f74a7169175

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 31fecfcc4fe5..05cf36165a96 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -543,7 +543,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
                              int nType,
                              int nCharCode,
                              int nKeyCode);
-static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis,
+static void doc_postWindowKeyEvent(LibreOfficeKitDocument* pThis,
                                    unsigned nLOKWindowId,
                                    int nType,
                                    int nCharCode,
@@ -642,7 +642,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->initializeForRendering = doc_initializeForRendering;
         m_pDocumentClass->registerCallback = doc_registerCallback;
         m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
-        m_pDocumentClass->postDialogKeyEvent = doc_postDialogKeyEvent;
+        m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent;
         m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
         m_pDocumentClass->postDialogMouseEvent = doc_postDialogMouseEvent;
         m_pDocumentClass->postDialogChildMouseEvent = doc_postDialogChildMouseEvent;
@@ -2247,7 +2247,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
     pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
 }
 
-static void doc_postDialogKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nCharCode, int nKeyCode)
+static void doc_postWindowKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nCharCode, int nKeyCode)
 {
     SolarMutexGuard aGuard;
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 5f9c894795fe..d3ef5855b8bc 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -276,8 +276,8 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::postWindow().
     void (*postWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId, int nAction);
 
-    /// @see lok::Document::postDialogKeyEvent().
-    void (*postDialogKeyEvent) (LibreOfficeKitDocument* pThis,
+    /// @see lok::Document::postWindowKeyEvent().
+    void (*postWindowKeyEvent) (LibreOfficeKitDocument* pThis,
                                 unsigned nDialogId,
                                 int nType,
                                 int nCharCode,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 946c371caf4f..bc8969f3c0ad 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -259,9 +259,9 @@ public:
      * @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 postDialogKeyEvent(unsigned nDialogId, int nType, int nCharCode, int nKeyCode)
+    void postWindowKeyEvent(unsigned nDialogId, int nType, int nCharCode, int nKeyCode)
     {
-        mpDoc->pClass->postDialogKeyEvent(mpDoc, nDialogId, nType, nCharCode, nKeyCode);
+        mpDoc->pClass->postWindowKeyEvent(mpDoc, nDialogId, nType, nCharCode, nKeyCode);
     }
 
     /**
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 197897c2a185..f6fddbba73d0 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -339,7 +339,7 @@ gtv_lok_dialog_signal_key(GtkWidget* pDialogDrawingArea, GdkEventKey* pEvent)
     ss << "gtv_lok_dialog::postKey(" << pEvent->type << ", " << nCharCode << ", " << nKeyCode << ")";
     g_info("%s", ss.str().c_str());
 
-    pDocument->pClass->postDialogKeyEvent(pDocument,
+    pDocument->pClass->postWindowKeyEvent(pDocument,
                                           priv->dialogid,
                                           pEvent->type == GDK_KEY_RELEASE ? LOK_KEYEVENT_KEYUP : LOK_KEYEVENT_KEYINPUT,
                                           nCharCode,
commit 8b33f4c6a6cd4fd286ee20b1984eb3b5393db2ea
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Dec 1 13:54:45 2017 +0530

    lokdialog: Simplify; make the LOK dialog API more generic
    
    Merge the dialog floating window callbacks and function calls into one.
    Unique window ids across vcl::Window is enough to distinguish between
    them.
    
    Floating windows don't have a LOK notifier as they are created in the
    vcl itself (so we can't access them from sfx2). Use the parent LOK
    notifier in that case (which would be a dialog).
    
    This API should also help in autopopup filter tunneling later.
    
    Change-Id: I63a2c97ffdd84695dc967e14c793089a7c50b41b

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a34a4effeaf7..31fecfcc4fe5 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -615,8 +615,6 @@ static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
                             const int nX, const int nY,
                             const int nWidth, const int nHeight);
 
-static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight);
-
 static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
@@ -669,7 +667,6 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->getPartHash = doc_getPartHash;
 
         m_pDocumentClass->paintWindow = doc_paintWindow;
-        m_pDocumentClass->paintActiveFloatingWindow = doc_paintActiveFloatingWindow;
         m_pDocumentClass->postWindow = doc_postWindow;
 
         gDocumentClass = m_pDocumentClass;
@@ -789,7 +786,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
         case LOK_CALLBACK_SET_PART:
         case LOK_CALLBACK_TEXT_VIEW_SELECTION:
         case LOK_CALLBACK_INVALIDATE_HEADER:
-        case LOK_CALLBACK_DIALOG:
+        case LOK_CALLBACK_WINDOW:
         {
             const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(),
                     [type] (const queue_type::value_type& elem) { return (elem.first == type); });
@@ -1022,27 +1019,27 @@ void CallbackFlushHandler::queue(const int type, const char* data)
             }
             break;
 
-            case LOK_CALLBACK_DIALOG:
+            case LOK_CALLBACK_WINDOW:
             {
                 // reading JSON by boost might be slow?
                 boost::property_tree::ptree aTree;
                 std::stringstream aStream(payload);
                 boost::property_tree::read_json(aStream, aTree);
-                const unsigned nLOKWindowId = aTree.get<unsigned>("dialogId", 0);
+                const unsigned nLOKWindowId = aTree.get<unsigned>("id", 0);
                 if (aTree.get<std::string>("action", "") == "invalidate")
                 {
                     std::string aRectStr = aTree.get<std::string>("rectangle", "");
-                    // no 'rectangle' field => invalidate all of the dialog =>
-                    // remove all previous dialog part invalidations
+                    // no 'rectangle' field => invalidate all of the window =>
+                    // remove all previous window part invalidations
                     if (aRectStr.empty())
                     {
                         removeAll([&nLOKWindowId] (const queue_type::value_type& elem) {
-                                if (elem.first == LOK_CALLBACK_DIALOG)
+                                if (elem.first == LOK_CALLBACK_WINDOW)
                                 {
                                     boost::property_tree::ptree aOldTree;
                                     std::stringstream aOldStream(elem.second);
                                     boost::property_tree::read_json(aOldStream, aOldTree);
-                                    const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
+                                    const unsigned nOldDialogId = aOldTree.get<unsigned>("id", 0);
                                     if (aOldTree.get<std::string>("action", "") == "invalidate" &&
                                         nLOKWindowId == nOldDialogId)
                                     {
@@ -1054,18 +1051,18 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                     }
                     else
                     {
-                        // if we have to invalidate all of the dialog, ignore
+                        // if we have to invalidate all of the window, ignore
                         // any part invalidation message
                         const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(),
                                                        [&nLOKWindowId] (const queue_type::value_type& elem)
                                                        {
-                                                           if (elem.first != LOK_CALLBACK_DIALOG)
+                                                           if (elem.first != LOK_CALLBACK_WINDOW)
                                                                return false;
 
                                                            boost::property_tree::ptree aOldTree;
                                                            std::stringstream aOldStream(elem.second);
                                                            boost::property_tree::read_json(aOldStream, aOldTree);
-                                                           const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
+                                                           const unsigned nOldDialogId = aOldTree.get<unsigned>("id", 0);
                                                            if (aOldTree.get<std::string>("action", "") == "invalidate" &&
                                                                nLOKWindowId == nOldDialogId &&
                                                                aOldTree.get<std::string>("rectangle", "").empty())
@@ -1075,10 +1072,10 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                                                            return false;
                                                        });
 
-                        // we found a invalidate-all dialog callback
+                        // we found a invalidate-all window callback
                         if (pos != m_queue.rend())
                         {
-                            SAL_INFO("lok.dialog", "Skipping queue [" << type << "]: [" << payload << "] since whole dialog needs to be invalidated.");
+                            SAL_INFO("lok.dialog", "Skipping queue [" << type << "]: [" << payload << "] since whole window needs to be invalidated.");
                             return;
                         }
 
@@ -1089,7 +1086,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                         tools::Rectangle aNewRect = tools::Rectangle(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
                         bool currentIsRedundant = false;
                         removeAll([&aNewRect, &nLOKWindowId, &currentIsRedundant] (const queue_type::value_type& elem) {
-                                if (elem.first != LOK_CALLBACK_DIALOG)
+                                if (elem.first != LOK_CALLBACK_WINDOW)
                                     return false;
 
                                 boost::property_tree::ptree aOldTree;
@@ -1097,7 +1094,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                                 boost::property_tree::read_json(aOldStream, aOldTree);
                                 if (aOldTree.get<std::string>("action", "") == "invalidate")
                                 {
-                                    const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
+                                    const unsigned nOldDialogId = aOldTree.get<unsigned>("id", 0);
                                     std::string aOldRectStr = aOldTree.get<std::string>("rectangle", "");
                                     // not possible that we encounter an empty
                                     // rectangle here; we already handled this
@@ -3294,29 +3291,6 @@ static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWind
     comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
-static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight)
-{
-    SolarMutexGuard aGuard;
-
-    VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
-    if (!pWindow)
-    {
-        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
-        return;
-    }
-
-    ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
-    pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
-
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(*nWidth, *nHeight), Fraction(1.0), Point(), pBuffer);
-
-    comphelper::LibreOfficeKit::setDialogPainting(true);
-    const Size aSize = pWindow->PaintActiveFloatingWindow(*pDevice.get());
-    *nWidth = aSize.getWidth();
-    *nHeight = aSize.getHeight();
-    comphelper::LibreOfficeKit::setDialogPainting(false);
-}
-
 static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nAction)
 {
     SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 36eb9432127f..5f9c894795fe 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -273,9 +273,6 @@ struct _LibreOfficeKitDocumentClass
                          const int x, const int y,
                          const int width, const int height);
 
-    /// @see lok::Document::paintActiveFloatingWindow().
-    void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
-
     /// @see lok::Document::postWindow().
     void (*postWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId, int nAction);
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 6db988b92aa4..946c371caf4f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -177,25 +177,6 @@ public:
     }
 
     /**
-     * Renders the active floating window of a dialog
-     *
-     * Client must truncate pBuffer according to the nWidth and nHeight returned after the call.
-     *
-     * @param nDialogId Unique dialog id
-     * @param pBuffer Buffer with enough memory allocated to render any dialog
-     * @param nWidth output parameter returning the width of the rendered dialog.
-     * @param nHeight output parameter returning the height of the rendered dialog
-     */
-    void paintActiveFloatingWindow(unsigned nDialogId,
-                                   unsigned char* pBuffer,
-                                   int& nWidth,
-                                   int& nHeight)
-    {
-        return mpDoc->pClass->paintActiveFloatingWindow(mpDoc, nDialogId, pBuffer,
-                                                        &nWidth, &nHeight);
-    }
-
-    /**
      * Posts a command to the window (dialog, popup, etc.) with given id
      *
      * @param nWindowid
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index facbd351633d..cf85d7c6b592 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -531,26 +531,7 @@ typedef enum
     /**
      * Dialog invalidation
      */
-    LOK_CALLBACK_DIALOG = 36,
-
-    /**
-     * Invalidation corresponding to dialog's children.
-     * Eg: Floating window etc.
-     *
-     * Payload example:
-     * {
-     *   "dialogID": "SpellDialog",
-     *   "action": "close"
-     * }
-     *
-     * - dialogID is the UNO command of the dialog
-     * - action can be
-     *   - close, means dialog child window is closed now
-     *   - invalidate, means dialog child window is invalidated
-     *     It also means that dialog child window is created if it's the first
-     *     invalidate
-     */
-    LOK_CALLBACK_DIALOG_CHILD = 37
+    LOK_CALLBACK_WINDOW = 36,
 }
 LibreOfficeKitCallbackType;
 
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 00288d04faac..f342b502e810 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -41,12 +41,10 @@ public:
     static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload);
     /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
     static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
-    /// Emits a LOK_CALLBACK_DIALOG
-    static void notifyWindow(vcl::LOKWindowId nDialogId,
+    /// Emits a LOK_CALLBACK_WINDOW
+    static void notifyWindow(vcl::LOKWindowId nWindowId,
                              const OUString& rAction,
                              const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
-    /// Emits a LOK_CALLBACK_DIALOG_CHILD
-    static void notifyWindowChild(vcl::LOKWindowId nDialogId, const OUString& rAction, const Point& rPos);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
     static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload);
     /// A special value to signify 'infinity'.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 90ade4ba1463..988e1d3490ec 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -223,7 +223,6 @@ public:
 
     // ILibreOfficeKitNotifier
     virtual void                notifyWindow(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) const override;
-    virtual void                notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos) const override;
 
     // Focus, KeyInput, Cursor
     virtual void                ShowCursor( bool bOn = true );
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 281d04385aee..ef8d42a4a46c 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -34,8 +34,6 @@ public:
     virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId,
                               const OUString& rAction,
                               const std::vector<LOKPayloadItem>& rPayload = std::vector<LOKPayloadItem>()) const = 0;
-
-    virtual void notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos) const = 0;
 };
 
 } // namespace vcl
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index f8c58122396d..3da4ec0cb59a 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -75,8 +75,6 @@ protected:
 public:
     SAL_DLLPRIVATE bool    IsInClose() const { return mbInClose; }
     virtual        void    doDeferredInit(WinBits nBits) override;
-                   void    InvalidateFloatingWindow(const Point& rPos);
-                   void    CloseFloatingWindow();
 
 protected:
     explicit        Dialog( WindowType nType );
diff --git a/include/vcl/floatwin.hxx b/include/vcl/floatwin.hxx
index f0faa3c3e260..6ebb5c84cf37 100644
--- a/include/vcl/floatwin.hxx
+++ b/include/vcl/floatwin.hxx
@@ -129,7 +129,7 @@ public:
     SAL_DLLPRIVATE tools::Rectangle&       ImplGetItemEdgeClipRect();
     SAL_DLLPRIVATE bool             ImplIsInPrivatePopupMode() const { return mbInPopupMode; }
     virtual        void             doDeferredInit(WinBits nBits) override;
-    virtual        void    LogicInvalidate(const tools::Rectangle* pRectangle) override;
+                   void             LogicInvalidate(const tools::Rectangle* pRectangle) override;
 
 public:
     explicit        FloatingWindow(vcl::Window* pParent, WinBits nStyle);
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 1485f0077439..5ca62f2d75f1 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1207,9 +1207,12 @@ public:
     void                        SetComponentInterface( css::uno::Reference< css::awt::XWindowPeer > const & xIFace );
 
     /// Interface to register for dialog / window tunneling.
+    void                                LOKRegisterWindow();
+    void                                LOKUnregisterWindow();
     void                                SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier);
     const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() const;
     vcl::LOKWindowId                    GetLOKWindowId() const;
+    vcl::Window*                        GetParentWithLOKNotifier();
 
     /// Indicate that LOK is not going to use this dialog any more.
     void                                ReleaseLOKNotifier();
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
index e5b67d18c57c..f58884c79207 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
@@ -21,6 +21,7 @@
 #include "gtv-lokdocview-signal-handlers.hxx"
 #include "gtv-calc-header-bar.hxx"
 #include "gtv-comments-sidebar.hxx"
+#include "gtv-lok-dialog.hxx"
 
 #include <boost/property_tree/json_parser.hpp>
 #include <boost/optional.hpp>
@@ -314,8 +315,7 @@ static void setupDocView(GtvApplicationWindow* window)
     g_signal_connect(window->lokdocview, "formula-changed", G_CALLBACK(LOKDocViewSigHandlers::formulaChanged), nullptr);
     g_signal_connect(window->lokdocview, "password-required", G_CALLBACK(LOKDocViewSigHandlers::passwordRequired), nullptr);
     g_signal_connect(window->lokdocview, "comment", G_CALLBACK(LOKDocViewSigHandlers::comment), nullptr);
-    g_signal_connect(window->lokdocview, "dialog", G_CALLBACK(LOKDocViewSigHandlers::dialog), nullptr);
-    g_signal_connect(window->lokdocview, "dialog-child", G_CALLBACK(LOKDocViewSigHandlers::dialogChild), nullptr);
+    g_signal_connect(window->lokdocview, "window", G_CALLBACK(LOKDocViewSigHandlers::window), nullptr);
 
     g_signal_connect(window->lokdocview, "configure-event", G_CALLBACK(LOKDocViewSigHandlers::configureEvent), nullptr);
 }
@@ -422,7 +422,7 @@ gtv_application_window_unregister_child_window(GtvApplicationWindow* window, Gtk
 }
 
 GtkWindow*
-gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, const gchar* pWinId)
+gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guint nWinId)
 {
     GtvApplicationWindowPrivate* priv = getPrivate(window);
     GList* pIt = nullptr;
@@ -430,25 +430,32 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, cons
     // For now, only dialogs are registered as child window
     for (pIt = priv->m_pChildWindows; pIt != nullptr; pIt = pIt->next)
     {
-        gchar* dialogId = nullptr;
+        guint dialogId = 0;
         g_object_get(G_OBJECT(pIt->data), "dialogid", &dialogId, nullptr);
 
-        // prepend .uno:
-        gchar* completeWinId = nullptr;
-        if (pWinId != nullptr)
-        {
-            completeWinId = g_strconcat(".uno:", pWinId, nullptr);
-        }
-
-        if (dialogId != nullptr && g_str_equal(dialogId, completeWinId))
+        if (dialogId == nWinId)
         {
             ret = GTK_WINDOW(pIt->data);
             break;
         }
     }
+
     return ret;
 }
 
+GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint nWinId)
+{
+    GtvApplicationWindowPrivate* priv = getPrivate(window);
+    GList* pIt = nullptr;
+    for (pIt = priv->m_pChildWindows; pIt != nullptr; pIt = pIt->next)
+    {
+        if (gtv_lok_dialog_is_parent_of(GTV_LOK_DIALOG(pIt->data), nWinId))
+            return GTK_WIDGET(pIt->data);
+    }
+    return nullptr;
+}
+
+
 // 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
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
index f0d5afc0513c..78e9bae3e97f 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
@@ -103,10 +103,12 @@ void gtv_application_window_register_child_window(GtvApplicationWindow* window,
 
 void gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin);
 
-GtkWindow* gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, const gchar* pWinId);
+GtkWindow* gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guint nWinId);
 
 GList* gtv_application_window_get_all_child_windows(GtvApplicationWindow* window);
 
+GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint nWinId);
+
 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 546913d5953f..197897c2a185 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -43,6 +43,9 @@ struct GtvLokDialogPrivate
     guint32 m_nHeight;
 
     // state for child floating windows
+    guint32 m_nChildId;
+    guint32 m_nChildWidth;
+    guint32 m_nChildHeight;
     guint32 m_nChildLastButtonPressTime;
     guint32 m_nChildLastButtonReleaseTime;
     guint32 m_nChildKeyModifier;
@@ -132,11 +135,9 @@ gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve
     else if (pEvent->type == GDK_BUTTON_RELEASE)
         aEventType = "BUTTON_RELEASE";
 
-    g_info("lok_dialog_signal_button (type: %s): %d, %d (in twips: %d, %d)",
+    g_info("lok_dialog_signal_button (type: %s): %d, %d",
            aEventType.c_str(),
-           (int)pEvent->x, (int)pEvent->y,
-           (int)pixelToTwip(pEvent->x),
-           (int)pixelToTwip(pEvent->y));
+           (int)pEvent->x, (int)pEvent->y);
     gtk_widget_grab_focus(pDialogDrawingArea);
 
     switch (pEvent->type)
@@ -355,6 +356,9 @@ gtv_lok_dialog_init(GtvLokDialog* dialog)
     GtkWidget* pContentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
     priv->pDialogDrawingArea = gtk_drawing_area_new();
     priv->pFloatingWin = nullptr;
+    priv->m_nChildId = 0;
+    priv->m_nChildWidth = 0;
+    priv->m_nChildHeight = 0;
 
     priv->m_nLastButtonPressTime = 0;
     priv->m_nLastButtonReleaseTime = 0;
@@ -478,17 +482,14 @@ gtv_lok_dialog_floating_win_draw(GtkWidget* pDrawingArea, cairo_t* pCairo, gpoin
     GtvLokDialogPrivate* priv = getPrivate(pDialog);
 
     g_info("gtv_lok_dialog_floating_win_draw triggered");
-    int nWidth = 800;
-    int nHeight = 600;
-    cairo_surface_t* pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nWidth, nHeight);
+    cairo_surface_t* pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, priv->m_nChildWidth, priv->m_nChildHeight);
     unsigned char* pBuffer = cairo_image_surface_get_data(pSurface);
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(priv->lokdocview));
-    pDocument->pClass->paintActiveFloatingWindow(pDocument, priv->dialogid, pBuffer, &nWidth, &nHeight);
-    g_info("Size of floating window: %d x %d", nWidth, nHeight);
+    pDocument->pClass->paintWindow(pDocument, priv->m_nChildId, pBuffer, 0, 0, priv->m_nChildWidth, priv->m_nChildHeight);
 
-    gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), nWidth, nHeight);
-    gtk_widget_set_size_request(GTK_WIDGET(pDialog), nWidth, nHeight);
-    gtk_window_resize(GTK_WINDOW(pDialog), nWidth, nHeight);
+    gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), priv->m_nChildWidth, priv->m_nChildHeight);
+    //gtk_widget_set_size_request(GTK_WIDGET(pDialog), nWidth, nHeight);
+    //gtk_window_resize(GTK_WINDOW(pDialog), nWidth, nHeight);
 
     cairo_surface_flush(pSurface);
     cairo_surface_mark_dirty(pSurface);
@@ -497,16 +498,6 @@ gtv_lok_dialog_floating_win_draw(GtkWidget* pDrawingArea, cairo_t* pCairo, gpoin
     cairo_paint(pCairo);
 }
 
-void
-gtv_lok_dialog_invalidate(GtvLokDialog* dialog, const GdkRectangle& aRectangle)
-{
-    GtvLokDialogPrivate* priv = getPrivate(dialog);
-    if (aRectangle.width != 0 && aRectangle.height != 0)
-        gtk_widget_queue_draw_area(priv->pDialogDrawingArea, aRectangle.x, aRectangle.y, aRectangle.width, aRectangle.height);
-    else
-        gtk_widget_queue_draw(priv->pDialogDrawingArea);
-}
-
 static gboolean
 gtv_lok_dialog_floating_win_signal_button(GtkWidget* /*pDialogChildDrawingArea*/, GdkEventButton* pEvent, gpointer userdata)
 {
@@ -551,13 +542,13 @@ gtv_lok_dialog_floating_win_signal_button(GtkWidget* /*pDialogChildDrawingArea*/
         }
         priv->m_nChildLastButtonPressed = nEventButton;
         pDocument->pClass->postDialogChildMouseEvent(pDocument,
-                                                priv->dialogid,
-                                                LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
-                                                (pEvent->x),
-                                                (pEvent->y),
-                                                nCount,
-                                                nEventButton,
-                                                priv->m_nChildKeyModifier);
+                                                     priv->m_nChildId,
+                                                     LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+                                                     (pEvent->x),
+                                                     (pEvent->y),
+                                                     nCount,
+                                                     nEventButton,
+                                                     priv->m_nChildKeyModifier);
 
         break;
     }
@@ -582,7 +573,7 @@ gtv_lok_dialog_floating_win_signal_button(GtkWidget* /*pDialogChildDrawingArea*/
         }
         priv->m_nChildLastButtonPressed = nEventButton;
         pDocument->pClass->postDialogChildMouseEvent(pDocument,
-                                                     priv->dialogid,
+                                                     priv->m_nChildId,
                                                      LOK_MOUSEEVENT_MOUSEBUTTONUP,
                                                      (pEvent->x),
                                                      (pEvent->y),
@@ -612,7 +603,7 @@ gtv_lok_dialog_floating_win_signal_motion(GtkWidget* /*pDialogDrawingArea*/, Gdk
            (int)pixelToTwip(pEvent->y));
 
     pDocument->pClass->postDialogChildMouseEvent(pDocument,
-                                                 priv->dialogid,
+                                                 priv->m_nChildId,
                                                  LOK_MOUSEEVENT_MOUSEMOVE,
                                                  (pEvent->x),
                                                  (pEvent->y),
@@ -623,40 +614,58 @@ gtv_lok_dialog_floating_win_signal_motion(GtkWidget* /*pDialogDrawingArea*/, Gdk
     return FALSE;
 }
 
-void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog, int nX, int nY)
+// Public methods below
+
+void gtv_lok_dialog_invalidate(GtvLokDialog* dialog, const GdkRectangle& aRectangle)
+{
+    GtvLokDialogPrivate* priv = getPrivate(dialog);
+    if (aRectangle.width != 0 && aRectangle.height != 0)
+        gtk_widget_queue_draw_area(priv->pDialogDrawingArea, aRectangle.x, aRectangle.y, aRectangle.width, aRectangle.height);
+    else
+        gtk_widget_queue_draw(priv->pDialogDrawingArea);
+}
+
+// checks if we are the parent of given childId
+gboolean gtv_lok_dialog_is_parent_of(GtvLokDialog* dialog, guint childId)
 {
-    g_info("Dialog's floating window invalidate");
+    GtvLokDialogPrivate* priv = getPrivate(dialog);
+
+    return priv->m_nChildId == childId;
+}
 
+void gtv_lok_dialog_child_create(GtvLokDialog* dialog, guint childId, guint nX, guint nY, guint width, guint height)
+{
     GtvLokDialogPrivate* priv = getPrivate(dialog);
-    // create new if doesn't exist
-    if (!priv->pFloatingWin)
-    {
-        priv->pFloatingWin = gtk_window_new(GTK_WINDOW_POPUP);
-        GtkWidget* pDrawingArea = gtk_drawing_area_new();
-        gtk_container_add(GTK_CONTAINER(priv->pFloatingWin), pDrawingArea);
-
-        gtk_window_set_transient_for(GTK_WINDOW(priv->pFloatingWin), GTK_WINDOW(dialog));
-        gtk_window_set_destroy_with_parent(GTK_WINDOW(priv->pFloatingWin), true);
-
-        gtk_widget_add_events(pDrawingArea,
-                              GDK_BUTTON_PRESS_MASK
-                              |GDK_POINTER_MOTION_MASK
-                              |GDK_BUTTON_RELEASE_MASK
-                              |GDK_BUTTON_MOTION_MASK);
-
-        g_signal_connect(G_OBJECT(pDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_floating_win_draw), dialog);
-        g_signal_connect(G_OBJECT(pDrawingArea), "button-press-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_button), dialog);
-        g_signal_connect(G_OBJECT(pDrawingArea), "button-release-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_button), dialog);
-        g_signal_connect(G_OBJECT(pDrawingArea), "motion-notify-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_motion), dialog);
-
-        gtk_widget_set_size_request(priv->pFloatingWin, 1, 1);
-        gtk_window_set_type_hint(GTK_WINDOW(priv->pFloatingWin), GDK_WINDOW_TYPE_HINT_POPUP_MENU);
-        gtk_window_set_screen(GTK_WINDOW(priv->pFloatingWin), gtk_window_get_screen(GTK_WINDOW(dialog)));
-
-        gtk_widget_show_all(priv->pFloatingWin);
-        gtk_window_present(GTK_WINDOW(priv->pFloatingWin));
-        gtk_widget_grab_focus(pDrawingArea);
-    }
+
+    g_debug("Dialog [ %d ] child window [ %d]  being created, with dimensions [%dx%d]@(%d,%d)", priv->dialogid, childId, width, height, nX, nY);
+    priv->pFloatingWin = gtk_window_new(GTK_WINDOW_POPUP);
+    priv->m_nChildId = childId;
+    priv->m_nChildWidth = width;
+    priv->m_nChildHeight = height;
+    GtkWidget* pDrawingArea = gtk_drawing_area_new();
+    gtk_container_add(GTK_CONTAINER(priv->pFloatingWin), pDrawingArea);
+
+    gtk_window_set_transient_for(GTK_WINDOW(priv->pFloatingWin), GTK_WINDOW(dialog));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(priv->pFloatingWin), true);
+
+    gtk_widget_add_events(pDrawingArea,
+                          GDK_BUTTON_PRESS_MASK
+                          |GDK_POINTER_MOTION_MASK
+                          |GDK_BUTTON_RELEASE_MASK
+                          |GDK_BUTTON_MOTION_MASK);
+
+    g_signal_connect(G_OBJECT(pDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_floating_win_draw), dialog);
+    g_signal_connect(G_OBJECT(pDrawingArea), "button-press-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_button), dialog);
+    g_signal_connect(G_OBJECT(pDrawingArea), "button-release-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_button), dialog);
+    g_signal_connect(G_OBJECT(pDrawingArea), "motion-notify-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_motion), dialog);
+
+    gtk_widget_set_size_request(priv->pFloatingWin, 1, 1);
+    gtk_window_set_type_hint(GTK_WINDOW(priv->pFloatingWin), GDK_WINDOW_TYPE_HINT_POPUP_MENU);
+    gtk_window_set_screen(GTK_WINDOW(priv->pFloatingWin), gtk_window_get_screen(GTK_WINDOW(dialog)));
+
+    gtk_widget_show_all(priv->pFloatingWin);
+    gtk_window_present(GTK_WINDOW(priv->pFloatingWin));
+    gtk_widget_grab_focus(pDrawingArea);
 
     // Get the root coords of our new floating window
     GdkWindow* pGdkWin = gtk_widget_get_window(GTK_WIDGET(dialog));
@@ -664,7 +673,12 @@ void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog, int nX, int nY)
     int nrY = 0;
     gdk_window_get_root_coords(pGdkWin, nX, nY, &nrX, &nrY);
     gtk_window_move(GTK_WINDOW(priv->pFloatingWin), nrX, nrY);
+}
 
+void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog)
+{
+    GtvLokDialogPrivate* priv = getPrivate(dialog);
+    g_debug("Dialog [ %d ] child invalidate request", priv->dialogid);
     gtk_widget_queue_draw(priv->pFloatingWin);
 }
 
@@ -677,12 +691,13 @@ void gtv_lok_dialog_child_close(GtvLokDialog* dialog)
     {
         gtk_widget_destroy(priv->pFloatingWin);
         priv->pFloatingWin = nullptr;
+        priv->m_nChildId = 0;
+        priv->m_nChildWidth = 0;
+        priv->m_nChildHeight = 0;
     }
 }
 
-
-GtkWidget*
-gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height)
+GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height)
 {
     g_debug("Dialog [ %d ] of size: %d x %d created", dialogId, width, height);
     GtkWindow* pWindow = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
index 0f7002c359d7..2a5bfb5957f8 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
@@ -39,10 +39,14 @@ GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width,
 
 void gtv_lok_dialog_invalidate(GtvLokDialog* dialog, const GdkRectangle& aRectangle);
 
-void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog, int nX, int nY);
+void gtv_lok_dialog_child_create(GtvLokDialog* dialog, guint childId, guint nX, guint nY, guint width, guint height);
+
+void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog);
 
 void gtv_lok_dialog_child_close(GtvLokDialog* dialog);
 
+gboolean gtv_lok_dialog_is_parent_of(GtvLokDialog* dialog, guint childId);
+
 G_END_DECLS
 
 #endif /* GTV_LOK_DIALOG_H */
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 2c97bd4d7393..aa15a03a83e1 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -301,47 +301,60 @@ void LOKDocViewSigHandlers::comment(LOKDocView* pDocView, gchar* pComment, gpoin
     }
 }
 
-void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpointer)
+void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpointer)
 {
     GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
 
     std::stringstream aStream(pPayload);
     boost::property_tree::ptree aRoot;
     boost::property_tree::read_json(aStream, aRoot);
-    const unsigned nDialogId = aRoot.get<unsigned>("dialogId");
+    const unsigned nWinId = aRoot.get<unsigned>("id");
     const std::string aAction = aRoot.get<std::string>("action");
 
     if (aAction == "created")
     {
+        const std::string aType = aRoot.get<std::string>("type");
         const std::string aSize = aRoot.get<std::string>("size");
-        std::vector<int> aPoints = GtvHelpers::split<int>(aSize, ", ", 2);
-        GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, nDialogId, aPoints[0], aPoints[1]);
-        g_info("created  dialog, for dialogid: %d with size: %s", nDialogId, aSize.c_str());
+        std::vector<int> aSizePoints = GtvHelpers::split<int>(aSize, ", ", 2);
 
-        gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog));
-        g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window);
-        g_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window);
+        if (aType == "dialog")
+        {
+            GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, nWinId, aSizePoints[0], aSizePoints[1]);
+            g_info("created  dialog, for dialogid: %d with size: %s", nWinId, aSize.c_str());
 
-        gtk_window_set_resizable(GTK_WINDOW(pDialog), false);
-        gtk_widget_show_all(GTK_WIDGET(pDialog));
-        gtk_window_present(GTK_WINDOW(pDialog));
+            gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog));
+            g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window);
+            g_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window);
 
-        return;
+            gtk_window_set_resizable(GTK_WINDOW(pDialog), false);
+            gtk_widget_show_all(GTK_WIDGET(pDialog));
+            gtk_window_present(GTK_WINDOW(pDialog));
+        }
+        else if (aType == "child")
+        {
+            const unsigned nParentId = std::atoi(aRoot.get<std::string>("parentId").c_str());
+            GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, nParentId);
+            const std::string aPos = aRoot.get<std::string>("position");
+            std::vector<int> aPosPoints = GtvHelpers::split<int>(aPos, ", ", 2);
+            gtv_lok_dialog_child_create(GTV_LOK_DIALOG(pDialog), nWinId, aPosPoints[0], aPosPoints[1], aSizePoints[0], aSizePoints[1]);
+        }
     }
-
-    GList* pChildWins = gtv_application_window_get_all_child_windows(window);
-    GList* pIt = nullptr;
-    bool found = false;
-    for (pIt = pChildWins; !found && pIt != nullptr; pIt = pIt->next)
+    else
     {
-        guint nChildDialogId = 0;
-        g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr);
-        if (nDialogId == nChildDialogId)
+        // check if it's a child window
+        GtkWidget* pParent = gtv_application_window_get_parent(window, nWinId);
+        if (pParent) // it's a floating window in the dialog
         {
-            found = true;
-
+            if (aAction == "invalidate")
+                gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pParent));
+            else if (aAction == "close")
+                gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pParent));
+        }
+        else // it's the dialog window itself
+        {
+            GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, nWinId);
             if (aAction == "close")
-                gtk_widget_destroy(GTK_WIDGET(pIt->data));
+                gtk_widget_destroy(GTK_WIDGET(pDialog));
             else if (aAction == "size_changed")
             {
                 const std::string aSize = aRoot.get<std::string>("size");
@@ -349,16 +362,16 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
                 if (aSizePoints.size() != 2)
                 {
                     g_error("Malformed size_changed callback");
-                    break;
+                    return;
                 }
 
-                g_object_set(G_OBJECT(pIt->data),
+                g_object_set(G_OBJECT(pDialog),
                              "width", aSizePoints[0],
                              "height", aSizePoints[1],
                              nullptr);
 
                 GdkRectangle aGdkRectangle = {0, 0, 0, 0};
-                gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data), aGdkRectangle);
+                gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pDialog), aGdkRectangle);
             }
             else if (aAction == "invalidate")
             {
@@ -373,51 +386,12 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
                 catch(const std::exception& e)
                 {}
 
-                gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data), aGdkRectangle);
+                gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pDialog), aGdkRectangle);
             }
         }
     }
 }
 
-void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, gpointer)
-{
-    GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
-
-    std::stringstream aStream(pPayload);
-    boost::property_tree::ptree aRoot;
-    boost::property_tree::read_json(aStream, aRoot);
-    const unsigned nDialogId = aRoot.get<unsigned>("dialogId");
-    const std::string aAction = aRoot.get<std::string>("action");
-    const std::string aPos = aRoot.get<std::string>("position");
-    gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2);
-    gchar** ppCoordinate = ppCoordinates;
-    int nX = 0;
-    int nY = 0;
-
-    if (*ppCoordinate)
-        nX = atoi(*ppCoordinate);
-    ++ppCoordinate;
-    if (*ppCoordinate)
-        nY = atoi(*ppCoordinate);
-
-    g_strfreev(ppCoordinates);
-
-    GList* pChildWins = gtv_application_window_get_all_child_windows(window);
-    GList* pIt = nullptr;
-    for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
-    {
-        guint nChildDialogId = 0;
-        g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr);
-        if (nDialogId == nChildDialogId)
-        {
-            if (aAction == "invalidate")
-                gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY);
-            else if (aAction == "close")
-                gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data));
-        }
-    }
-}
-
 gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/)
 {
     GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pWidget)));
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx
index 54f54b396bf3..aedc8d216ad0 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx
@@ -25,8 +25,7 @@ namespace LOKDocViewSigHandlers {
     void formulaChanged(LOKDocView* pDocView, char* pPayload, gpointer);
     void passwordRequired(LOKDocView* pDocView, char* pUrl, gboolean bModify, gpointer);
     void comment(LOKDocView* pDocView, gchar* pComment, gpointer);
-    void dialog(LOKDocView* pDocView, gchar* pDialogId, gpointer);
-    void dialogChild(LOKDocView* pDocView, gchar* pPayload, gpointer);
+    void window(LOKDocView* pDocView, gchar* pPayload, gpointer);
 
     gboolean configureEvent(GtkWidget* pWidget, GdkEventConfigure* pEvent, gpointer pData);
 }
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 607a8624ecc3..eae5c6225cd9 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -277,8 +277,7 @@ enum
     PASSWORD_REQUIRED,
     COMMENT,
     RULER,
-    DIALOG,
-    DIALOG_CHILD,
+    WINDOW,
 
     LAST_SIGNAL
 };
@@ -436,10 +435,8 @@ callbackTypeToString (int nType)
         return "LOK_CALLBACK_COMMENT";
     case LOK_CALLBACK_RULER_UPDATE:
         return "LOK_CALLBACK_RULER_UPDATE";
-    case LOK_CALLBACK_DIALOG:
-        return "LOK_CALLBACK_DIALOG";
-    case LOK_CALLBACK_DIALOG_CHILD:
-        return "LOK_CALLBACK_DIALOG_CHILD";
+    case LOK_CALLBACK_WINDOW:
+        return "LOK_CALLBACK_WINDOW";
     }
     g_assert(false);
     return nullptr;
@@ -1413,11 +1410,8 @@ callback (gpointer pData)
     case LOK_CALLBACK_RULER_UPDATE:
         g_signal_emit(pCallback->m_pDocView, doc_view_signals[RULER], 0, pCallback->m_aPayload.c_str());
         break;
-    case LOK_CALLBACK_DIALOG:
-        g_signal_emit(pCallback->m_pDocView, doc_view_signals[DIALOG], 0, pCallback->m_aPayload.c_str());
-        break;
-    case LOK_CALLBACK_DIALOG_CHILD:
-        g_signal_emit(pCallback->m_pDocView, doc_view_signals[DIALOG_CHILD], 0, pCallback->m_aPayload.c_str());
+    case LOK_CALLBACK_WINDOW:
+        g_signal_emit(pCallback->m_pDocView, doc_view_signals[WINDOW], 0, pCallback->m_aPayload.c_str());
         break;
     default:
         g_assert(false);
@@ -3217,43 +3211,12 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
                      G_TYPE_STRING);
 
     /**
-     * LOKDocView::dialog-invalidate:
+     * LOKDocView::window
      * @pDocView: the #LOKDocView on which the signal is emitted
-     * @pDialogId: The uno command for the dialog (dialog ID)
-     */
-    doc_view_signals[DIALOG] =
-        g_signal_new("dialog",
-                     G_TYPE_FROM_CLASS(pGObjectClass),
-                     G_SIGNAL_RUN_FIRST,
-                     0,
-                     nullptr, nullptr,
-                     g_cclosure_marshal_generic,
-                     G_TYPE_NONE, 1,
-                     G_TYPE_STRING);
-
-    /**
-     * LOKDocView::dialog-child:
-     * @pDocView: the #LOKDocView on which the signal is emitted
-     * @pPayload: JSON described below:
-     *
-     * Invalidation corresponding to dialog's children.
-     * Eg: Floating window etc.
-     *
-     * Payload example:
-     * {
-     *   "dialogID": "SpellDialog",
-     *   "action": "close"
-     * }
-     *
-     * - dialogID is the UNO command of the dialog
-     * - action can be
-     *   - close, means dialog child window is closed now
-     *   - invalidate, means dialog child window is invalidated
-     *     It also means that dialog child window is created if it's the first
-     *     invalidate
+     * @pPayload: JSON containing the information, including id, about the window
      */
-    doc_view_signals[DIALOG_CHILD] =
-        g_signal_new("dialog-child",
+    doc_view_signals[WINDOW] =
+        g_signal_new("window",
                      G_TYPE_FROM_CLASS(pGObjectClass),
                      G_SIGNAL_RUN_FIRST,
                      0,
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index e9cadef82db0..16b69cd9c0aa 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -179,6 +179,7 @@ short SfxModalDialog::Execute()
         SetLOKNotifier(pViewShell);
         const Size aSize = GetOptimalSize();
         std::vector<vcl::LOKPayloadItem> aItems;
+        aItems.emplace_back(std::make_pair("type", "dialog"));
         aItems.emplace_back(std::make_pair("size", aSize.toString()));
         pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
     }
@@ -252,6 +253,7 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
             // Check GetSizePixel() ?
             const Size aOptimalSize = GetOptimalSize();
             std::vector<vcl::LOKPayloadItem> aItems;
+            aItems.emplace_back(std::make_pair("type", "dialog"));
             aItems.emplace_back(std::make_pair("size", aOptimalSize.toString()));
             pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
         }
@@ -522,6 +524,7 @@ bool SfxFloatingWindow::Close()
     pBindings->GetDispatcher_Impl()->ExecuteList(
             pImpl->pMgr->GetType(),
             SfxCallMode::RECORD|SfxCallMode::SYNCHRON, { &aValue });
+
     return true;
 }
 
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index ce9e1a753984..eac3ea1968ae 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -524,6 +524,7 @@ short SfxTabDialog::Execute()
         SetLOKNotifier(pViewShell);
         const Size aSize = GetOptimalSize();
         std::vector<vcl::LOKPayloadItem> aItems;
+        aItems.emplace_back(std::make_pair("type", "dialog"));
         aItems.emplace_back(std::make_pair("size", aSize.toString()));
         pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
     }
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index d5d868010490..d78763acd3f0 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -151,8 +151,7 @@ void SfxLokHelper::notifyWindow(vcl::LOKWindowId nLOKWindowId,
     if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
         return;
 
-
-    OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nLOKWindowId) + OString("\"");
+    OString aPayload = OString("{ \"id\": \"") + OString::number(nLOKWindowId) + OString("\"");
     aPayload += OString(", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\"");
 
     for (const auto& rItem: rPayload)
@@ -166,22 +165,7 @@ void SfxLokHelper::notifyWindow(vcl::LOKWindowId nLOKWindowId,
     aPayload += "}";
 
     if (SfxViewShell* pViewShell = SfxViewShell::Current())
-        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG, aPayload.getStr());
-}
-
-void SfxLokHelper::notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos)
-{
-    if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
-        return;
-
-
-    const OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nLOKWindowId) +
-        OString("\", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() +
-        OString("\", \"position\": \"") + OString::number(rPos.getX()) + OString(", ") + OString::number(rPos.getY()) +
-        + "\" }";
-
-    if (SfxViewShell* pViewShell = SfxViewShell::Current())
-        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG_CHILD, aPayload.getStr());
+        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, aPayload.getStr());
 }
 
 void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload)
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 4f08ef2298d6..437a8a744db4 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1953,11 +1953,6 @@ void SfxViewShell::notifyWindow(vcl::LOKWindowId nDialogId, const OUString& rAct
     SfxLokHelper::notifyWindow(nDialogId, rAction, rPayload);
 }
 
-void SfxViewShell::notifyWindowChild(vcl::LOKWindowId nDialogId, const OUString& rAction, const Point& rPos) const
-{
-    SfxLokHelper::notifyWindowChild(nDialogId, rAction, rPos);
-}
-
 uno::Reference< datatransfer::clipboard::XClipboardNotifier > SfxViewShell::GetClipboardNotifier()
 {
     uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClipboardNotifier;
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index b62c90563d46..977003a14d16 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -425,7 +425,7 @@ void Control::LogicInvalidate(const tools::Rectangle* /*pRectangle*/)
         vcl::Window* pWindow = this;
         while (pWindow)
         {
-            if (pWindow->ImplIsFloatingWindow())
+            if (pWindow->ImplIsFloatingWindow() && pWindow->GetLOKWindowId())
             {
                 static_cast<FloatingWindow*>(pWindow)->LogicInvalidate(nullptr);
                 return;
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index fe5004976c2d..6d0f495af227 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -882,18 +882,6 @@ bool Dialog::selectPageByUIXMLDescription(const OString& /*rUIXMLDescription*/)
     return true;
 }
 
-void Dialog::InvalidateFloatingWindow(const Point& rPos)
-{
-    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-        pNotifier->notifyWindowChild(GetLOKWindowId(), "invalidate", rPos);
-}
-
-void Dialog::CloseFloatingWindow()
-{
-    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-        pNotifier->notifyWindowChild(GetLOKWindowId(), "close", Point(0, 0));
-}
-
 void Dialog::ensureRepaint()
 {
     // ensure repaint
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index f5d9927a2482..8e0a0e426306 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -587,10 +587,13 @@ bool FloatingWindow::EventNotify( NotifyEvent& rNEvt )
 
 void FloatingWindow::LogicInvalidate(const tools::Rectangle* /*pRectangle*/)
 {
-    Dialog* pParentDlg = GetParentDialog();
-    if (pParentDlg)
+    if (vcl::Window* pParent = GetParentWithLOKNotifier())
     {
-        pParentDlg->InvalidateFloatingWindow(mpImplData->maPos);
+        const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier();
+        // if we haven't yet created a LOK window id yet for ourself, we are
+        // doing soemthing wrong
+        assert(GetLOKWindowId());
+        pNotifier->notifyWindow(GetLOKWindowId(), "invalidate");
     }
 }
 
@@ -602,14 +605,26 @@ void FloatingWindow::StateChanged( StateChangedType nType )
     }
 
     SystemWindow::StateChanged( nType );
-    Dialog* pParentDlg = GetParentDialog();
-    if (pParentDlg && nType == StateChangedType::InitShow && IsVisible())
-    {
-        pParentDlg->InvalidateFloatingWindow(mpImplData->maPos);
-    }
-    else if (pParentDlg && !IsVisible())
+
+    if (vcl::Window* pParent = GetParentWithLOKNotifier())
     {
-        pParentDlg->CloseFloatingWindow();
+        const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier();
+        if (nType == StateChangedType::InitShow && IsVisible())
+        {
+            LOKRegisterWindow();
+
+            std::vector<vcl::LOKPayloadItem> aItems;
+            aItems.emplace_back(std::make_pair("type", "child"));
+            aItems.emplace_back(std::make_pair("parentId", OString::number(pParent->GetLOKWindowId())));
+            aItems.emplace_back(std::make_pair("size", GetSizePixel().toString()));
+            aItems.emplace_back(std::make_pair("position", mpImplData->maPos.toString()));
+            pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
+        }
+        else if (!IsVisible())
+        {
+            pNotifier->notifyWindow(GetLOKWindowId(), "close");
+            LOKUnregisterWindow();
+        }
     }
 
     if ( nType == StateChangedType::ControlBackground )
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 6707540da3e8..d35b4973a564 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3174,16 +3174,22 @@ void Window::SetComponentInterface( Reference< css::awt::XWindowPeer > const & x
         pWrapper->SetWindowInterface( this, xIFace );
 }
 
+void Window::LOKRegisterWindow()
+{
+    // assign the LOK window id
+    assert(mpWindowImpl->mnLOKWindowId == 0);
+
+    mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++;
+    sLOKWindows.insert(std::map<vcl::LOKWindowId, VclPtr<vcl::Window>>::value_type(mpWindowImpl->mnLOKWindowId, this));
+}
+
 void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier)
 {
     // don't allow setting this twice
     assert(mpWindowImpl->mpLOKNotifier == nullptr);
     assert(pNotifier);
 
-    // assign the LOK window id
-    assert(mpWindowImpl->mnLOKWindowId == 0);
-    mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++;
-    sLOKWindows.insert(std::map<vcl::LOKWindowId, VclPtr<vcl::Window>>::value_type(mpWindowImpl->mnLOKWindowId, this));
+    LOKRegisterWindow();
 
     mpWindowImpl->mpLOKNotifier = pNotifier;
 }
@@ -3197,16 +3203,21 @@ VclPtr<Window> Window::FindLOKWindow(vcl::LOKWindowId nWindowId)
     return VclPtr<Window>();
 }
 
-void Window::ReleaseLOKNotifier()
+void Window::LOKUnregisterWindow()
 {
     // unregister the LOK window binding
     if (mpWindowImpl->mnLOKWindowId > 0)
         sLOKWindows.erase(mpWindowImpl->mnLOKWindowId);
 
-    mpWindowImpl->mpLOKNotifier = nullptr;
     mpWindowImpl->mnLOKWindowId = 0;
 }
 
+void Window::ReleaseLOKNotifier()
+{
+    LOKUnregisterWindow();
+    mpWindowImpl->mpLOKNotifier = nullptr;
+}
+
 const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
 {
     return mpWindowImpl->mpLOKNotifier;
@@ -3214,32 +3225,22 @@ const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
 
 vcl::LOKWindowId Window::GetLOKWindowId() const
 {
-    assert(mpWindowImpl->mnLOKWindowId > 0);
-
     return mpWindowImpl->mnLOKWindowId;
 }
 
-Size Window::PaintActiveFloatingWindow(VirtualDevice& rDevice) const
+vcl::Window* Window::GetParentWithLOKNotifier()
 {
-    Size aRet;
-    ImplSVData* pSVData = ImplGetSVData();
-    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
-    if (pFirstFloat)
+    vcl::Window* pWindow = this;
+    bool found = false;
+    while (pWindow && !found)
     {
-        // TODO:: run a while loop here and check all the active floating
-        // windows ( chained together, cf. pFirstFloat->mpNextFloat )
-        // For now just assume that the active floating window is the one we
-        // want to render
-        if (pFirstFloat->GetParentDialog() == this)
-        {
-            pFirstFloat->PaintToDevice(&rDevice, Point(0, 0), Size());
-            aRet = pFirstFloat->GetSizePixel();
-        }
-
-        pFirstFloat = nullptr;
+        if (pWindow->GetLOKNotifier())
+            found = true;
+        else
+            pWindow = pWindow->GetParent();
     }
 
-    return aRet;
+    return found ? pWindow : nullptr;
 }
 
 void Window::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
@@ -3270,36 +3271,21 @@ void Window::LogicMouseButtonDownChild(const MouseEvent& rMouseEvent)
 {
     assert(comphelper::LibreOfficeKit::isActive());
 
-    ImplSVData* pSVData = ImplGetSVData();
-    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
-    if (pFirstFloat && pFirstFloat->GetParentDialog() == this)
-    {
-        ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent);
-    }
+    ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent);
 }
 
 void Window::LogicMouseButtonUpChild(const MouseEvent& rMouseEvent)
 {
     assert(comphelper::LibreOfficeKit::isActive());
 
-    ImplSVData* pSVData = ImplGetSVData();
-    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
-    if (pFirstFloat && pFirstFloat->GetParentDialog() == this)
-    {
-        ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent);
-    }
+    ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent);
 }
 
 void Window::LogicMouseMoveChild(const MouseEvent& rMouseEvent)
 {
     assert(comphelper::LibreOfficeKit::isActive());
 
-    ImplSVData* pSVData = ImplGetSVData();
-    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
-    if (pFirstFloat && pFirstFloat->GetParentDialog() == this)
-    {
-        ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent);
-    }
+    ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent);
 }
 
 void Window::LOKKeyInput(const KeyEvent& rKeyEvent)
commit 90de930d54718a3b1ee11a046fd47852f336f7ca
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Dec 1 00:37:11 2017 +0530

    lokdialog: Do not underestimate the dialog size
    
    Some of them like, EditStyle, can be much bigger.
    
    Change-Id: Iaad02fadba18846976b959369f06e2020feffc6f

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index bb206acb109e..546913d5953f 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -457,14 +457,14 @@ gtv_lok_dialog_class_init(GtvLokDialogClass* klass)
     properties[PROP_DIALOG_WIDTH] = g_param_spec_uint("width",
                                                       "Dialog width",
                                                       "Dialog width",
-                                                      0, 1024, 0,
+                                                      0, 4096, 0,
                                                       static_cast<GParamFlags>(G_PARAM_READWRITE |
                                                                                G_PARAM_STATIC_STRINGS));
 
     properties[PROP_DIALOG_HEIGHT] = g_param_spec_uint("height",
                                                        "Dialog height",
                                                        "Dialog height",
-                                                       0, 1024, 0,
+                                                       0, 2048, 0,
                                                        static_cast<GParamFlags>(G_PARAM_READWRITE |
                                                                                 G_PARAM_STATIC_STRINGS));
 
commit 0e0fe44cdbe73e84ceda1db22e864921c3587e79
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Nov 30 23:35:05 2017 +0530

    lokdialog: Kill some code; use already existing method to paint
    
    This is not require now in the new approach where the dialog is already
    created by the time paint request call for dialog happens. Layouting is
    already complete by that time.
    
    Change-Id: I610b050a268e61e8d4036aa7eb5766cf0c8b37e0

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e090fc8be3eb..a34a4effeaf7 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3290,7 +3290,7 @@ static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWind
     pDevice->SetMapMode(aMapMode);
 
     comphelper::LibreOfficeKit::setDialogPainting(true);
-    pWindow->paintDialog(*pDevice.get());
+    pWindow->PaintToDevice(pDevice.get(), Point(0, 0), Size());
     comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index acc1ceef2701..f8c58122396d 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -78,9 +78,6 @@ public:
                    void    InvalidateFloatingWindow(const Point& rPos);
                    void    CloseFloatingWindow();
 
-    /// Paints the current dialog to the given virtual device
-    void paintDialog(VirtualDevice& rDevice) override;
-
 protected:
     explicit        Dialog( WindowType nType );
     explicit        Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag = InitFlag::Default, bool bBorder = false );
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 6df774ccde85..1485f0077439 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1218,7 +1218,6 @@ public:
     static VclPtr<Window>               FindLOKWindow(vcl::LOKWindowId nWindowId);
 
     /// Dialog / window tunneling related methods.
-    virtual void paintDialog(VirtualDevice& rDevice);
     Size PaintActiveFloatingWindow(VirtualDevice& rDevice) const;
 
     void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index e0bfc6cc1b06..fe5004976c2d 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -882,17 +882,6 @@ bool Dialog::selectPageByUIXMLDescription(const OString& /*rUIXMLDescription*/)
     return true;
 }
 
-void Dialog::paintDialog(VirtualDevice& rDevice)
-{
-    setDeferredProperties();
-    ImplAdjustNWFSizes();
-    Show();
-    ToTop();
-    ensureRepaint();
-
-    PaintToDevice(&rDevice, Point(0, 0), Size());
-}
-
 void Dialog::InvalidateFloatingWindow(const Point& rPos)
 {
     if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 93f554d06dc9..6707540da3e8 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3219,15 +3219,6 @@ vcl::LOKWindowId Window::GetLOKWindowId() const
     return mpWindowImpl->mnLOKWindowId;
 }
 
-void Window::paintDialog(VirtualDevice& rDevice)
-{
-    // FIXME are these two necessary?
-    Show();
-    ToTop();
-
-    PaintToDevice(&rDevice, Point(0, 0), Size());
-}
-
 Size Window::PaintActiveFloatingWindow(VirtualDevice& rDevice) const
 {
     Size aRet;
commit 8a65d42305129c2aebc986156938c2f81080bbb3
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Nov 29 17:47:10 2017 +0530

    lokdialog: Allow closing a dialog from LOK client
    
    ... and rename paintDialog -> paintWindow before it's too late. We not
    only render dialogs now but also popups.
    
    Change-Id: I6b1253c4d9be0c79199b683df4413658a461f850

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 95d4cda6ecd9..e090fc8be3eb 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -611,12 +611,14 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
                           int* pFontHeight);
 static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer,
+static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer,
                             const int nX, const int nY,
                             const int nWidth, const int nHeight);
 
 static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
+static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction);
+
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
     : mxComponent(xComponent)
 {
@@ -666,8 +668,9 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->renderFont = doc_renderFont;
         m_pDocumentClass->getPartHash = doc_getPartHash;
 
-        m_pDocumentClass->paintDialog = doc_paintDialog;
+        m_pDocumentClass->paintWindow = doc_paintWindow;
         m_pDocumentClass->paintActiveFloatingWindow = doc_paintActiveFloatingWindow;
+        m_pDocumentClass->postWindow = doc_postWindow;
 
         gDocumentClass = m_pDocumentClass;
     }
@@ -3263,7 +3266,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
     return nullptr;
 }
 
-static void doc_paintDialog(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
+static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
                             unsigned char* pBuffer,
                             const int nX, const int nY,
                             const int nWidth, const int nHeight)
@@ -3314,6 +3317,24 @@ static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* /*pThis*/, uns
     comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
+static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nAction)
+{
+    SolarMutexGuard aGuard;
+
+    VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
+    if (!pWindow)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
+        return;
+    }
+
+    if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow.get()))
+    {
+        if (nAction == LOK_WINDOW_CLOSE)
+            pDialog->EndDialog( RET_OK );
+    }
+}
+
 static char* lo_getError (LibreOfficeKit *pThis)
 {
     SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index e623ecb2508e..36eb9432127f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -267,8 +267,8 @@ struct _LibreOfficeKitDocumentClass
                        size_t nSize);
 
     /// Paints dialog with given dialog id to the buffer
-    /// @see lok::Document::paintDialog().
-    void (*paintDialog) (LibreOfficeKitDocument* pThis, unsigned nDialogId,
+    /// @see lok::Document::paintWindow().
+    void (*paintWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
                          unsigned char* pBuffer,
                          const int x, const int y,
                          const int width, const int height);
@@ -276,6 +276,9 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::paintActiveFloatingWindow().
     void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
+    /// @see lok::Document::postWindow().
+    void (*postWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId, int nAction);
+
     /// @see lok::Document::postDialogKeyEvent().
     void (*postDialogKeyEvent) (LibreOfficeKitDocument* pThis,
                                 unsigned nDialogId,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 86ceab46c484..6db988b92aa4 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -156,25 +156,23 @@ public:
     }
 
     /**
-     * Renders a dialog with give dialog id and writes the width and height of the rendered dialog
+     * Renders a window (dialog, popup, etc.) with give id
      *
-     * Client must truncate pBuffer according to the nWidth and nHeight returned after the call.
-     *
-     * @param nDialogId Unique dialog id to be painted
+     * @param nWindowId
      * @param pBuffer Buffer with enough memory allocated to render any dialog
      * @param x x-coordinate from where the dialog should start painting
      * @param y y-coordinate from where the dialog should start painting
      * @param width The width of the dialog image to be painted
      * @param height The height of the dialog image to be painted
      */
-    void paintDialog(unsigned nDialogId,
+    void paintWindow(unsigned nWindowId,
                      unsigned char* pBuffer,
                      const int x,
                      const int y,
                      const int width,
                      const int height)
     {
-        return mpDoc->pClass->paintDialog(mpDoc, nDialogId, pBuffer,
+        return mpDoc->pClass->paintWindow(mpDoc, nWindowId, pBuffer,
                                           x, y, width, height);
     }
 
@@ -198,6 +196,16 @@ public:
     }
 
     /**
+     * Posts a command to the window (dialog, popup, etc.) with given id
+     *
+     * @param nWindowid
+     */
+    void postWindow(unsigned nWindowId, int nAction)
+    {
+        return mpDoc->pClass->postWindow(mpDoc, nWindowId, nAction);
+    }
+
+    /**
      * Gets the tile mode: the pixel format used for the pBuffer of paintTile().
      *
      * @return an element of the LibreOfficeKitTileMode enum.
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 62b9faf7ecb4..facbd351633d 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -40,6 +40,12 @@ typedef enum
 }
 LibreOfficeKitTileMode;
 
+typedef enum
+{
+    LOK_WINDOW_CLOSE
+}
+LibreOfficeKitWindowAction;
+
 /** Optional features of LibreOfficeKit, in particular callbacks that block
  *  LibreOfficeKit until the corresponding reply is received, which would
  *  deadlock if the client does not support the feature.
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
index 118be6c0100d..e5b67d18c57c 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
@@ -412,7 +412,13 @@ gtv_application_window_unregister_child_window(GtvApplicationWindow* window, Gtk
 {
     GtvApplicationWindowPrivate* priv = getPrivate(window);
     if (pChildWin)
+    {
         priv->m_pChildWindows = g_list_remove(priv->m_pChildWindows, pChildWin);
+        LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(window->lokdocview));
+        guint dialogId = 0;
+        g_object_get(G_OBJECT(pChildWin), "dialogid", &dialogId, nullptr);
+        pDocument->pClass->postWindow(pDocument, dialogId, LOK_WINDOW_CLOSE);
+    }
 }
 
 GtkWindow*
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 9cad1e8fb117..bb206acb109e 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -106,7 +106,7 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
     cairo_surface_t* pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nWidth, nHeight);
     unsigned char* pBuffer = cairo_image_surface_get_data(pSurface);
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(priv->lokdocview));
-    pDocument->pClass->paintDialog(pDocument, priv->dialogid, pBuffer, aRect.x, aRect.y, nWidth, nHeight);
+    pDocument->pClass->paintWindow(pDocument, priv->dialogid, pBuffer, aRect.x, aRect.y, nWidth, nHeight);
 
     gtk_widget_set_size_request(GTK_WIDGET(pDialogDrawingArea), priv->m_nWidth, priv->m_nHeight);
 
commit 7ceabd2ed7835d5ae8e9c9da3707b94be4622bdb
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 28 16:43:54 2017 +0530

    gtv: Remember recently executed UNO commands
    
    Saves the recently executed UNO commands in a temp file and make it
    accessible to user in a combo box. Useful when debugging.
    
    Change-Id: Ic66961a388cc59dee3f65cb8d4de3c29a8a75eaa

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
index 9d461b1e329e..47a810e97856 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
@@ -212,7 +212,6 @@ void recentUnoChanged( GtkWidget* pSelector, gpointer /* pItem */ )
     if (aUnoArgs.empty())
         return;
 
-    std::string aUnoCmdStr = std::string(pUnoCmd) + " | " + aUnoArgs;
     lok_doc_view_post_command(LOK_DOC_VIEW(pWindow->lokdocview), pUnoCmd, (aUnoArgs.empty() ? nullptr : aUnoArgs.c_str()), false);
     g_free(pUnoCmd);
 }
commit 4bfd661990919592091256c6a8e35e3a9912e4d5
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 28 16:43:54 2017 +0530

    gtv: Remember recently executed UNO commands
    
    Saves the recently executed UNO commands in a temp file and make it
    accessible to user in a combo box. Useful when debugging.
    
    Change-Id: Ic66961a388cc59dee3f65cb8d4de3c29a8a75eaa

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx
index 9dee02a0ac45..5dca746d5f25 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx
@@ -148,23 +148,4 @@ const std::string GtvHelpers::getDirPath(const std::string& filePath)
     return dirPath;
 }
 
-const std::vector<int> GtvHelpers::splitIntoIntegers(const std::string& aPayload, const std::string& aDelim, const int nItems)
-{
-    std::vector<int> aRet;
-
-    if (!aPayload.empty())
-    {
-        gchar** ppCoordinates = g_strsplit(aPayload.c_str(), aDelim.c_str(), nItems);
-        gchar** ppCoordinate  = ppCoordinates;
-        while (*ppCoordinate)
-        {
-            aRet.push_back(atoi(*ppCoordinate));
-            ++ppCoordinate;
-        }
-        g_strfreev(ppCoordinates);
-    }
-
-    return aRet;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx b/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx
index 9e984846f0ab..9474f4c0271a 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx
@@ -39,7 +39,28 @@ namespace GtvHelpers
 
     const std::string getDirPath(const std::string& filePath);
 
-    const std::vector<int> splitIntoIntegers(const std::string& aPayload, const std::string& aDelim, const int nItems);
+    template<typename T>
+    const std::vector<T> split(const std::string& aPayload, const std::string& aDelim, const int nItems)
+    {
+        std::vector<T> aRet;
+
+        if (!aPayload.empty())
+        {

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list