Kaydet (Commit) d6490d3c authored tarafından Pranav Kant's avatar Pranav Kant

lokdialog: Move the floating window to its actual position

gtk_window_move them to the position broadcasted to us by vcl

Change-Id: Id27b52a24e721b51d7a153cc7c0e03197a99ee2f
üst 9cdaccc0
......@@ -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)
......
......@@ -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);
......
......@@ -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));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment