libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx | 14 +++++++--- libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx | 2 - libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx | 14 +++++++++- 3 files changed, 25 insertions(+), 5 deletions(-)
New commits: commit 9c44a71a06cb2312fd24ffd7c48302f0ae7807c1 Author: Pranav Kant <pran...@collabora.co.uk> Date: Thu Aug 3 22:58:04 2017 +0530 lokdialog: Move the floating window to its actual position gtk_window_move them to the position broadcasted to us by vcl Change-Id: Id27b52a24e721b51d7a153cc7c0e03197a99ee2f diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx index 1bfb9d538ead..6b19ddc506c0 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx @@ -460,7 +460,7 @@ gtv_lok_dialog_invalidate(GtvLokDialog* dialog) gtk_widget_queue_draw(priv->pDialogDrawingArea); } -void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog) +void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog, int nX, int nY) { g_info("Dialog's floating window invalidate"); @@ -474,14 +474,22 @@ void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog) gtk_container_add(GTK_CONTAINER(priv->pFloatingWin), pDrawingArea); gtk_window_set_transient_for(GTK_WINDOW(priv->pFloatingWin), GTK_WINDOW(dialog)); - gtk_window_set_position(GTK_WINDOW(priv->pFloatingWin), GTK_WIN_POS_MOUSE); gtk_window_set_destroy_with_parent(GTK_WINDOW(priv->pFloatingWin), true); - g_signal_connect(G_OBJECT(pDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_floating_win_draw), 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)); + + // Get the root coords of our new floating window + GdkWindow* pGdkWin = gtk_widget_get_window(GTK_WIDGET(dialog)); + int nrX = 0; + 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_close(GtvLokDialog* dialog) diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx index bce9edbadba1..ba565b4cebb0 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx @@ -39,7 +39,7 @@ GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId); void gtv_lok_dialog_invalidate(GtvLokDialog* dialog); -void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog); +void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog, int nX, int nY); void gtv_lok_dialog_child_close(GtvLokDialog* dialog); diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index d0778cef473d..72916b56f9ce 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -309,6 +309,18 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g boost::property_tree::read_json(aStream, aRoot); std::string aDialogId = aRoot.get<std::string>("dialogId"); std::string aAction = aRoot.get<std::string>("action"); + std::string aPos = aRoot.get<std::string>("position"); + gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2); + int nX = 0; + int nY = 0; + + if (*ppCoordinates) + nX = atoi(*ppCoordinates); + ++ppCoordinates; + if (*ppCoordinates) + nY = atoi(*ppCoordinates); + + g_strfreev(ppCoordinates); // temporary hack to invalidate/close floating window of all opened dialogs GList* pChildWins = gtv_application_window_get_all_child_windows(window); @@ -316,7 +328,7 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next) { if (aAction == "invalidate") - gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data)); + 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)); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits