summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-08-03 22:58:04 +0530
committerJan Holesovsky <kendy@collabora.com>2017-11-15 17:07:11 +0100
commitc3468f4cc553e892fa2da0d49c16c476721f5f05 (patch)
tree122e665c62761ecbfb83fa7819a45f784e1d6436 /libreofficekit
parentcc42b2599dfffa3483699d918f0b8eb28505b54f (diff)
lokdialog: Move the floating window to its actual position
gtk_window_move them to the position broadcasted to us by vcl Change-Id: Id27b52a24e721b51d7a153cc7c0e03197a99ee2f
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx14
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx2
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx15
3 files changed, 26 insertions, 5 deletions
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 8896566499c1..3acd6b78e234 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -309,6 +309,19 @@ 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);
+ gchar** ppCoordinate = ppCoordinates;
+ int nX = 0;
+ int nY = 0;
+
+ if (*ppCoordinate)
+ nX = atoi(*ppCoordinate);
+ ++ppCoordinate;
+ if (*ppCoordinate)
+ nY = atoi(*ppCoordinate);
+
+ 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 +329,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));
}